Search in sources :

Example 11 with FederationConfigElement

use of com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement in project OpenAM by OpenRock.

the class WSFederationCOTUtils method removeFromEntityConfig.

/**
     * Removes the circle of trust name passed from the <code>cotlist</code>
     * attribute in the Entity Config. The Service Provider and Identity
     * Provider Entity Configuration are updated.
     *
     * @param realm the realm of the provider
     * @param name the circle of trust name to be removed.
     * @param entityId the entity identifier of the provider.
     * @throws WSFederationMetaException 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 name, String entityId) throws WSFederationMetaException, JAXBException {
    String classMethod = "WSFederationCOTUtils.removeFromEntityConfig: ";
    WSFederationMetaManager metaManager = null;
    if (callerSession != null) {
        metaManager = new WSFederationMetaManager(callerSession);
    } else {
        metaManager = new WSFederationMetaManager();
    }
    // Check whether the entity id existed in the DS
    FederationElement edes = metaManager.getEntityDescriptor(realm, entityId);
    if (edes == null) {
        debug.error(classMethod + "No such entity: " + entityId);
        String[] data = { realm, entityId };
        throw new WSFederationMetaException("entityid_invalid", data);
    }
    FederationConfigElement eConfig = metaManager.getEntityConfig(realm, entityId);
    if (eConfig != null) {
        List elist = eConfig.getIDPSSOConfigOrSPSSOConfig();
        for (Iterator iter = elist.iterator(); iter.hasNext(); ) {
            BaseConfigType bConfig = (BaseConfigType) iter.next();
            List list = bConfig.getAttribute();
            for (Iterator iter2 = list.iterator(); iter2.hasNext(); ) {
                AttributeType avp = (AttributeType) iter2.next();
                if (avp.getName().trim().equalsIgnoreCase(SAML2Constants.COT_LIST)) {
                    List avpl = avp.getValue();
                    if (avpl != null && !avpl.isEmpty() && containsValue(avpl, name)) {
                        avpl.remove(name);
                        metaManager.setEntityConfig(realm, eConfig);
                        break;
                    }
                }
            }
        }
    }
}
Also used : BaseConfigType(com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType) AttributeType(com.sun.identity.wsfederation.jaxb.entityconfig.AttributeType) Iterator(java.util.Iterator) FederationConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement) List(java.util.List) FederationElement(com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement)

Example 12 with FederationConfigElement

use of com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement in project OpenAM by OpenRock.

the class WSFederationMetaManager 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 ID <code>String</code>.
     * @throws WSFederationMetaException if unable to retrieve the entity ids.
     */
public List<String> getAllRemoteEntities(String realm) throws WSFederationMetaException {
    List<String> remoteEntityIds = new ArrayList();
    String[] objs = { realm };
    try {
        Set entityIds = configInst.getAllConfigurationNames(realm);
        if (entityIds != null && !entityIds.isEmpty()) {
            for (Iterator iter = entityIds.iterator(); iter.hasNext(); ) {
                String federationId = (String) iter.next();
                FederationConfigElement config = getEntityConfig(realm, federationId);
                if (config == null || !config.isHosted()) {
                    remoteEntityIds.add(federationId);
                }
            }
        }
    } catch (ConfigurationException e) {
        debug.error("WSFederationMetaManager.getAllRemoteEntities:", e);
        String[] data = { e.getMessage(), realm };
        LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_GET_ALL_REMOTE_ENTITIES, data, null);
        throw new WSFederationMetaException(e);
    }
    LogUtil.access(Level.FINE, LogUtil.GOT_ALL_REMOTE_ENTITIES, objs, null);
    return remoteEntityIds;
}
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) FederationConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement)

Example 13 with FederationConfigElement

use of com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement in project OpenAM by OpenRock.

the class WSFederationMetaManager method getAllHostedEntities.

/**
     * Returns all hosted entities under the realm.
     * 
     * @param realm The realm under which the hosted entities reside.
     * @return a <code>List</code> of entity ID <code>String</code>.
     * @throws WSFederationMetaException if unable to retrieve the entity ids.
     */
public List<String> getAllHostedEntities(String realm) throws WSFederationMetaException {
    List<String> hostedEntityIds = new ArrayList<String>();
    try {
        Set entityIds = configInst.getAllConfigurationNames(realm);
        if (entityIds != null && !entityIds.isEmpty()) {
            for (Iterator iter = entityIds.iterator(); iter.hasNext(); ) {
                String federationId = (String) iter.next();
                FederationConfigElement config = getEntityConfig(realm, federationId);
                if (config != null && config.isHosted()) {
                    hostedEntityIds.add(federationId);
                }
            }
        }
    } catch (ConfigurationException e) {
        debug.error("WSFederationMetaManager.getAllHostedEntities:", e);
        String[] data = { e.getMessage(), realm };
        LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_GET_ALL_HOSTED_ENTITIES, data, null);
        throw new WSFederationMetaException(e);
    }
    String[] objs = { realm };
    LogUtil.access(Level.FINE, LogUtil.GOT_ALL_HOSTED_ENTITIES, objs, null);
    return hostedEntityIds;
}
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) FederationConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement)

