Search in sources :

Example 46 with IDFFMetaException

use of com.sun.identity.federation.meta.IDFFMetaException in project OpenAM by OpenRock.

the class IDFFModelImpl method updateEntityIDPDescriptor.

public void updateEntityIDPDescriptor(String realm, String entityName, Map attrValues, Map extendedValues, boolean ishosted) throws AMConsoleException {
    String[] params = { realm, entityName, "IDFF", "IDP-Standard Metadata" };
    logEvent("ATTEMPT_MODIFY_ENTITY_DESCRIPTOR", params);
    try {
        //save key and encryption details if present for hosted
        if (ishosted == true) {
            String keysize = getValueByKey(attrValues, ATTR_ENCRYPTION_KEY_SIZE);
            String algorithm = getValueByKey(attrValues, ATTR_ENCRYPTION_ALGORITHM);
            String e_certAlias = getValueByKey(extendedValues, ATTR_ENCRYPTION_CERT_ALIAS);
            String s_certAlias = getValueByKey(extendedValues, ATTR_SIGNING_CERT_ALIAS);
            int keysi = (keysize != null && keysize.length() > 0) ? Integer.parseInt(keysize) : 128;
            String alg = (algorithm == null || algorithm.length() == 0) ? "http://www.w3.org/2001/04/xmlenc#aes128-cbc" : algorithm;
            IDFFMetaSecurityUtils.updateProviderKeyInfo(realm, entityName, e_certAlias, false, true, alg, keysi);
            IDFFMetaSecurityUtils.updateProviderKeyInfo(realm, entityName, s_certAlias, true, true, alg, keysi);
        }
        IDFFMetaManager idffManager = getIDFFMetaManager();
        EntityDescriptorElement entityDescriptor = idffManager.getEntityDescriptor(realm, entityName);
        IDPDescriptorType pDesc = idffManager.getIDPDescriptor(realm, entityName);
        //Protocol Support Enumeration
        pDesc.getProtocolSupportEnumeration().clear();
        pDesc.getProtocolSupportEnumeration().addAll((Collection) attrValues.get(ATTR_PROTOCOL_SUPPORT_ENUMERATION));
        //communication URLs
        pDesc.setSoapEndpoint((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_SOAP_END_POINT)));
        pDesc.setSingleSignOnServiceURL((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_SINGLE_SIGN_ON_SERVICE_URL)));
        pDesc.setSingleLogoutServiceURL((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_SINGLE_LOGOUT_SERVICE_URL)));
        pDesc.setSingleLogoutServiceReturnURL((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_SINGLE_LOGOUT_SERVICE_RETURN_URL)));
        pDesc.setFederationTerminationServiceURL((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_FEDERATION_TERMINATION_SERVICES_URL)));
        pDesc.setFederationTerminationServiceReturnURL((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_FEDERATION_TERMINATION_SERVICE_RETURN_URL)));
        pDesc.setRegisterNameIdentifierServiceURL((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_REGISTRATION_NAME_IDENTIFIER_SERVICE_URL)));
        pDesc.setRegisterNameIdentifierServiceReturnURL((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_REGISTRATION_NAME_IDENTIFIER_SERVICE_RETURN_URL)));
        // communication profiles
        pDesc.getFederationTerminationNotificationProtocolProfile().clear();
        pDesc.getFederationTerminationNotificationProtocolProfile().add((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_FEDERATION_TERMINATION_NOTIFICATION_PROTOCOL_PROFILE)));
        int size = federationTerminationProfileList.size();
        for (int i = 0; i < size; i++) {
            if (!federationTerminationProfileList.get(i).equals((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_FEDERATION_TERMINATION_NOTIFICATION_PROTOCOL_PROFILE)))) {
                pDesc.getFederationTerminationNotificationProtocolProfile().add(federationTerminationProfileList.get(i));
            }
        }
        pDesc.getSingleLogoutProtocolProfile().clear();
        pDesc.getSingleLogoutProtocolProfile().add((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_SINGLE_LOGOUT_PROTOCOL_PROFILE)));
        size = singleLogoutProfileList.size();
        for (int i = 0; i < size; i++) {
            if (!singleLogoutProfileList.get(i).equals((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_SINGLE_LOGOUT_PROTOCOL_PROFILE)))) {
                pDesc.getSingleLogoutProtocolProfile().add(singleLogoutProfileList.get(i));
            }
        }
        pDesc.getRegisterNameIdentifierProtocolProfile().clear();
        pDesc.getRegisterNameIdentifierProtocolProfile().add((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_REGISTRATION_NAME_IDENTIFIER_PROFILE_PROFILE)));
        size = nameRegistrationProfileList.size();
        for (int i = 0; i < size; i++) {
            if (!nameRegistrationProfileList.get(i).equals((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_REGISTRATION_NAME_IDENTIFIER_PROFILE_PROFILE)))) {
                pDesc.getRegisterNameIdentifierProtocolProfile().add(nameRegistrationProfileList.get(i));
            }
        }
        pDesc.getSingleSignOnProtocolProfile().clear();
        pDesc.getSingleSignOnProtocolProfile().add((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_SINGLE_SIGN_ON_PROTOCOL_PROFILE)));
        size = federationProfileList.size();
        for (int i = 0; i < size; i++) {
            if (!federationProfileList.get(i).equals((String) AMAdminUtils.getValue((Set) attrValues.get(ATTR_SINGLE_SIGN_ON_PROTOCOL_PROFILE)))) {
                pDesc.getSingleSignOnProtocolProfile().add(federationProfileList.get(i));
            }
        }
        entityDescriptor.getIDPDescriptor().clear();
        entityDescriptor.getIDPDescriptor().add(pDesc);
        idffManager.setEntityDescriptor(realm, entityDescriptor);
        logEvent("SUCCEED_MODIFY_ENTITY_DESCRIPTOR", params);
    } catch (IDFFMetaException e) {
        debug.error("IDFFMetaException , updateEntityIDPDescriptor", e);
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "IDFF", "SP-Standard Metadata", strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_ENTITY_DESCRIPTOR", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : IDPDescriptorType(com.sun.identity.liberty.ws.meta.jaxb.IDPDescriptorType) HashSet(java.util.HashSet) Set(java.util.Set) IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) EntityDescriptorElement(com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement)

Example 47 with IDFFMetaException

use of com.sun.identity.federation.meta.IDFFMetaException in project OpenAM by OpenRock.

the class IDFFModelImpl method updateSPAuthenticationContexts.

/**
     * update SP Authentication Contexts
     *
     * @param realm Realm of Entity
     * @param entityName Name of Entity Descriptor.     
     * @param cxt IDFFAuthContexts object contains SP
     *        Authentication Contexts values
     */
public void updateSPAuthenticationContexts(String realm, String entityName, IDFFAuthContexts cxt) throws AMConsoleException {
    List list = cxt.toSPAuthContextInfo();
    String[] params = { realm, entityName, "IDFF", "SP-updateSPAuthenticationContexts" };
    logEvent("ATTEMPT_MODIFY_ENTITY_DESCRIPTOR", params);
    try {
        IDFFMetaManager idffMetaMgr = getIDFFMetaManager();
        EntityConfigElement entityConfig = idffMetaMgr.getEntityConfig(realm, entityName);
        if (entityConfig == null) {
            throw new AMConsoleException("invalid.entity.name");
        }
        SPDescriptorConfigElement spDecConfigElement = idffMetaMgr.getSPDescriptorConfig(realm, entityName);
        if (spDecConfigElement == null) {
            throw new AMConsoleException("invalid.config.element");
        } else {
            // update sp entity config
            updateAttrInConfig(spDecConfigElement, ATTR_SP_AUTHN_CONTEXT_MAPPING, list);
        }
        //saves the attributes by passing the new entityConfig object
        idffMetaMgr.setEntityConfig(realm, entityConfig);
        logEvent("SUCCEED_MODIFY_ENTITY_DESCRIPTOR", params);
    } catch (IDFFMetaException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "IDFF", "SP-updateSPAuthenticationContexts", strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_ENTITY_DESCRIPTOR", paramsEx);
        throw new AMConsoleException(strError);
    }
    return;
}
Also used : IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) SPDescriptorConfigElement(com.sun.identity.federation.jaxb.entityconfig.SPDescriptorConfigElement) ArrayList(java.util.ArrayList) List(java.util.List) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) EntityConfigElement(com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement)

