Search in sources :

Example 1 with AssertionConsumerServiceElement

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

the class SPSSOFederate method getACSUrl.

/**
     * Returns an Ordered Set containing the AssertionConsumerServiceURL
     * and AssertionConsumerServiceIndex.
     */
static OrderedSet getACSUrl(SPSSODescriptorElement spsso, String binding) {
    String responseBinding = binding;
    if ((binding != null) && (binding.length() > 0) && (binding.indexOf(SAML2Constants.BINDING_PREFIX) == -1)) {
        responseBinding = new StringBuffer().append(SAML2Constants.BINDING_PREFIX).append(binding).toString();
    }
    List acsList = spsso.getAssertionConsumerService();
    String acsURL = null;
    if (acsList != null && !acsList.isEmpty()) {
        Iterator ac = acsList.iterator();
        while (ac.hasNext()) {
            AssertionConsumerServiceElement ace = (AssertionConsumerServiceElement) ac.next();
            if ((ace != null && ace.isIsDefault()) && (responseBinding == null || responseBinding.length() == 0)) {
                acsURL = ace.getLocation();
                responseBinding = ace.getBinding();
                break;
            } else if ((ace != null) && (ace.getBinding().equals(responseBinding))) {
                acsURL = ace.getLocation();
                break;
            }
        }
    }
    OrderedSet ol = new OrderedSet();
    ol.add(acsURL);
    ol.add(responseBinding);
    if (SAML2Utils.debug.messageEnabled()) {
        SAML2Utils.debug.message("SPSSOFederate: AssertionConsumerService :" + " URL :" + acsURL);
        SAML2Utils.debug.message("SPSSOFederate: AssertionConsumerService :" + " Binding Passed in Query: " + binding);
        SAML2Utils.debug.message("SPSSOFederate: AssertionConsumerService :" + " Binding : " + responseBinding);
    }
    return ol;
}
Also used : OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) Iterator(java.util.Iterator) AssertionConsumerServiceElement(com.sun.identity.saml2.jaxb.metadata.AssertionConsumerServiceElement) List(java.util.List) IDPList(com.sun.identity.saml2.protocol.IDPList) ArrayList(java.util.ArrayList)

Example 2 with AssertionConsumerServiceElement

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

the class TaskModelImpl method setAcsUrl.

/**
     * Saves the Salesforce login url as the Assertion Consumer Service Location
     * @param realm Realm
     * @param entityId Entity Name
     * @param acsUrl assertion consumer service location
     * @throws AMConsoleException if value cannot be saved.
     */
public void setAcsUrl(String realm, String entityId, String acsUrl) throws AMConsoleException {
    SPSSODescriptorElement spssoDescriptor = null;
    try {
        SAML2MetaManager samlManager = new SAML2MetaManager();
        EntityDescriptorElement entityDescriptor = samlManager.getEntityDescriptor(realm, entityId);
        spssoDescriptor = samlManager.getSPSSODescriptor(realm, entityId);
        if (spssoDescriptor != null) {
            List asconsServiceList = spssoDescriptor.getAssertionConsumerService();
            for (Iterator i = asconsServiceList.listIterator(); i.hasNext(); ) {
                AssertionConsumerServiceElement acsElem = (AssertionConsumerServiceElement) i.next();
                if (acsElem.getBinding().contains("HTTP-POST")) {
                    acsElem.setLocation(acsUrl);
                }
            }
            samlManager.setEntityDescriptor(realm, entityDescriptor);
        }
    } catch (SAML2MetaException e) {
        debug.warning("SAMLv2ModelImpl.setSPStdAttributeValues:", e);
    }
}
Also used : SPSSODescriptorElement(com.sun.identity.saml2.jaxb.metadata.SPSSODescriptorElement) Iterator(java.util.Iterator) AssertionConsumerServiceElement(com.sun.identity.saml2.jaxb.metadata.AssertionConsumerServiceElement) List(java.util.List) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) EntityDescriptorElement(com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException)

Example 3 with AssertionConsumerServiceElement

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

the class IDPSSOUtil method getACSurlFromMetaByIndex.

/**
     * Returns the assertion consumer service <code>URL</code> from
     * meta data by binding
     *
     * @param spEntityID      the entity id of the service provider
     * @param realm           the realm name of the identity provider
     * @param acsIndex        the <code>ACS</code> index
     * @param returnedBinding the binding used to send back
     *                        <code>Response</code>
     * @return the assertion consumer service <code>URL</code>
     * @throws SAML2Exception if the operation is not successful
     */
