Search in sources :

Example 1 with EntityDescriptorElement

use of com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement 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 2 with EntityDescriptorElement

use of com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement 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 3 with EntityDescriptorElement

use of com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement in project OpenAM by OpenRock.

the class CreateMetaDataModelImpl method createIDFFProvider.

/**
     * Creates a IDFF provider.
     *
     * @param realm Realm Name.
     * @param entityId Entity Id.
     * @param values   Map of property name to values.
     */
public void createIDFFProvider(String realm, String entityId, Map values) throws AMConsoleException {
    try {
        IDFFMetaManager metaManager = new IDFFMetaManager(null);
        String metadata = CreateIDFFMetaDataTemplate.createStandardMetaTemplate(entityId, values, requestURL);
        String extendedData = CreateIDFFMetaDataTemplate.createExtendedMetaTemplate(entityId, values);
        EntityDescriptorElement descriptor = (EntityDescriptorElement) IDFFMetaUtils.convertStringToJAXB(metadata);
        EntityConfigElement configElt = (EntityConfigElement) IDFFMetaUtils.convertStringToJAXB(extendedData);
        metaManager.createEntityDescriptor(realm, descriptor);
        metaManager.createEntityConfig(realm, configElt);
    } catch (JAXBException ex) {
        throw new AMConsoleException(ex.getMessage());
    } catch (IDFFMetaException ex) {
        throw new AMConsoleException(ex.getMessage());
    }
}
Also used : IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) JAXBException(javax.xml.bind.JAXBException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) EntityDescriptorElement(com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement) EntityConfigElement(com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement)

Example 4 with EntityDescriptorElement

use of com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement in project OpenAM by OpenRock.

the class IDFFMetaManager method getEntityDescriptor.

/**
     * Returns the standard metadata entity descriptor under the realm.
     * @param realm The realm under which the entity resides.
     * @param entityID identifier of the entity to be retrieved.
     * @return <code>EntityDescriptorElement</code> for the entity or null if
     *         not found.
     * @throws IDFFMetaException if unable to retrieve the entity descriptor.
     */
public EntityDescriptorElement getEntityDescriptor(String realm, String entityID) throws IDFFMetaException {
    String classMethod = "IDFFMetaManager.getEntityDescriptor:";
    if (debug.messageEnabled()) {
        debug.message(classMethod + " Retreiving EntityDescriptor");
    }
    EntityDescriptorElement entityDescriptor = null;
    if (entityID != null) {
        if ((realm == null) || (realm.length() == 0)) {
            realm = ROOT_REALM;
        }
        String[] args = { entityID, realm };
        // retrieve from cache
        if (callerSession == null) {
            entityDescriptor = IDFFMetaCache.getEntityDescriptor(realm, entityID);
        }
        if (entityDescriptor == null) {
            try {
                Map attrs = idffMetaConfigInstance.getConfiguration(realm, entityID);
                if (attrs != null) {
                    Set metaValues = (Set) attrs.get(IDFF_METADATA_ATTR);
                    if (metaValues != null && !metaValues.isEmpty()) {
                        String metaValue = (String) metaValues.iterator().next();
                        Object object = IDFFMetaUtils.convertStringToJAXB(metaValue);
                        if (object instanceof EntityDescriptorElement) {
                            entityDescriptor = (EntityDescriptorElement) object;
                            IDFFMetaCache.setEntityDescriptor(realm, entityID, entityDescriptor);
                        } else {
                            debug.error(classMethod + "Invalid standard " + " meta value for : " + entityID);
                        }
                    }
                }
            } catch (ConfigurationException ce) {
                debug.error("Cannot retrieve entity descriptor", ce);
                LogUtil.error(Level.INFO, LogUtil.GET_ENTITY_FAILED, args);
                throw new IDFFMetaException("cannotRetreiveEntityDescriptor", null);
            } catch (JAXBException jaxbe) {
                debug.error(classMethod, jaxbe);
                LogUtil.error(Level.INFO, LogUtil.INVALID_ENTITY_DESCRIPTOR, args);
                throw new IDFFMetaException("invalidEntityDescriptor", args);
            }
        }
        if (entityDescriptor != null) {
            LogUtil.access(Level.INFO, LogUtil.GET_ENTITY_SUCCEEDED, args);
        }
    } else {
        LogUtil.error(Level.INFO, LogUtil.NULL_ENTITY_ID, null);
        throw new IDFFMetaException("nullEntityID", null);
    }
    return entityDescriptor;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) JAXBException(javax.xml.bind.JAXBException) EntityDescriptorElement(com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement) Map(java.util.Map)

Example 5 with EntityDescriptorElement

use of com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement in project OpenAM by OpenRock.

the class IDFFCOTUtils method updateEntityConfig.

