Search in sources :

Example 16 with CircleOfTrustDescriptor

use of com.sun.identity.cot.CircleOfTrustDescriptor 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 17 with CircleOfTrustDescriptor

use of com.sun.identity.cot.CircleOfTrustDescriptor in project OpenAM by OpenRock.

the class FSLoginHelper method getTLDURL.

private String getTLDURL() {
    String tldURL = null;
    FSUtils.debug.message("FSLoginHelper.getTLDURL() :: called");
    try {
        if ((cotList == null) || (cotList.isEmpty())) {
            FSUtils.debug.error("FSLoginHelper::getTLDURL():" + "Received COT Set is Invalid");
        } else {
            if (cotList.size() > 1) {
                if (FSUtils.debug.messageEnabled()) {
                    FSUtils.debug.message("FSLoginHelper::getTLDURL() " + "Multiple COTs found will do polling ");
                }
            } else {
                FSUtils.debug.message("FSLoginHelper::getTLDURL() Single COT found");
            }
            Iterator iter = cotList.iterator();
            CircleOfTrustManager cotManager = new CircleOfTrustManager();
            while (iter.hasNext()) {
                CircleOfTrustDescriptor cotDesc = cotManager.getCircleOfTrust(realm, (String) iter.next());
                if (cotDesc != null && (cotDesc.getCircleOfTrustStatus()).equalsIgnoreCase(IFSConstants.ACTIVE)) {
                    if (FSUtils.debug.messageEnabled()) {
                        FSUtils.debug.message("FSLoginHelper::getTLDURL " + "found a active cot with cotid : " + cotDesc.getCircleOfTrustName());
                    }
                    tldURL = cotDesc.getIDFFReaderServiceURL();
                    break;
                }
            }
        }
    } catch (COTException ame) {
        FSUtils.debug.error("FSLoginHelper.getTLDURL():" + "COTException:", ame);
    } catch (Exception exp) {
        FSUtils.debug.error("FSLoginHelper.getTLDURL():General Exception:", exp);
    }
    if (FSUtils.debug.messageEnabled()) {
        FSUtils.debug.message("FSLoginHelper::getTLDURL().tldURL  " + tldURL);
    }
    return tldURL;
}
Also used : CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) Iterator(java.util.Iterator) CircleOfTrustDescriptor(com.sun.identity.cot.CircleOfTrustDescriptor) COTException(com.sun.identity.cot.COTException) COTException(com.sun.identity.cot.COTException) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException)

Example 18 with CircleOfTrustDescriptor

use of com.sun.identity.cot.CircleOfTrustDescriptor in project OpenAM by OpenRock.

the class SAML2Utils method getReaderURL.

public static String getReaderURL(String spMetaAlias) {
    // get spExtended
    String classMethod = "SAML2Utils:getReaderURL:";
    String readerURL = null;
    try {
        String realm = SAML2MetaUtils.getRealmByMetaAlias(spMetaAlias);
        String spEntityID = saml2MetaManager.getEntityByMetaAlias(spMetaAlias);
        if (debug.messageEnabled()) {
            debug.message(classMethod + "metaAlias is :" + spMetaAlias);
            debug.message(classMethod + "Realm is :" + realm);
            debug.message(classMethod + "spEntityID is :" + spEntityID);
        }
        SPSSOConfigElement spEntityCfg = saml2MetaManager.getSPSSOConfig(realm, spEntityID);
        Map spConfigAttrsMap = null;
        if (spEntityCfg != null) {
            spConfigAttrsMap = SAML2MetaUtils.getAttributes(spEntityCfg);
            List cotList = (List) spConfigAttrsMap.get("cotlist");
            String cotListStr = (String) cotList.iterator().next();
            CircleOfTrustDescriptor cotDesc = cotManager.getCircleOfTrust(realm, cotListStr);
            readerURL = cotDesc.getSAML2ReaderServiceURL();
        }
    } catch (COTException ce) {
        if (debug.messageEnabled()) {
            debug.message(classMethod + "Error retreiving circle of trust", ce);
        }
    } catch (SAML2Exception s2e) {
        if (debug.messageEnabled()) {
            debug.message(classMethod + "Error getting reader URL : ", s2e);
        }
    } catch (Exception e) {
        if (debug.messageEnabled()) {
            debug.message(classMethod + "Error getting reader URL : ", e);
        }
    }
    return readerURL;
}
Also used : SPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement) ArrayList(java.util.ArrayList) List(java.util.List) CircleOfTrustDescriptor(com.sun.identity.cot.CircleOfTrustDescriptor) COTException(com.sun.identity.cot.COTException) Map(java.util.Map) HashMap(java.util.HashMap) SystemConfigurationException(com.sun.identity.common.SystemConfigurationException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) IOException(java.io.IOException) ServletException(javax.servlet.ServletException) SessionException(com.sun.identity.plugin.session.SessionException) DataStoreProviderException(com.sun.identity.plugin.datastore.DataStoreProviderException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) COTException(com.sun.identity.cot.COTException) SAML2TokenRepositoryException(org.forgerock.openam.federation.saml2.SAML2TokenRepositoryException)

