Search in sources :

Example 1 with IDPDescriptorConfigElement

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

the class IDFFMetaUtils method getFirstAttributeValueFromIDPConfig.

public static String getFirstAttributeValueFromIDPConfig(IDFFMetaManager metaManager, String realm, String idpEntityID, String attrName) {
    if (metaManager == null || idpEntityID == null || attrName == null) {
        return null;
    }
    String returnVal = null;
    try {
        IDPDescriptorConfigElement idpConfig = metaManager.getIDPDescriptorConfig(realm, idpEntityID);
        if (idpConfig != null) {
            Map attributes = getAttributes(idpConfig);
            returnVal = getFirstAttributeValue(attributes, attrName);
        }
    } catch (IDFFMetaException e) {
        returnVal = null;
    }
    return returnVal;
}
Also used : IDPDescriptorConfigElement(com.sun.identity.federation.jaxb.entityconfig.IDPDescriptorConfigElement) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with IDPDescriptorConfigElement

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

the class FSAuthnDecisionHandler method getIDPAuthContextInfo.

private void getIDPAuthContextInfo(String realm, String entityID) {
    if (metaManager == null) {
        return;
    }
    try {
        IDPDescriptorConfigElement entityConfig = metaManager.getIDPDescriptorConfig(realm, entityID);
        if (entityConfig == null) {
            return;
        }
        Map attributes = IDFFMetaUtils.getAttributes(entityConfig);
        List mappings = (List) attributes.get(IFSConstants.IDP_AUTHNCONTEXT_MAPPING);
        if (mappings != null && !mappings.isEmpty()) {
            idpAuthContextMap = new HashMap();
            Iterator iter = mappings.iterator();
            while (iter.hasNext()) {
                String infoString = (String) iter.next();
                try {
                    FSIDPAuthenticationContextInfo info = new FSIDPAuthenticationContextInfo(infoString);
                    idpAuthContextMap.put(info.getAuthenticationContext(), info);
                } catch (FSException fe) {
                    if (FSUtils.debug.messageEnabled()) {
                        FSUtils.debug.message("FSAuthContextHandler.getIDPAuthContextInfo: " + "info is not valid:" + infoString + " ", fe);
                    }
                    continue;
                }
            }
        }
    } catch (IDFFMetaException e) {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("FSAuthContextHandler.getIDPAuthContextInfo: ", e);
        }
    }
}
Also used : HashMap(java.util.HashMap) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) Iterator(java.util.Iterator) FSException(com.sun.identity.federation.common.FSException) List(java.util.List) IDPDescriptorConfigElement(com.sun.identity.federation.jaxb.entityconfig.IDPDescriptorConfigElement) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with IDPDescriptorConfigElement

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

the class FSDefaultAttributePlugin 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 4 with IDPDescriptorConfigElement

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

the class IDFFMetaManager method getEntityIDByMetaAlias.

/**
     * Returns entity ID associated with the metaAlias.
     *
     * @param metaAlias The Meta Alias of the provider.
     * @return entity ID associated with the metaAlias or null if not found.
     * @throws IDFFMetaException if unable to retrieve the entity id.
     */
