aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/AuthenticationManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/AuthenticationManager.java')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/AuthenticationManager.java71
1 files changed, 52 insertions, 19 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/AuthenticationManager.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/AuthenticationManager.java
index 3254927ed..21e431bf8 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/AuthenticationManager.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/AuthenticationManager.java
@@ -11,6 +11,8 @@ import at.gv.egovernment.moa.id.MOAIDException;
import at.gv.egovernment.moa.id.auth.MOAIDAuthConstants;
import at.gv.egovernment.moa.id.auth.WrongParametersException;
import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;
+import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException;
+import at.gv.egovernment.moa.id.storage.AuthenticationSessionStoreage;
import at.gv.egovernment.moa.id.util.HTTPSessionUtils;
import at.gv.egovernment.moa.id.util.ParamValidatorUtils;
import at.gv.egovernment.moa.logging.Logger;
@@ -25,7 +27,12 @@ public class AuthenticationManager implements MOAIDAuthConstants {
String sessionID = HTTPSessionUtils.getHTTPSessionString(session,
MOA_SESSION, null);
if (sessionID != null) {
- return AuthenticationSessionStore.getSession(sessionID);
+ try {
+ return AuthenticationSessionStoreage.getSession(sessionID);
+
+ } catch (MOADatabaseException e) {
+ return null;
+ }
}
return null;
}
@@ -50,15 +57,24 @@ public class AuthenticationManager implements MOAIDAuthConstants {
return false;
}
- AuthenticationSession authSession = AuthenticationSessionStore
- .getSession(moaSessionID);
-
- if(authSession == null) {
- Logger.info("NO MOA Authentication data for ID " + moaSessionID);
- return false;
- }
+// AuthenticationSession authSession;
+// try {
+// authSession = AuthenticationSessionStoreage
+// .getSession(moaSessionID);
+//
+// } catch (MOADatabaseException e) {
+// Logger.info("NO MOA Authentication data for ID " + moaSessionID);
+// return false;
+// }
+//
+// if(authSession == null) {
+// Logger.info("NO MOA Authentication data for ID " + moaSessionID);
+// return false;
+// }
+//
+// return authSession.isAuthenticated();
- return authSession.isAuthenticated();
+ return AuthenticationSessionStoreage.isAuthenticated(moaSessionID);
}
/**
@@ -76,8 +92,14 @@ public class AuthenticationManager implements MOAIDAuthConstants {
String sessionID = (String) request.getParameter(PARAM_SESSIONID);
if (sessionID != null) {
Logger.info("got MOASession: " + sessionID);
- AuthenticationSession authSession = AuthenticationSessionStore
- .getSession(sessionID);
+ AuthenticationSession authSession;
+ try {
+ authSession = AuthenticationSessionStoreage.getSession(sessionID);
+
+ } catch (MOADatabaseException e) {
+ return false;
+ }
+
if (authSession != null) {
Logger.info("MOASession found! A: "
+ authSession.isAuthenticated() + ", AU "
@@ -111,18 +133,29 @@ public class AuthenticationManager implements MOAIDAuthConstants {
return;
}
- AuthenticationSession authSession = AuthenticationSessionStore
- .getSession(moaSessionID);
+ AuthenticationSession authSession;
+ try {
+ authSession = AuthenticationSessionStoreage
+ .getSession(moaSessionID);
+
+ if(authSession == null) {
+ Logger.info("NO MOA Authentication data for ID " + moaSessionID);
+ return;
+ }
+
+ authSession.setAuthenticated(false);
+ HTTPSessionUtils.setHTTPSessionString(session, MOA_SESSION, null); // remove moa session from HTTP Session
+
+ //TODO: delete session from Database!!!
+ //AuthenticationSessionStoreage.destroySession(moaSessionID);
+
+ session.invalidate();
- if(authSession == null) {
+ } catch (MOADatabaseException e) {
Logger.info("NO MOA Authentication data for ID " + moaSessionID);
return;
}
-
- authSession.setAuthenticated(false);
- HTTPSessionUtils.setHTTPSessionString(session, MOA_SESSION, null); // remove moa session from HTTP Session
- AuthenticationSessionStore.destroySession(moaSessionID);
- session.invalidate();
+
}
public static void doAuthentication(HttpServletRequest request,