Search in sources :

Example 51 with ConfigurationException

use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.

the class IDFFMetaManager method createEntityConfig.

/**
     * Creates the extended entity configuration under the realm.
     *
     * @param realm The realm under which the entity configuration will be
     * created.
     * @param entityConfig extended entity configuration to be created.
     * @throws IDFFMetaException if unable to create the entity configuration.
     */
public void createEntityConfig(String realm, EntityConfigElement entityConfig) throws IDFFMetaException {
    String classMethod = "IDFFMetaManager.createEntityConfig:";
    String entityID = null;
    if (entityConfig == null) {
        LogUtil.error(Level.INFO, LogUtil.NULL_ENTITY_CONFIG, null);
        throw new IDFFMetaException("nullEntityConfig", null);
    } else {
        entityID = entityConfig.getEntityID();
        if (entityID == null) {
            LogUtil.error(Level.INFO, LogUtil.NULL_ENTITY_ID, null);
            debug.error(classMethod + "entity ID is null");
            throw new IDFFMetaException("nullEntityID", null);
        }
    }
    if ((realm == null) || (realm.length() == 0)) {
        realm = ROOT_REALM;
    }
    String[] args = { entityID, realm };
    try {
        Map attrs = IDFFMetaUtils.convertJAXBToAttrMap(IDFF_ENTITY_CONFIG_ATTR, entityConfig);
        Map origAttrs = idffMetaConfigInstance.getConfiguration(realm, entityID);
        if (origAttrs == null) {
            if (debug.messageEnabled()) {
                debug.message(classMethod + "Entity Descriptor for" + entityID + " does not exist");
            }
            LogUtil.error(Level.INFO, LogUtil.ENTITY_CONFIG_NOT_FOUND, args);
            throw new IDFFMetaException("noEntityDescriptor", args);
        }
        Set origValues = (Set) origAttrs.get(IDFF_ENTITY_CONFIG_ATTR);
        if (!origValues.isEmpty()) {
            if (debug.messageEnabled()) {
                debug.message(classMethod + "Entity Config exists. " + "Use setEntityConfig to set the configuration");
            }
            LogUtil.error(Level.INFO, LogUtil.ENTITY_CONFIG_EXISTS, args);
            throw new IDFFMetaException("entityConfigExists", args);
        }
        if (debug.messageEnabled()) {
            debug.message(classMethod + "Entity Config Attrs :" + attrs);
        }
        idffMetaConfigInstance.setConfiguration(realm, entityID, attrs);
        // add entity to the circle of trust
        addEntityToCOT(realm, entityID);
        LogUtil.access(Level.INFO, LogUtil.CREATE_ENTITY_CONFIG_SUCCEEDED, args);
    } catch (ConfigurationException ce) {
        debug.error(classMethod + "Cannot create entity config", ce);
        LogUtil.error(Level.INFO, LogUtil.CREATE_ENTITY_CONFIG_FAILED, args);
        throw new IDFFMetaException(ce);
    } catch (UnsupportedOperationException uoe) {
        debug.error(classMethod + "Unsupported operation");
        LogUtil.error(Level.INFO, LogUtil.UNSUPPORTED_OPERATION, args);
        throw new IDFFMetaException(uoe);
    } catch (JAXBException jaxbe) {
        debug.error(classMethod, jaxbe);
        LogUtil.error(Level.INFO, LogUtil.INVALID_ENTITY_CONFIG, args);
        throw new IDFFMetaException("invalidEntityConfig", args);
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) JAXBException(javax.xml.bind.JAXBException) Map(java.util.Map)

Example 52 with ConfigurationException

use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.

the class IDFFMetaManager method setEntityConfig.

/**
     * Sets the extended entity configuration under the realm.
     * The EntityConfig should exist in order to set attributes in
     * the EntityConfig.
     *
     * @param realm The realm under which the entity resides in
     * @param entityConfig The extended entity configuration object to be set.
     * @throws IDFFMetaException if unable to set the entity configuration.
     */
public void setEntityConfig(String realm, EntityConfigElement entityConfig) throws IDFFMetaException {
    String classMethod = "IDFFMetaManager:setEntityConfig";
    if (entityConfig != null) {
        String entityID = entityConfig.getEntityID();
        if ((realm == null) || (realm.length() == 0)) {
            realm = ROOT_REALM;
        }
        Map origEntityAttrs = null;
        String[] args = { entityID, realm };
        try {
            if (entityID != null) {
                origEntityAttrs = idffMetaConfigInstance.getConfiguration(realm, entityID);
                Map newAttrs = IDFFMetaUtils.convertJAXBToAttrMap(IDFF_ENTITY_CONFIG_ATTR, entityConfig);
                origEntityAttrs.put(IDFF_ENTITY_CONFIG_ATTR, newAttrs.get(IDFF_ENTITY_CONFIG_ATTR));
            } else {
                if (debug.messageEnabled()) {
                    debug.message(classMethod + "Entity Identifier is null");
                }
                LogUtil.error(Level.INFO, LogUtil.NULL_ENTITY_ID, null);
                throw new IDFFMetaException("nullEntityID", null);
            }
            idffMetaConfigInstance.setConfiguration(realm, entityID, origEntityAttrs);
            LogUtil.access(Level.INFO, LogUtil.SET_ENTITY_CONFIG_SUCCEEDED, args);
        } catch (ConfigurationException ce) {
            debug.error("Error setting Entity Descriptor ", ce);
            LogUtil.error(Level.INFO, LogUtil.SET_ENTITY_CONFIG_FAILED, args);
            throw new IDFFMetaException(ce);
        } catch (JAXBException jaxbe) {
            debug.error(classMethod, jaxbe);
            LogUtil.error(Level.INFO, LogUtil.INVALID_ENTITY_CONFIG, args);
            throw new IDFFMetaException("invalidEntityConfig", args);
        }
    }
}
Also used : ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) JAXBException(javax.xml.bind.JAXBException) Map(java.util.Map)

