Search in sources :

Example 16 with IDPSSOConfigElement

use of com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement in project OpenAM by OpenRock.

the class SAML2IDPProxyFRImpl method getAttributeListValueFromIDPSSOConfig.

public List getAttributeListValueFromIDPSSOConfig(String realm, String hostEntityId, String attrName) {
    String classMethod = "IDPSSOUtil.getAttributeValueFromIDPSSOConfig: ";
    List result = null;
    try {
        IDPSSOConfigElement config = SAML2Utils.getSAML2MetaManager().getIDPSSOConfig(realm, hostEntityId);
        Map attrs = SAML2MetaUtils.getAttributes(config);
        List value = (List) attrs.get(attrName);
        if (value != null && value.size() != 0) {
            result = value;
        }
    } catch (SAML2MetaException sme) {
        if (SAML2Utils.debug.messageEnabled()) {
            SAML2Utils.debug.message(classMethod + "get IDPSSOConfig failed:", sme);
        }
        result = null;
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) IDPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement) HashMap(java.util.HashMap) Map(java.util.Map) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException)

Example 17 with IDPSSOConfigElement

use of com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement in project OpenAM by OpenRock.

the class NameIDMapping method getNameID.

private static NameID getNameID(NameIDMappingRequest nimRequest, String realm, String idpEntityID) {
    NameID nameID = nimRequest.getNameID();
    if (nameID == null) {
        EncryptedID encryptedID = nimRequest.getEncryptedID();
        try {
            final IDPSSOConfigElement idpSsoConfig = metaManager.getIDPSSOConfig(realm, idpEntityID);
            nameID = encryptedID.decrypt(KeyUtil.getDecryptionKeys(idpSsoConfig));
        } catch (SAML2Exception ex) {
            if (SAML2Utils.debug.messageEnabled()) {
                SAML2Utils.debug.message("NameIDMapping.getNameID:", ex);
            }
            return null;
        }
    }
    if (!SAML2Utils.isPersistentNameID(nameID)) {
        return null;
    }
    return nameID;
}
Also used : SAML2Exception(com.sun.identity.saml2.common.SAML2Exception) NameID(com.sun.identity.saml2.assertion.NameID) IDPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement) EncryptedID(com.sun.identity.saml2.assertion.EncryptedID)

Example 18 with IDPSSOConfigElement

use of com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement in project OpenAM by OpenRock.

the class IDPSSOUtil method getWriterURL.

private static String getWriterURL(String realm, String idpEntityID, String spEntityID) {
    String classMethod = "IDPSSOUtil.getWriterURL: ";
    String writerURL = null;
    try {
        // get cot list of the idp
        IDPSSOConfigElement idpEntityCfg = metaManager.getIDPSSOConfig(realm, idpEntityID);
        Map idpConfigAttrsMap = null;
        if (idpEntityCfg != null) {
            idpConfigAttrsMap = SAML2MetaUtils.getAttributes(idpEntityCfg);
        }
        if ((idpConfigAttrsMap == null) || (idpConfigAttrsMap.size() == 0)) {
            return null;
        }
        List idpCOTList = (List) idpConfigAttrsMap.get(SAML2Constants.COT_LIST);
        if ((idpCOTList == null) || (idpCOTList.size() == 0)) {
            return null;
        }
        // get cot list of the sp
        SPSSOConfigElement spEntityCfg = metaManager.getSPSSOConfig(realm, spEntityID);
        Map spConfigAttrsMap = null;
        if (spEntityCfg != null) {
            spConfigAttrsMap = SAML2MetaUtils.getAttributes(spEntityCfg);
        }
        if ((spConfigAttrsMap == null) || (spConfigAttrsMap.size() == 0)) {
            return null;
        }
        List spCOTList = (List) spConfigAttrsMap.get(SAML2Constants.COT_LIST);
        if ((spCOTList == null) || (spCOTList.size() == 0)) {
            return null;
        }
        // retain in the idpCOTList the intersection of two lists
        idpCOTList.retainAll(spCOTList);
        for (int i = 0; i < idpCOTList.size(); i++) {
            String cotName = (String) idpCOTList.get(i);
            CircleOfTrustDescriptor cotDescriptor = cotManager.getCircleOfTrust(realm, cotName);
            writerURL = cotDescriptor.getSAML2WriterServiceURL();
            if ((writerURL != null) && (writerURL.trim().length() != 0)) {
                break;
            }
        }
    } catch (COTException ce) {
        if (SAML2Utils.debug.messageEnabled()) {
            SAML2Utils.debug.message(classMethod + "Error retreiving of " + "circle of trust", ce);
        }
    } catch (SAML2Exception se) {
        if (SAML2Utils.debug.messageEnabled()) {
            SAML2Utils.debug.message(classMethod + "Not able to getting writer URL : ", se);
        }
    } catch (Exception e) {
        if (SAML2Utils.debug.messageEnabled()) {
            SAML2Utils.debug.message(classMethod + "Not able to getting writer URL : ", e);
        }
    }
    return writerURL;
}
Also used : SAML2Exception(com.sun.identity.saml2.common.SAML2Exception) SPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement) IDPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement) List(java.util.List) ArrayList(java.util.ArrayList) CircleOfTrustDescriptor(com.sun.identity.cot.CircleOfTrustDescriptor) COTException(com.sun.identity.cot.COTException) Map(java.util.Map) HashMap(java.util.HashMap) SAML2InvalidNameIDPolicyException(com.sun.identity.saml2.common.SAML2InvalidNameIDPolicyException) SessionException(com.sun.identity.plugin.session.SessionException) COTException(com.sun.identity.cot.COTException) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) SAML2TokenRepositoryException(org.forgerock.openam.federation.saml2.SAML2TokenRepositoryException) IOException(java.io.IOException) SAML2Exception(com.sun.identity.saml2.common.SAML2Exception)

