Search in sources :

Example 26 with BaseConfigType

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

the class NameIDMapping method initiateNameIDMappingRequest.

/**
     * Parses the request parameters and builds the NameIDMappingRequest to
     * sent to remote identity provider.
     *
     * @param session user session.
     * @param realm the realm of hosted entity
     * @param spEntityID entity ID of hosted service provider
     * @param idpEntityID entity ID of remote idendity provider
     * @param targetSPEntityID entity ID of target entity ID of service
     *     provider
     * @param targetNameIDFormat format of target Name ID
     * @param paramsMap Map of all other parameters
     *
     * @return the <code>NameIDMappingResponse</code>
     * @throws SAML2Exception if error initiating request to remote entity.
     *
     * @supported.api
     */
public static NameIDMappingResponse initiateNameIDMappingRequest(Object session, String realm, String spEntityID, String idpEntityID, String targetSPEntityID, String targetNameIDFormat, Map paramsMap) throws SAML2Exception {
    if (spEntityID == null) {
        throw new SAML2Exception(SAML2Utils.bundle.getString("nullSPEntityID"));
    }
    if (idpEntityID == null) {
        throw new SAML2Exception(SAML2Utils.bundle.getString("nullIDPEntityID"));
    }
    String userID = null;
    try {
        userID = sessionProvider.getPrincipalName(session);
    } catch (SessionException e) {
        if (SAML2Utils.debug.messageEnabled()) {
            SAML2Utils.debug.message("NameIDMapping.createNameIDMappingRequest: ", e);
        }
    }
    if (userID == null) {
        throw new SAML2Exception(SAML2Utils.bundle.getString("invalidSSOToken"));
    }
    if (SAML2Utils.debug.messageEnabled()) {
        SAML2Utils.debug.message("NameIDMapping.initiateNameMappingRequest:" + " IDP EntityID is : " + idpEntityID);
        SAML2Utils.debug.message("NameIDMapping.initiateNameMappingRequest:" + " SP HOST EntityID is : " + spEntityID);
        SAML2Utils.debug.message("NameIDMapping.initiateNameMappingRequest:" + " target SP EntityID is : " + targetSPEntityID);
    }
    try {
        // nameIDMappingService
        String binding = SAML2Utils.getParameter(paramsMap, SAML2Constants.BINDING);
        if (binding == null) {
            binding = SAML2Constants.SOAP;
        } else if (!binding.equals(SAML2Constants.SOAP)) {
            throw new SAML2Exception(SAML2Utils.bundle.getString("nimServiceBindingUnsupport"));
        }
        String nimURL = SAML2Utils.getParameter(paramsMap, "nimURL");
        if (nimURL == null) {
            NameIDMappingServiceElement nameIDMappingService = getNameIDMappingService(realm, idpEntityID, binding);
            if (nameIDMappingService != null) {
                nimURL = nameIDMappingService.getLocation();
            }
        }
        if (SAML2Utils.debug.messageEnabled()) {
            SAML2Utils.debug.message("NameIDMapping.initiateNameMappingRequest:" + " nimURL" + nimURL);
        }
        if (nimURL == null) {
            throw new SAML2Exception(SAML2Utils.bundle.getString("nimServiceNotFound"));
        }
        NameIDMappingRequest nimRequest = createNameIDMappingRequest(userID, realm, spEntityID, idpEntityID, nimURL, targetSPEntityID, targetNameIDFormat);
        signNIMRequest(nimRequest, realm, spEntityID, false);
        BaseConfigType config = metaManager.getIDPSSOConfig(realm, idpEntityID);
        nimURL = SAML2SDKUtils.fillInBasicAuthInfo(config, nimURL);
        return doNIMBySOAP(nimRequest.toXMLString(true, true), nimURL, realm, spEntityID);
    } catch (SAML2MetaException sme) {
        throw new SAML2Exception(SAML2Utils.bundle.getString("metaDataError"));
    }
}
Also used : SAML2Exception(com.sun.identity.saml2.common.SAML2Exception) NameIDMappingServiceElement(com.sun.identity.saml2.jaxb.metadata.NameIDMappingServiceElement) BaseConfigType(com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType) SessionException(com.sun.identity.plugin.session.SessionException) NameIDMappingRequest(com.sun.identity.saml2.protocol.NameIDMappingRequest) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException)

