Search in sources :

Example 91 with SSOException

use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.

the class BaseURLProviderFactory method create.

private synchronized BaseURLProvider create(String realmDN) {
    if (!providers.containsKey(realmDN)) {
        debug.message("Creating base URL provider for realm: {}", realmDN);
        OpenAMSettingsImpl settings = new OpenAMSettingsImpl(SERVICE_NAME, SERVICE_VERSION);
        try {
            BaseURLProvider provider;
            if (settings.hasConfig(realmDN)) {
                ProviderType providerType = ProviderType.valueOf(settings.getStringSetting(realmDN, PROVIDER_TYPE));
                provider = providerType.getProvider();
                provider.init(settings, realmDN);
                provider.setContextPath(settings.getStringSetting(realmDN, CONTEXT_PATH));
            } else {
                provider = new RequestValuesBaseURLProvider();
                provider.setContextPath(servletContext.getContextPath());
            }
            provider.setCoreWrapper(coreWrapper);
            providers.put(realmDN, provider);
        } catch (SMSException | SSOException e) {
            debug.error("Unable to access BaseURL config for realm {}", realmDN, e);
            throw new IllegalStateException(e);
        }
    }
    return providers.get(realmDN);
}
Also used : SMSException(com.sun.identity.sm.SMSException) OpenAMSettingsImpl(org.forgerock.openam.utils.OpenAMSettingsImpl) SSOException(com.iplanet.sso.SSOException)

Example 92 with SSOException

use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.

the class SMPostAuthPlugin method onLoginSuccess.

/**
     * Post processing on successful authentication.
     *
     * @param requestParamsMap map containing <code>HttpServletRequest</code>
     *        parameters
     * @param request <code>HttpServletRequest</code> object.
     * @param response <code>HttpServletResponse</code> object.
     * @param ssoToken authenticated user's single sign token.
     * @exception AuthenticationException if there is an error.
     */
public void onLoginSuccess(Map requestParamsMap, HttpServletRequest request, HttpServletResponse response, SSOToken ssoToken) throws AuthenticationException {
    Set configuredHTTPHeaders = (Set) request.getAttribute("SM-HTTPHeaders");
    if (configuredHTTPHeaders == null || configuredHTTPHeaders.isEmpty()) {
        System.out.println("HTTP headers in auth module are not configured");
        return;
    }
    for (Iterator iter = configuredHTTPHeaders.iterator(); iter.hasNext(); ) {
        String configHeader = (String) iter.next();
        String headerValue = request.getHeader(configHeader);
        if (headerValue == null) {
            System.out.println("Config Header " + configHeader + " is not present");
            continue;
        }
        try {
            ssoToken.setProperty(configHeader, headerValue);
        } catch (SSOException se) {
            throw new AuthenticationException(se.getMessage());
        }
    }
}
Also used : Set(java.util.Set) AuthenticationException(com.sun.identity.authentication.spi.AuthenticationException) Iterator(java.util.Iterator) SSOException(com.iplanet.sso.SSOException)

Example 93 with SSOException

use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.

the class CDCServlet method redirectWithAuthNResponse.

/**
     * Constructs the Liberty AuthNResponse with Restricted SSOToken
     * and redirects the user to the requested resouce
     */
