Search in sources :

Example 6 with EntityConfigElement

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

the class IDFFMetaManager method getAffiliationDescriptorConfig.

/**
     * Returns Affiliation Configuration for the entity identifier.
     *
     * @param realm The realm under which the entity resides.
     * @param entityID ID of the entity to be retrieved.
     * @return <code>AffiliationDescriptorConfigElement</code> for the entity
     *         identifier .  A null is returned if the configuration
     *         is not found.
     * @throws IDFFMetaException if there is an error retrieving service
     *         provider configuration.
     */
public AffiliationDescriptorConfigElement getAffiliationDescriptorConfig(String realm, String entityID) throws IDFFMetaException {
    AffiliationDescriptorConfigElement affiliationDesConfig = null;
    EntityConfigElement entityConfig = getEntityConfig(realm, entityID);
    if (entityConfig != null) {
        affiliationDesConfig = (AffiliationDescriptorConfigElement) entityConfig.getAffiliationDescriptorConfig();
    }
    return affiliationDesConfig;
}
Also used : AffiliationDescriptorConfigElement(com.sun.identity.federation.jaxb.entityconfig.AffiliationDescriptorConfigElement) EntityConfigElement(com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement)

Example 7 with EntityConfigElement

use of com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement 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 8 with EntityConfigElement

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

the class IDFFMetaCache method getEntityConfig.

/**
     * Returns the Entity Config under the realm from the cache.
     *
     * @param realm The realm under which the entity resides.
     * @param entityID the entity config identifier.
     * @return <code>EntityConfigElement</code> object for the entity or null
     *         if not found.
     */
public static EntityConfigElement getEntityConfig(String realm, String entityID) {
    String classMethod = "IDFFMetaCache:getEntityConfig";
    String cacheKey = buildCacheKey(realm, entityID);
    EntityConfigElement entityConfig = (EntityConfigElement) entityConfigCache.get(cacheKey);
    if (debug.messageEnabled()) {
        if (entityConfig != null) {
            debug.message(classMethod + "Entity Config found for " + cacheKey);
        } else {
            debug.message(classMethod + "Entity Config not found for " + cacheKey);
        }
    }
    return entityConfig;
}
Also used : EntityConfigElement(com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement)

Example 9 with EntityConfigElement

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

the class IDFFMetaManager method getEntityConfig.

/**
     * Returns extended entity configuration under the realm.
     *
     * @param realm The realm under which the entity resides.
     * @param entityID identifier of the entity whose config is to be
     *        retrieved.
     * @return <code>EntityConfigElement</code> object of the entity or null
     *         if the entity configuration does not exist.
     * @throws IDFFMetaException if unable to retrieve the entity
     *                            configuration.
     */
public EntityConfigElement getEntityConfig(String realm, String entityID) throws IDFFMetaException {
    String classMethod = "IDFFMetaManager:getEntityConfig:";
    EntityConfigElement entityConfig = null;
    if (entityID != null) {
        if ((realm == null) || (realm.length() == 0)) {
            realm = ROOT_REALM;
        }
        String[] args = { entityID, realm };
        if (callerSession == null) {
            // retrieve config from cache
            entityConfig = IDFFMetaCache.getEntityConfig(realm, entityID);
        }
        if (entityConfig == null) {
            try {
                Map attrs = idffMetaConfigInstance.getConfiguration(realm, entityID);
                if (attrs != null) {
                    Set cfgValues = (Set) attrs.get(IDFF_ENTITY_CONFIG_ATTR);
                    if (cfgValues != null && !cfgValues.isEmpty()) {
                        String cfgValue = (String) cfgValues.iterator().next();
                        Object object = IDFFMetaUtils.convertStringToJAXB(cfgValue);
                        if (object instanceof EntityConfigElement) {
                            entityConfig = (EntityConfigElement) object;
                            IDFFMetaCache.setEntityConfig(realm, entityID, entityConfig);
                        } else {
                            debug.error(classMethod + "Invalid entityID" + entityID);
                        }
                    }
                }
            } catch (ConfigurationException ce) {
                debug.error(classMethod + "Cannot retrieve entity config", ce);
                LogUtil.error(Level.INFO, LogUtil.GET_ENTITY_CONFIG_FAILED, args);
                throw new IDFFMetaException("cannotRetreiveEntityConfig", null);
            } catch (JAXBException jaxbe) {
                debug.error(classMethod, jaxbe);
                LogUtil.error(Level.INFO, LogUtil.INVALID_ENTITY_CONFIG, args);
                throw new IDFFMetaException("invalidEntityConfig", args);
            }
        }
        if (entityConfig != null) {
            LogUtil.access(Level.INFO, LogUtil.GET_ENTITY_CONFIG_SUCCEEDED, args);
        }
    } else {
        LogUtil.error(Level.INFO, LogUtil.NULL_ENTITY_ID, null);
        throw new IDFFMetaException("nullEntityID", null);
    }
    return entityConfig;
}
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) EntityConfigElement(com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement)

Example 10 with EntityConfigElement

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

the class IDFFMetaSecurityUtils method updateProviderKeyInfo.

/**
     * Updates signing or encryption key info for SP or IDP. 
     * This will update both signing/encryption alias on extended metadata and
     * certificates in standard metadata. 
     * @param realm Realm the entity resides.
     * @param entityID ID of the entity to be updated.  
     * @param certAlias Alias of the certificate to be set to the entity. If
     *        null, will remove existing key information from the SP or IDP.
     * @param isSigning true if this is signing certificate alias, false if 
     *        this is encryption certification alias.
     * @param isIDP true if this is for IDP signing/encryption alias, false
     *        if this is for SP signing/encryption alias
     * @param encAlgo Encryption algorithm URI, this is applicable for
     *        encryption cert only.
     * @param keySize Encryption key size, this is applicable for
     *        encryption cert only. 
     * @throws IDFFMetaException if failed to update the certificate alias for 
     *        the entity.
     */
