Search in sources :

Example 56 with IDFFMetaException

use of com.sun.identity.federation.meta.IDFFMetaException in project OpenAM by OpenRock.

the class FSPreLogin method setMetaInfo.

/**
     * Retrieves hosted provider and local configuration attributes.
     *
     * @param metaAlias the provider alias.
     * @param httpRequest the HttpServletRequest object.
     * @exception FSPreLoginException on error.
     */
private void setMetaInfo(String metaAlias, HttpServletRequest httpRequest) throws FSPreLoginException {
    if (FSUtils.debug.messageEnabled()) {
        FSUtils.debug.message("FSPreLogin::setMetaInfo called with metaAlias =" + metaAlias);
    }
    String authType = null;
    try {
        String hostedEntityID = null;
        String hostedProviderRole = IFSConstants.SP;
        if (metaManager != null) {
            hostedProviderRole = metaManager.getProviderRoleByMetaAlias(metaAlias);
            hostedEntityID = metaManager.getEntityIDByMetaAlias(metaAlias);
        } else {
            FSUtils.debug.error("FSPreLogin::setMetaInfo " + "meta manager is null. " + "Cannot proceed so throwing error page");
            throw new FSPreLoginException("FSPreLogin:: could not get meta manager handle.");
        }
        realm = IDFFMetaUtils.getRealmByMetaAlias(metaAlias);
        BaseConfigType hostedConfig = null;
        if (hostedProviderRole != null) {
            if (hostedProviderRole.equals(IFSConstants.SP)) {
                hostedConfig = metaManager.getSPDescriptorConfig(realm, hostedEntityID);
            } else if (hostedProviderRole.equals(IFSConstants.IDP)) {
                hostedConfig = metaManager.getIDPDescriptorConfig(realm, hostedEntityID);
            }
        }
        if (hostedConfig != null) {
            Map attributes = IDFFMetaUtils.getAttributes(hostedConfig);
            homePage = IDFFMetaUtils.getFirstAttributeValue(attributes, IFSConstants.PROVIDER_HOME_PAGE_URL);
            authType = IDFFMetaUtils.getFirstAttributeValue(attributes, IFSConstants.AUTH_TYPE);
            commonLoginPage = FSServiceUtils.getCommonLoginPageURL(httpRequest, hostedConfig);
            errorPage = FSServiceUtils.getErrorPageURL(httpRequest, hostedConfig, metaAlias);
        } else {
            FSUtils.debug.error("FSPreLogin::setMetaInfo " + "getDescriptorConfig retured null. " + "Cannot proceed so throwing error page");
            throw new FSPreLoginException("FSPreLogin:: could not get sp config.");
        }
        if (authType != null && authType.equalsIgnoreCase(IFSConstants.AUTH_LOCAL)) {
            doLocalAuth = true;
        } else {
            FSUtils.debug.message("FSPreLogin::setMetaInfo " + "authType=" + authType + "Setting authType to default false.");
        }
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("FSPreLogin::setMetaInfo.realm = " + realm + " doLocalAuth = " + doLocalAuth);
        }
    } catch (IDFFMetaException allianExp) {
        FSUtils.debug.error("FSPreLogin::setMetaInfo." + " IDFFMetaException caught. ", allianExp);
        throw new FSPreLoginException("FSPreLogin::IDFFMetaException. ");
    } catch (Exception exp) {
        FSUtils.debug.error("FSPreLogin::setMetaInfo." + " General Exception caught. ", exp);
        throw new FSPreLoginException("Prelogin exception");
    }
}
Also used : BaseConfigType(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) HashMap(java.util.HashMap) Map(java.util.Map) SessionException(com.sun.identity.plugin.session.SessionException) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) FSLoginHelperException(com.sun.identity.federation.services.FSLoginHelperException)

Example 57 with IDFFMetaException

use of com.sun.identity.federation.meta.IDFFMetaException in project OpenAM by OpenRock.

the class FSPostLogin method setMetaInfo.