Example 53 with ConfigurationException

use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.

the class IDFFMetaManager method createEntityDescriptor.

/**
     * Creates the standard metadata entity descriptor.
     * The metadata is created under the realm.
     *
     * @param realm The realm under which the entity resides.
     * @param entityDescriptor The standard entity descriptor object to
     *        be created.
     * @throws IDFFMetaException if unable to create the entity descriptor.
     */
public void createEntityDescriptor(String realm, EntityDescriptorElement entityDescriptor) throws IDFFMetaException {
    String classMethod = "IDFFMetaManager.createEntityDescriptor:";
    String entityId = null;
    if (entityDescriptor == null) {
        LogUtil.error(Level.INFO, LogUtil.NULL_ENTITY_DESCRIPTOR, null);
        throw new IDFFMetaException("nullEntityDescriptor", null);
    } else {
        entityId = entityDescriptor.getProviderID();
        if (entityId == null) {
            debug.error(classMethod + "Entity ID is null");
            LogUtil.error(Level.INFO, LogUtil.NULL_ENTITY_ID, null);
            throw new IDFFMetaException("nullEntityID", null);
        }
    }
    if ((realm == null) || (realm.length() == 0)) {
        realm = ROOT_REALM;
    }
    String[] args = { entityId, realm };
    EntityDescriptorElement descriptor = getEntityDescriptor(realm, entityId);
    if (descriptor != null) {
        List idps = descriptor.getIDPDescriptor();
        boolean hasIDP = (idps != null) && !idps.isEmpty();
        List sps = descriptor.getSPDescriptor();
        boolean hasSP = (sps != null) && !sps.isEmpty();
        List newIDPs = entityDescriptor.getIDPDescriptor();
        List newSPs = entityDescriptor.getSPDescriptor();
        if ((newIDPs != null) && !newIDPs.isEmpty() && hasIDP) {
            LogUtil.error(Level.INFO, LogUtil.SET_ENTITY_FAILED, args);
            throw new IDFFMetaException("idpAlreadyExisted", args);
        }
        if ((newSPs != null) && !newSPs.isEmpty() && hasSP) {
            LogUtil.error(Level.INFO, LogUtil.SET_ENTITY_FAILED, args);
            throw new IDFFMetaException("spAlreadyExisted", args);
        }
        idps.addAll(newIDPs);
        sps.addAll(newSPs);
        setEntityDescriptor(realm, descriptor);
    } else {
        try {
            Map attrs = IDFFMetaUtils.convertJAXBToAttrMap(IDFF_METADATA_ATTR, entityDescriptor);
            if (debug.messageEnabled()) {
                debug.message(classMethod + attrs);
            }
            idffMetaConfigInstance.createConfiguration(realm, entityId, attrs);
            LogUtil.access(Level.INFO, LogUtil.CREATE_ENTITY_SUCCEEDED, args);
        } catch (ConfigurationException ce) {
            debug.error("Cannot create entity descriptor", ce);
            LogUtil.error(Level.INFO, LogUtil.CREATE_ENTITY_FAILED, args);
            throw new IDFFMetaException(ce);
        } catch (UnsupportedOperationException uoe) {
            debug.error("Creating EntityDescriptor : Unsupported operation");
            LogUtil.error(Level.INFO, LogUtil.UNSUPPORTED_OPERATION, null);
            throw new IDFFMetaException("unsupportedOperation", null);
        } catch (JAXBException jaxbe) {
            debug.error(classMethod, jaxbe);
            LogUtil.error(Level.INFO, LogUtil.INVALID_ENTITY_DESCRIPTOR, args);
            throw new IDFFMetaException("invalidEntityDescriptor", args);
        }
    }
}
Also used : ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) JAXBException(javax.xml.bind.JAXBException) ArrayList(java.util.ArrayList) List(java.util.List) EntityDescriptorElement(com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement) Map(java.util.Map)

