Search in sources :

Example 1 with AttributeServiceElement

use of com.sun.identity.saml2.jaxb.metadata.AttributeServiceElement in project OpenAM by OpenRock.

the class SAMLv2ModelImpl method getStandardAttributeAuthorityAttributes.

/**
     * Returns a map with standard AttributeAuthority attributes and values.
     *
     * @param realm to which the entity belongs.
     * @param entityName is the entity id.
     * @return Map with AttributeAuthority values.
     * @throws AMConsoleException if unable to retrieve std AttributeAuthority
     *       values based on the realm and entityName passed.
     */
public Map getStandardAttributeAuthorityAttributes(String realm, String entityName) throws AMConsoleException {
    String[] params = { realm, entityName, "SAMLv2", "AttribAuthority-Std" };
    logEvent("ATTEMPT_GET_ATTR_AUTH_ATTR_VALUES", params);
    Map map = new HashMap();
    AttributeAuthorityDescriptorElement attrauthDescriptor = null;
    try {
        SAML2MetaManager samlManager = getSAML2MetaManager();
        attrauthDescriptor = samlManager.getAttributeAuthorityDescriptor(realm, entityName);
        map.put(ATTR_SEFVICE_DEFAULT_LOCATION, Collections.EMPTY_SET);
        map.put(SUPPORTS_X509, Collections.EMPTY_SET);
        map.put(ATTR_SEFVICE_LOCATION, Collections.EMPTY_SET);
        if (attrauthDescriptor != null) {
            List artServiceList = attrauthDescriptor.getAttributeService();
            for (int i = 0; i < artServiceList.size(); i++) {
                AttributeServiceElement key = (AttributeServiceElement) artServiceList.get(i);
                if ((key.getLocation() != null) && (key.isSupportsX509Query())) {
                    map.put(SUPPORTS_X509, returnEmptySetIfValueIsNull(key.isSupportsX509Query()));
                    map.put(ATTR_SEFVICE_LOCATION, returnEmptySetIfValueIsNull(key.getLocation()));
                } else if ((key.getLocation() != null) && (key.getLocation().length() > 0)) {
                    map.put(ATTR_SEFVICE_DEFAULT_LOCATION, returnEmptySetIfValueIsNull(key.getLocation()));
                }
            }
            map.put(ASSERTION_ID_SAOP_LOC, Collections.EMPTY_SET);
            map.put(ASSERTION_ID_URI_LOC, Collections.EMPTY_SET);
            List assertionIDReqList = attrauthDescriptor.getAssertionIDRequestService();
            for (int i = 0; i < assertionIDReqList.size(); i++) {
                AssertionIDRequestServiceElement elem1 = (AssertionIDRequestServiceElement) assertionIDReqList.get(i);
                if (elem1.getBinding().contains("SOAP")) {
                    map.put(ASSERTION_ID_SAOP_LOC, returnEmptySetIfValueIsNull(elem1.getLocation()));
                } else if (elem1.getBinding().contains("URI")) {
                    map.put(ASSERTION_ID_URI_LOC, returnEmptySetIfValueIsNull(elem1.getLocation()));
                }
            }
            map.put(ATTRIBUTE_PROFILE, Collections.EMPTY_SET);
            List attrProfileList = attrauthDescriptor.getAttributeProfile();
            if (!attrProfileList.isEmpty()) {
                String key = (String) attrProfileList.get(0);
                map.put(ATTRIBUTE_PROFILE, returnEmptySetIfValueIsNull(key));
            }
        }
        logEvent("SUCCEED_GET_ATTR_AUTH_ATTR_VALUES", params);
    } catch (SAML2MetaException e) {
        debug.warning("SAMLv2ModelImpl.getStandardAttributeAuthorityAttributes:", e);
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "AttribAuthority-Std", strError };
        logEvent("FEDERATION_EXCEPTION_GET_ATTR_AUTH_ATTR_VALUES", paramsEx);
        throw new AMConsoleException(strError);
    }
    return map;
}
Also used : AttributeServiceElement(com.sun.identity.saml2.jaxb.metadata.AttributeServiceElement) AssertionIDRequestServiceElement(com.sun.identity.saml2.jaxb.metadata.AssertionIDRequestServiceElement) HashMap(java.util.HashMap) AttributeAuthorityDescriptorElement(com.sun.identity.saml2.jaxb.metadata.AttributeAuthorityDescriptorElement) List(java.util.List) ArrayList(java.util.ArrayList) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map) HashMap(java.util.HashMap) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException)

