Search in sources :

Example 31 with BaseConfigType

use of com.sun.identity.federation.jaxb.entityconfig.BaseConfigType in project OpenAM by OpenRock.

the class FSRegistrationRequestServlet method doGetPost.

/**
     * Handles registration request.
     * in the application
     * @param request <code>HttpServletRequest</code> object that contains the
     *  request the client has made of the servlet.
     * @param response <code>HttpServletResponse</code> object that contains
     *  the response the servlet sends to the client.
     * @exception IOException if the request could not be handled
     */
private void doGetPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // Alias processing        
    String providerAlias = FSServiceUtils.getMetaAlias(request);
    if (providerAlias == null || providerAlias.length() < 1) {
        FSUtils.debug.error("Unable to retrieve alias, Hosted " + "Provider. Cannot process request");
        response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString("aliasNotFound"));
        return;
    }
    if (metaManager == null) {
        FSUtils.debug.error("Cannot retrieve hosted descriptor. " + "Cannot process request");
        response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString(IFSConstants.FAILED_HOSTED_DESCRIPTOR));
        return;
    }
    String realm = IDFFMetaUtils.getRealmByMetaAlias(providerAlias);
    ProviderDescriptorType hostedProviderDesc = null;
    BaseConfigType hostedConfig = null;
    String hostedEntityId = null;
    String hostedProviderRole = null;
    try {
        hostedProviderRole = metaManager.getProviderRoleByMetaAlias(providerAlias);
        hostedEntityId = metaManager.getEntityIDByMetaAlias(providerAlias);
        if (hostedProviderRole != null && hostedProviderRole.equalsIgnoreCase(IFSConstants.IDP)) {
            hostedProviderDesc = metaManager.getIDPDescriptor(realm, hostedEntityId);
            hostedConfig = metaManager.getIDPDescriptorConfig(realm, hostedEntityId);
        } else if (hostedProviderRole != null && hostedProviderRole.equalsIgnoreCase(IFSConstants.SP)) {
            hostedProviderDesc = metaManager.getSPDescriptor(realm, hostedEntityId);
            hostedConfig = metaManager.getSPDescriptorConfig(realm, hostedEntityId);
        }
        if (hostedProviderDesc == null) {
            throw new IDFFMetaException((String) null);
        }
    } catch (IDFFMetaException eam) {
        FSUtils.debug.error("Unable to find Hosted Provider. not process request");
        response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString(IFSConstants.FAILED_HOSTED_DESCRIPTOR));
        return;
    }
    this.request = request;
    setRegistrationURL(hostedConfig, providerAlias);
    FSNameRegistrationRequest regisRequest = new FSNameRegistrationRequest();
    try {
        regisRequest = FSNameRegistrationRequest.parseURLEncodedRequest(request);
    } catch (FSMsgException e) {
        FSServiceUtils.showErrorPage(response, COMMON_ERROR_PAGE, IFSConstants.REGISTRATION_REQUEST_IMPROPER, IFSConstants.REGISTRATION_FAILED);
        return;
    } catch (SAMLException e) {
        FSServiceUtils.showErrorPage(response, COMMON_ERROR_PAGE, IFSConstants.REGISTRATION_REQUEST_IMPROPER, IFSConstants.REGISTRATION_FAILED);
        return;
    }
    if (regisRequest == null) {
        FSServiceUtils.showErrorPage(response, COMMON_ERROR_PAGE, IFSConstants.REGISTRATION_REQUEST_IMPROPER, IFSConstants.REGISTRATION_FAILED);
    } else {
        doRequestProcessing(request, response, hostedProviderDesc, hostedConfig, hostedProviderRole, realm, hostedEntityId, providerAlias, regisRequest);
    }
}
Also used : BaseConfigType(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType) FSMsgException(com.sun.identity.federation.message.common.FSMsgException) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) ProviderDescriptorType(com.sun.identity.liberty.ws.meta.jaxb.ProviderDescriptorType) FSNameRegistrationRequest(com.sun.identity.federation.message.FSNameRegistrationRequest) SAMLException(com.sun.identity.saml.common.SAMLException)

