use of com.sun.identity.wsfederation.jaxb.entityconfig.ObjectFactory 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;
}
use of com.sun.identity.wsfederation.jaxb.entityconfig.ObjectFactory in project OpenAM by OpenRock.
the class WSFederationMetaSecurityUtils method setExtendedAttributeValue.
private static void setExtendedAttributeValue(BaseConfigType config, String attrName, Set attrVal) throws WSFederationMetaException {
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 WSFederationMetaException(e);
}
}
use of com.sun.identity.wsfederation.jaxb.entityconfig.ObjectFactory 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));
}
}
use of com.sun.identity.wsfederation.jaxb.entityconfig.ObjectFactory in project OpenAM by OpenRock.
the class WSFederationCOTUtils method updateEntityConfig.
/**
* Updates the entity config to add the circle of trust name to the
* <code>cotlist</code> attribute. The Service Provider and Identity
* Provider Configuration are updated.
*
* @param realm the realm name where the entity configuration is.
* @param name the circle of trust name.
* @param entityId the name of the Entity identifier.
* @throws WSFederationMetaException 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 name, String entityId) throws WSFederationMetaException, JAXBException {
String classMethod = "WSFederationCOTUtils.updateEntityConfig: ";
WSFederationMetaManager metaManager = null;
if (callerSession != null) {
metaManager = new WSFederationMetaManager(callerSession);
} else {
metaManager = new WSFederationMetaManager();
}
ObjectFactory objFactory = new ObjectFactory();
// Check whether the entity id existed in the DS
FederationElement edes = metaManager.getEntityDescriptor(realm, entityId);
if (edes == null) {
debug.error(classMethod + "No such entity: " + entityId);
String[] data = { realm, entityId };
throw new WSFederationMetaException("entityid_invalid", data);
}
FederationConfigElement eConfig = metaManager.getEntityConfig(realm, entityId);
if (eConfig == null) {
BaseConfigType bctype = null;
AttributeType atype = objFactory.createAttributeType();
atype.setName(SAML2Constants.COT_LIST);
atype.getValue().add(name);
// add to eConfig
FederationConfigElement ele = objFactory.createFederationConfigElement();
ele.setFederationID(entityId);
ele.setHosted(false);
List ll = ele.getIDPSSOConfigOrSPSSOConfig();
// IdP will have UriNamedClaimTypesOffered
if (metaManager.getUriNamedClaimTypesOffered(edes) != null) {
bctype = objFactory.createIDPSSOConfigElement();
bctype.getAttribute().add(atype);
ll.add(bctype);
} else {
bctype = objFactory.createSPSSOConfigElement();
bctype.getAttribute().add(atype);
ll.add(bctype);
}
metaManager.setEntityConfig(realm, ele);
} else {
List elist = eConfig.getIDPSSOConfigOrSPSSOConfig();
for (Iterator iter = elist.iterator(); iter.hasNext(); ) {
BaseConfigType bConfig = (BaseConfigType) iter.next();
List list = bConfig.getAttribute();
boolean foundCOT = false;
for (Iterator iter2 = list.iterator(); iter2.hasNext(); ) {
AttributeType avp = (AttributeType) iter2.next();
if (avp.getName().trim().equalsIgnoreCase(SAML2Constants.COT_LIST)) {
foundCOT = true;
List avpl = avp.getValue();
if (avpl.isEmpty() || !containsValue(avpl, name)) {
avpl.add(name);
metaManager.setEntityConfig(realm, eConfig);
break;
}
}
}
// no cot_list in the original entity config
if (!foundCOT) {
AttributeType atype = objFactory.createAttributeType();
atype.setName(SAML2Constants.COT_LIST);
atype.getValue().add(name);
list.add(atype);
metaManager.setEntityConfig(realm, eConfig);
}
}
}
}
Aggregations