Search in sources :

Example 11 with EntityConfigElement

use of com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement in project OpenAM by OpenRock.

the class IDFFMetaManager method getAllRemoteEntities.

/**
     * Returns all remote entities under the realm.
     *
     * @param realm The realm under which the hosted entities reside.
     * @return a <code>List</code> of entity identifiers as Strings.
     * @throws IDFFMetaException if unable to retrieve the remote entity
     *         identifiers.
     */
public List getAllRemoteEntities(String realm) throws IDFFMetaException {
    List remoteEntityList = new ArrayList();
    try {
        Set entityIDs = idffMetaConfigInstance.getAllConfigurationNames(realm);
        if (entityIDs != null && !entityIDs.isEmpty()) {
            Iterator entityIterator = entityIDs.iterator();
            while (entityIterator.hasNext()) {
                String entityID = (String) entityIterator.next();
                EntityConfigElement entityConfig = getEntityConfig(realm, entityID);
                if (entityConfig != null && !entityConfig.isHosted()) {
                    remoteEntityList.add(entityID);
                }
            }
        }
        LogUtil.access(Level.INFO, LogUtil.GET_REMOTE_ENTITIES_SUCCEEDED, null);
    } catch (ConfigurationException e) {
        debug.error("IDFFMetaManager.getAllRemoteEntities:", e);
        LogUtil.error(Level.INFO, LogUtil.GET_REMOTE_ENTITIES_FAILED, null);
        throw new IDFFMetaException(e);
    }
    return remoteEntityList;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) EntityConfigElement(com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement)

Example 12 with EntityConfigElement

use of com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement in project OpenAM by OpenRock.

the class IDFFProviderManager method isNameIDEncryptionEnabled.

/**
     * Returns whether the specified provider requires name ID encryption
     * or not.
     * @param providerID provider ID.
     * @return true if the specified provider requires name ID encryption,
     *     false if it doesn't.
     */
public boolean isNameIDEncryptionEnabled(String providerID) {
    EntityConfigElement entityConfig = null;
    try {
        entityConfig = idffMetaManager.getEntityConfig(ROOT_REALM, providerID);
    } catch (IDFFMetaException imex) {
        ProviderUtil.debug.error("IDFFProviderManager.isNameIDEncryptionEnabled:", imex);
    }
    if (entityConfig == null) {
        return false;
    }
    BaseConfigType baseConfig = IDFFMetaUtils.getSPDescriptorConfig(entityConfig);
    if (baseConfig == null) {
        baseConfig = IDFFMetaUtils.getIDPDescriptorConfig(entityConfig);
        if (baseConfig == null) {
            return false;
        }
    }
    Map attrMap = IDFFMetaUtils.getAttributes(baseConfig);
    if ((attrMap == null) || (attrMap.isEmpty())) {
        return false;
    }
    List values = (List) attrMap.get(IFSConstants.ENABLE_NAMEID_ENCRYPTION);
    if ((values == null) || values.isEmpty()) {
        return false;
    }
    return ((String) values.get(0)).equalsIgnoreCase("true");
}
Also used : BaseConfigType(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) List(java.util.List) Map(java.util.Map) EntityConfigElement(com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement)

Example 13 with EntityConfigElement

use of com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement in project OpenAM by OpenRock.

the class IDFFModelImpl method createEntityConfig.

