Search in sources :

Example 21 with BaseConfigType

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

the class FSLoginHelper method getIDPs.

private Set getIDPs(String metaAlias) {
    Set idpSet = new HashSet();
    try {
        String provider = "";
        String providerStatus = "";
        String role = IFSConstants.IDP.toLowerCase();
        IDPDescriptorType providerDesc = null;
        BaseConfigType providerConfig = null;
        Set trustedProviders = metaManager.getAllTrustedProviders(metaAlias);
        if (trustedProviders != null && !trustedProviders.isEmpty()) {
            Iterator it = trustedProviders.iterator();
            while (it.hasNext()) {
                provider = (String) it.next();
                providerDesc = metaManager.getIDPDescriptor(realm, provider);
                providerConfig = metaManager.getIDPDescriptorConfig(realm, provider);
                if (providerDesc == null || providerConfig == null) {
                    continue;
                }
                providerStatus = IDFFMetaUtils.getFirstAttributeValueFromConfig(providerConfig, IFSConstants.PROVIDER_STATUS);
                if (FSUtils.debug.messageEnabled()) {
                    FSUtils.debug.message("FSLoginHelper::getIDPs For " + "providerId " + provider + " status is " + providerStatus);
                }
                if (providerStatus == null || providerStatus.length() == 0 || (providerStatus != null && providerStatus.equalsIgnoreCase(IFSConstants.ACTIVE))) {
                    idpSet.add(provider);
                }
            }
        }
    } catch (IDFFMetaException ame) {
        FSUtils.debug.error("FSLoginHelper::getIDPs Error in getting idp List:", ame);
    }
    if (FSUtils.debug.messageEnabled()) {
        FSUtils.debug.message("FSLoginHelper::getIDPs returing idpset as " + idpSet);
    }
    return idpSet;
}
Also used : IDPDescriptorType(com.sun.identity.liberty.ws.meta.jaxb.IDPDescriptorType) BaseConfigType(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType) HashSet(java.util.HashSet) Set(java.util.Set) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) Iterator(java.util.Iterator) HashSet(java.util.HashSet)

Example 22 with BaseConfigType

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

the class IDFFCOTUtils method updateCOTAttrInConfig.

/**
     * Updates the entity config to update the values of the
     * <code>cotlist</code> attribute.
     *
     * @param realm realm the entity resides in.
     * @param configList the list containing config elements.
     * @param cotName the circle of trust name.
     * @param entityConfig the <code>EntityConfigElement</code> object
     * @param objFactory the object factory object
     * @param idffMetaMgr the <code>IDFFMetaManager</code> object.
     * @throws <code>IDFFMetaException</code> if there is an error retrieving
     *         and updating the entityConfig.
     * @throws <code>JAXBException</code> if there is an error setting the
     *         config.
     */
private void updateCOTAttrInConfig(String realm, List configList, String cotName, EntityConfigElement entityConfig, ObjectFactory objFactory, IDFFMetaManager idffMetaMgr) throws IDFFMetaException, JAXBException {
    boolean foundCOT = false;
    for (Iterator iter = configList.iterator(); iter.hasNext(); ) {
        BaseConfigType bConfig = (BaseConfigType) iter.next();
        List list = bConfig.getAttribute();
        for (Iterator iter2 = list.iterator(); iter2.hasNext(); ) {
            AttributeType avp = (AttributeType) iter2.next();
            if (avp.getName().trim().equalsIgnoreCase(COT_LIST)) {
                foundCOT = true;
                List avpl = avp.getValue();
                if (avpl.isEmpty() || !containsValue(avpl, cotName)) {
                    avpl.add(cotName);
                    idffMetaMgr.setEntityConfig(realm, entityConfig);
                    break;
                }
            }
        }
        // no cot_list in the original entity config
        if (!foundCOT) {
            AttributeType atype = objFactory.createAttributeType();
            atype.setName(COT_LIST);
            atype.getValue().add(cotName);
            list.add(atype);
            idffMetaMgr.setEntityConfig(realm, entityConfig);
        }
    }
}
Also used : BaseConfigType(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType) AttributeType(com.sun.identity.federation.jaxb.entityconfig.AttributeType) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList)

Example 23 with BaseConfigType

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

the class IDFFCOTUtils method updateEntityConfig.

/**
     * Updates the entity config to add the circle of turst name to the
     * <code>cotlist</code> attribute. The Service Provider and Identity
     * Provider Configurations are updated.
     *
     * @param realm realm the entity resides in.
     * @param cotName the circle of trust name.
     * @param entityID the name of the Entity identifier.
     * @throws IDFFMetaException if there is a configuration error when
     *         updating the configuration.
     * @throws JAXBException is there is an error updating the entity
     *          configuration.
     */