Example 27 with BaseConfigType

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

the class SAMLv2ModelImpl method getExtendedAttributeAuthorityAttributes.

/**
     * Returns a map with extended AttributeAuthority attributes and values.
     *
     * @param realm to which the entity belongs.
     * @param entityName is the entity id.
     * @return Map with extended AttributeAuthority values.
     * @throws AMConsoleException if unable to retrieve ext AttributeAuthority
     *     attributes based on the realm and entityName passed.
     */
public Map getExtendedAttributeAuthorityAttributes(String realm, String entityName) throws AMConsoleException {
    String[] params = { realm, entityName, "SAMLv2", "AttribAuthority-Ext" };
    logEvent("ATTEMPT_GET_ATTR_AUTH_ATTR_VALUES", params);
    Map map = null;
    AttributeAuthorityConfigElement attributeAuthorityConfig = null;
    try {
        SAML2MetaManager samlManager = getSAML2MetaManager();
        attributeAuthorityConfig = samlManager.getAttributeAuthorityConfig(realm, entityName);
        if (attributeAuthorityConfig != null) {
            BaseConfigType baseConfig = (BaseConfigType) attributeAuthorityConfig;
            map = SAML2MetaUtils.getAttributes(baseConfig);
        }
        logEvent("SUCCEED_GET_ATTR_AUTH_ATTR_VALUES", params);
    } catch (SAML2MetaException e) {
        debug.warning("SAMLv2ModelImpl.getExtendedAttributeAuthorityAttributes:", e);
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "AttribAuthority-Ext", strError };
        logEvent("FEDERATION_EXCEPTION_GET_ATTR_AUTH_ATTR_VALUES", paramsEx);
        throw new AMConsoleException(strError);
    }
    return (map != null) ? map : Collections.EMPTY_MAP;
}
Also used : BaseConfigType(com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) AttributeAuthorityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.AttributeAuthorityConfigElement) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map) HashMap(java.util.HashMap) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException)

Example 28 with BaseConfigType

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

the class SAMLv2ModelImpl method updateBaseConfig.

/**
     * Updates the BaseConfigElement.
     *
     * @param baseConfig is the BaseConfigType passed.
     * @param values the Map which contains the new attribute/value pairs.
     * @param role the role of entity.
     * @throws AMConsoleException if update of baseConfig object fails.
     */
private void updateBaseConfig(BaseConfigType baseConfig, Map values, String role) throws JAXBException, AMConsoleException {
    List attrList = baseConfig.getAttribute();
    if (role.equals(EntityModel.IDENTITY_PROVIDER)) {
        attrList.clear();
        baseConfig = addAttributeType(extendedMetaIdpMap, baseConfig);
        attrList = baseConfig.getAttribute();
    } else if (role.equals(EntityModel.SERVICE_PROVIDER)) {
        attrList.clear();
        baseConfig = addAttributeType(extendedMetaSpMap, baseConfig);
        attrList = baseConfig.getAttribute();
    } else if (role.equals(EntityModel.POLICY_ENFORCEMENT_POINT_DESCRIPTOR)) {
        attrList.clear();
        baseConfig = addAttributeType(xacmlPEPExtendedMeta, baseConfig);
        attrList = baseConfig.getAttribute();
    } else if (role.equals(EntityModel.POLICY_DECISION_POINT_DESCRIPTOR)) {
        attrList.clear();
        baseConfig = addAttributeType(xacmlPDPExtendedMeta, baseConfig);
        attrList = baseConfig.getAttribute();
    }
    for (Iterator it = attrList.iterator(); it.hasNext(); ) {
        AttributeElement avpnew = (AttributeElement) it.next();
        String name = avpnew.getName();
        if (values.keySet().contains(name)) {
            Set set = (Set) values.get(name);
            if (set != null) {
                avpnew.getValue().clear();
                avpnew.getValue().addAll(set);
            }
        }
    }
}
Also used : Set(java.util.Set) OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) AttributeElement(com.sun.identity.saml2.jaxb.entityconfig.AttributeElement)