/**
     * Retrieves the entityID of the provider.
     *
     * @param metaAlias the provider alias.
     * @param request the <code>HttpServletRequest</code> object.
     * @exception FSPostLoginException on error.
     */
private void setMetaInfo(String metaAlias, HttpServletRequest request) throws FSPostLoginException {
    if (metaManager != null) {
        BaseConfigType hostedConfig = null;
        try {
            providerRole = metaManager.getProviderRoleByMetaAlias(metaAlias);
            entityID = metaManager.getEntityIDByMetaAlias(metaAlias);
            realm = IDFFMetaUtils.getRealmByMetaAlias(metaAlias);
            if (providerRole != null && providerRole.equals(IFSConstants.IDP)) {
                isIDP = true;
                hostedConfig = metaManager.getIDPDescriptorConfig(realm, entityID);
            } else if (providerRole != null && providerRole.equalsIgnoreCase(IFSConstants.SP)) {
                hostedConfig = metaManager.getSPDescriptorConfig(realm, entityID);
            }
        } catch (IDFFMetaException ie) {
            FSUtils.debug.error("FSPostLogin::setMetaInfo: exception:", ie);
        }
        consentPage = FSServiceUtils.getConsentPageURL(request, hostedConfig);
        federationPage = FSServiceUtils.getDoFederatePageURL(request, hostedConfig);
        errorPage = FSServiceUtils.getErrorPageURL(request, hostedConfig, metaAlias);
    } else {
        FSUtils.debug.error("FSPostLogin::setMetaInfo " + "could not get alliane manager handle " + "Cannot proceed so throwing error page");
        throw new FSPostLoginException("FSPostLogin:: could not get meta manager handle.");
    }
}
Also used : BaseConfigType(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException)

Example 58 with IDFFMetaException

use of com.sun.identity.federation.meta.IDFFMetaException in project OpenAM by OpenRock.

the class FSSOAPReceiver method getRemoteProviderDescriptor.

private ProviderDescriptorType getRemoteProviderDescriptor(String hostedProviderRole, String remoteEntityId, String realm) {
    try {
        IDFFMetaManager metaManager = FSUtils.getIDFFMetaManager();
        if (metaManager == null) {
            FSUtils.debug.message("Unable to get meta manager");
            return null;
        }
        ProviderDescriptorType remoteDesc = null;
        if (hostedProviderRole.equalsIgnoreCase(IFSConstants.SP)) {
            remoteDesc = metaManager.getIDPDescriptor(realm, remoteEntityId);
        } else {
            remoteDesc = metaManager.getSPDescriptor(realm, remoteEntityId);
        }
        return remoteDesc;
    } catch (IDFFMetaException eam) {
        FSUtils.debug.error("Unable to find Hosted Provider.Cannot process request:", eam);
        return null;
    }
}
Also used : IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) ProviderDescriptorType(com.sun.identity.liberty.ws.meta.jaxb.ProviderDescriptorType)

Example 59 with IDFFMetaException

use of com.sun.identity.federation.meta.IDFFMetaException in project OpenAM by OpenRock.

the class FSDefaultRealmAttributePlugin method getAttributeStatements.

/**
     * Returns list of <code>AttributeStatement</code>s by using attribute
     * map defined in the configuration.
     * @param realm The realm under which the entity resides.
     * @param hostEntityId Hosted identity provider entity id.
     * @param remoteEntityID Remote provider's entity id
     * @param subject Subject subject of the authenticated principal.
     * @param token user's session.
     * @return list of SAML <code>AttributeStatement<code>s.
     */
