Search in sources :

Example 1 with ObjectFactory

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

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

the class IDFFModelImpl method addAttributeType.

private BaseConfigType addAttributeType(Map values, BaseConfigType bctype) throws JAXBException {
    ObjectFactory objFactory = new ObjectFactory();
    for (Iterator iter = values.keySet().iterator(); iter.hasNext(); ) {
        AttributeType avp = objFactory.createAttributeElement();
        String key = (String) iter.next();
        avp.setName(key);
        avp.getValue().addAll(Collections.EMPTY_LIST);
        bctype.getAttribute().add(avp);
    }
    return bctype;
}
Also used : ObjectFactory(com.sun.identity.federation.jaxb.entityconfig.ObjectFactory) AttributeType(com.sun.identity.federation.jaxb.entityconfig.AttributeType) Iterator(java.util.Iterator)

Example 3 with ObjectFactory

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

the class IDFFModelImpl method createEntityConfig.

public void createEntityConfig(String realm, String entityName, String role, String location) throws AMConsoleException {
    try {
        IDFFMetaManager idffMetaMgr = getIDFFMetaManager();
        ObjectFactory objFactory = new ObjectFactory();
        // Check whether the entity id existed in the DS
        EntityDescriptorElement entityDesc = idffMetaMgr.getEntityDescriptor(realm, entityName);
        if (entityDesc == null) {
            throw new AMConsoleException("invalid.entity.name");
        }
        EntityConfigElement entityConfig = idffMetaMgr.getEntityConfig(realm, entityName);
        if (entityConfig == null) {
            entityConfig = objFactory.createEntityConfigElement();
            // add to entityConfig
            entityConfig.setEntityID(entityName);
            if (location.equals("remote")) {
                entityConfig.setHosted(false);
            } else {
                entityConfig.setHosted(true);
            }
        }
        // create entity config and add the attribute
        BaseConfigType baseCfgType = null;
        // It could have one sp and one idp.
        if ((role.equals(IFSConstants.SP)) && (IDFFMetaUtils.getSPDescriptor(entityDesc) != null)) {
            baseCfgType = objFactory.createSPDescriptorConfigElement();
            for (Iterator iter = extendedMetaMap.keySet().iterator(); iter.hasNext(); ) {
                AttributeType atype = objFactory.createAttributeType();
                String key = (String) iter.next();
                atype.setName(key);
                atype.getValue().addAll(Collections.EMPTY_LIST);
                baseCfgType.getAttribute().add(atype);
            }
            for (Iterator iter = extendedMetaSpMap.keySet().iterator(); iter.hasNext(); ) {
                AttributeType atype = objFactory.createAttributeType();
                String key = (String) iter.next();
                atype.setName(key);
                atype.getValue().addAll(Collections.EMPTY_LIST);
                baseCfgType.getAttribute().add(atype);
            }
            entityConfig.getSPDescriptorConfig().add(baseCfgType);
        } else if ((role.equals(IFSConstants.IDP)) && (IDFFMetaUtils.getIDPDescriptor(entityDesc) != null)) {
            baseCfgType = objFactory.createIDPDescriptorConfigElement();
            for (Iterator iter = extendedMetaMap.keySet().iterator(); iter.hasNext(); ) {
                AttributeType atype = objFactory.createAttributeType();
                String key = (String) iter.next();
                atype.setName(key);
                atype.getValue().addAll(Collections.EMPTY_LIST);
                baseCfgType.getAttribute().add(atype);
            }
            for (Iterator iter = extendedMetaIdpMap.keySet().iterator(); iter.hasNext(); ) {
                AttributeType atype = objFactory.createAttributeType();
                String key = (String) iter.next();
                atype.setName(key);
                atype.getValue().addAll(Collections.EMPTY_LIST);
                baseCfgType.getAttribute().add(atype);
            }
            entityConfig.getIDPDescriptorConfig().add(baseCfgType);
        }
        idffMetaMgr.setEntityConfig(realm, entityConfig);
    } catch (IDFFMetaException e) {
        throw new AMConsoleException(getErrorString(e));
    } catch (JAXBException e) {
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : BaseConfigType(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType) ObjectFactory(com.sun.identity.federation.jaxb.entityconfig.ObjectFactory) IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) AttributeType(com.sun.identity.federation.jaxb.entityconfig.AttributeType) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) JAXBException(javax.xml.bind.JAXBException) Iterator(java.util.Iterator) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) EntityDescriptorElement(com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement) EntityConfigElement(com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement)

Example 4 with ObjectFactory

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

the class IDFFMetaSecurityUtils method setExtendedAttributeValue.

private static void setExtendedAttributeValue(BaseConfigType config, String attrName, Set attrVal) throws IDFFMetaException {
    try {
        List attributes = config.getAttribute();
        for (Iterator iter = attributes.iterator(); iter.hasNext(); ) {
            AttributeType avp = (AttributeType) iter.next();
            if (avp.getName().trim().equalsIgnoreCase(attrName)) {
                iter.remove();
            }
        }
        if (attrVal != null) {
            ObjectFactory factory = new ObjectFactory();
            AttributeType atype = factory.createAttributeType();
            atype.setName(attrName);
            atype.getValue().addAll(attrVal);
            config.getAttribute().add(atype);
        }
    } catch (JAXBException e) {
        throw new IDFFMetaException(e);
    }
}
Also used : ObjectFactory(com.sun.identity.federation.jaxb.entityconfig.ObjectFactory) AttributeType(com.sun.identity.federation.jaxb.entityconfig.AttributeType) JAXBException(javax.xml.bind.JAXBException) Iterator(java.util.Iterator) List(java.util.List)

Aggregations

AttributeType (com.sun.identity.federation.jaxb.entityconfig.AttributeType)4 ObjectFactory (com.sun.identity.federation.jaxb.entityconfig.ObjectFactory)4 Iterator (java.util.Iterator)3 BaseConfigType (com.sun.identity.federation.jaxb.entityconfig.BaseConfigType)2 EntityConfigElement (com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement)2 EntityDescriptorElement (com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement)2 List (java.util.List)2 JAXBException (javax.xml.bind.JAXBException)2 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)1 IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)1 IDFFMetaManager (com.sun.identity.federation.meta.IDFFMetaManager)1 ArrayList (java.util.ArrayList)1