public void updateEntityConfig(String realm, String cotName, String entityID) throws IDFFMetaException, JAXBException {
    String classMethod = "IDFFCOTUtils.updateEntityConfig: ";
    IDFFMetaManager idffMetaMgr = new IDFFMetaManager(callerSession);
    ObjectFactory objFactory = new ObjectFactory();
    // Check whether the entity id existed in the DS
    EntityDescriptorElement entityDesc = idffMetaMgr.getEntityDescriptor(realm, entityID);
    if (entityDesc == null) {
        debug.error(classMethod + " No such entity: " + entityID);
        String[] data = { entityID };
        throw new IDFFMetaException("invalidEntityID", data);
    }
    EntityConfigElement entityConfig = idffMetaMgr.getEntityConfig(realm, entityID);
    if (entityConfig == null) {
        // create entity config and add the cot attribute
        BaseConfigType IDFFCOTUtils = null;
        AttributeType atype = objFactory.createAttributeType();
        atype.setName(COT_LIST);
        atype.getValue().add(cotName);
        // add to entityConfig
        entityConfig = objFactory.createEntityConfigElement();
        entityConfig.setEntityID(entityID);
        entityConfig.setHosted(false);
        // It could have one sp and one idp.
        if (IDFFMetaUtils.getSPDescriptor(entityDesc) != null) {
            IDFFCOTUtils = objFactory.createSPDescriptorConfigElement();
            IDFFCOTUtils.getAttribute().add(atype);
            entityConfig.getSPDescriptorConfig().add(IDFFCOTUtils);
        }
        if (IDFFMetaUtils.getIDPDescriptor(entityDesc) != null) {
            IDFFCOTUtils = objFactory.createIDPDescriptorConfigElement();
            IDFFCOTUtils.getAttribute().add(atype);
            entityConfig.getIDPDescriptorConfig().add(IDFFCOTUtils);
        }
        if (entityDesc.getAffiliationDescriptor() != null) {
            IDFFCOTUtils = objFactory.createAffiliationDescriptorConfigElement();
            IDFFCOTUtils.getAttribute().add(atype);
            entityConfig.setAffiliationDescriptorConfig(IDFFCOTUtils);
        }
        idffMetaMgr.setEntityConfig(realm, entityConfig);
    } else {
        // update the sp and idp entity config
        List spConfigList = entityConfig.getSPDescriptorConfig();
        List idpConfigList = entityConfig.getIDPDescriptorConfig();
        updateCOTAttrInConfig(realm, spConfigList, cotName, entityConfig, objFactory, idffMetaMgr);
        updateCOTAttrInConfig(realm, idpConfigList, cotName, entityConfig, objFactory, idffMetaMgr);
        BaseConfigType affiConfig = entityConfig.getAffiliationDescriptorConfig();
        if (affiConfig != null) {
            List affiConfigList = new ArrayList();
            affiConfigList.add(affiConfig);
            updateCOTAttrInConfig(realm, affiConfigList, cotName, entityConfig, objFactory, idffMetaMgr);
        }
    }
}
Also used : BaseConfigType(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType) ObjectFactory(com.sun.identity.federation.jaxb.entityconfig.ObjectFactory) AttributeType(com.sun.identity.federation.jaxb.entityconfig.AttributeType) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) EntityDescriptorElement(com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement) EntityConfigElement(com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement)

Example 24 with BaseConfigType

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

the class IDFFModelImpl method getSPAuthenticationContexts.

/**
     * Returns  the object of Auththentication Contexts in SP.
     *
     * @param realm Realm of Entity
     * @param entityName Name of Entity Descriptor.     
     * @return attributes values of provider.
     */
public IDFFAuthContexts getSPAuthenticationContexts(String realm, String entityName) throws AMConsoleException {
    IDFFAuthContexts cxt = new IDFFAuthContexts();
    String str = null;
    try {
        List tmpList = new ArrayList();
        IDFFMetaManager manager = getIDFFMetaManager();
        Map map = new HashMap();
        BaseConfigType spConfig = manager.getSPDescriptorConfig(realm, entityName);
        if (spConfig != null) {
            map = IDFFMetaUtils.getAttributes(spConfig);
        } else {
            throw new AMConsoleException("invalid.entity.name");
        }
        List list = (List) map.get(ATTR_SP_AUTHN_CONTEXT_MAPPING);
        for (int i = 0; i < list.size(); i++) {
            String tmp = (String) list.get(i);
            int index = tmp.lastIndexOf("|");
            String level = removeKey(tmp.substring(index + 1));
            String name = removeKey(tmp.substring(0, index));
            cxt.put(name, "true", level);
        }
    } catch (IDFFMetaException e) {
        throw new AMConsoleException(getErrorString(e));
    } catch (AMConsoleException e) {
        throw new AMConsoleException(getErrorString(e));
    }
    return (cxt != null) ? cxt : new IDFFAuthContexts();
}
Also used : BaseConfigType(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType) HashMap(java.util.HashMap) IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map) IDFFAuthContexts(com.sun.identity.console.federation.IDFFAuthContexts)

Example 25 with BaseConfigType

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

the class IDFFModelImpl method getAffiliateProfileAttributeValues.

/**
     * Returns affiliate profile attribute values.
     *
     * @param realm the realm in which the entity resides.
     * @param entityName name of Entity Descriptor.
     * @return affiliate profile attribute values.
     * @throws AMConsoleException if attribute values cannot be obtained.
     */
