Search in sources :

Example 11 with COTException

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

the class CreateRemoteSP method execute.

/**
     * Creates remote service provider.
     *
     * @param locale Locale of the request.
     * @param params Map of creation parameters.
     */
@Override
public String execute(Locale locale, Map params) throws WorkflowException {
    validateParameters(params);
    String realm = getString(params, ParameterKeys.P_REALM);
    String metadataFile = getString(params, ParameterKeys.P_META_DATA);
    String metadata = getContent(metadataFile, locale);
    String extendedMeta = null;
    List attrMapping = getAttributeMapping(params);
    if (!attrMapping.isEmpty()) {
        try {
            EntityDescriptorElement e = SAML2MetaUtils.getEntityDescriptorElement(metadata);
            String eId = e.getEntityID();
            extendedMeta = createExtendedDataTemplate(eId, false);
        } catch (SAML2MetaException ex) {
            throw new WorkflowException(ex.getMessage());
        } catch (JAXBException ex) {
            throw new WorkflowException(ex.getMessage());
        }
    }
    String[] results = ImportSAML2MetaData.importData(realm, metadata, extendedMeta);
    String entityId = results[1];
    String cot = getString(params, ParameterKeys.P_COT);
    if ((cot != null) && (cot.length() > 0)) {
        try {
            AddProviderToCOT.addToCOT(realm, cot, entityId);
        } catch (COTException e) {
            throw new WorkflowException(e.getMessage());
        }
    }
    try {
        if (!attrMapping.isEmpty()) {
            SAML2MetaManager manager = new SAML2MetaManager();
            EntityConfigElement config = manager.getEntityConfig(realm, entityId);
            SPSSOConfigElement ssoConfig = manager.getSPSSOConfig(realm, entityId);
            if (ssoConfig != null) {
                ObjectFactory objFactory = new ObjectFactory();
                AttributeType avp = objFactory.createAttributeElement();
                String key = SAML2Constants.ATTRIBUTE_MAP;
                avp.setName(key);
                avp.getValue().addAll(attrMapping);
                ssoConfig.getAttribute().add(avp);
            }
            manager.setEntityConfig(realm, config);
        }
    } catch (SAML2MetaException e) {
        throw new WorkflowException(e.getMessage());
    } catch (JAXBException e) {
        throw new WorkflowException(e.getMessage());
    }
    return getMessage("sp.configured", locale);
}
Also used : JAXBException(javax.xml.bind.JAXBException) SPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement) COTException(com.sun.identity.cot.COTException) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) EntityDescriptorElement(com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement) ObjectFactory(com.sun.identity.saml2.jaxb.entityconfig.ObjectFactory) AttributeType(com.sun.identity.saml2.jaxb.entityconfig.AttributeType) List(java.util.List) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Example 12 with COTException

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

the class CreateFedlet method loadMetaData.

private void loadMetaData(Map params, String workDir) throws WorkflowException {
    String realm = getString(params, ParameterKeys.P_REALM);
    String entityId = getString(params, ParameterKeys.P_ENTITY_ID);
    String cot = getString(params, ParameterKeys.P_COT);
    String assertConsumer = getString(params, ParameterKeys.P_ASSERT_CONSUMER);
    List attrMapping = getAttributeMapping(params);
    String metadata = FedletMetaData.createStandardMetaData(entityId, assertConsumer);
    String extended = FedletMetaData.createExtendedMetaData(realm, entityId, attrMapping, assertConsumer);
    // Add the AttributeQueryConfig to SP extended meta data
    extended = addAttributeQueryTemplate(extended, cot);
    // Add the XACMLAuthzDecisionQueryConfig to SP extended meta data
    extended = addXACMLAuthzQueryTemplate(extended, cot);
    ImportSAML2MetaData.importData(realm, metadata, extended);
    if (!StringUtils.isBlank(cot)) {
        try {
            AddProviderToCOT.addToCOT(realm, cot, entityId);
        } catch (COTException e) {
            throw new WorkflowException(e.getMessage());
        }
        int idx = extended.indexOf("<Attribute name=\"cotlist\">");
        idx = extended.indexOf("</Attribute>", idx);
        extended = extended.substring(0, idx) + "<Value>" + cot + "</Value>" + extended.substring(idx);
    }
    String extendedModified = flipHostedParameter(extended, true);
    writeToFile(workDir + "/sp-extended.xml", extendedModified);
    writeToFile(workDir + "/sp.xml", metadata);
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) COTException(com.sun.identity.cot.COTException)