public void createEntityConfig(String realm, String entityName, String role, String location) throws AMConsoleException {
    try {
        IDFFMetaManager idffMetaMgr = getIDFFMetaManager();
        ObjectFactory objFactory = new ObjectFactory();
        // Check whether the entity id existed in the DS
        EntityDescriptorElement entityDesc = idffMetaMgr.getEntityDescriptor(realm, entityName);
        if (entityDesc == null) {
            throw new AMConsoleException("invalid.entity.name");
        }
        EntityConfigElement entityConfig = idffMetaMgr.getEntityConfig(realm, entityName);
        if (entityConfig == null) {
            entityConfig = objFactory.createEntityConfigElement();
            // add to entityConfig
            entityConfig.setEntityID(entityName);
            if (location.equals("remote")) {
                entityConfig.setHosted(false);
            } else {
                entityConfig.setHosted(true);
            }
        }
        // create entity config and add the attribute
        BaseConfigType baseCfgType = null;
        // It could have one sp and one idp.
        if ((role.equals(IFSConstants.SP)) && (IDFFMetaUtils.getSPDescriptor(entityDesc) != null)) {
            baseCfgType = objFactory.createSPDescriptorConfigElement();
            for (Iterator iter = extendedMetaMap.keySet().iterator(); iter.hasNext(); ) {
                AttributeType atype = objFactory.createAttributeType();
                String key = (String) iter.next();
                atype.setName(key);
                atype.getValue().addAll(Collections.EMPTY_LIST);
                baseCfgType.getAttribute().add(atype);
            }
            for (Iterator iter = extendedMetaSpMap.keySet().iterator(); iter.hasNext(); ) {
                AttributeType atype = objFactory.createAttributeType();
                String key = (String) iter.next();
                atype.setName(key);
                atype.getValue().addAll(Collections.EMPTY_LIST);
                baseCfgType.getAttribute().add(atype);
            }
            entityConfig.getSPDescriptorConfig().add(baseCfgType);
        } else if ((role.equals(IFSConstants.IDP)) && (IDFFMetaUtils.getIDPDescriptor(entityDesc) != null)) {
            baseCfgType = objFactory.createIDPDescriptorConfigElement();
            for (Iterator iter = extendedMetaMap.keySet().iterator(); iter.hasNext(); ) {
                AttributeType atype = objFactory.createAttributeType();
                String key = (String) iter.next();
                atype.setName(key);
                atype.getValue().addAll(Collections.EMPTY_LIST);
                baseCfgType.getAttribute().add(atype);
            }
            for (Iterator iter = extendedMetaIdpMap.keySet().iterator(); iter.hasNext(); ) {
                AttributeType atype = objFactory.createAttributeType();
                String key = (String) iter.next();
                atype.setName(key);
                atype.getValue().addAll(Collections.EMPTY_LIST);
                baseCfgType.getAttribute().add(atype);
            }
            entityConfig.getIDPDescriptorConfig().add(baseCfgType);
        }
        idffMetaMgr.setEntityConfig(realm, entityConfig);
    } catch (IDFFMetaException e) {
        throw new AMConsoleException(getErrorString(e));
    } catch (JAXBException e) {
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : BaseConfigType(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType) ObjectFactory(com.sun.identity.federation.jaxb.entityconfig.ObjectFactory) IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) AttributeType(com.sun.identity.federation.jaxb.entityconfig.AttributeType) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) JAXBException(javax.xml.bind.JAXBException) Iterator(java.util.Iterator) 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 14 with EntityConfigElement

use of com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement in project OpenAM by OpenRock.

the class IDFFCOTUtils method removeFromEntityConfig.

/**
     * Removes the circle trust name passed from the <code>cotlist</code>
     * list attribute in the Entity Config. The Service Provider and Identity
     * Provider Entity Configuration are updated.
     *
     * @param realm realm the entity resides in.
     * @param cotName the circle of trust name to be removed.
     * @param entityID the entity identifier of the provider.
     * @throws IDFFMetaException if there is an error updating the entity
     *          config.
     * @throws JAXBException if there is an error updating the entity config.
     */
public void removeFromEntityConfig(String realm, String cotName, String entityID) throws IDFFMetaException, JAXBException {
    String classMethod = "IDFFCOTUtils.removeFromEntityConfig: ";
    IDFFMetaManager idffMetaMgr = new IDFFMetaManager(callerSession);
    // 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) {
        List spConfigList = entityConfig.getSPDescriptorConfig();
        List idpConfigList = entityConfig.getIDPDescriptorConfig();
        removeCOTNameFromConfig(realm, spConfigList, cotName, entityConfig, idffMetaMgr);
        removeCOTNameFromConfig(realm, idpConfigList, cotName, entityConfig, idffMetaMgr);
        BaseConfigType affiConfig = entityConfig.getAffiliationDescriptorConfig();
        if (affiConfig != null) {
            List affiConfigList = new ArrayList();
            affiConfigList.add(affiConfig);
            removeCOTNameFromConfig(realm, affiConfigList, cotName, entityConfig, idffMetaMgr);
        }
    }
}
Also used : BaseConfigType(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType) 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)

Example 15 with EntityConfigElement

use of com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement in project OpenAM by OpenRock.

the class IDFFMetaManager method getAllHostedEntities.

/**
     * Returns all remote entities under the realm.
     *
     * @param realm The realm under which the hosted entities reside.
     * @return a <code>List</code> of entity identifiers as Strings.
     * @throws IDFFMetaException if unable to retrieve the remote entity
     *         identifiers.
     */
public List getAllHostedEntities(String realm) throws IDFFMetaException {
    List hostedEntityList = new ArrayList();
    try {
        Set entityIDs = idffMetaConfigInstance.getAllConfigurationNames(realm);
        if (entityIDs != null && !entityIDs.isEmpty()) {
            Iterator entityIterator = entityIDs.iterator();
            while (entityIterator.hasNext()) {
                String entityID = (String) entityIterator.next();
                EntityConfigElement entityConfig = getEntityConfig(realm, entityID);
                if (entityConfig != null && entityConfig.isHosted()) {
                    hostedEntityList.add(entityID);
                }
            }
        }
        LogUtil.access(Level.INFO, LogUtil.GET_HOSTED_ENTITIES_SUCCEEDED, null);
    } catch (ConfigurationException e) {
        debug.error("IDFFMetaManager.getAllHostedEntities:", e);
        LogUtil.error(Level.INFO, LogUtil.GET_HOSTED_ENTITIES_FAILED, null);
        throw new IDFFMetaException(e);
    }
    return hostedEntityList;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) EntityConfigElement(com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement)

Aggregations

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