Example 19 with IDPSSOConfigElement

use of com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement in project OpenAM by OpenRock.

the class IDPSSOUtil method getAttributeValueFromIDPSSOConfig.

public static String getAttributeValueFromIDPSSOConfig(String realm, String hostEntityId, String attrName) {
    String classMethod = "IDPSSOUtil.getAttributeValueFromIDPSSOConfig: ";
    String result = null;
    try {
        IDPSSOConfigElement config = metaManager.getIDPSSOConfig(realm, hostEntityId);
        Map attrs = SAML2MetaUtils.getAttributes(config);
        List value = (List) attrs.get(attrName);
        if (value != null && value.size() != 0) {
            result = (String) value.get(0);
        }
    } catch (SAML2MetaException sme) {
        if (SAML2Utils.debug.messageEnabled()) {
            SAML2Utils.debug.message(classMethod + "get IDPSSOConfig failed:", sme);
        }
        result = null;
    }
    return result;
}
Also used : IDPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException)

Example 20 with IDPSSOConfigElement

use of com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement in project OpenAM by OpenRock.

the class GetIDPSPPairingInCOT method getHostedIDPMetaAlias.

private List getHostedIDPMetaAlias(String realm, List hostedIDP) throws WorkflowException {
    try {
        List list = new ArrayList();
        SAML2MetaManager mgr = new SAML2MetaManager();
        for (Iterator i = hostedIDP.iterator(); i.hasNext(); ) {
            String e = (String) i.next();
            IDPSSOConfigElement cfg = mgr.getIDPSSOConfig(realm, e);
            list.add(e + "(" + cfg.getMetaAlias() + ")");
        }
        return list;
    } catch (SAML2MetaException ex) {
        throw new WorkflowException(ex.getMessage());
    }
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) IDPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException)

Aggregations

IDPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement)27 List (java.util.List)17 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)16 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)11 ArrayList (java.util.ArrayList)11 HashMap (java.util.HashMap)9 Map (java.util.Map)9 SAML2Exception (com.sun.identity.saml2.common.SAML2Exception)7 SPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement)7 IDPSSODescriptorElement (com.sun.identity.saml2.jaxb.metadata.IDPSSODescriptorElement)7 Iterator (java.util.Iterator)7 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)6 EntityConfigElement (com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)5 BaseConfigType (com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType)4 COTException (com.sun.identity.cot.COTException)3 SessionException (com.sun.identity.plugin.session.SessionException)3 NameID (com.sun.identity.saml2.assertion.NameID)3 DataStoreProviderException (com.sun.identity.plugin.datastore.DataStoreProviderException)2 EncryptedID (com.sun.identity.saml2.assertion.EncryptedID)2 XACMLAuthzDecisionQueryConfigElement (com.sun.identity.saml2.jaxb.entityconfig.XACMLAuthzDecisionQueryConfigElement)2