use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.
the class AuthD method getSession.
/**
* Returns the session associated with a session ID.
*
* @param sessId Session ID.
* @return the <code>InternalSession</code> associated with a session ID.
*/
public static InternalSession getSession(String sessId) {
if (debug.messageEnabled()) {
debug.message("getSession for " + sessId);
}
InternalSession is = null;
if (sessId != null) {
SessionID sid = new SessionID(sessId);
is = getSession(sid);
}
if (is == null) {
debug.message("getSession returned null");
}
return is;
}
use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.
the class SSOProviderImpl method refreshSession.
/**
* Refresh the Session corresponding to the single sign on token from the
* Session Server.
*
* @param token single sign on token for which session need to be refreshed.
* @param possiblyResetIdleTime if true, the idle time may be reset, if false it will never be.
* @throws SSOException if the session cannot be refreshed.
*/
@Override
public void refreshSession(SSOToken token, boolean possiblyResetIdleTime) throws SSOException {
try {
SSOTokenID tokenId = token.getTokenID();
SessionID sid = new SessionID(tokenId.toString());
Session session = sessionCache.getSession(sid);
session.refresh(possiblyResetIdleTime);
} catch (Exception e) {
debug.error("Error in refreshing the session from sessions server");
throw new SSOException(e);
}
}
use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.
the class StatelessSessionActivator method activateSession.
@Override
public boolean activateSession(final LoginState loginState, final SessionService sessionService, final InternalSession authSession, final Subject subject, final Object loginContext) throws AuthException {
if (loginState.getForceFlag()) {
if (DEBUG.messageEnabled()) {
DEBUG.message("Cannot force auth stateless sessions.");
}
throw new AuthException(AMAuthErrorCode.STATELESS_FORCE_FAILED, null);
}
if (loginState.isSessionUpgrade()) {
//set our old session -- necessary as if the currently owned token is stateless this won't be set
SessionID sid = new SessionID(loginState.getHttpServletRequest());
try {
SessionInfo info = getStatelessSessionFactory().getSessionInfo(sid);
oldSession = getStatelessSessionFactory().generate(info);
loginState.setOldStatelessSession(oldSession);
} catch (SessionException e) {
throw new AuthException(AMAuthErrorCode.SESSION_UPGRADE_FAILED, null);
}
}
//create our new session - the loginState needs this session as it's the one we'll be passing back to the user
final InternalSession session = createSession(sessionService, loginState);
loginState.setSession(session);
return updateSessions(session, loginState, session, authSession, sessionService, subject, loginContext);
}
use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.
the class LoginState method createSession.
/* create new session */
void createSession(HttpServletRequest req, AuthContextLocal authContext) throws AuthException {
DEBUG.message("LoginState: createSession: Creating new session: ");
SessionID sid = null;
DEBUG.message("Save authContext in InternalSession");
session = LazyConfig.AUTHD.newSession(getOrgDN(), null, false);
//save the AuthContext object in Session
sid = session.getID();
session.setObject(ISAuthConstants.AUTH_CONTEXT_OBJ, authContext);
this.sid = sid;
if (DEBUG.messageEnabled()) {
DEBUG.message("LoginState:createSession: New session/sid=" + sid);
DEBUG.message("LoginState:New session: ac=" + authContext);
}
}
use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.
the class LogWriter method logToAuditService.
private static void logToAuditService(int type, String msgid, String[] msgdata, SSOToken ssoToken, LogMessageProvider msgProvider, SSOToken adminSSOToken) throws Exception {
String operation = msgid.substring(msgid.indexOf('_') + 1);
LogMessageID logMessageID = msgProvider.getAllHashMessageIDs().get(msgid);
if (logMessageID == null) {
DEBUG.error("Attempted audit logging for unknown message ID {}", msgid);
return;
}
List<String> fields = logMessageID.getDataColumns();
AMAuditEventBuilder builder;
String topic;
if ("LOGIN".equals(operation) && !msgid.startsWith("ATTEMPT")) {
builder = authenticationEventBuilder(type, msgid, fields, msgdata);
topic = AuditConstants.AUTHENTICATION_TOPIC;
} else if (!"LOGIN".equals(operation)) {
builder = accessEventBuilder(type, msgid, msgdata, operation, fields);
topic = AuditConstants.ACCESS_TOPIC;
} else {
return;
}
JsonValue eventJson = builder.transactionId(CommandManager.TRANSACTION_ID.getValue()).timestamp(System.currentTimeMillis()).userId(ssoToken.getPrincipal().getName()).trackingIdFromSSOToken(ssoToken).component(AuditConstants.Component.SSOADM).toEvent().getValue();
String sessionId = adminSSOToken.getTokenID().toString();
sendEvent(topic, eventJson, sessionId, new SessionID(sessionId).getSessionServerURL());
}
Aggregations