Example 32 with BaseConfigType

use of com.sun.identity.federation.jaxb.entityconfig.BaseConfigType in project OpenAM by OpenRock.

the class FSRegistrationInitiationServlet method doGetPost.

/**
     * Invoked when the user clicks on the registration link in the application.
     * @param request <code>HttpServletRequest</code> object that contains the
     *  request the client has made of the servlet.
     * @param response <code>HttpServletResponse</code> object that contains
     *  the response the servlet sends to the client.
     * @exception ServletException, IOException if the request could not be
     *  handled
     */
private void doGetPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // Alias processing
    String providerAlias = request.getParameter(IFSConstants.META_ALIAS);
    if (providerAlias == null || providerAlias.length() < 1) {
        FSUtils.debug.error("Unable to retrieve alias, Hosted Provider. " + "Cannot process request");
        response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString("aliasNotFound"));
        return;
    }
    if (metaManager == null) {
        FSUtils.debug.error("Cannot retrieve hosted descriptor. " + "Cannot process request");
        response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString(IFSConstants.FAILED_HOSTED_DESCRIPTOR));
        return;
    }
    ProviderDescriptorType hostedProviderDesc = null;
    BaseConfigType hostedConfig = null;
    String hostedRole = null;
    String hostedEntityId = null;
    String realm = IDFFMetaUtils.getRealmByMetaAlias(providerAlias);
    try {
        hostedRole = metaManager.getProviderRoleByMetaAlias(providerAlias);
        hostedEntityId = metaManager.getEntityIDByMetaAlias(providerAlias);
        if (hostedRole != null && hostedRole.equalsIgnoreCase(IFSConstants.SP)) {
            hostedProviderDesc = metaManager.getSPDescriptor(realm, hostedEntityId);
            hostedConfig = metaManager.getSPDescriptorConfig(realm, hostedEntityId);
        } else if (hostedRole != null && hostedRole.equalsIgnoreCase(IFSConstants.IDP)) {
            hostedProviderDesc = metaManager.getIDPDescriptor(realm, hostedEntityId);
            hostedConfig = metaManager.getIDPDescriptorConfig(realm, hostedEntityId);
        }
        if (hostedProviderDesc == null) {
            throw new IDFFMetaException((String) null);
        }
    } catch (IDFFMetaException eam) {
        FSUtils.debug.error("Unable to find Hosted Provider. not process request", eam);
        response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString(IFSConstants.FAILED_HOSTED_DESCRIPTOR));
        return;
    }
    boolean isIDP = false;
    if (hostedRole != null && hostedRole.equalsIgnoreCase(IFSConstants.IDP)) {
        isIDP = true;
    }
    if (FSUtils.needSetLBCookieAndRedirect(request, response, isIDP)) {
        return;
    }
    this.request = request;
    setRegistrationURL(hostedConfig, providerAlias);
    doRegistrationInitiation(request, response, hostedProviderDesc, hostedConfig, hostedEntityId, hostedRole, providerAlias);
}
Also used : BaseConfigType(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) ProviderDescriptorType(com.sun.identity.liberty.ws.meta.jaxb.ProviderDescriptorType)

Example 33 with BaseConfigType

use of com.sun.identity.federation.jaxb.entityconfig.BaseConfigType in project OpenAM by OpenRock.

the class FSLogoutUtil method sendErrorPage.

/**
     * Returns the hosted provider's failure page to the user.
     * @param request the <code>HttpServletRequest</code> object
     * @param response the <code>HttpServletResponse</code> object
     * @param providerAlias the provider alias corresponding to the hosted
     *  provider
     */