private void redirectWithAuthNResponse(HttpServletRequest request, HttpServletResponse response, SSOToken token) throws ServletException, IOException {
    String gotoURL = getRedirectURL(request, response);
    if (debug.messageEnabled()) {
        debug.message("CDCServlet.redirectWithAuthNResponse: gotoURL = " + gotoURL);
    }
    if (debug.messageEnabled()) {
        debug.message("CDCServlet.redirectWithAuthNResponse: After encoding: gotoURL = " + gotoURL);
    }
    if (gotoURL != null) {
        try {
            String inResponseTo = request.getParameter(REQUEST_ID);
            String spDescriptor = request.getParameter(PROVIDER_ID);
            String resTokenID = null;
            /**
                 * validateAndGetRestriction throws an exception if an agent
                 * profile with provider id and goto url is not present
                 */
            TokenRestriction tokenRes = spValidator.validateAndGetRestriction(FSAuthnRequest.parseURLEncodedRequest(request), gotoURL);
            if (uniqueCookieEnabled) {
                resTokenID = sessionService.getRestrictedTokenId(token.getTokenID().toString(), tokenRes);
            } else {
                resTokenID = token.getTokenID().toString();
            }
            FSAssertion assertion = createAssertion(spDescriptor, SELF_PROVIDER_ID, resTokenID, token.getAuthType(), token.getProperty("authInstant"), token.getPrincipal().getName(), inResponseTo);
            String relayState = request.getParameter(RELAY_STATE);
            Status status = new Status(new StatusCode(IFSConstants.STATUS_CODE_SUCCESS));
            FSAuthnResponse authnResponse = createAuthnResponse(SELF_PROVIDER_ID, responseID, inResponseTo, status, assertion, relayState);
            sendAuthnResponse(request, response, authnResponse, gotoURL);
        } catch (SAMLException se) {
            debug.error("CDCServlet.doGetPost", se);
            showError(response);
        } catch (FSMsgException fe) {
            debug.error("CDCServlet.doGetPost", fe);
            showError(response);
        } catch (FSException fse) {
            debug.error("CDCServlet.doGetPost", fse);
            showError(response);
        } catch (SessionException e) {
            debug.error("CDCServlet.doGetPost", e);
        } catch (SSOException ssoe) {
            debug.error("CDCServlet.doGetPost", ssoe);
        } catch (Exception e) {
            debug.error("CDCServlet.doGetPost", e);
            spValidator = new LdapSPValidator();
            showError(response, FORBIDDEN_STR_MATCH);
        }
    }
}
Also used : Status(com.sun.identity.saml.protocol.Status) FSMsgException(com.sun.identity.federation.message.common.FSMsgException) TokenRestriction(com.iplanet.dpro.session.TokenRestriction) SessionException(com.iplanet.dpro.session.SessionException) SSOException(com.iplanet.sso.SSOException) StatusCode(com.sun.identity.saml.protocol.StatusCode) SAMLException(com.sun.identity.saml.common.SAMLException) ServletException(javax.servlet.ServletException) ParseException(java.text.ParseException) SSOException(com.iplanet.sso.SSOException) FSMsgException(com.sun.identity.federation.message.common.FSMsgException) SAMLException(com.sun.identity.saml.common.SAMLException) FSException(com.sun.identity.federation.common.FSException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) SessionException(com.iplanet.dpro.session.SessionException) FSAuthnResponse(com.sun.identity.federation.message.FSAuthnResponse) FSAssertion(com.sun.identity.federation.message.FSAssertion) FSException(com.sun.identity.federation.common.FSException)

Example 94 with SSOException

use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.

the class CDCServlet method checkForPolicyAdvice.

/**
     * Returns policy advices
     */
private String checkForPolicyAdvice(SSOToken token, HttpServletRequest request, HttpServletResponse response) {
    StringBuilder adviceList = null;
    for (Enumeration e = request.getParameterNames(); e.hasMoreElements(); ) {
        String paramName = (String) e.nextElement();
        // upgrade
        if (adviceParams.contains(paramName)) {
            if (token != null) {
                if (paramName.equals("realm") && request.getParameter("sunamcompositeadvice") == null) {
                    try {
                        String orgDN = token.getProperty("Organization");
                        if (orgDN != null) {
                            String tokenRealm = LDAPUtils.rdnTypeFromDn(orgDN);
                            if (tokenRealm.equalsIgnoreCase(SMSEntry.getRootSuffix())) {
                                tokenRealm = "/";
                            } else {
                                int orgIndex = tokenRealm.indexOf(SMSEntry.ORGANIZATION_RDN + SMSEntry.EQUALS);
                                tokenRealm = tokenRealm.substring(orgIndex + 2, tokenRealm.length());
                            }
                            String requestRealm = request.getParameter(paramName);
                            if (tokenRealm.equalsIgnoreCase(requestRealm)) {
                                //then it's not session upgrade and therefore no re-auth necessary
                                return null;
                            }
                        }
                    } catch (SSOException ssoe) {
                        debug.error("CDCServlet.checkForPolicyAdvice: Failed to get realm info. ", ssoe);
                    }
                }
            }
            if (adviceList == null) {
                adviceList = new StringBuilder();
            } else {
                adviceList.append(AMP);
            }
            String[] values = request.getParameterValues(paramName);
            if (values != null) {
                for (int i = 0; i < values.length; i++) {
                    adviceList.append(paramName).append(EQUALS).append(values[i]);
                }
            }
        }
    }
    if (debug.messageEnabled()) {
        debug.message("CDCServlet.checkForPolicyAdvice: Advice List is : " + adviceList);
    }
    return (adviceList == null) ? null : adviceList.toString();
}
Also used : Enumeration(java.util.Enumeration) SSOException(com.iplanet.sso.SSOException)