Example 13 with COTException

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

the class FSPostLogin method doConsentToIntro.

/**
     * Returns the Introduction Writer URL.
     *
     * @param metaAlias the provider alias.
     * @param targetURL the url the writer servlet will redirect to.
     * @param cotSelected the name of the Circle fo Trust.
     * @return the writer url.
     * @exception FSPostLoginException on error.
     */
private String doConsentToIntro(String metaAlias, String targetURL, String cotSelected) throws FSPostLoginException {
    String tldURL = null;
    try {
        if (entityID == null) {
            if (metaManager != null) {
                entityID = metaManager.getEntityIDByMetaAlias(metaAlias);
            }
        }
        if (realm == null) {
            realm = IDFFMetaUtils.getRealmByMetaAlias(metaAlias);
        }
        CircleOfTrustManager cotManager = new CircleOfTrustManager();
        CircleOfTrustDescriptor cotDesc = cotManager.getCircleOfTrust(realm, cotSelected);
        if (cotDesc != null && (cotDesc.getCircleOfTrustStatus()).equalsIgnoreCase(IFSConstants.ACTIVE)) {
            tldURL = cotDesc.getIDFFWriterServiceURL();
        }
    } catch (IDFFMetaException metaExp) {
        FSUtils.debug.error("FSPostLogin::doConsentToIntro in cot managment expextion:", metaExp);
        tldURL = null;
    } catch (COTException meta2Exp) {
        FSUtils.debug.error("FSPostLogin::doConsentToIntro in cot managment expextion:", meta2Exp);
        tldURL = null;
    }
    String redirectURL = targetURL;
    if (tldURL != null && entityID != null) {
        redirectURL = new StringBuffer().append(tldURL).append(IFSConstants.QUESTION_MARK).append(IFSConstants.LRURL).append(IFSConstants.EQUAL_TO).append(URLEncDec.encode(targetURL)).append(IFSConstants.AMPERSAND).append(IFSConstants.PROVIDER_ID_KEY).append(IFSConstants.EQUAL_TO).append(URLEncDec.encode(entityID)).toString();
    }
    if (FSUtils.debug.messageEnabled()) {
        FSUtils.debug.message("FSPostLogin::doConsentToIntro return url" + redirectURL);
    }
    return redirectURL;
}
Also used : CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) CircleOfTrustDescriptor(com.sun.identity.cot.CircleOfTrustDescriptor) COTException(com.sun.identity.cot.COTException)

Example 14 with COTException

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

the class IDFFMetaManager method getAllTrustedProviders.

/**
     * Returns a set of remote providers trusted by the hosted providers.
     *
     * @param hostedProviderMetaAlias the metaAlias of the hosted provider.
     * @return a set of trusted remote providers. An empty set is returned
     *         if there is an error or no trusted providers are found.
     */
public Set getAllTrustedProviders(String hostedProviderMetaAlias) {
    String classMethod = "IDFFMetaManager:getAllTrustedProviders:";
    Set trustedProviders = new HashSet();
    try {
        String hostedEntityID = getEntityIDByMetaAlias(hostedProviderMetaAlias);
        String role = getProviderRoleByMetaAlias(hostedProviderMetaAlias);
        String realm = IDFFMetaUtils.getRealmByMetaAlias(hostedProviderMetaAlias);
        List hostedEntityIDs = new ArrayList();
        List remoteEntityIDs = new ArrayList();
        if (role != null && role.equalsIgnoreCase(IFSConstants.SP)) {
            hostedEntityIDs = getAllHostedServiceProviderEntities(realm);
            remoteEntityIDs = getAllRemoteIdentityProviderIDs(realm);
        } else if (role != null && role.equalsIgnoreCase(IFSConstants.IDP)) {
            hostedEntityIDs = getAllHostedIdentityProviderIDs(realm);
            remoteEntityIDs = getAllRemoteServiceProviderEntities(realm);
        }
        Map idffCOTs = cotManager.getIDFFCOTProviderMapping(realm);
        Set cotSet = idffCOTs.keySet();
        if (hostedEntityIDs.size() > 0 && hostedEntityIDs.contains(hostedEntityID)) {
            for (Iterator iter = cotSet.iterator(); iter.hasNext(); ) {
                String name = (String) iter.next();
                Set tProviders = (Set) idffCOTs.get(name);
                if (tProviders.contains(hostedEntityID)) {
                    for (Iterator i = tProviders.iterator(); i.hasNext(); ) {
                        String trustedProvider = (String) i.next();
                        if (remoteEntityIDs.size() > 0 && remoteEntityIDs.contains(trustedProvider)) {
                            trustedProviders.add(trustedProvider);
                        }
                    }
                }
            }
        }
    } catch (COTException cote) {
        debug.error(classMethod + "Error getting trustedProvider list", cote);
    } catch (IDFFMetaException ide) {
        debug.error(classMethod + "Error getting trustedProvider list", ide);
    }
    if (debug.messageEnabled()) {
        debug.message(classMethod + " remote trusted providers :" + trustedProviders);
    }
    return trustedProviders;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) COTException(com.sun.identity.cot.COTException) Map(java.util.Map) HashSet(java.util.HashSet)