protected static void sendErrorPage(HttpServletRequest request, HttpServletResponse response, String providerAlias) {
    try {
        String retURL = "";
        String realm = IDFFMetaUtils.getRealmByMetaAlias(providerAlias);
        if (metaManager != null) {
            String hostedRole = metaManager.getProviderRoleByMetaAlias(providerAlias);
            String hostedEntityId = metaManager.getEntityIDByMetaAlias(providerAlias);
            BaseConfigType hostedConfig = null;
            if (hostedEntityId != null && IFSConstants.IDP.equalsIgnoreCase(hostedRole)) {
                hostedConfig = metaManager.getIDPDescriptorConfig(realm, hostedEntityId);
            } else if (hostedEntityId != null && IFSConstants.SP.equalsIgnoreCase(hostedRole)) {
                hostedConfig = metaManager.getSPDescriptorConfig(realm, hostedEntityId);
            }
            retURL = FSServiceUtils.getLogoutDonePageURL(request, hostedConfig, providerAlias);
            if (retURL == null || retURL.length() < 1) {
                FSServiceUtils.showErrorPage(response, FSServiceUtils.getErrorPageURL(request, hostedConfig, providerAlias), IFSConstants.LOGOUT_FAILED, IFSConstants.METADATA_ERROR);
            } else {
                StringBuffer finalReturnURL = new StringBuffer();
                finalReturnURL.append(retURL);
                char delimiter;
                if (retURL.indexOf(IFSConstants.QUESTION_MARK) < 0) {
                    delimiter = IFSConstants.QUESTION_MARK;
                } else {
                    delimiter = IFSConstants.AMPERSAND;
                }
                finalReturnURL.append(delimiter).append(IFSConstants.LOGOUT_STATUS).append(IFSConstants.EQUAL_TO).append(IFSConstants.LOGOUT_FAILURE);
                response.sendRedirect(finalReturnURL.toString());
            }
            return;
        } else {
            FSUtils.debug.error("Meta manager instance is null");
            response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString("failedToReadDataStore"));
            return;
        }
    } catch (IOException ex) {
        FSUtils.debug.error("FSSingleLogoutServlet: IOException caught:", ex);
        return;
    } catch (IDFFMetaException e) {
        FSUtils.debug.error("FSSingleLogoutServlet:IDFFMetaException:", e);
        return;
    }
}
Also used : BaseConfigType(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) IOException(java.io.IOException)

Example 34 with BaseConfigType

use of com.sun.identity.federation.jaxb.entityconfig.BaseConfigType in project OpenAM by OpenRock.

the class LibertyManager method getNameRegistrationDonePageURL.

/** 
     * Returns the Name <code>RegistrationDonePageURL</code> from the
     * <code>providerID</code> under a realm.
     *
     * @param realm The realm under which the entity resides.
     * @param providerID provider's entity ID.
     * @param providerRole provider Role.
     * @param request HTTP servlet request.
     * @return the Name <code>RegistrationDonePageURL</code> from the
     *  <code>providerID</code>.
     */
public static String getNameRegistrationDonePageURL(String realm, String providerID, String providerRole, HttpServletRequest request) {
    BaseConfigType extendedConfig = IDFFMetaUtils.getExtendedConfig(realm, providerID, providerRole, metaManager);
    String metaAlias = null;
    if (extendedConfig != null) {
        metaAlias = extendedConfig.getMetaAlias();
    }
    return FSServiceUtils.getRegistrationDonePageURL(request, extendedConfig, metaAlias);
}
Also used : BaseConfigType(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType)

Example 35 with BaseConfigType

use of com.sun.identity.federation.jaxb.entityconfig.BaseConfigType in project OpenAM by OpenRock.

the class IDFFModelImpl method getSPEntityConfig.

/**
     * Returns attributes values in extended metadata.
     *
     * @param realm where the entity exists.
     * @param entityName Name of Entity Descriptor.
     * @param location Location of provider such as Hosted or Remote.
     * @return attributes values of provider.
     */