Example 14 with FederationConfigElement

use of com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement in project OpenAM by OpenRock.

the class WSFederationMetaManager method getAllHostedMetaAliasesByRealm.

/**
     * Returns all the hosted entity metaAliases for a realm.
     *
     * @param realm The given realm.
     * @return all the hosted entity metaAliases for a realm or an empty arrayList if not found.
     * @throws WSFederationMetaException  if unable to retrieve the entity ids.
     */
public List<String> getAllHostedMetaAliasesByRealm(String realm) throws WSFederationMetaException {
    List<String> metaAliases = new ArrayList<String>();
    try {
        Set<String> entityIds = configInst.getAllConfigurationNames(realm);
        if (entityIds == null || entityIds.isEmpty()) {
            return metaAliases;
        }
        for (String entityId : entityIds) {
            FederationConfigElement config = getEntityConfig(realm, entityId);
            if (config == null || !config.isHosted()) {
                continue;
            }
            List<BaseConfigType> configList = config.getIDPSSOConfigOrSPSSOConfig();
            for (BaseConfigType bConfigType : configList) {
                String curMetaAlias = bConfigType.getMetaAlias();
                if (curMetaAlias != null && !curMetaAlias.isEmpty()) {
                    metaAliases.add(curMetaAlias);
                }
            }
        }
    } catch (ConfigurationException e) {
        debug.error("WSFederationMetaManager.getAllHostedMetaAliasesByRealm: Error getting " + "hostedMetaAliases for realm: " + realm, e);
        throw new WSFederationMetaException(e);
    }
    return metaAliases;
}
Also used : BaseConfigType(com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) ArrayList(java.util.ArrayList) FederationConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement)

Example 15 with FederationConfigElement

use of com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement in project OpenAM by OpenRock.

the class WSFedPropertiesModelImpl method setIDPExtAttributeValues.

/**
     * Saves the standard attribute values for the SP.
     *
     * @param realm to which the entity belongs.
     * @param fedId is the entity id.
     * @param idpExtValues has the extended attribute value pairs of IDP.
     * @param location has the information whether remote or hosted.
     * @throws AMConsoleException if saving of attribute value fails.
     */
public void setIDPExtAttributeValues(String realm, String fedId, Map idpExtValues, String location) throws AMConsoleException {
    try {
        String role = EntityModel.IDENTITY_PROVIDER;
        // fed is the extended entity configuration under the realm
        WSFederationMetaManager metaManager = getWSFederationMetaManager();
        FederationConfigElement fed = metaManager.getEntityConfig(realm, fedId);
        if (fed == null) {
            IDPEX_DATA_MAP.put(TF_DISPNAME, Collections.EMPTY_SET);
            createExtendedObject(realm, fedId, location, IDENTITY_PROVIDER, IDPEX_DATA_MAP);
            fed = metaManager.getEntityConfig(realm, fedId);
        }
        IDPSSOConfigElement idpsso = getidpsso(fed);
        if (idpsso != null) {
            BaseConfigType baseConfig = (BaseConfigType) idpsso;
            updateBaseConfig(idpsso, idpExtValues, role);
        }
        //saves the new configuration by passing new fed element created
        metaManager.setEntityConfig(realm, fed);
    } catch (JAXBException e) {
        debug.warning("WSFedPropertiesModelImpl.setIDPExtAttributeValues", e);
        throw new AMConsoleException(getErrorString(e));
    } catch (WSFederationMetaException e) {
        debug.warning("WSFedPropertiesModelImpl.setIDPExtAttributeValues", e);
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : BaseConfigType(com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType) WSFederationMetaManager(com.sun.identity.wsfederation.meta.WSFederationMetaManager) JAXBException(javax.xml.bind.JAXBException) FederationConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement) IDPSSOConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.IDPSSOConfigElement) WSFederationMetaException(com.sun.identity.wsfederation.meta.WSFederationMetaException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Aggregations

FederationConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement)16 BaseConfigType (com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType)7 Iterator (java.util.Iterator)7 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)6 List (java.util.List)6 ConfigurationException (com.sun.identity.plugin.configuration.ConfigurationException)5 FederationElement (com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement)5 Set (java.util.Set)5 JAXBException (javax.xml.bind.JAXBException)5 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)4 WSFederationMetaException (com.sun.identity.wsfederation.meta.WSFederationMetaException)4 WSFederationMetaManager (com.sun.identity.wsfederation.meta.WSFederationMetaManager)4 IDPSSOConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.IDPSSOConfigElement)3 SPSSOConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.SPSSOConfigElement)3 AttributeType (com.sun.identity.wsfederation.jaxb.entityconfig.AttributeType)2 ObjectFactory (com.sun.identity.wsfederation.jaxb.entityconfig.ObjectFactory)2 TokenSigningKeyInfoElement (com.sun.identity.wsfederation.jaxb.wsfederation.TokenSigningKeyInfoElement)1 StringWriter (java.io.StringWriter)1 CertificateEncodingException (java.security.cert.CertificateEncodingException)1