Search in sources :

Example 6 with AuthContextLocal

use of com.sun.identity.authentication.server.AuthContextLocal in project OpenAM by OpenRock.

the class LoginState method createAuthContext.

/**
     * Creates <code>AuthContextLocal</code> for new requests.
     *
     * @return the created <code>AuthContextLocal</code>
     * @throws AuthException if fails to create <code>AuthContextLocal</code>
     */
public AuthContextLocal createAuthContext(SessionID sid, String orgName, HttpServletRequest req) throws AuthException {
    this.userOrg = getDomainNameByOrg(orgName);
    if (DEBUG.messageEnabled()) {
        DEBUG.message("createAuthContext: userOrg is : " + userOrg);
    }
    if ((this.userOrg == null) || (this.userOrg.equals(""))) {
        DEBUG.error("domain is null, error condtion");
        logFailed(LazyConfig.AUTHD.bundle.getString("invalidDomain"), "INVALIDDOMAIN");
        auditor.auditLoginFailure(this, INVALID_REALM);
        throw new AuthException(AMAuthErrorCode.AUTH_INVALID_DOMAIN, null);
    }
    if (DEBUG.messageEnabled()) {
        DEBUG.message("AuthUtil::getAuthContext::Creating new " + "AuthContextLocal & LoginState");
    }
    AuthContextLocal authContext = new AuthContextLocal(this.userOrg);
    newRequest = true;
    this.sid = sid;
    if (DEBUG.messageEnabled()) {
        DEBUG.message("requestType : " + newRequest);
        DEBUG.message("sid : " + sid);
        DEBUG.message("orgName passed: " + orgName);
    }
    try {
        createSession(req, authContext);
    } catch (Exception e) {
        DEBUG.error("Exception creating session .. :", e);
        throw new AuthException(AMAuthErrorCode.AUTH_ERROR, null);
    }
    amIdRepo = LazyConfig.AUTHD.getAMIdentityRepository(getOrgDN());
    populateOrgProfile();
    isLocaleSet = false;
    return authContext;
}
Also used : NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) SSOException(com.iplanet.sso.SSOException) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) IdRepoException(com.sun.identity.idm.IdRepoException) AuthenticationException(com.sun.identity.authentication.spi.AuthenticationException) AMException(com.iplanet.am.sdk.AMException) SessionException(com.iplanet.dpro.session.SessionException) AuthContextLocal(com.sun.identity.authentication.server.AuthContextLocal)

Example 7 with AuthContextLocal

use of com.sun.identity.authentication.server.AuthContextLocal in project OpenAM by OpenRock.

the class LoginState method createAuthContext.

/**
     * Returns authentication context for new request.
     *
     * @return Authentication context for new request.
     * @throws AuthException if it fails to instantiate <code>AuthContext</code>
     */
public AuthContextLocal createAuthContext(HttpServletRequest request, HttpServletResponse response, SessionID sid, Hashtable requestHash) throws AuthException {
    // Get / Construct the Original Login URL
    this.loginURL = AuthUtils.constructLoginURL(request);
    // Get query param indicating a request "forward" after
    // successful authentication.
    this.forwardSuccess = AuthUtils.forwardSuccessExists(request);
    // set the locale
    setRequestLocale(request);
    if (DEBUG.messageEnabled()) {
        DEBUG.message("locale : " + localeContext.getLocale());
    }
    this.userOrg = getUserDomain(request, sid, requestHash);
    if (DEBUG.messageEnabled()) {
        DEBUG.message("createAuthContext: userOrg is : " + userOrg);
    }
    if ((this.userOrg == null) || this.userOrg.length() == 0) {
        DEBUG.message("domain is null, error condtion");
        logFailed(LazyConfig.AUTHD.bundle.getString("invalidDomain"), "INVALIDDOMAIN");
        auditor.auditLoginFailure(this, INVALID_REALM);
        throw new AuthException(AMAuthErrorCode.AUTH_INVALID_DOMAIN, null);
    }
    if (DEBUG.messageEnabled()) {
        DEBUG.message("AuthUtil:getAuthContext:" + "Creating new AuthContextLocal & LoginState");
    }
    AuthContextLocal authContext = new AuthContextLocal(this.userOrg);
    newRequest = true;
    servletRequest = request;
    servletResponse = response;
    setParamHash(requestHash);
    client = getClient();
    this.sid = sid;
    if (DEBUG.messageEnabled()) {
        DEBUG.message("requestType : " + newRequest);
        DEBUG.message("client : " + client);
        DEBUG.message("sid : " + sid);
    }
    try {
        createSession(request, authContext);
    } catch (Exception e) {
        DEBUG.error("Exception creating session .. :", e);
        throw new AuthException(e);
    }
    String cookieSupport = AuthUtils.getCookieSupport(getClientType());
    cookieDetect = AuthUtils.getCookieDetect(cookieSupport);
    if ((cookieSupport != null) && cookieSupport.equals("false")) {
        cookieSupported = false;
    }
    if (DEBUG.messageEnabled()) {
        DEBUG.message("cookieSupport is : " + cookieSupport);
        DEBUG.message("cookieDetect is .. : " + cookieDetect);
        DEBUG.message("cookieSupported is .. : " + cookieSupported);
    }
    if (AuthUtils.isClientDetectionEnabled() && cookieDetect) {
        cookieSet = true;
    }
    setDecodedGoToOnFailURL();
    amIdRepo = LazyConfig.AUTHD.getAMIdentityRepository(getOrgDN());
    populateOrgProfile();
    populateGlobalProfile();
    return authContext;
}
Also used : NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) SSOException(com.iplanet.sso.SSOException) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) IdRepoException(com.sun.identity.idm.IdRepoException) AuthenticationException(com.sun.identity.authentication.spi.AuthenticationException) AMException(com.iplanet.am.sdk.AMException) SessionException(com.iplanet.dpro.session.SessionException) AuthContextLocal(com.sun.identity.authentication.server.AuthContextLocal)

Aggregations

AuthContextLocal (com.sun.identity.authentication.server.AuthContextLocal)7 SessionException (com.iplanet.dpro.session.SessionException)5 SSOException (com.iplanet.sso.SSOException)5 InternalSession (com.iplanet.dpro.session.service.InternalSession)4 AuthLoginException (com.sun.identity.authentication.spi.AuthLoginException)3 SMSException (com.sun.identity.sm.SMSException)3 AMException (com.iplanet.am.sdk.AMException)2 SessionID (com.iplanet.dpro.session.SessionID)2 AMConfigurationException (com.sun.identity.authentication.config.AMConfigurationException)2 AuthenticationException (com.sun.identity.authentication.spi.AuthenticationException)2 IdRepoException (com.sun.identity.idm.IdRepoException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 Hashtable (java.util.Hashtable)2 SSOToken (com.iplanet.sso.SSOToken)1 URL (java.net.URL)1