Example 95 with SSOException

use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.

the class CDCServlet method init.

/**
     * Initiates the servlet.
     *
     * @param config Servlet Configuration object that contains configutation
     *        information for this servlet.
     * @throws ServletException if servlet failed to initialize.
     */
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    debug.message("CDCServlet Initializing...");
    try {
        tokenManager = SSOTokenManager.getInstance();
        sessionService = InjectorHolder.getInstance(SessionService.class);
        spValidator = new LdapSPValidator();
        DNSAddress = SystemConfigurationUtil.getProperty(Constants.AM_SERVER_HOST);
        IPAddress = InetAddress.getByName(DNSAddress).getHostAddress();
        authURLCookieName = SystemConfigurationUtil.getProperty(Constants.AUTH_UNIQUE_COOKIE_NAME, UNIQUE_COOKIE_NAME);
        authURLCookieDomain = SystemConfigurationUtil.getProperty(Constants.AUTH_UNIQUE_COOKIE_DOMAIN, "");
        deployDescriptor = SystemConfigurationUtil.getProperty(Constants.AM_SERVICES_DEPLOYMENT_DESCRIPTOR, DEFAULT_DEPLOY_URI);
        // Check if CDC needs to generate restricted SSO Tokens
        uniqueCookieEnabled = Boolean.valueOf(SystemConfigurationUtil.getProperty(Constants.IS_ENABLE_UNIQUE_COOKIE, "false")).booleanValue();
        if (debug.messageEnabled()) {
            debug.message("CDCServlet init params:" + " Restricted Token Enabled = " + uniqueCookieEnabled + " Auth URL Cookie Name = " + authURLCookieName + " Auth URL Cookie Domain = " + authURLCookieDomain + " Deployment Descriptor: " + deployDescriptor);
        }
    } catch (SSOException e) {
        debug.error("CDCServlet.init: Unable to get SSOTokenManager", e);
        throw new ServletException(e.getMessage());
    } catch (UnknownHostException e) {
        debug.error("CDCServlet.init", e);
        throw new ServletException(e.getMessage());
    }
}
Also used : ServletException(javax.servlet.ServletException) SessionService(com.iplanet.dpro.session.service.SessionService) UnknownHostException(java.net.UnknownHostException) SSOException(com.iplanet.sso.SSOException)

Aggregations

SSOException (com.iplanet.sso.SSOException)1002 SMSException (com.sun.identity.sm.SMSException)553 Set (java.util.Set)374 SSOToken (com.iplanet.sso.SSOToken)336 IdRepoException (com.sun.identity.idm.IdRepoException)291 HashSet (java.util.HashSet)289 Map (java.util.Map)223 HashMap (java.util.HashMap)205 AMIdentity (com.sun.identity.idm.AMIdentity)193 Iterator (java.util.Iterator)189 CLIException (com.sun.identity.cli.CLIException)170 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)126 ServiceConfig (com.sun.identity.sm.ServiceConfig)126 IOutput (com.sun.identity.cli.IOutput)121 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)104 ServiceSchema (com.sun.identity.sm.ServiceSchema)101 ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)93 AMIdentityRepository (com.sun.identity.idm.AMIdentityRepository)88 IOException (java.io.IOException)65 PolicyException (com.sun.identity.policy.PolicyException)62