Search in sources :

Example 51 with SessionID

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;
}
Also used : InternalSession(com.iplanet.dpro.session.service.InternalSession) SessionID(com.iplanet.dpro.session.SessionID)

Example 52 with SessionID

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);
    }
}
Also used : SSOTokenID(com.iplanet.sso.SSOTokenID) SSOException(com.iplanet.sso.SSOException) SessionID(com.iplanet.dpro.session.SessionID) SSOException(com.iplanet.sso.SSOException) SessionException(com.iplanet.dpro.session.SessionException) Session(com.iplanet.dpro.session.Session)

Example 53 with SessionID

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);
}
Also used : InternalSession(com.iplanet.dpro.session.service.InternalSession) SessionInfo(com.iplanet.dpro.session.share.SessionInfo) SessionException(com.iplanet.dpro.session.SessionException) SessionID(com.iplanet.dpro.session.SessionID)

Example 54 with SessionID

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);
    }
}
Also used : SessionID(com.iplanet.dpro.session.SessionID)

Example 55 with SessionID

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());
}
Also used : JsonValue(org.forgerock.json.JsonValue) AMAuditEventBuilder(org.forgerock.openam.audit.AMAuditEventBuilder) SessionID(com.iplanet.dpro.session.SessionID) LogMessageID(com.sun.identity.log.messageid.LogMessageID)

Aggregations

SessionID (com.iplanet.dpro.session.SessionID)105 Test (org.testng.annotations.Test)44 SessionException (com.iplanet.dpro.session.SessionException)31 SSOToken (com.iplanet.sso.SSOToken)23 InternalSession (com.iplanet.dpro.session.service.InternalSession)18 SSOException (com.iplanet.sso.SSOException)18 AuthContextLocalWrapper (org.forgerock.openam.core.rest.authn.core.wrappers.AuthContextLocalWrapper)17 HttpServletResponse (javax.servlet.http.HttpServletResponse)16 HttpServletRequest (javax.servlet.http.HttpServletRequest)15 Session (com.iplanet.dpro.session.Session)14 URL (java.net.URL)9 Map (java.util.Map)9 AuthLoginException (com.sun.identity.authentication.spi.AuthLoginException)8 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 SMSException (com.sun.identity.sm.SMSException)4 Token (org.forgerock.openam.cts.api.tokens.Token)4 SessionIDExtensions (com.iplanet.dpro.session.SessionIDExtensions)3 TokenRestriction (com.iplanet.dpro.session.TokenRestriction)3 SessionInfo (com.iplanet.dpro.session.share.SessionInfo)3