Example 48 with IDFFMetaException

use of com.sun.identity.federation.meta.IDFFMetaException in project OpenAM by OpenRock.

the class IDFFModelImpl method getCommonAttributeValues.

/**
     * Returns provider-affiliate common attribute values.
     * @param realm the realm in which the entity resides.
     * @param entityName Name of Entity Descriptor.
     * @return provider-affiliate common attribute values.
     * @throws IDFFMetaException if attribute values cannot be obtained.
     */
public Map getCommonAttributeValues(String realm, String entityName) throws AMConsoleException {
    Map values = new HashMap(26);
    String[] param = { realm, entityName, "IDFF", "General" };
    logEvent("ATTEMPT_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", param);
    try {
        IDFFMetaManager manager = getIDFFMetaManager();
        EntityDescriptorElement desc = manager.getEntityDescriptor(realm, entityName);
        values.put(ATTR_VALID_UNTIL, returnEmptySetIfValueIsNull(desc.getValidUntil()));
        values.put(ATTR_CACHE_DURATION, returnEmptySetIfValueIsNull(desc.getCacheDuration()));
        logEvent("SUCCEED_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", param);
    } catch (IDFFMetaException e) {
        String[] paramsEx = { realm, entityName, "IDFF", "General", getErrorString(e) };
        logEvent("FEDERATION_EXCEPTION_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", paramsEx);
        throw new AMConsoleException(getErrorString(e));
    }
    return values;
}
Also used : HashMap(java.util.HashMap) IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map) EntityDescriptorElement(com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement)

