Search in sources :

Example 6 with WSFederationMetaManager

use of com.sun.identity.wsfederation.meta.WSFederationMetaManager in project OpenAM by OpenRock.

the class CreateMetaDataModelImpl method createWSFedProvider.

/**
     * Creates a WS Federation provider.
     *
     * @param realm Realm Name.
     * @param entityId Entity Id.
     * @param values   Map of property name to values.
     * 
     * @throws AMConsoleException if duplicate metaAliases provided or unable to create or import metadata.
     * */
public void createWSFedProvider(String realm, String entityId, Map values) throws AMConsoleException {
    try {
        List<String> metaAliases = getFederationAlias(values, MetaTemplateParameters.P_WS_FED_ALIASES);
        Set<String> duplicateCheck = new HashSet<String>(metaAliases);
        if (duplicateCheck.size() < metaAliases.size()) {
            throw new AMConsoleException(getLocalizedString("federation.create.provider.duplicate.metaAlias"));
        }
        WSFederationMetaManager metaManager = new WSFederationMetaManager();
        metaManager.validateMetaAliasForNewEntity(realm, metaAliases);
        String metadata = CreateWSFedMetaDataTemplate.createStandardMetaTemplate(entityId, values, requestURL);
        String extendedData = CreateWSFedMetaDataTemplate.createExtendedMetaTemplate(entityId, values);
        FederationElement elt = (FederationElement) WSFederationMetaUtils.convertStringToJAXB(metadata);
        String federationID = elt.getFederationID();
        if (federationID == null) {
            federationID = WSFederationConstants.DEFAULT_FEDERATION_ID;
        }
        metaManager.createFederation(realm, elt);
        FederationConfigElement cfg = (FederationConfigElement) WSFederationMetaUtils.convertStringToJAXB(extendedData);
        metaManager.createEntityConfig(realm, cfg);
    } catch (WSFederationMetaException ex) {
        throw new AMConsoleException(ex.getMessage());
    } catch (JAXBException ex) {
        throw new AMConsoleException(ex.getMessage());
    } catch (CertificateEncodingException ex) {
        throw new AMConsoleException(ex.getMessage());
    }
}
Also used : WSFederationMetaManager(com.sun.identity.wsfederation.meta.WSFederationMetaManager) JAXBException(javax.xml.bind.JAXBException) FederationConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement) CertificateEncodingException(java.security.cert.CertificateEncodingException) WSFederationMetaException(com.sun.identity.wsfederation.meta.WSFederationMetaException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) FederationElement(com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement) HashSet(java.util.HashSet)

Example 7 with WSFederationMetaManager

use of com.sun.identity.wsfederation.meta.WSFederationMetaManager in project OpenAM by OpenRock.

the class EntityModelImpl method getWSFedEntities.

/**
     * Returns a map of all the wsfed entities including data about
     * what realm, the roles, and location of each entity.
     *
     * @throws AMConsoleException if unable to retrieve the WSFED entities.
     */
