1 package com.daffodilwoods.daffodildb.server.sessionsystem; 2 3 import java.util.TimeZone ; 4 import com.daffodilwoods.database.resource.*; 5 import com.daffodilwoods.daffodildb.server.serversystem.*; 6 import java.util.Stack ; 7 import java.util.ArrayList ; 8 import java.sql.*; 9 import java.io.Serializable ; 10 public class SessionSQL implements Serializable { 11 Stack authorisationStack; 12 SessionTransactionMode transactionMode; 13 transient DateTimeFunctions dateTime; 14 public SessionSQL() throws DException { 15 authorisationStack = new Stack (); 16 dateTime = new DateTimeFunctions(); 17 } 18 19 24 25 public void pushAuthorizationIdentifier(AuthorizationIdentifier athrznIdntfr) throws DException { 26 authorisationStack.push(athrznIdntfr); 27 } 28 29 34 35 public void setRole(String role) throws DException { 36 AuthorizationIdentifier authrztnIdntfr = (AuthorizationIdentifier)authorisationStack.peek(); 37 authrztnIdntfr.setRole(role); 38 } 39 40 45 46 public void setUser(String user) throws DException { 47 AuthorizationIdentifier authrztnIdntfr = (AuthorizationIdentifier)authorisationStack.peek(); 48 authrztnIdntfr.setUser(user); 49 } 50 51 58 59 public boolean isEnabledAuthorizationIdentifier(String authorizationIdentifier, _ServerSession globalSession) throws DException{ 60 AuthorizationIdentifier authrztnIdntfr = (AuthorizationIdentifier)authorisationStack.peek(); 61 ArrayList s = authrztnIdntfr.getEnabledAuthorizationIdentifiers( globalSession ); 62 for (int i = 0; i < s.size(); i++) { 63 if( authorizationIdentifier.equalsIgnoreCase((String )s.get(i)) ) 64 return true; 65 } 66 return false; 67 } 68 69 74 75 public String getAuthorizationIdentifier() throws DException { 76 AuthorizationIdentifier authrztnIdntfr = (AuthorizationIdentifier)authorisationStack.peek(); 77 return authrztnIdntfr.getCurrentAuthorizationIdentifier(); 78 } 79 80 85 86 public String getCurrentRole() throws DException { 87 AuthorizationIdentifier authrztnIdntfr = (AuthorizationIdentifier)authorisationStack.peek(); 88 return authrztnIdntfr.getRole(); 89 } 90 91 96 97 public String getCurrentUser() throws DException { 98 AuthorizationIdentifier authrztnIdntfr = (AuthorizationIdentifier)authorisationStack.peek(); 99 return authrztnIdntfr.getUser(); 100 } 101 102 107 108 public void setTransactionMode(SessionTransactionMode transactinMode) throws DException { 109 this.transactionMode = transactinMode; 110 } 111 112 117 118 public SessionTransactionMode getTransactionMode() throws DException { 119 return transactionMode; 120 } 121 122 127 128 public Date getDate() throws DException { 129 return dateTime.getDate(); 130 } 131 132 137 138 public Time getTime() throws DException { 139 return dateTime.getTime(); 140 } 141 142 147 148 public int getMonth() throws DException { 149 dateTime.setCurrentTime(); 150 return dateTime.getMonth(); 151 } 152 153 158 159 public int getYear() throws DException { 160 dateTime.setCurrentTime(); 161 return dateTime.getYear(); 162 } 163 164 169 170 public int getHour() throws DException { 171 dateTime.setCurrentTime(); 172 return dateTime.getHour(); 173 } 174 175 180 181 public int getMinutes() throws DException { 182 dateTime.setCurrentTime(); 183 return dateTime.getMinutes(); 184 } 185 186 191 192 public int getSeconds() throws DException { 193 dateTime.setCurrentTime(); 194 return dateTime.getSeconds(); 195 } 196 197 202 203 public TimeZone getTimeZone() throws DException { 204 return TimeZone.getDefault(); 205 } 206 207 212 213 public java.sql.Timestamp getTimeStamp( ) throws DException { 214 return dateTime.getTimeStamp(); 215 } 216 public void resetTransactionDate(){ 217 dateTime.resetTransactionDate(); 218 } 219 220 } 221 | Popular Tags |