public List getAttributeStatements(String realm, String hostEntityId, String remoteEntityID, FSSubject subject, Object token) {
    FSUtils.debug.message("FSDefaultAttributePlugin.getAttributeStatements");
    Map attributeMap = null;
    try {
        IDFFMetaManager metaManager = FSUtils.getIDFFMetaManager();
        if (metaManager != null) {
            IDPDescriptorConfigElement idpConfig = metaManager.getIDPDescriptorConfig(realm, hostEntityId);
            if (idpConfig != null) {
                Map attributes = IDFFMetaUtils.getAttributes(idpConfig);
                attributeMap = FSServiceUtils.parseAttributeConfig((List) attributes.get(IFSConstants.IDP_ATTRIBUTE_MAP));
            }
        }
    } catch (IDFFMetaException me) {
        FSUtils.debug.error("FSDefaultAttributePlugin.getAttribute" + "Statements: meta exception.", me);
        return null;
    }
    if (attributeMap == null || attributeMap.isEmpty()) {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("FSDefaultAttributePlugin.getAttribute" + "Statements: Attribute map configuration is empty.");
        }
        return null;
    } else {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("FSDefaultAttributePlugin.getAttribute" + "Statements: Attribute map configuration: " + attributeMap);
        }
    }
    List statements = new ArrayList();
    List attributes = new ArrayList();
    try {
        Iterator iter = attributeMap.entrySet().iterator();
        while (iter.hasNext()) {
            Map.Entry entry = (Map.Entry) iter.next();
            String attributeName = (String) entry.getKey();
            String attributeValue = getAttributeValue(token, (String) entry.getValue());
            if (attributeValue != null) {
                Attribute attr = new Attribute(attributeName, SAMLConstants.assertionSAMLNameSpaceURI, attributeValue);
                attributes.add(attr);
            }
        }
        AttributeStatement statement = new AttributeStatement(subject, attributes);
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("FSDefaultAttributePlugin.getAttribute" + "Statements: attribute statement: " + statement.toString());
        }
        statements.add(statement);
        return statements;
    } catch (SAMLException ex) {
        FSUtils.debug.error("FSDefaultAttributePlugin.getAttribute" + "Statements: SAML Exception", ex);
    }
    return new ArrayList();
}
Also used : Attribute(com.sun.identity.saml.assertion.Attribute) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) ArrayList(java.util.ArrayList) SAMLException(com.sun.identity.saml.common.SAMLException) IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) AttributeStatement(com.sun.identity.saml.assertion.AttributeStatement) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) IDPDescriptorConfigElement(com.sun.identity.federation.jaxb.entityconfig.IDPDescriptorConfigElement) Map(java.util.Map)

Example 60 with IDFFMetaException

use of com.sun.identity.federation.meta.IDFFMetaException in project OpenAM by OpenRock.

the class FSLoginHelper method setMetaInfo.