public Map getWSFedEntities() throws AMConsoleException {
    Map wsfedMap = new HashMap();
    for (Iterator i = realms.iterator(); i.hasNext(); ) {
        String realm = (String) i.next();
        try {
            WSFederationMetaManager metaManager = new WSFederationMetaManager();
            Set wsfedEntities = metaManager.getAllEntities(realm);
            List hosted = metaManager.getAllHostedEntities(realm);
            for (Iterator j = wsfedEntities.iterator(); j.hasNext(); ) {
                String entity = (String) j.next();
                Map data = new HashMap(8);
                data.put(REALM, realm);
                data.put(PROTOCOL, WSFED);
                data.put(ROLE, listToString(getWSFedRoles(entity, realm)));
                if ((hosted != null) && (hosted.contains(entity))) {
                    data.put(LOCATION, HOSTED);
                } else {
                    data.put(LOCATION, REMOTE);
                }
                String entityNamewithRealm = entity + "," + realm;
                wsfedMap.put(entityNamewithRealm, (HashMap) data);
            }
        } catch (WSFederationMetaException e) {
            debug.error("EntityModel.getWSFedEntities", e);
            throw new AMConsoleException(e.getMessage());
        }
    }
    return (wsfedMap != null) ? wsfedMap : Collections.EMPTY_MAP;
}
Also used : WSFederationMetaManager(com.sun.identity.wsfederation.meta.WSFederationMetaManager) HashSet(java.util.HashSet) Set(java.util.Set) OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) HashMap(java.util.HashMap) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) WSFederationMetaException(com.sun.identity.wsfederation.meta.WSFederationMetaException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 8 with WSFederationMetaManager

use of com.sun.identity.wsfederation.meta.WSFederationMetaManager in project OpenAM by OpenRock.

the class EntityModelImpl method getWSFedRoles.

public List getWSFedRoles(String entity, String realm) {
    List roles = new ArrayList(4);
    boolean isSP = true;
    int cnt = 0;
    try {
        WSFederationMetaManager metaManager = new WSFederationMetaManager();
        if (metaManager.getIDPSSOConfig(realm, entity) != null) {
            roles.add(IDENTITY_PROVIDER);
        }
        if (metaManager.getSPSSOConfig(realm, entity) != null) {
            roles.add(SERVICE_PROVIDER);
        }
        //to handle dual roles specifically for WSFED
        if (roles.isEmpty()) {
            FederationElement fedElem = metaManager.getEntityDescriptor(realm, entity);
            if (fedElem != null) {
                for (Iterator iter = fedElem.getAny().iterator(); iter.hasNext(); ) {
                    Object o = iter.next();
                    if (o instanceof UriNamedClaimTypesOfferedElement) {
                        roles.add(IDENTITY_PROVIDER);
                        isSP = false;
                    } else if (o instanceof TokenIssuerEndpointElement) {
                        cnt++;
                    }
                }
                if ((isSP) || (cnt > 1)) {
                    roles.add(SERVICE_PROVIDER);
                }
            }
        }
    } catch (WSFederationMetaException e) {
        debug.warning("EntityModelImpl.getWSFedRoles", e);
    }
    return (roles != null) ? roles : Collections.EMPTY_LIST;
}
Also used : WSFederationMetaManager(com.sun.identity.wsfederation.meta.WSFederationMetaManager) UriNamedClaimTypesOfferedElement(com.sun.identity.wsfederation.jaxb.wsfederation.UriNamedClaimTypesOfferedElement) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) WSFederationMetaException(com.sun.identity.wsfederation.meta.WSFederationMetaException) FederationElement(com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement) TokenIssuerEndpointElement(com.sun.identity.wsfederation.jaxb.wsfederation.TokenIssuerEndpointElement)

Example 9 with WSFederationMetaManager

use of com.sun.identity.wsfederation.meta.WSFederationMetaManager in project OpenAM by OpenRock.

the class WSFedPropertiesModelImpl method getIdentityProviderAttributes.

/**
     * Returns a <code>Map</code> with identity provider attributes and values.
     *
     * @param realm to which the entity belongs.
     * @param fedId is the Federation Id otherwise known as the entity id.
     * @return attribute values of IDP based on realm and fedId passed.
     * @throws AMConsoleException if unable to retreive the Identity Provider
     *     attrubutes based on the realm and fedId passed.
     */
public Map getIdentityProviderAttributes(String realm, String fedId) throws AMConsoleException {
    Map IDPAttributes = null;
    try {
        WSFederationMetaManager metaManager = getWSFederationMetaManager();
        IDPSSOConfigElement idpconfig = metaManager.getIDPSSOConfig(realm, fedId);
        if (idpconfig != null) {
            IDPAttributes = WSFederationMetaUtils.getAttributes(idpconfig);
        }
    } catch (WSFederationMetaException e) {
        debug.warning("WSFedPropertiesModelImpl.getIdentityProviderAttributes", e);
        throw new AMConsoleException(e.getMessage());
    }
    return (IDPAttributes != null) ? IDPAttributes : Collections.EMPTY_MAP;
}
Also used : WSFederationMetaManager(com.sun.identity.wsfederation.meta.WSFederationMetaManager) IDPSSOConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.IDPSSOConfigElement) WSFederationMetaException(com.sun.identity.wsfederation.meta.WSFederationMetaException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 10 with WSFederationMetaManager

use of com.sun.identity.wsfederation.meta.WSFederationMetaManager in project OpenAM by OpenRock.

the class WSFedPropertiesModelImpl method setSPExtAttributeValues.

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

Aggregations

WSFederationMetaManager (com.sun.identity.wsfederation.meta.WSFederationMetaManager)31 WSFederationMetaException (com.sun.identity.wsfederation.meta.WSFederationMetaException)20 List (java.util.List)13 FederationElement (com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement)12 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)11 JAXBException (javax.xml.bind.JAXBException)10 Iterator (java.util.Iterator)9 CLIException (com.sun.identity.cli.CLIException)8 ArrayList (java.util.ArrayList)8 WSFederationException (com.sun.identity.wsfederation.common.WSFederationException)7 HashMap (java.util.HashMap)7 SPSSOConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.SPSSOConfigElement)6 Map (java.util.Map)6 SessionException (com.sun.identity.plugin.session.SessionException)5 Set (java.util.Set)5 BaseConfigType (com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType)4 FederationConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement)4 IDPSSOConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.IDPSSOConfigElement)4 TokenIssuerEndpointElement (com.sun.identity.wsfederation.jaxb.wsfederation.TokenIssuerEndpointElement)4 IOException (java.io.IOException)4