public static void updateProviderKeyInfo(String realm, String entityID, String certAlias, boolean isSigning, boolean isIDP, String encAlgo, int keySize) throws IDFFMetaException {
    IDFFMetaManager metaManager = FSUtils.getIDFFMetaManager();
    EntityConfigElement config = metaManager.getEntityConfig(realm, entityID);
    if (!config.isHosted()) {
        String[] args = { entityID, realm };
        throw new IDFFMetaException("entityNotHosted", args);
    }
    EntityDescriptorElement desp = metaManager.getEntityDescriptor(realm, entityID);
    if (isIDP) {
        IDPDescriptorConfigElement idpConfig = IDFFMetaUtils.getIDPDescriptorConfig(config);
        IDPDescriptorType idpDesp = IDFFMetaUtils.getIDPDescriptor(desp);
        if ((idpConfig == null) || (idpDesp == null)) {
            String[] args = { entityID, realm };
            throw new IDFFMetaException("entityNotIDP", args);
        }
        // update standard metadata
        if ((certAlias == null) || (certAlias.length() == 0)) {
            // remove key info
            removeKeyDescriptor(idpDesp, isSigning);
            if (isSigning) {
                setExtendedAttributeValue(idpConfig, IFSConstants.SIGNING_CERT_ALIAS, null);
            } else {
                setExtendedAttributeValue(idpConfig, IFSConstants.ENCRYPTION_CERT_ALIAS, null);
            }
        } else {
            KeyDescriptorElement kde = getKeyDescriptor(certAlias, isSigning, encAlgo, keySize);
            updateKeyDescriptor(idpDesp, kde);
            // update extended metadata
            Set value = new HashSet();
            value.add(certAlias);
            if (isSigning) {
                setExtendedAttributeValue(idpConfig, IFSConstants.SIGNING_CERT_ALIAS, value);
            } else {
                setExtendedAttributeValue(idpConfig, IFSConstants.ENCRYPTION_CERT_ALIAS, value);
            }
        }
        metaManager.setEntityDescriptor(realm, desp);
        metaManager.setEntityConfig(realm, config);
    } else {
        SPDescriptorConfigElement spConfig = IDFFMetaUtils.getSPDescriptorConfig(config);
        SPDescriptorType spDesp = IDFFMetaUtils.getSPDescriptor(desp);
        if ((spConfig == null) || (spDesp == null)) {
            String[] args = { entityID, realm };
            throw new IDFFMetaException("entityNotSP", args);
        }
        // update standard metadata
        if ((certAlias == null) || (certAlias.length() == 0)) {
            // remove key info
            removeKeyDescriptor(spDesp, isSigning);
            if (isSigning) {
                setExtendedAttributeValue(spConfig, IFSConstants.SIGNING_CERT_ALIAS, null);
            } else {
                setExtendedAttributeValue(spConfig, IFSConstants.ENCRYPTION_CERT_ALIAS, null);
            }
        } else {
            KeyDescriptorElement kde = getKeyDescriptor(certAlias, isSigning, encAlgo, keySize);
            updateKeyDescriptor(spDesp, kde);
            // update extended metadata
            Set value = new HashSet();
            value.add(certAlias);
            if (isSigning) {
                setExtendedAttributeValue(spConfig, IFSConstants.SIGNING_CERT_ALIAS, value);
            } else {
                setExtendedAttributeValue(spConfig, IFSConstants.ENCRYPTION_CERT_ALIAS, value);
            }
        }
        metaManager.setEntityDescriptor(realm, desp);
        metaManager.setEntityConfig(realm, config);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) SPDescriptorConfigElement(com.sun.identity.federation.jaxb.entityconfig.SPDescriptorConfigElement) SPDescriptorType(com.sun.identity.liberty.ws.meta.jaxb.SPDescriptorType) EntityDescriptorElement(com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement) IDPDescriptorType(com.sun.identity.liberty.ws.meta.jaxb.IDPDescriptorType) IDPDescriptorConfigElement(com.sun.identity.federation.jaxb.entityconfig.IDPDescriptorConfigElement) KeyDescriptorElement(com.sun.identity.liberty.ws.meta.jaxb.KeyDescriptorElement) EntityConfigElement(com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement) HashSet(java.util.HashSet)

Aggregations

EntityConfigElement (com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement)15 List (java.util.List)8 IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)7 ArrayList (java.util.ArrayList)7 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)6 IDFFMetaManager (com.sun.identity.federation.meta.IDFFMetaManager)6 EntityDescriptorElement (com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement)5 HashSet (java.util.HashSet)5 Set (java.util.Set)5 JAXBException (javax.xml.bind.JAXBException)5 BaseConfigType (com.sun.identity.federation.jaxb.entityconfig.BaseConfigType)4 IDPDescriptorConfigElement (com.sun.identity.federation.jaxb.entityconfig.IDPDescriptorConfigElement)3 SPDescriptorConfigElement (com.sun.identity.federation.jaxb.entityconfig.SPDescriptorConfigElement)3 ConfigurationException (com.sun.identity.plugin.configuration.ConfigurationException)3 Iterator (java.util.Iterator)3 AttributeType (com.sun.identity.federation.jaxb.entityconfig.AttributeType)2 ObjectFactory (com.sun.identity.federation.jaxb.entityconfig.ObjectFactory)2 Map (java.util.Map)2 AffiliationDescriptorConfigElement (com.sun.identity.federation.jaxb.entityconfig.AffiliationDescriptorConfigElement)1 IDPDescriptorType (com.sun.identity.liberty.ws.meta.jaxb.IDPDescriptorType)1