Example 2 with AttributeServiceElement

use of com.sun.identity.saml2.jaxb.metadata.AttributeServiceElement in project OpenAM by OpenRock.

the class SAMLv2ModelImpl method setStdAttributeAuthorityValues.

/**
     * Saves the standard attribute values for Attribute Authority.
     *
     * @param realm to which the entity belongs.
     * @param entityName is the entity id.
     * @param attrAuthValues Map which contains standard attribute auth values.
     * @throws AMConsoleException if saving of attribute value fails.
     */
public void setStdAttributeAuthorityValues(String realm, String entityName, Map attrAuthValues) throws AMConsoleException {
    String[] params = { realm, entityName, "SAMLv2", "AttribAuthority-Std" };
    com.sun.identity.saml2.jaxb.metadata.ObjectFactory objFact = new com.sun.identity.saml2.jaxb.metadata.ObjectFactory();
    logEvent("ATTEMPT_MODIFY_ATTR_AUTH_ATTR_VALUES", params);
    AttributeAuthorityDescriptorElement attrauthDescriptor = null;
    try {
        SAML2MetaManager samlManager = getSAML2MetaManager();
        EntityDescriptorElement entityDescriptor = samlManager.getEntityDescriptor(realm, entityName);
        attrauthDescriptor = samlManager.getAttributeAuthorityDescriptor(realm, entityName);
        if (attrauthDescriptor != null) {
            //save attribute Service
            String defLocation = getResult(attrAuthValues, ATTR_SEFVICE_DEFAULT_LOCATION);
            boolean is509 = setToBoolean(attrAuthValues, SUPPORTS_X509);
            String x509Location = getResult(attrAuthValues, ATTR_SEFVICE_LOCATION);
            AttributeServiceElement key1 = objFact.createAttributeServiceElement();
            AttributeServiceElement key2 = objFact.createAttributeServiceElement();
            key1.setBinding(soapBinding);
            key1.setLocation("");
            key2.setBinding(soapBinding);
            key2.setSupportsX509Query(false);
            key2.setLocation("");
            if (defLocation != null && defLocation.length() > 0) {
                key1.setLocation(defLocation);
            }
            if (x509Location != null && x509Location.length() > 0) {
                key2.setLocation(x509Location);
                key2.setSupportsX509Query(is509);
            }
            attrauthDescriptor.getAttributeService().clear();
            attrauthDescriptor.getAttributeService().add(key1);
            attrauthDescriptor.getAttributeService().add(key2);
            //save assertion ID request
            String soapLocation = getResult(attrAuthValues, ASSERTION_ID_SAOP_LOC);
            String uriLocation = getResult(attrAuthValues, ASSERTION_ID_URI_LOC);
            AssertionIDRequestServiceElement elem1 = objFact.createAssertionIDRequestServiceElement();
            AssertionIDRequestServiceElement elem2 = objFact.createAssertionIDRequestServiceElement();
            elem1.setBinding(soapBinding);
            elem2.setBinding(uriBinding);
            if (soapLocation != null) {
                elem1.setLocation(soapLocation);
            }
            if (uriLocation != null) {
                elem2.setLocation(uriLocation);
            }
            attrauthDescriptor.getAssertionIDRequestService().clear();
            attrauthDescriptor.getAssertionIDRequestService().add(elem1);
            attrauthDescriptor.getAssertionIDRequestService().add(elem2);
            //save attribute profile
            String attrProfile = getResult(attrAuthValues, ATTRIBUTE_PROFILE);
            List attrProfileList = attrauthDescriptor.getAttributeProfile();
            if (!attrProfileList.isEmpty()) {
                attrauthDescriptor.getAttributeProfile().clear();
            }
            attrauthDescriptor.getAttributeProfile().add(attrProfile);
            samlManager.setEntityDescriptor(realm, entityDescriptor);
        }
        logEvent("SUCCEED_MODIFY_ATTR_AUTH_ATTR_VALUES", params);
    } catch (SAML2MetaException e) {
        debug.warning("SAMLv2ModelImpl.setStdAttributeAuthorityValues:", e);
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "AttribAuthority-Std", strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_ATTR_AUTH_ATTR_VALUES", paramsEx);
        throw new AMConsoleException(strError);
    } catch (JAXBException e) {
        debug.warning("SAMLv2ModelImpl.setStdAttributeAuthorityValues:", e);
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "AttribAuthority-Std", strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_ATTR_AUTH_ATTR_VALUES", paramsEx);
    }
}
Also used : AttributeServiceElement(com.sun.identity.saml2.jaxb.metadata.AttributeServiceElement) AssertionIDRequestServiceElement(com.sun.identity.saml2.jaxb.metadata.AssertionIDRequestServiceElement) JAXBException(javax.xml.bind.JAXBException) AttributeAuthorityDescriptorElement(com.sun.identity.saml2.jaxb.metadata.AttributeAuthorityDescriptorElement) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) EntityDescriptorElement(com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement) ObjectFactory(com.sun.identity.saml2.jaxb.entityconfig.ObjectFactory) List(java.util.List) ArrayList(java.util.ArrayList) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException)