Example 29 with BaseConfigType

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

the class SAMLv2ModelImpl method updateBaseConfig.

/**
     * Updates the BaseConfigElement.
     *
     * @param baseConfig is the BaseConfigType passed.
     * @param attributeName is the attribute name
     * @param list the list which contains the new values.
     * @throws AMConsoleException if update of baseConfig object fails.
     */
private void updateBaseConfig(BaseConfigType baseConfig, String attributeName, List list) throws AMConsoleException {
    List attrList = baseConfig.getAttribute();
    for (Iterator it = attrList.iterator(); it.hasNext(); ) {
        AttributeElement avpnew = (AttributeElement) it.next();
        String name = avpnew.getName();
        if (name.equals(attributeName)) {
            avpnew.getValue().clear();
            avpnew.getValue().addAll(list);
        }
    }
}
Also used : Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) AttributeElement(com.sun.identity.saml2.jaxb.entityconfig.AttributeElement)

Example 30 with BaseConfigType

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

the class SAMLv2ModelImpl method getExtendedIdentityProviderAttributes.

/**
     * Returns a map with extended identity provider attributes and values.
     *
     * @param realm to which the entity belongs.
     * @param entityName is the entity id.
     * @return Map with extended attribute values of Identity Provider.
     * @throws AMConsoleException if unable to retrieve the Identity Provider
     *     attrubutes based on the realm and entityName passed.
     */
public Map<String, List<String>> getExtendedIdentityProviderAttributes(String realm, String entityName) throws AMConsoleException {
    String[] params = { realm, entityName, "SAMLv2", "IDP-Extended" };
    logEvent("ATTEMPT_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", params);
    Map<String, List<String>> map = null;
    IDPSSOConfigElement idpssoConfig = null;
    try {
        SAML2MetaManager samlManager = getSAML2MetaManager();
        idpssoConfig = samlManager.getIDPSSOConfig(realm, entityName);
        if (idpssoConfig != null) {
            BaseConfigType baseConfig = (BaseConfigType) idpssoConfig;
            map = SAML2MetaUtils.getAttributes(baseConfig);
        }
        logEvent("SUCCEED_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", params);
    } catch (SAML2MetaException e) {
        debug.warning("SAMLv2ModelImpl.getExtIdentityProviderAttributes:", e);
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "IDP-Extended", strError };
        logEvent("FEDERATION_EXCEPTION_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", paramsEx);
        throw new AMConsoleException(strError);
    }
    return (map != null) ? map : Collections.EMPTY_MAP;
}
Also used : BaseConfigType(com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType) List(java.util.List) ArrayList(java.util.ArrayList) IDPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException)

Aggregations

BaseConfigType (com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType)36 List (java.util.List)31 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)25 ArrayList (java.util.ArrayList)17 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)16 Iterator (java.util.Iterator)15 HashMap (java.util.HashMap)14 Map (java.util.Map)14 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)12 EntityConfigElement (com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)11 SAML2Exception (com.sun.identity.saml2.common.SAML2Exception)10 SessionException (com.sun.identity.plugin.session.SessionException)7 AttributeType (com.sun.identity.saml2.jaxb.entityconfig.AttributeType)5 ConfigurationException (com.sun.identity.plugin.configuration.ConfigurationException)4 AffiliationConfigElement (com.sun.identity.saml2.jaxb.entityconfig.AffiliationConfigElement)4 IDPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement)4 ObjectFactory (com.sun.identity.saml2.jaxb.entityconfig.ObjectFactory)4 EntityDescriptorElement (com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement)4 IDPSSODescriptorElement (com.sun.identity.saml2.jaxb.metadata.IDPSSODescriptorElement)4 SessionProvider (com.sun.identity.plugin.session.SessionProvider)3