Search in sources :

Example 21 with FederationElement

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

the class WSFederationMetaCache method getFederation.

/**
     * Returns the standard metadata entity descriptor under the realm from
     * cache.
     * @param realm The realm under which the entity resides.
     * @param entityId ID of the entity to be retrieved. 
     * @return <code>FederationElement</code> for the entity or null
     *         if not found. 
     */
static FederationElement getFederation(String realm, String federationId) {
    String cacheKey = buildCacheKey(realm, federationId);
    FederationElement federation = (FederationElement) federationCache.get(cacheKey);
    if (debug.messageEnabled()) {
        debug.message("WSFederationMetaCache.getEntityDescriptor: " + "cacheKey = " + cacheKey + ", found = " + (federation != null));
    }
    return federation;
}
Also used : FederationElement(com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement)

Example 22 with FederationElement

use of com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement 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 23 with FederationElement

use of com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement 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

FederationElement (com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement)23 WSFederationMetaManager (com.sun.identity.wsfederation.meta.WSFederationMetaManager)12 WSFederationMetaException (com.sun.identity.wsfederation.meta.WSFederationMetaException)10 List (java.util.List)8 Iterator (java.util.Iterator)7 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)6 HashSet (java.util.HashSet)6 JAXBException (javax.xml.bind.JAXBException)6 FederationConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement)5 BaseConfigType (com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType)4 TokenIssuerEndpointElement (com.sun.identity.wsfederation.jaxb.wsfederation.TokenIssuerEndpointElement)4 CLIException (com.sun.identity.cli.CLIException)3 WSFederationException (com.sun.identity.wsfederation.common.WSFederationException)3 UriNamedClaimTypesOfferedElement (com.sun.identity.wsfederation.jaxb.wsfederation.UriNamedClaimTypesOfferedElement)3 ArrayList (java.util.ArrayList)3 Set (java.util.Set)3 WSFedPropertiesModel (com.sun.identity.console.federation.model.WSFedPropertiesModel)2 ConfigurationException (com.sun.identity.plugin.configuration.ConfigurationException)2 AttributeType (com.sun.identity.wsfederation.jaxb.entityconfig.AttributeType)2 ObjectFactory (com.sun.identity.wsfederation.jaxb.entityconfig.ObjectFactory)2