/**
     * Updates the entity config to add the circle of turst name to the
     * <code>cotlist</code> attribute. The Service Provider and Identity
     * Provider Configurations are updated.
     *
     * @param realm realm the entity resides in.
     * @param cotName the circle of trust name.
     * @param entityID the name of the Entity identifier.
     * @throws IDFFMetaException if there is a configuration error when
     *         updating the configuration.
     * @throws JAXBException is there is an error updating the entity
     *          configuration.
     */
public void updateEntityConfig(String realm, String cotName, String entityID) throws IDFFMetaException, JAXBException {
    String classMethod = "IDFFCOTUtils.updateEntityConfig: ";
    IDFFMetaManager idffMetaMgr = new IDFFMetaManager(callerSession);
    ObjectFactory objFactory = new ObjectFactory();
    // Check whether the entity id existed in the DS
    EntityDescriptorElement entityDesc = idffMetaMgr.getEntityDescriptor(realm, entityID);
    if (entityDesc == null) {
        debug.error(classMethod + " No such entity: " + entityID);
        String[] data = { entityID };
        throw new IDFFMetaException("invalidEntityID", data);
    }
    EntityConfigElement entityConfig = idffMetaMgr.getEntityConfig(realm, entityID);
    if (entityConfig == null) {
        // create entity config and add the cot attribute
        BaseConfigType IDFFCOTUtils = null;
        AttributeType atype = objFactory.createAttributeType();
        atype.setName(COT_LIST);
        atype.getValue().add(cotName);
        // add to entityConfig
        entityConfig = objFactory.createEntityConfigElement();
        entityConfig.setEntityID(entityID);
        entityConfig.setHosted(false);
        // It could have one sp and one idp.
        if (IDFFMetaUtils.getSPDescriptor(entityDesc) != null) {
            IDFFCOTUtils = objFactory.createSPDescriptorConfigElement();
            IDFFCOTUtils.getAttribute().add(atype);
            entityConfig.getSPDescriptorConfig().add(IDFFCOTUtils);
        }
        if (IDFFMetaUtils.getIDPDescriptor(entityDesc) != null) {
            IDFFCOTUtils = objFactory.createIDPDescriptorConfigElement();
            IDFFCOTUtils.getAttribute().add(atype);
            entityConfig.getIDPDescriptorConfig().add(IDFFCOTUtils);
        }
        if (entityDesc.getAffiliationDescriptor() != null) {
            IDFFCOTUtils = objFactory.createAffiliationDescriptorConfigElement();
            IDFFCOTUtils.getAttribute().add(atype);
            entityConfig.setAffiliationDescriptorConfig(IDFFCOTUtils);
        }
        idffMetaMgr.setEntityConfig(realm, entityConfig);
    } else {
        // update the sp and idp entity config
        List spConfigList = entityConfig.getSPDescriptorConfig();
        List idpConfigList = entityConfig.getIDPDescriptorConfig();
        updateCOTAttrInConfig(realm, spConfigList, cotName, entityConfig, objFactory, idffMetaMgr);
        updateCOTAttrInConfig(realm, idpConfigList, cotName, entityConfig, objFactory, idffMetaMgr);
        BaseConfigType affiConfig = entityConfig.getAffiliationDescriptorConfig();
        if (affiConfig != null) {
            List affiConfigList = new ArrayList();
            affiConfigList.add(affiConfig);
            updateCOTAttrInConfig(realm, affiConfigList, cotName, entityConfig, objFactory, idffMetaMgr);
        }
    }
}
Also used : BaseConfigType(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType) ObjectFactory(com.sun.identity.federation.jaxb.entityconfig.ObjectFactory) AttributeType(com.sun.identity.federation.jaxb.entityconfig.AttributeType) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) EntityDescriptorElement(com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement) EntityConfigElement(com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement)

Aggregations

EntityDescriptorElement (com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement)14 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)7 IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)7 IDFFMetaManager (com.sun.identity.federation.meta.IDFFMetaManager)7 EntityConfigElement (com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement)5 JAXBException (javax.xml.bind.JAXBException)5 HashSet (java.util.HashSet)4 Set (java.util.Set)4 BaseConfigType (com.sun.identity.federation.jaxb.entityconfig.BaseConfigType)3 ObjectFactory (com.sun.identity.federation.jaxb.entityconfig.ObjectFactory)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Map (java.util.Map)3 AttributeType (com.sun.identity.federation.jaxb.entityconfig.AttributeType)2 AffiliationDescriptorType (com.sun.identity.liberty.ws.meta.jaxb.AffiliationDescriptorType)2 IDPDescriptorType (com.sun.identity.liberty.ws.meta.jaxb.IDPDescriptorType)2 SPDescriptorType (com.sun.identity.liberty.ws.meta.jaxb.SPDescriptorType)2 ConfigurationException (com.sun.identity.plugin.configuration.ConfigurationException)2 Iterator (java.util.Iterator)2 IDPDescriptorConfigElement (com.sun.identity.federation.jaxb.entityconfig.IDPDescriptorConfigElement)1