Search in sources :

Example 11 with BaseConfigType

use of com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType 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 12 with BaseConfigType

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

Example 13 with BaseConfigType

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

the class WSFedPropertiesModelImpl method createExtendedObject.

/**
     * Creates the extended config object when it does not exist.
     * @param realm to which the entity belongs.
     * @param fedId is the entity id.
     * @param location is either hosted or remote
     * @param role is SP, IDP or SP/IDP.
     * @param keys which contain all extended attribute keys.
     * @throws WSFederationMetaException, JAXBException,
     *     AMConsoleException if saving of attribute value fails.
     */
private void createExtendedObject(String realm, String fedId, String location, String role, Map keys) throws WSFederationMetaException, JAXBException, AMConsoleException {
    try {
        ObjectFactory objFactory = new ObjectFactory();
        WSFederationMetaManager metaManager = getWSFederationMetaManager();
        FederationElement edes = metaManager.getEntityDescriptor(realm, fedId);
        if (edes == null) {
            if (debug.warningEnabled()) {
                debug.warning("WSFedPropertiesModelImpl.createExtendedObject: " + "No such entity: " + fedId);
            }
            String[] data = { realm, fedId };
            throw new WSFederationMetaException("fedId_invalid", data);
        }
        FederationConfigElement eConfig = metaManager.getEntityConfig(realm, fedId);
        if (eConfig == null) {
            BaseConfigType bctype = null;
            FederationConfigElement ele = objFactory.createFederationConfigElement();
            ele.setFederationID(fedId);
            if (location.equals("remote")) {
                ele.setHosted(false);
            }
            List ll = ele.getIDPSSOConfigOrSPSSOConfig();
            // Right now, it is either an SP or an IdP or dual role
            if (isDualRole(edes)) {
                //for dual role create both idp and sp config objects
                BaseConfigType bctype_idp = null;
                BaseConfigType bctype_sp = null;
                bctype_idp = objFactory.createIDPSSOConfigElement();
                bctype_idp = createAttributeElement(keys, bctype_idp);
                bctype_sp = objFactory.createSPSSOConfigElement();
                bctype_sp = createAttributeElement(keys, bctype_sp);
                ll.add(bctype_idp);
                ll.add(bctype_sp);
            } else if (role.equals(IDENTITY_PROVIDER)) {
                bctype = objFactory.createIDPSSOConfigElement();
                //bctype.getAttribute().add(atype);
                bctype = createAttributeElement(keys, bctype);
                ll.add(bctype);
            } else if (role.equals(SERVICE_PROVIDER)) {
                bctype = objFactory.createSPSSOConfigElement();
                bctype = createAttributeElement(keys, bctype);
                ll.add(bctype);
            }
            metaManager.setEntityConfig(realm, ele);
        }
    } catch (JAXBException e) {
        debug.warning("WSFedPropertiesModelImpl.createExtendedObject", e);
        throw new AMConsoleException(getErrorString(e));
    } catch (WSFederationMetaException e) {
        debug.warning("WSFedPropertiesModelImpl.createExtendedObject", e);
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : BaseConfigType(com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType) WSFederationMetaManager(com.sun.identity.wsfederation.meta.WSFederationMetaManager) ObjectFactory(com.sun.identity.wsfederation.jaxb.entityconfig.ObjectFactory) JAXBException(javax.xml.bind.JAXBException) FederationConfigElement(com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement) List(java.util.List) WSFederationMetaException(com.sun.identity.wsfederation.meta.WSFederationMetaException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) FederationElement(com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement)

Aggregations

BaseConfigType (com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType)13 List (java.util.List)9 FederationConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement)7 WSFederationMetaException (com.sun.identity.wsfederation.meta.WSFederationMetaException)6 Iterator (java.util.Iterator)6 FederationElement (com.sun.identity.wsfederation.jaxb.wsfederation.FederationElement)4 WSFederationMetaManager (com.sun.identity.wsfederation.meta.WSFederationMetaManager)4 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)3 JAXBException (javax.xml.bind.JAXBException)3 ConfigurationException (com.sun.identity.plugin.configuration.ConfigurationException)2 WSFederationException (com.sun.identity.wsfederation.common.WSFederationException)2 AttributeType (com.sun.identity.wsfederation.jaxb.entityconfig.AttributeType)2 IDPSSOConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.IDPSSOConfigElement)2 ObjectFactory (com.sun.identity.wsfederation.jaxb.entityconfig.ObjectFactory)2 SPSSOConfigElement (com.sun.identity.wsfederation.jaxb.entityconfig.SPSSOConfigElement)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 SessionException (com.sun.identity.plugin.session.SessionException)1 HashSet (java.util.HashSet)1