Example 54 with ConfigurationException

use of com.sun.identity.plugin.configuration.ConfigurationException 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)

Example 55 with ConfigurationException

use of com.sun.identity.plugin.configuration.ConfigurationException in project OpenAM by OpenRock.

the class IDFFMetaManager method deleteEntityConfig.

/**
     * Deletes the extended entity configuration.
     * @param realm The realm under which the entity resides.
     * @param entityId The ID of the entity for whom the extended entity
     *                 configuration will be deleted.
     * @throws IDFFMetaException if unable to delete the entity descriptor.
     */
public void deleteEntityConfig(String realm, String entityId) throws IDFFMetaException {
    if (entityId == null) {
        LogUtil.error(Level.INFO, LogUtil.NULL_ENTITY_ID, null);
        throw new IDFFMetaException("nullEntityID", null);
    } else {
        if ((realm == null) || (realm.length() == 0)) {
            realm = ROOT_REALM;
        }
        String[] args = { entityId, realm };
        try {
            Map oldAttrs = idffMetaConfigInstance.getConfiguration(realm, entityId);
            if (oldAttrs == null || oldAttrs.isEmpty()) {
                LogUtil.error(Level.INFO, LogUtil.ENTITY_DOES_NOT_EXISTS, args);
                throw new IDFFMetaException("entityDoesNotExists", args);
            }
            Set oldValues = (Set) oldAttrs.get(IDFF_ENTITY_CONFIG_ATTR);
            if (oldValues == null || oldValues.isEmpty()) {
                LogUtil.error(Level.INFO, LogUtil.NO_ENTITY_CONFIG_TO_DELETE, args);
                throw new IDFFMetaException("noEntityConfig", args);
            }
            removeEntityFromCOT(realm, entityId);
            Set attr = new HashSet();
            attr.add(IDFF_ENTITY_CONFIG_ATTR);
            idffMetaConfigInstance.deleteConfiguration(realm, entityId, attr);
            LogUtil.access(Level.INFO, LogUtil.DELETE_ENTITY_CONFIG_SUCCEEDED, args);
            IDFFMetaCache.setEntityConfig(realm, entityId, null);
        } catch (ConfigurationException e) {
            debug.error("IDFFMetaManager.deleteEntityConfig:", e);
            LogUtil.error(Level.INFO, LogUtil.DELETE_ENTITY_CONFIG_FAILED, args);
            throw new IDFFMetaException(e);
        } catch (UnsupportedOperationException uoe) {
            debug.error("Unsupported operation", uoe);
            LogUtil.error(Level.INFO, LogUtil.UNSUPPORTED_OPERATION, null);
            throw new IDFFMetaException("unsupportedOperation", null);
        }
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) Map(java.util.Map) HashSet(java.util.HashSet)

Aggregations

ConfigurationException (com.sun.identity.plugin.configuration.ConfigurationException)59 Set (java.util.Set)38 Map (java.util.Map)35 HashSet (java.util.HashSet)31 JAXBException (javax.xml.bind.JAXBException)19 Iterator (java.util.Iterator)18 HashMap (java.util.HashMap)14 ArrayList (java.util.ArrayList)13 List (java.util.List)9 EntityConfigElement (com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)6 SSOException (com.iplanet.sso.SSOException)5 SMSException (com.sun.identity.sm.SMSException)5 FederationConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement)5 ServiceConfig (com.sun.identity.sm.ServiceConfig)4 ServiceSchema (com.sun.identity.sm.ServiceSchema)4 EntityConfigElement (com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement)3 IDPSSOConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.IDPSSOConfigElement)3 SPSSOConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.SPSSOConfigElement)3 StringTokenizer (java.util.StringTokenizer)3 SSOToken (com.iplanet.sso.SSOToken)2