public Map getSPEntityConfig(String realm, String entityName, String location) throws AMConsoleException {
    String[] params = { realm, entityName, "IDFF", "SP-Extended Metadata" };
    logEvent("ATTEMPT_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", params);
    IDFFMetaManager manager;
    Map map = new HashMap();
    Map tmpMap = new HashMap();
    try {
        manager = getIDFFMetaManager();
        String metaAlias = null;
        BaseConfigType spConfig = manager.getSPDescriptorConfig(realm, entityName);
        if (spConfig != null) {
            map = IDFFMetaUtils.getAttributes(spConfig);
            metaAlias = spConfig.getMetaAlias();
        } else {
            createEntityConfig(realm, entityName, IFSConstants.SP, location);
        }
        Set entries = map.entrySet();
        Iterator iterator = entries.iterator();
        while (iterator.hasNext()) {
            Map.Entry entry = (Map.Entry) iterator.next();
            if (((String) entry.getKey()).equals(ATTR_SUPPORTED_SSO_PROFILE)) {
                List supportedSSOProfileList = (List) entry.getValue();
                if (!supportedSSOProfileList.isEmpty()) {
                    tmpMap.put((String) entry.getKey(), returnEmptySetIfValueIsNull((String) supportedSSOProfileList.get(0)));
                }
            } else {
                tmpMap.put((String) entry.getKey(), returnEmptySetIfValueIsNull(convertListToSet((List) entry.getValue())));
            }
        }
        tmpMap.put(ATTR_PROVIDER_ALIAS, returnEmptySetIfValueIsNull(metaAlias));
        if (!tmpMap.containsKey(ATTR_SIGNING_CERT_ALIAS)) {
            tmpMap.put(ATTR_SIGNING_CERT_ALIAS, Collections.EMPTY_SET);
        }
        if (!tmpMap.containsKey(ATTR_ENCRYPTION_CERT_ALIAS)) {
            tmpMap.put(ATTR_ENCRYPTION_CERT_ALIAS, Collections.EMPTY_SET);
        }
        logEvent("SUCCEED_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", params);
    } catch (IDFFMetaException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "IDFF", "SP-Extended Metadata", strError };
        logEvent("FEDERATION_EXCEPTION_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", paramsEx);
        throw new AMConsoleException(getErrorString(e));
    } catch (AMConsoleException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "IDFF", "SP-Extended Metadata", strError };
        logEvent("FEDERATION_EXCEPTION_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", paramsEx);
        throw new AMConsoleException(getErrorString(e));
    }
    return tmpMap;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) BaseConfigType(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType) IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

BaseConfigType (com.sun.identity.federation.jaxb.entityconfig.BaseConfigType)54 IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)33 IDFFMetaManager (com.sun.identity.federation.meta.IDFFMetaManager)18 List (java.util.List)18 FSException (com.sun.identity.federation.common.FSException)17 SessionException (com.sun.identity.plugin.session.SessionException)14 IOException (java.io.IOException)14 ArrayList (java.util.ArrayList)14 Iterator (java.util.Iterator)14 IDPDescriptorType (com.sun.identity.liberty.ws.meta.jaxb.IDPDescriptorType)13 SAMLException (com.sun.identity.saml.common.SAMLException)13 FSMsgException (com.sun.identity.federation.message.common.FSMsgException)12 ProviderDescriptorType (com.sun.identity.liberty.ws.meta.jaxb.ProviderDescriptorType)12 FSSessionManager (com.sun.identity.federation.services.FSSessionManager)10 HashMap (java.util.HashMap)10 Map (java.util.Map)10 ServletException (javax.servlet.ServletException)10 FSAuthnRequest (com.sun.identity.federation.message.FSAuthnRequest)9 Set (java.util.Set)9 FSAccountMgmtException (com.sun.identity.federation.accountmgmt.FSAccountMgmtException)8