Search in sources :

Example 31 with ConfigurationException

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

the class WSFederationMetaManager method getEntityDescriptor.

/**
     * Returns the standard metadata federation element under the realm.
     * 
     * @param realm The realm under which the federation resides.
     * @param entityId ID of the federation to be retrieved.
     * @return <code>FederationElement</code> for the entity or null if
     *         not found.
     * @throws WSFederationMetaException if unable to retrieve the entity 
     * descriptor.
     */
public FederationElement getEntityDescriptor(String realm, String entityId) throws WSFederationMetaException {
    if (entityId == null) {
        return null;
    }
    if (realm == null) {
        realm = "/";
    }
    String[] objs = { entityId, realm };
    FederationElement federation = null;
    if (callerSession == null) {
        federation = WSFederationMetaCache.getFederation(realm, entityId);
        if (federation != null) {
            LogUtil.access(Level.FINE, LogUtil.GOT_FEDERATION, objs, null);
            return federation;
        }
    }
    try {
        Map attrs = configInst.getConfiguration(realm, entityId);
        if (attrs == null) {
            return null;
        }
        Set values = (Set) attrs.get(ATTR_METADATA);
        if (values == null || values.isEmpty()) {
            return null;
        }
        String value = (String) values.iterator().next();
        Object obj = WSFederationMetaUtils.convertStringToJAXB(value);
        if (obj instanceof FederationElement) {
            federation = (FederationElement) obj;
            WSFederationMetaCache.putFederation(realm, entityId, federation);
            LogUtil.access(Level.FINE, LogUtil.GOT_FEDERATION, objs, null);
            return federation;
        }
        debug.error("WSFederationMetaManager.getFederation: " + "invalid descriptor");
        LogUtil.error(Level.INFO, LogUtil.GOT_INVALID_ENTITY_DESCRIPTOR, objs, null);
        throw new WSFederationMetaException("invalid_descriptor", objs);
    } catch (ConfigurationException e) {
        debug.error("WSFederationMetaManager.getFederation:", e);
        String[] data = { e.getMessage(), entityId, realm };
        LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_GET_ENTITY_DESCRIPTOR, data, null);
        throw new WSFederationMetaException(e);
    } catch (JAXBException jaxbe) {
        debug.error("WSFederationMetaManager.getFederation:", jaxbe);
        LogUtil.error(Level.INFO, LogUtil.GOT_INVALID_ENTITY_DESCRIPTOR, objs, null);
        throw new WSFederationMetaException("invalid_descriptor", objs);
    }
}
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) FederationElement(com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement)

Example 32 with ConfigurationException

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

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

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

the class WSFederationMetaManager method setEntityConfig.

/**
     * Sets the extended entity configuration under the realm.
     * 
     * @param realm The realm under which the entity resides.
     * @param config The extended entity configuration object to be set.
     * @throws WSFederationMetaException if unable to set the entity 
     * configuration.
     */
public void setEntityConfig(String realm, FederationConfigElement config) throws WSFederationMetaException {
    String federationId = config.getFederationID();
    if (federationId == null) {
        debug.error("WSFederationMetaManager.setEntityConfig: " + "entity ID is null");
        String[] data = { realm };
        LogUtil.error(Level.INFO, LogUtil.NO_ENTITY_ID_SET_ENTITY_CONFIG, data, null);
        throw new WSFederationMetaException("empty_entityid", null);
    }
    if (realm == null) {
        realm = "/";
    }
    String[] objs = { federationId, realm };
    try {
        Map attrs = WSFederationMetaUtils.convertJAXBToAttrMap(ATTR_ENTITY_CONFIG, config);
        Map oldAttrs = configInst.getConfiguration(realm, federationId);
        oldAttrs.put(ATTR_ENTITY_CONFIG, attrs.get(ATTR_ENTITY_CONFIG));
        configInst.setConfiguration(realm, federationId, oldAttrs);
        LogUtil.access(Level.INFO, LogUtil.SET_ENTITY_CONFIG, objs, null);
    } catch (ConfigurationException e) {
        debug.error("WSFederationMetaManager.setEntityConfig:", e);
        String[] data = { e.getMessage(), federationId, realm };
        LogUtil.error(Level.INFO, LogUtil.CONFIG_ERROR_SET_ENTITY_CONFIG, data, null);
        throw new WSFederationMetaException(e);
    } catch (JAXBException jaxbe) {
        debug.error("WSFederationMetaManager.setEntityConfig:", jaxbe);
        LogUtil.error(Level.INFO, LogUtil.SET_INVALID_ENTITY_CONFIG, objs, null);
        throw new WSFederationMetaException("invalid_config", objs);
    }
}
Also used : ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) JAXBException(javax.xml.bind.JAXBException) Map(java.util.Map)

Example 35 with ConfigurationException

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

the class WSFederationMetaManager method getEntityByTokenIssuerName.

/**
     * Returns entity ID associated with the token issuer name.
     * 
     * @param issuer Token issuer name.
     * @return entity ID associated with the metaAlias or null if not found.
     * @throws WSFederationMetaException if unable to retrieve the entity ids.
     */
public String getEntityByTokenIssuerName(String realm, String issuer) throws WSFederationMetaException {
    try {
        Set entityIds = configInst.getAllConfigurationNames(realm);
        if (entityIds == null || entityIds.isEmpty()) {
            return null;
        }
        for (Iterator iter = entityIds.iterator(); iter.hasNext(); ) {
            String federationId = (String) iter.next();
            FederationElement fed = getEntityDescriptor(realm, federationId);
            if (issuer.equals(getTokenIssuerName(fed))) {
                return federationId;
            }
        }
    } catch (ConfigurationException e) {
        debug.error("WSFederationMetaManager.getEntityByMetaAlias:", e);
        throw new WSFederationMetaException(e);
    }
    return null;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) Iterator(java.util.Iterator) FederationElement(com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement)

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