Example 19 with CircleOfTrustDescriptor

use of com.sun.identity.cot.CircleOfTrustDescriptor in project OpenAM by OpenRock.

the class SAML2Test method deleteCircleOfTrust.

@Test(groups = { "samlv2" }, dependsOnMethods = { "removeProviderFromCircleOfTrust" }, expectedExceptions = { COTException.class })
public void deleteCircleOfTrust() throws CLIException, COTException, SAML2MetaException {
    entering("deleteCircleOfTrust", null);
    String[] args = { "delete-cot", CLIConstants.PREFIX_ARGUMENT_LONG + FedCLIConstants.ARGUMENT_COT, NAME_COT };
    CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
    cmdManager.addToRequestQueue(req);
    cmdManager.serviceRequestQueue();
    try {
        cmdManager.serviceRequestQueue();
        CircleOfTrustManager cotManager = new CircleOfTrustManager();
        CircleOfTrustDescriptor objCircleOfTrust = cotManager.getCircleOfTrust("/", NAME_COT);
    } finally {
        exiting("deleteCircleOfTrust");
    }
}
Also used : CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) CLIRequest(com.sun.identity.cli.CLIRequest) CircleOfTrustDescriptor(com.sun.identity.cot.CircleOfTrustDescriptor) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 20 with CircleOfTrustDescriptor

use of com.sun.identity.cot.CircleOfTrustDescriptor in project OpenAM by OpenRock.

the class SAML2Test method createCircleOfTrust.

@Test(groups = { "samlv2" })
public void createCircleOfTrust() throws CLIException, COTException, SAML2MetaException {
    entering("createCircleOfTrust", null);
    String[] args = { "create-cot", CLIConstants.PREFIX_ARGUMENT_LONG + FedCLIConstants.ARGUMENT_COT, NAME_COT };
    CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
    cmdManager.addToRequestQueue(req);
    try {
        cmdManager.serviceRequestQueue();
        CircleOfTrustManager cotManager = new CircleOfTrustManager();
        CircleOfTrustDescriptor objCircleOfTrust = cotManager.getCircleOfTrust("/", NAME_COT);
        assert (objCircleOfTrust != null);
    } finally {
        exiting("createCircleOfTrust");
    }
}
Also used : CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) CLIRequest(com.sun.identity.cli.CLIRequest) CircleOfTrustDescriptor(com.sun.identity.cot.CircleOfTrustDescriptor) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

CircleOfTrustDescriptor (com.sun.identity.cot.CircleOfTrustDescriptor)20 CircleOfTrustManager (com.sun.identity.cot.CircleOfTrustManager)16 COTException (com.sun.identity.cot.COTException)15 HashSet (java.util.HashSet)9 Set (java.util.Set)9 ArrayList (java.util.ArrayList)7 Iterator (java.util.Iterator)7 List (java.util.List)7 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)6 HashMap (java.util.HashMap)5 Map (java.util.Map)5 SPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement)4 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)4 IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)3 SAML2Exception (com.sun.identity.saml2.common.SAML2Exception)3 CLIRequest (com.sun.identity.cli.CLIRequest)2 BaseConfigType (com.sun.identity.federation.jaxb.entityconfig.BaseConfigType)2 SessionException (com.sun.identity.plugin.session.SessionException)2 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)2 IOException (java.io.IOException)2