Example 3 with AttributeServiceElement

use of com.sun.identity.saml2.jaxb.metadata.AttributeServiceElement in project OpenAM by OpenRock.

the class AttributeQueryUtil method findLocation.

private static String findLocation(AttributeAuthorityDescriptorElement aad, String binding, String attrQueryProfile, String attrProfile) {
    SAML2Utils.debug.message("AttributeQueryUtil.findLocation entering...");
    List attrProfiles = aad.getAttributeProfile();
    if ((attrProfiles == null) || (attrProfiles.isEmpty())) {
        SAML2Utils.debug.message("AttributeQueryUtil.findLocation: attrProfiles is null or empty");
        if (attrProfile != null) {
            SAML2Utils.debug.message("AttributeQueryUtil.findLocation: attrProfiles is null or empty and attrProfile is null");
            return null;
        }
    } else if (!attrProfiles.contains(attrProfile)) {
        SAML2Utils.debug.message("AttributeQueryUtil.findLocation: attrProfile not found in the attrProfiles");
        return null;
    }
    SAML2Utils.debug.message("AttributeQueryUtil.findLocation: entering...");
    List attrServices = aad.getAttributeService();
    for (Iterator iter = attrServices.iterator(); iter.hasNext(); ) {
        AttributeServiceElement attrService = (AttributeServiceElement) iter.next();
        if (isValidAttributeService(binding, attrService, attrQueryProfile)) {
            SAML2Utils.debug.message("AttributeQueryUtil.findLocation: found valid service");
            return attrService.getLocation();
        }
    }
    SAML2Utils.debug.message("AttributeQueryUtil.findLocation: nothing found, leaving last line with null");
    return null;
}
Also used : AttributeServiceElement(com.sun.identity.saml2.jaxb.metadata.AttributeServiceElement) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

AttributeServiceElement (com.sun.identity.saml2.jaxb.metadata.AttributeServiceElement)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)2 AssertionIDRequestServiceElement (com.sun.identity.saml2.jaxb.metadata.AssertionIDRequestServiceElement)2 AttributeAuthorityDescriptorElement (com.sun.identity.saml2.jaxb.metadata.AttributeAuthorityDescriptorElement)2 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)2 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)2 ObjectFactory (com.sun.identity.saml2.jaxb.entityconfig.ObjectFactory)1 EntityDescriptorElement (com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 JAXBException (javax.xml.bind.JAXBException)1