use of com.sun.identity.wsfederation.meta.WSFederationMetaManager 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.meta.WSFederationMetaManager in project OpenAM by OpenRock.
the class EntityModelImpl method getWSFedEntities.
/**
* Returns a map of all the wsfed entities including data about
* what realm, the roles, and location of each entity.
*
* @throws AMConsoleException if unable to retrieve the WSFED entities.
*/
public Map getWSFedEntities() throws AMConsoleException {
Map wsfedMap = new HashMap();
for (Iterator i = realms.iterator(); i.hasNext(); ) {
String realm = (String) i.next();
try {
WSFederationMetaManager metaManager = new WSFederationMetaManager();
Set wsfedEntities = metaManager.getAllEntities(realm);
List hosted = metaManager.getAllHostedEntities(realm);
for (Iterator j = wsfedEntities.iterator(); j.hasNext(); ) {
String entity = (String) j.next();
Map data = new HashMap(8);
data.put(REALM, realm);
data.put(PROTOCOL, WSFED);
data.put(ROLE, listToString(getWSFedRoles(entity, realm)));
if ((hosted != null) && (hosted.contains(entity))) {
data.put(LOCATION, HOSTED);
} else {
data.put(LOCATION, REMOTE);
}
String entityNamewithRealm = entity + "," + realm;
wsfedMap.put(entityNamewithRealm, (HashMap) data);
}
} catch (WSFederationMetaException e) {
debug.error("EntityModel.getWSFedEntities", e);
throw new AMConsoleException(e.getMessage());
}
}
return (wsfedMap != null) ? wsfedMap : Collections.EMPTY_MAP;
}
use of com.sun.identity.wsfederation.meta.WSFederationMetaManager in project OpenAM by OpenRock.
the class EntityModelImpl method getWSFedRoles.
public List getWSFedRoles(String entity, String realm) {
List roles = new ArrayList(4);
boolean isSP = true;
int cnt = 0;
try {
WSFederationMetaManager metaManager = new WSFederationMetaManager();
if (metaManager.getIDPSSOConfig(realm, entity) != null) {
roles.add(IDENTITY_PROVIDER);
}
if (metaManager.getSPSSOConfig(realm, entity) != null) {
roles.add(SERVICE_PROVIDER);
}
//to handle dual roles specifically for WSFED
if (roles.isEmpty()) {
FederationElement fedElem = metaManager.getEntityDescriptor(realm, entity);
if (fedElem != null) {
for (Iterator iter = fedElem.getAny().iterator(); iter.hasNext(); ) {
Object o = iter.next();
if (o instanceof UriNamedClaimTypesOfferedElement) {
roles.add(IDENTITY_PROVIDER);
isSP = false;
} else if (o instanceof TokenIssuerEndpointElement) {
cnt++;
}
}
if ((isSP) || (cnt > 1)) {
roles.add(SERVICE_PROVIDER);
}
}
}
} catch (WSFederationMetaException e) {
debug.warning("EntityModelImpl.getWSFedRoles", e);
}
return (roles != null) ? roles : Collections.EMPTY_LIST;
}
use of com.sun.identity.wsfederation.meta.WSFederationMetaManager in project OpenAM by OpenRock.
the class WSFedPropertiesModelImpl method getIdentityProviderAttributes.
/**
* Returns a <code>Map</code> with identity provider attributes and values.
*
* @param realm to which the entity belongs.
* @param fedId is the Federation Id otherwise known as the entity id.
* @return attribute values of IDP based on realm and fedId passed.
* @throws AMConsoleException if unable to retreive the Identity Provider
* attrubutes based on the realm and fedId passed.
*/
public Map getIdentityProviderAttributes(String realm, String fedId) throws AMConsoleException {
Map IDPAttributes = null;
try {
WSFederationMetaManager metaManager = getWSFederationMetaManager();
IDPSSOConfigElement idpconfig = metaManager.getIDPSSOConfig(realm, fedId);
if (idpconfig != null) {
IDPAttributes = WSFederationMetaUtils.getAttributes(idpconfig);
}
} catch (WSFederationMetaException e) {
debug.warning("WSFedPropertiesModelImpl.getIdentityProviderAttributes", e);
throw new AMConsoleException(e.getMessage());
}
return (IDPAttributes != null) ? IDPAttributes : Collections.EMPTY_MAP;
}
use of com.sun.identity.wsfederation.meta.WSFederationMetaManager 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());
}
}
Aggregations