public String getEntityIDByMetaAlias(String metaAlias) throws IDFFMetaException {
    try {
        if (metaAlias == null || metaAlias.length() == 0) {
            return null;
        }
        // check cache first
        String entityId = IDFFMetaCache.getEntityByMetaAlias(metaAlias);
        if (entityId != null) {
            if (debug.messageEnabled()) {
                debug.message("IDFFMetaManager.getEntityByMetaAlias :" + " found entity in cache, metaAlias=" + metaAlias + ", ID=" + entityId);
            }
            return entityId;
        }
        String realm = IDFFMetaUtils.getRealmByMetaAlias(metaAlias);
        Set entityIds = idffMetaConfigInstance.getAllConfigurationNames(realm);
        if (entityIds == null || entityIds.isEmpty()) {
            return null;
        }
        for (Iterator iter = entityIds.iterator(); iter.hasNext(); ) {
            String tmpId = (String) iter.next();
            if (debug.messageEnabled()) {
                debug.message("IDFFMetaManager.getEntityByMetaAlias :" + " process entity cache for metaAlias=" + metaAlias + ", ID=" + tmpId);
            }
            SPDescriptorConfigElement spconfig = getSPDescriptorConfig(realm, tmpId);
            if (spconfig != null) {
                String tmpMetaAlias = spconfig.getMetaAlias();
                if (tmpMetaAlias != null && tmpMetaAlias.length() > 0) {
                    if (metaAlias.equals(tmpMetaAlias)) {
                        // remember this and continue to process others,
                        entityId = tmpId;
                    }
                    IDFFMetaCache.setMetaAliasEntityMapping(tmpMetaAlias, tmpId);
                    IDFFMetaCache.setMetaAliasRoleMapping(tmpMetaAlias, IFSConstants.SP);
                    if (debug.messageEnabled()) {
                        debug.message("IDFFMetaManager.getEntityByMetaAlias :" + " save to cache, metaAlias=" + tmpMetaAlias + ", ID=" + tmpId + ", role=" + IFSConstants.SP);
                    }
                }
            }
            IDPDescriptorConfigElement idpconfig = getIDPDescriptorConfig(realm, tmpId);
            if (idpconfig != null) {
                String tmpMetaAlias = idpconfig.getMetaAlias();
                if (tmpMetaAlias != null && tmpMetaAlias.length() > 0) {
                    if (metaAlias.equals(tmpMetaAlias)) {
                        // remember this and continue to process others,
                        entityId = tmpId;
                    }
                    IDFFMetaCache.setMetaAliasEntityMapping(tmpMetaAlias, tmpId);
                    IDFFMetaCache.setMetaAliasRoleMapping(tmpMetaAlias, IFSConstants.IDP);
                    if (debug.messageEnabled()) {
                        debug.message("IDFFMetaManager.getEntityByMetaAlias :" + " save to cache, metaAlias=" + tmpMetaAlias + ", ID=" + tmpId + ", role=" + IFSConstants.IDP);
                    }
                }
            }
        }
        return entityId;
    } catch (ConfigurationException e) {
        debug.error("IDFFMetaManager.getEntityByMetaAlias:", e);
        throw new IDFFMetaException(e);
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) Iterator(java.util.Iterator) SPDescriptorConfigElement(com.sun.identity.federation.jaxb.entityconfig.SPDescriptorConfigElement) IDPDescriptorConfigElement(com.sun.identity.federation.jaxb.entityconfig.IDPDescriptorConfigElement)

Example 5 with IDPDescriptorConfigElement

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

the class IDFFMetaManager method addEntityToCOT.

/**
     * Adds an entity identifier to circle of trust.
     *
     * @param realm The realm under which the entity resides in
     * @param entityID the entity identifier.
     * @throws IDFFMetaException if there is an error adding entity to circle
     *         of trust.
     */
private void addEntityToCOT(String realm, String entityID) throws IDFFMetaException {
    IDPDescriptorConfigElement idpConfig = getIDPDescriptorConfig(realm, entityID);
    if (idpConfig != null) {
        addToCircleOfTrust(idpConfig, realm, entityID);
    }
    SPDescriptorConfigElement spConfig = getSPDescriptorConfig(realm, entityID);
    if (spConfig != null) {
        addToCircleOfTrust(spConfig, realm, entityID);
    }
}
Also used : SPDescriptorConfigElement(com.sun.identity.federation.jaxb.entityconfig.SPDescriptorConfigElement) IDPDescriptorConfigElement(com.sun.identity.federation.jaxb.entityconfig.IDPDescriptorConfigElement)

Aggregations

IDPDescriptorConfigElement (com.sun.identity.federation.jaxb.entityconfig.IDPDescriptorConfigElement)16 SPDescriptorConfigElement (com.sun.identity.federation.jaxb.entityconfig.SPDescriptorConfigElement)8 IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)8 IDFFMetaManager (com.sun.identity.federation.meta.IDFFMetaManager)8 Iterator (java.util.Iterator)6 List (java.util.List)5 Map (java.util.Map)4 Set (java.util.Set)4 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)3 EntityConfigElement (com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 CLIException (com.sun.identity.cli.CLIException)2 CircleOfTrustManager (com.sun.identity.cot.CircleOfTrustManager)2 ConfigurationException (com.sun.identity.plugin.configuration.ConfigurationException)2 Attribute (com.sun.identity.saml.assertion.Attribute)2 AttributeStatement (com.sun.identity.saml.assertion.AttributeStatement)2 SAMLException (com.sun.identity.saml.common.SAMLException)2 HashMap (java.util.HashMap)2 COTException (com.sun.identity.cot.COTException)1