use of com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement in project OpenAM by OpenRock.
the class WSFederationMetaManager method getSPSSOConfig.
/**
* Returns first service provider's SSO configuration in an entity under
* the realm.
*
* @param realm The realm under which the entity resides.
* @param federationId ID of the entity to be retrieved.
* @return <code>SPSSOConfigElement</code> for the entity or null if not
* found.
* @throws WSFederationMetaException if unable to retrieve the first service
* provider's SSO configuration.
*/
public SPSSOConfigElement getSPSSOConfig(String realm, String federationId) throws WSFederationMetaException {
FederationConfigElement eConfig = getEntityConfig(realm, federationId);
if (eConfig == null) {
return null;
}
List list = eConfig.getIDPSSOConfigOrSPSSOConfig();
for (Iterator iter = list.iterator(); iter.hasNext(); ) {
Object obj = iter.next();
if (obj instanceof SPSSOConfigElement) {
return (SPSSOConfigElement) obj;
}
}
return null;
}
use of com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement in project OpenAM by OpenRock.
the class WSFederationMetaManager method getIDPSSOConfig.
/**
* Returns first identity provider's SSO configuration in an entity under
* the realm.
*
* @param realm The realm under which the entity resides.
* @param federationId ID of the entity to be retrieved.
* @return <code>IDPSSOConfigElement</code> for the entity or null if not
* found.
* @throws WSFederationMetaException if unable to retrieve the first
* identity provider's SSO configuration.
*/
public IDPSSOConfigElement getIDPSSOConfig(String realm, String federationId) throws WSFederationMetaException {
FederationConfigElement eConfig = getEntityConfig(realm, federationId);
if (eConfig == null) {
return null;
}
List list = eConfig.getIDPSSOConfigOrSPSSOConfig();
for (Iterator iter = list.iterator(); iter.hasNext(); ) {
Object obj = iter.next();
if (obj instanceof IDPSSOConfigElement) {
return (IDPSSOConfigElement) obj;
}
}
return null;
}
use of com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement in project OpenAM by OpenRock.
the class CreateMetaDataModelImpl method createWSFedProvider.
/**
* Creates a WS Federation provider.
*
* @param realm Realm Name.
* @param entityId Entity Id.
* @param values Map of property name to values.
*
* @throws AMConsoleException if duplicate metaAliases provided or unable to create or import metadata.
* */
public void createWSFedProvider(String realm, String entityId, Map values) throws AMConsoleException {
try {
List<String> metaAliases = getFederationAlias(values, MetaTemplateParameters.P_WS_FED_ALIASES);
Set<String> duplicateCheck = new HashSet<String>(metaAliases);
if (duplicateCheck.size() < metaAliases.size()) {
throw new AMConsoleException(getLocalizedString("federation.create.provider.duplicate.metaAlias"));
}
WSFederationMetaManager metaManager = new WSFederationMetaManager();
metaManager.validateMetaAliasForNewEntity(realm, metaAliases);
String metadata = CreateWSFedMetaDataTemplate.createStandardMetaTemplate(entityId, values, requestURL);
String extendedData = CreateWSFedMetaDataTemplate.createExtendedMetaTemplate(entityId, values);
FederationElement elt = (FederationElement) WSFederationMetaUtils.convertStringToJAXB(metadata);
String federationID = elt.getFederationID();
if (federationID == null) {
federationID = WSFederationConstants.DEFAULT_FEDERATION_ID;
}
metaManager.createFederation(realm, elt);
FederationConfigElement cfg = (FederationConfigElement) WSFederationMetaUtils.convertStringToJAXB(extendedData);
metaManager.createEntityConfig(realm, cfg);
} catch (WSFederationMetaException ex) {
throw new AMConsoleException(ex.getMessage());
} catch (JAXBException ex) {
throw new AMConsoleException(ex.getMessage());
} catch (CertificateEncodingException ex) {
throw new AMConsoleException(ex.getMessage());
}
}
use of com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement in project OpenAM by OpenRock.
the class WSFedPropertiesModelImpl method setSPExtAttributeValues.
/**
* Saves the extended metadata attribute values for the SP.
*
* @param realm to which the entity belongs.
* @param fedId is the entity id.
* @param spExtvalues has the extended attribute value pairs of SP.
* @param location has the information whether remote or hosted.
* @throws AMConsoleException if saving of attribute value fails.
*/
public void setSPExtAttributeValues(String realm, String fedId, Map spExtvalues, String location) throws AMConsoleException {
try {
String role = EntityModel.SERVICE_PROVIDER;
//fed is the extended entity configuration object under the realm
WSFederationMetaManager metaManager = getWSFederationMetaManager();
FederationConfigElement fed = metaManager.getEntityConfig(realm, fedId);
if (fed == null) {
SPEX_DATA_MAP.put(TF_DISPNAME, Collections.EMPTY_SET);
createExtendedObject(realm, fedId, location, SERVICE_PROVIDER, SPEX_DATA_MAP);
fed = metaManager.getEntityConfig(realm, fedId);
}
SPSSOConfigElement spsso = getspsso(fed);
if (spsso != null) {
BaseConfigType baseConfig = (BaseConfigType) spsso;
updateBaseConfig(baseConfig, spExtvalues, role);
}
//saves the attributes by passing the new fed object
metaManager.setEntityConfig(realm, fed);
} catch (JAXBException e) {
debug.warning("WSFedPropertiesModelImpl.setSPExtAttributeValues", e);
throw new AMConsoleException(e.getMessage());
} catch (WSFederationMetaException e) {
debug.warning("WSFedPropertiesModelImpl.setSPExtAttributeValues", e);
throw new AMConsoleException(e.getMessage());
}
}
use of com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement 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