Example 49 with IDFFMetaException

use of com.sun.identity.federation.meta.IDFFMetaException in project OpenAM by OpenRock.

the class IDFFModelImpl method getAllEntityDescriptorNames.

/**
     * Returns a <code>Set</code> of entity descriptor names.
     *
     * @param realm the realm in which the entity resides.
     * @return the IDFF entity descriptor
     * @throws AMConsoleException
     */
public Set getAllEntityDescriptorNames(String realm) throws AMConsoleException {
    Set entitySet = null;
    try {
        IDFFMetaManager idffManager = getIDFFMetaManager();
        entitySet = idffManager.getAllEntities(realm);
    } catch (IDFFMetaException e) {
        throw new AMConsoleException(e.getMessage());
    }
    return (entitySet != null) ? entitySet : Collections.EMPTY_SET;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 50 with IDFFMetaException

use of com.sun.identity.federation.meta.IDFFMetaException in project OpenAM by OpenRock.

the class IDFFModelImpl method getSPAuthenticationContexts.

/**
     * Returns  the object of Auththentication Contexts in SP.
     *
     * @param realm Realm of Entity
     * @param entityName Name of Entity Descriptor.     
     * @return attributes values of provider.
     */
public IDFFAuthContexts getSPAuthenticationContexts(String realm, String entityName) throws AMConsoleException {
    IDFFAuthContexts cxt = new IDFFAuthContexts();
    String str = null;
    try {
        List tmpList = new ArrayList();
        IDFFMetaManager manager = getIDFFMetaManager();
        Map map = new HashMap();
        BaseConfigType spConfig = manager.getSPDescriptorConfig(realm, entityName);
        if (spConfig != null) {
            map = IDFFMetaUtils.getAttributes(spConfig);
        } else {
            throw new AMConsoleException("invalid.entity.name");
        }
        List list = (List) map.get(ATTR_SP_AUTHN_CONTEXT_MAPPING);
        for (int i = 0; i < list.size(); i++) {
            String tmp = (String) list.get(i);
            int index = tmp.lastIndexOf("|");
            String level = removeKey(tmp.substring(index + 1));
            String name = removeKey(tmp.substring(0, index));
            cxt.put(name, "true", level);
        }
    } catch (IDFFMetaException e) {
        throw new AMConsoleException(getErrorString(e));
    } catch (AMConsoleException e) {
        throw new AMConsoleException(getErrorString(e));
    }
    return (cxt != null) ? cxt : new IDFFAuthContexts();
}
Also used : BaseConfigType(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType) HashMap(java.util.HashMap) IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map) IDFFAuthContexts(com.sun.identity.console.federation.IDFFAuthContexts)

Aggregations

IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)89 IDFFMetaManager (com.sun.identity.federation.meta.IDFFMetaManager)55 BaseConfigType (com.sun.identity.federation.jaxb.entityconfig.BaseConfigType)30 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)27 Iterator (java.util.Iterator)25 Map (java.util.Map)25 HashMap (java.util.HashMap)24 List (java.util.List)24 ProviderDescriptorType (com.sun.identity.liberty.ws.meta.jaxb.ProviderDescriptorType)22 Set (java.util.Set)21 SAMLException (com.sun.identity.saml.common.SAMLException)17 HashSet (java.util.HashSet)17 ArrayList (java.util.ArrayList)14 FSException (com.sun.identity.federation.common.FSException)13 FSMsgException (com.sun.identity.federation.message.common.FSMsgException)12 CLIException (com.sun.identity.cli.CLIException)10 SessionException (com.sun.identity.plugin.session.SessionException)9 IOException (java.io.IOException)9 IDPDescriptorConfigElement (com.sun.identity.federation.jaxb.entityconfig.IDPDescriptorConfigElement)8 SPDescriptorConfigElement (com.sun.identity.federation.jaxb.entityconfig.SPDescriptorConfigElement)8