public Map getAffiliateProfileAttributeValues(String realm, String entityName) throws AMConsoleException {
    String[] params = { realm, entityName, "IDFF", "IDP" };
    logEvent("ATTEMPT_GET_AFFILIATE_ENTITY_DESCRIPTOR_ATTR_VALUES", params);
    Map values = new HashMap();
    try {
        IDFFMetaManager idffManager = getIDFFMetaManager();
        AffiliationDescriptorType aDesc = (AffiliationDescriptorType) idffManager.getAffiliationDescriptor(realm, entityName);
        if (aDesc != null) {
            values.put(ATTR_AFFILIATE_ID, returnEmptySetIfValueIsNull(aDesc.getAffiliationID()));
            values.put(ATTR_AFFILIATE_OWNER_ID, returnEmptySetIfValueIsNull(aDesc.getAffiliationOwnerID()));
            BaseConfigType affiliationConfig = idffManager.getAffiliationDescriptorConfig(realm, entityName);
            if (affiliationConfig != null) {
                Map map = IDFFMetaUtils.getAttributes(affiliationConfig);
                if (map.containsKey(ATTR_AFFILIATE_SIGNING_CERT_ALIAS)) {
                    values.put(ATTR_AFFILIATE_SIGNING_CERT_ALIAS, returnEmptySetIfValueIsNull(convertListToSet((List) map.get(ATTR_AFFILIATE_SIGNING_CERT_ALIAS))));
                } else {
                    values.put(ATTR_AFFILIATE_SIGNING_CERT_ALIAS, Collections.EMPTY_SET);
                }
                if (map.containsKey(ATTR_AFFILIATE_ENCRYPTION_CERT_ALIAS)) {
                    values.put(ATTR_AFFILIATE_ENCRYPTION_CERT_ALIAS, returnEmptySetIfValueIsNull(convertListToSet((List) map.get(ATTR_AFFILIATE_ENCRYPTION_CERT_ALIAS))));
                } else {
                    values.put(ATTR_AFFILIATE_ENCRYPTION_CERT_ALIAS, Collections.EMPTY_SET);
                }
            }
        } else {
            values.put(ATTR_AFFILIATE_ID, Collections.EMPTY_SET);
            values.put(ATTR_AFFILIATE_OWNER_ID, Collections.EMPTY_SET);
            values.put(ATTR_AFFILIATE_VALID_UNTIL, Collections.EMPTY_SET);
            values.put(ATTR_AFFILIATE_CACHE_DURATION, Collections.EMPTY_SET);
            values.put(ATTR_AFFILIATE_SIGNING_CERT_ALIAS, Collections.EMPTY_SET);
            values.put(ATTR_AFFILIATE_ENCRYPTION_CERT_ALIAS, Collections.EMPTY_SET);
            values.put(ATTR_AFFILIATE_ENCRYPTION_KEY_SIZE, Collections.EMPTY_SET);
            values.put(ATTR_AFFILIATE_ENCRYPTION_KEY_ALGORITHM, Collections.EMPTY_SET);
        }
        logEvent("SUCCEED_GET_AFFILIATE_ENTITY_DESCRIPTOR_ATTR_VALUES", params);
    } catch (IDFFMetaException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "IDFF", "SP", strError };
        logEvent("FEDERATION_EXCEPTION_GET_AFFILIATE_ENTITY_DESCRIPTOR_ATTR_VALUES", paramsEx);
        throw new AMConsoleException(strError);
    }
    return (values != null) ? values : Collections.EMPTY_MAP;
}
Also used : BaseConfigType(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType) HashMap(java.util.HashMap) IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) AffiliationDescriptorType(com.sun.identity.liberty.ws.meta.jaxb.AffiliationDescriptorType) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

BaseConfigType (com.sun.identity.federation.jaxb.entityconfig.BaseConfigType)54 IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)33 IDFFMetaManager (com.sun.identity.federation.meta.IDFFMetaManager)18 List (java.util.List)18 FSException (com.sun.identity.federation.common.FSException)17 SessionException (com.sun.identity.plugin.session.SessionException)14 IOException (java.io.IOException)14 ArrayList (java.util.ArrayList)14 Iterator (java.util.Iterator)14 IDPDescriptorType (com.sun.identity.liberty.ws.meta.jaxb.IDPDescriptorType)13 SAMLException (com.sun.identity.saml.common.SAMLException)13 FSMsgException (com.sun.identity.federation.message.common.FSMsgException)12 ProviderDescriptorType (com.sun.identity.liberty.ws.meta.jaxb.ProviderDescriptorType)12 FSSessionManager (com.sun.identity.federation.services.FSSessionManager)10 HashMap (java.util.HashMap)10 Map (java.util.Map)10 ServletException (javax.servlet.ServletException)10 FSAuthnRequest (com.sun.identity.federation.message.FSAuthnRequest)9 Set (java.util.Set)9 FSAccountMgmtException (com.sun.identity.federation.accountmgmt.FSAccountMgmtException)8