Example 15 with COTException

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

the class FSAuthDomainsModelImpl method getAttributeValues.

/**
     * Returns attribute values.
     *
     * @param name Name of authentication domain.
     * @return Map of attribute name to values.
     * @throws AMConsoleException if attribute values cannot be retrieved.
     */
public Map getAttributeValues(String realm, String name) throws AMConsoleException {
    Map values = new HashMap(16);
    String[] param = { realm, name };
    logEvent("ATTEMPT_GET_AUTH_DOMAIN_ATTR_VALUES", param);
    try {
        CircleOfTrustManager manager = getCircleOfTrustManager();
        CircleOfTrustDescriptor desc = manager.getCircleOfTrust(realm, name);
        values.put(TF_DESCRIPTION, AMAdminUtils.wrapInSet(desc.getCircleOfTrustDescription()));
        values.put(TF_IDFF_WRITER_SERVICE_URL, AMAdminUtils.wrapInSet(desc.getIDFFWriterServiceURL()));
        values.put(TF_IDFF_READER_SERVICE_URL, AMAdminUtils.wrapInSet(desc.getIDFFReaderServiceURL()));
        values.put(TF_SAML2_WRITER_SERVICE_URL, AMAdminUtils.wrapInSet(desc.getSAML2WriterServiceURL()));
        values.put(TF_SAML2_READER_SERVICE_URL, AMAdminUtils.wrapInSet(desc.getSAML2ReaderServiceURL()));
        values.put(SINGLE_CHOICE_REALM, AMAdminUtils.wrapInSet(desc.getCircleOfTrustRealm()));
        values.put(SINGLE_CHOICE_STATUS, AMAdminUtils.wrapInSet(desc.getCircleOfTrustStatus()));
        logEvent("SUCCEED_GET_AUTH_DOMAIN_ATTR_VALUES", param);
    } catch (COTException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, name, strError };
        logEvent("FEDERATION_EXCEPTION_GET_AUTH_DOMAIN_ATTR_VALUES", paramsEx);
        throw new AMConsoleException(strError);
    }
    return values;
}
Also used : CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) HashMap(java.util.HashMap) CircleOfTrustDescriptor(com.sun.identity.cot.CircleOfTrustDescriptor) COTException(com.sun.identity.cot.COTException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

COTException (com.sun.identity.cot.COTException)42 CircleOfTrustManager (com.sun.identity.cot.CircleOfTrustManager)29 Set (java.util.Set)18 Iterator (java.util.Iterator)16 CircleOfTrustDescriptor (com.sun.identity.cot.CircleOfTrustDescriptor)15 List (java.util.List)15 Map (java.util.Map)14 ArrayList (java.util.ArrayList)13 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)12 HashMap (java.util.HashMap)11 CLIException (com.sun.identity.cli.CLIException)10 HashSet (java.util.HashSet)10 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)9 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)9 SPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement)7 EntityConfigElement (com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)6 IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)5 JAXBException (javax.xml.bind.JAXBException)5 IDFFMetaManager (com.sun.identity.federation.meta.IDFFMetaManager)4 EntityDescriptorElement (com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement)4