Search in sources :

Example 1 with AttributeElement

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

the class WSFedPropertiesModelImpl method createAttributeElement.

/**
     * Returns BaseConfig object after updating with Attribute Elements.
     * @param values contain the keys for extended metadata attributes.
     * @param bconfig is the BaseConfigType object passed.
     *
     * @return BaseConfig object after updating with Attribute Elements.
     */
private BaseConfigType createAttributeElement(Map values, BaseConfigType bconfig) throws AMConsoleException {
    try {
        ObjectFactory objFactory = new ObjectFactory();
        for (Iterator iter = values.keySet().iterator(); iter.hasNext(); ) {
            AttributeElement avp = objFactory.createAttributeElement();
            String key = (String) iter.next();
            avp.setName(key);
            bconfig.getAttribute().add(avp);
        }
    } catch (JAXBException e) {
        debug.warning("WSFedPropertiesModelImpl.createAttributeElement", e);
        throw new AMConsoleException(e.getMessage());
    }
    return bconfig;
}
Also used : ObjectFactory(com.sun.identity.wsfederation.jaxb.entityconfig.ObjectFactory) JAXBException(javax.xml.bind.JAXBException) Iterator(java.util.Iterator) AttributeElement(com.sun.identity.wsfederation.jaxb.entityconfig.AttributeElement) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 2 with AttributeElement

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

the class WSFedPropertiesModelImpl method updateBaseConfig.

/**
     * Updates the BaseConfig Object with the map of values passed.
     *
     * @param baseConfig is the BaseConfigType object passed.
     * @param values the Map which contains the new attribute/value pairs.
     * @throws AMConsoleException if update of baseconfig object fails.
     */
private void updateBaseConfig(BaseConfigType baseConfig, Map values, String role) throws AMConsoleException {
    List attrList = baseConfig.getAttribute();
    if (role.equals(EntityModel.IDENTITY_PROVIDER)) {
        attrList.clear();
        baseConfig = createAttributeElement(getIDPEXDataMap(), baseConfig);
        attrList = baseConfig.getAttribute();
    } else if (role.equals(EntityModel.SERVICE_PROVIDER)) {
        attrList.clear();
        baseConfig = createAttributeElement(getSPEXDataMap(), baseConfig);
        attrList = baseConfig.getAttribute();
    }
    for (Iterator it = attrList.iterator(); it.hasNext(); ) {
        AttributeElement avpnew = (AttributeElement) it.next();
        String name = avpnew.getName();
        if (values.keySet().contains(name)) {
            Set set = (Set) values.get(name);
            if (set != null) {
                avpnew.getValue().clear();
                avpnew.getValue().addAll(set);
            }
        }
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) Iterator(java.util.Iterator) List(java.util.List) AttributeElement(com.sun.identity.wsfederation.jaxb.entityconfig.AttributeElement)

Example 3 with AttributeElement

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

the class WSFederationMetaUtils method setAttributes.

/**
     * Sets attribute value pairs in <code>BaseConfigType</code>. NOTE - 
     * existing AVPs are discarded! The key is 
     * @param config the <code>BaseConfigType</code> object
     * @param map mapping from attribute names to <code>List</code>s of 
     * attribute values;
     */
public static void setAttributes(BaseConfigType config, Map<String, List<String>> map) throws JAXBException {
    JAXBContext jc = WSFederationMetaUtils.getMetaJAXBContext();
    com.sun.identity.wsfederation.jaxb.entityconfig.ObjectFactory objFactory = new com.sun.identity.wsfederation.jaxb.entityconfig.ObjectFactory();
    List attributeList = config.getAttribute();
    attributeList.clear();
    // add the new content
    for (String key : map.keySet()) {
        AttributeElement avp = objFactory.createAttributeElement();
        avp.setName(key);
        avp.getValue().addAll(map.get(key));
        attributeList.add(avp);
    }
}
Also used : JAXBContext(javax.xml.bind.JAXBContext) List(java.util.List) AttributeElement(com.sun.identity.wsfederation.jaxb.entityconfig.AttributeElement)

Aggregations

AttributeElement (com.sun.identity.wsfederation.jaxb.entityconfig.AttributeElement)3 Iterator (java.util.Iterator)2 List (java.util.List)2 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)1 ObjectFactory (com.sun.identity.wsfederation.jaxb.entityconfig.ObjectFactory)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 JAXBContext (javax.xml.bind.JAXBContext)1 JAXBException (javax.xml.bind.JAXBException)1