use of com.iplanet.dpro.session.SessionException in project OpenAM by OpenRock.
the class SMProfileModelImpl method invalidateSessions.
public List<String> invalidateSessions(List<String> list, String pattern) throws AMConsoleException {
List<String> failList = Collections.emptyList();
if ((list != null) && !list.isEmpty()) {
Session session = getCurrentSession();
Map<String, Session> validSessions = getValidSessions(session, pattern);
list.retainAll(validSessions.keySet());
if (!list.isEmpty()) {
String currentSessionHandler = null;
try {
currentSessionHandler = session.getProperty(SESSION_HANDLE_PROP);
} catch (SessionException se) {
throw new AMConsoleException(getErrorString(se));
}
String[] params = new String[2];
params[0] = serverName;
String curSessionId = null;
failList = new ArrayList<String>(list.size());
for (String sessionId : list) {
Session s = validSessions.get(sessionId);
params[1] = sessionId;
boolean isCurrentSession = false;
try {
isCurrentSession = currentSessionHandler.equals(s.getProperty(SESSION_HANDLE_PROP));
} catch (SessionException se) {
logEvent("SESSION_EXCEPTION_INVALIDATE_SESSIONS", params);
throw new AMConsoleException(getErrorString(se));
}
if (isCurrentSession) {
curSessionId = sessionId;
validSession = false;
} else {
try {
logEvent("ATTEMPT_INVALIDATE_SESSIONS", params);
session.destroySession(s);
logEvent("SUCCEED_INVALIDATE_SESSIONS", params);
} catch (SessionException se) {
String[] paramsEx = { serverName, sessionId, getErrorString(se) };
logEvent("SESSION_EXCEPTION_INVALIDATE_SESSIONS", paramsEx);
try {
failList.add(s.getProperty(USER_ID));
} catch (SessionException e) {
debug.error("SMProfileModelImpl.invalidateSessions", e);
}
debug.error("SMProfileModelImpl.invalidateSessions", se);
}
}
}
if (!validSession) {
params[1] = curSessionId;
logEvent("ATTEMPT_INVALIDATE_SESSIONS", params);
try {
session.destroySession(session);
logEvent("SUCCEED_INVALIDATE_SESSIONS", params);
} catch (SessionException se) {
String[] paramsEx = { serverName, curSessionId, getErrorString(se) };
logEvent("SESSION_EXCEPTION_INVALIDATE_SESSIONS", paramsEx);
}
}
}
}
return failList;
}
use of com.iplanet.dpro.session.SessionException in project OpenAM by OpenRock.
the class SSOProviderImpl method logout.
@Override
public void logout(final SSOToken token) throws SSOException {
try {
Session session = sessionCache.getSession(new SessionID(token.getTokenID().toString()));
session.logout();
} catch (SessionException e) {
if (debug.messageEnabled()) {
debug.message("Logout: ", e);
}
throw new SSOException(e);
}
}
use of com.iplanet.dpro.session.SessionException in project OpenAM by OpenRock.
the class AuthD method initAuthSession.
private Session initAuthSession() throws SSOException, SessionException {
final Session authSession = getSessionService().getAuthenticationSession(defaultOrg, null);
if (authSession == null) {
debug.error("AuthD failed to get auth session");
throw new SessionException(BUNDLE_NAME, "gettingSessionFailed", null);
}
String clientID = authSession.getClientID();
authSession.setProperty("Principal", clientID);
authSession.setProperty("Organization", defaultOrg);
authSession.setProperty("Host", authSession.getID().getSessionServer());
if (LDAPUtils.isDN(clientID)) {
String id = "id=" + rdnValueFromDn(clientID) + ",ou=user," + ServiceManager.getBaseDN();
authSession.setProperty(Constants.UNIVERSAL_IDENTIFIER, id);
}
return authSession;
}
use of com.iplanet.dpro.session.SessionException in project OpenAM by OpenRock.
the class StatelessOperationsTest method shouldNotBlacklistSessionOnDestroyIfNotAllowed.
@Test(expectedExceptions = SessionException.class, expectedExceptionsMessageRegExp = "test")
public void shouldNotBlacklistSessionOnDestroyIfNotAllowed() throws Exception {
// Given
Session requester = mock(Session.class);
SessionException ex = new SessionException("test");
willThrow(ex).given(mockSessionService).checkPermissionToDestroySession(requester, sid);
// When
try {
statelessOperations.destroy(requester, mockSession);
} finally {
// Then
verifyZeroInteractions(mockSessionBlacklist);
}
}
use of com.iplanet.dpro.session.SessionException in project OpenAM by OpenRock.
the class CTSSessionBlacklistTest method shouldPropagateSessionExceptions.
@Test(expectedExceptions = SessionException.class)
public void shouldPropagateSessionExceptions() throws Exception {
// Given
given(mockSession.getBlacklistExpiryTime(anyLong())).willThrow(new SessionException("test"));
// When
testBlacklist.blacklist(mockSession);
// Then - exception
}
Aggregations