public static String getACSurlFromMetaByIndex(String spEntityID, String realm, int acsIndex, StringBuffer returnedBinding) throws SAML2Exception {
    String classMethod = "IDPSSOUtil.getACSurlFromMetaByIndex: ";
    SPSSODescriptorElement spSSODescriptorElement = getSPSSODescriptor(realm, spEntityID, classMethod);
    List acsList = spSSODescriptorElement.getAssertionConsumerService();
    int index;
    String acsURL = null;
    String binding = null;
    String defaultAcsURL = null;
    String defaultBinding = null;
    String firstAcsURL = null;
    String firstBinding = null;
    AssertionConsumerServiceElement acs = null;
    for (int i = 0; i < acsList.size(); i++) {
        acs = (AssertionConsumerServiceElement) acsList.get(i);
        index = acs.getIndex();
        binding = acs.getBinding();
        if (index == acsIndex) {
            acsURL = acs.getLocation();
            binding = acs.getBinding();
            break;
        }
        if (acs.isIsDefault()) {
            defaultAcsURL = acs.getLocation();
            defaultBinding = acs.getBinding();
        }
        if (i == 0) {
            firstAcsURL = acs.getLocation();
            firstBinding = acs.getBinding();
        }
    }
    if (acsURL == null || acsURL.length() == 0) {
        acsURL = defaultAcsURL;
        if (acsURL == null || acsURL.length() == 0) {
            acsURL = firstAcsURL;
            if (acsURL == null || acsURL.length() == 0) {
                acsURL = null;
                SAML2Utils.debug.error(classMethod + "Unable to get valid Assertion " + "Consumer Service URL");
                return null;
            }
            returnedBinding.append(firstBinding);
        } else {
            returnedBinding.append(defaultBinding);
        }
    } else {
        returnedBinding.append(binding);
    }
    return acsURL;
}
Also used : SPSSODescriptorElement(com.sun.identity.saml2.jaxb.metadata.SPSSODescriptorElement) AssertionConsumerServiceElement(com.sun.identity.saml2.jaxb.metadata.AssertionConsumerServiceElement) List(java.util.List) ArrayList(java.util.ArrayList)

Example 4 with AssertionConsumerServiceElement

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

the class IDPSSOUtil method getBindingForAcsUrl.

/**
     * Returns the assertion consumer service url binding from
     * the metadata.
     *
     * @param spEntityID the entity id of the service provider
     * @param realm      the realm name of the identity provider
     * @return the assertion consumer service url binding
     * @throws SAML2Exception if the operation is not successful
     */
public static String getBindingForAcsUrl(String spEntityID, String realm, String acsURL) throws SAML2Exception {
    String classMethod = "IDPSSOUtil.getBindingForAcsUrl: ";
    SPSSODescriptorElement spSSODescriptorElement = getSPSSODescriptor(realm, spEntityID, classMethod);
    List acsList = spSSODescriptorElement.getAssertionConsumerService();
    AssertionConsumerServiceElement acs = null;
    String binding = null;
    for (int i = 0; i < acsList.size(); i++) {
        acs = (AssertionConsumerServiceElement) acsList.get(i);
        String location = acs.getLocation();
        if (location != null && location.equals(acsURL)) {
            return acs.getBinding();
        }
    }
    return null;
}
Also used : SPSSODescriptorElement(com.sun.identity.saml2.jaxb.metadata.SPSSODescriptorElement) AssertionConsumerServiceElement(com.sun.identity.saml2.jaxb.metadata.AssertionConsumerServiceElement) List(java.util.List) ArrayList(java.util.ArrayList)

Example 5 with AssertionConsumerServiceElement

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

the class IDPSSOUtil method isACSurlValidInMetadataSP.

/**
     * Validates if the Assertion Consumer Service URL acsURL exists in the
     * metadata of the Service Provider spEntityID
     *
     * @param acsURL     the assertion consumer service <code>URL</code>
     * @param spEntityID the entity id of the service provider
     * @param realm      the realm name of the identity provider
     * @return true if the assertion consumer service URL was found
     *         false otherwise
     */
private static boolean isACSurlValidInMetadataSP(String acsURL, String spEntityID, String realm) throws SAML2Exception {
    boolean isValidACSurl = false;
    String classMethod = "IDPSSOUtil.isACSurlValidInMetadataSP: ";
    SPSSODescriptorElement spSSODescriptorElement = getSPSSODescriptor(realm, spEntityID, classMethod);
    List acsList = spSSODescriptorElement.getAssertionConsumerService();
    AssertionConsumerServiceElement acs = null;
    for (int i = 0; i < acsList.size(); i++) {
        acs = (AssertionConsumerServiceElement) acsList.get(i);
        String acsInMeta = acs.getLocation();
        if (acsInMeta.equalsIgnoreCase(acsURL)) {
            isValidACSurl = true;
            SAML2Utils.debug.message(classMethod + " acsURL=" + acsURL + "Found in the metadata");
            break;
        }
    }
    return isValidACSurl;
}
Also used : SPSSODescriptorElement(com.sun.identity.saml2.jaxb.metadata.SPSSODescriptorElement) AssertionConsumerServiceElement(com.sun.identity.saml2.jaxb.metadata.AssertionConsumerServiceElement) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

AssertionConsumerServiceElement (com.sun.identity.saml2.jaxb.metadata.AssertionConsumerServiceElement)12 List (java.util.List)9 SPSSODescriptorElement (com.sun.identity.saml2.jaxb.metadata.SPSSODescriptorElement)7 ArrayList (java.util.ArrayList)7 Iterator (java.util.Iterator)3 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)2 SAMLv2Model (com.sun.identity.console.federation.model.SAMLv2Model)2 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)2 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)2 SubjectConfirmation (com.sun.identity.saml2.assertion.SubjectConfirmation)1 SubjectConfirmationData (com.sun.identity.saml2.assertion.SubjectConfirmationData)1 ObjectFactory (com.sun.identity.saml2.jaxb.entityconfig.ObjectFactory)1 EntityDescriptorElement (com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement)1 IDPList (com.sun.identity.saml2.protocol.IDPList)1 OrderedSet (com.sun.identity.shared.datastruct.OrderedSet)1 CCActionTable (com.sun.web.ui.view.table.CCActionTable)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 JAXBException (javax.xml.bind.JAXBException)1