private void setMetaInfo(String metaAlias, String authLevel) throws FSLoginHelperException {
    try {
        realm = IDFFMetaUtils.getRealmByMetaAlias(metaAlias);
        if (metaManager != null) {
            hostEntityID = metaManager.getEntityIDByMetaAlias(metaAlias);
            hostDescriptor = metaManager.getSPDescriptor(realm, hostEntityID);
            hostConfig = metaManager.getSPDescriptorConfig(realm, hostEntityID);
        } else {
            FSUtils.debug.error("FSLoginHelper::setMetaInfo " + "could not get meta manager handle " + "Cannot proceed so throwing error page");
            throw new FSLoginHelperException("FSLoginHelper:: could not get meta manager handle.");
        }
        if (hostDescriptor == null) {
            FSUtils.debug.error("FSLoginHelper::setMetaInfo " + "getHostedProviderByMetaAlias retured null. " + "Cannot proceed so throwing error page");
            throw new FSLoginHelperException("FSLoginHelper:: could not get" + " host provider Descriptor handle.");
        }
        if (hostConfig != null) {
            nameIDPolicy = IDFFMetaUtils.getFirstAttributeValueFromConfig(hostConfig, IFSConstants.NAMEID_POLICY);
            cotList = IDFFMetaUtils.getAttributeValueFromConfig(hostConfig, IFSConstants.COT_LIST);
            respondWithString = IFSConstants.RESPOND_WITH;
            forceAuthn = IDFFMetaUtils.getBooleanAttributeValueFromConfig(hostConfig, IFSConstants.FORCE_AUTHN);
            isPassive = IDFFMetaUtils.getBooleanAttributeValueFromConfig(hostConfig, IFSConstants.IS_PASSIVE);
            protocolProfile = IDFFMetaUtils.getFirstAttributeValueFromConfig(hostConfig, IFSConstants.SUPPORTED_SSO_PROFILE);
            authContextString = IDFFMetaUtils.getFirstAttributeValueFromConfig(hostConfig, IFSConstants.DEFAULT_AUTHNCONTEXT);
            errorPage = FSServiceUtils.getErrorPageURL(request, hostConfig, metaAlias);
            if (authLevel != null) {
                FSUtils.debug.message("FSLoginHelper()::authLevel not null");
                Map spAuthInfoMap = FSServiceUtils.getSPAuthContextInfo(hostConfig);
                Set mapSet = spAuthInfoMap.entrySet();
                Iterator iter = mapSet.iterator();
                FSSPAuthenticationContextInfo tmpObj = null;
                while (iter.hasNext()) {
                    Map.Entry mapEntry = (Map.Entry) iter.next();
                    tmpObj = (FSSPAuthenticationContextInfo) mapEntry.getValue();
                    int authLevelInt = Integer.parseInt(authLevel);
                    if (tmpObj.getAuthenticationLevel() == authLevelInt) {
                        authContextString = tmpObj.getAuthenticationContext();
                        if (FSUtils.debug.messageEnabled()) {
                            FSUtils.debug.message("FSLoginHelper()::Found auth context " + authContextString + "for auth level " + authLevel);
                        }
                        break;
                    }
                }
            }
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("FSLoginHelper()::respondWithString: " + respondWithString);
                FSUtils.debug.message("FSLoginHelper()::providerID: " + hostEntityID);
                FSUtils.debug.message("FSLoginHelper()::forceAuthn: " + forceAuthn);
                FSUtils.debug.message("FSLoginHelper()::isPassive: " + isPassive);
            }
        } else {
            FSUtils.debug.error("FSLoginHelper:setMetaInfo failed" + "host extended meta is null");
            throw new FSLoginHelperException("FSLoginHelper::could not get host meta config.");
        }
    } catch (IDFFMetaException metaExp) {
        FSUtils.debug.error("FSLoginHelper::setMetaInfo " + "meta management Failed.", metaExp);
        throw new FSLoginHelperException("FSLoginHelper::IDFFMetaException:" + metaExp.getMessage());
    } catch (Exception exp) {
        FSUtils.debug.error("FSLoginHelper::setMetaInfo " + "General Exception caugth.", exp);
        throw new FSLoginHelperException("FSLoginHelper::Exception:" + exp.getMessage());
    }
}
Also used : IDPEntry(com.sun.identity.federation.message.common.IDPEntry) HashSet(java.util.HashSet) Set(java.util.Set) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) Iterator(java.util.Iterator) HashMap(java.util.HashMap) Map(java.util.Map) COTException(com.sun.identity.cot.COTException) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException)

Aggregations

IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)89 IDFFMetaManager (com.sun.identity.federation.meta.IDFFMetaManager)55 BaseConfigType (com.sun.identity.federation.jaxb.entityconfig.BaseConfigType)30 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)27 Iterator (java.util.Iterator)25 Map (java.util.Map)25 HashMap (java.util.HashMap)24 List (java.util.List)24 ProviderDescriptorType (com.sun.identity.liberty.ws.meta.jaxb.ProviderDescriptorType)22 Set (java.util.Set)21 SAMLException (com.sun.identity.saml.common.SAMLException)17 HashSet (java.util.HashSet)17 ArrayList (java.util.ArrayList)14 FSException (com.sun.identity.federation.common.FSException)13 FSMsgException (com.sun.identity.federation.message.common.FSMsgException)12 CLIException (com.sun.identity.cli.CLIException)10 SessionException (com.sun.identity.plugin.session.SessionException)9 IOException (java.io.IOException)9 IDPDescriptorConfigElement (com.sun.identity.federation.jaxb.entityconfig.IDPDescriptorConfigElement)8 SPDescriptorConfigElement (com.sun.identity.federation.jaxb.entityconfig.SPDescriptorConfigElement)8