use of com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement in project OpenAM by OpenRock.
the class IDFFCOTUtils method removeFromEntityConfig.
/**
* Removes the circle trust name passed from the <code>cotlist</code>
* list attribute in the Entity Config. The Service Provider and Identity
* Provider Entity Configuration are updated.
*
* @param realm realm the entity resides in.
* @param cotName the circle of trust name to be removed.
* @param entityID the entity identifier of the provider.
* @throws IDFFMetaException if there is an error updating the entity
* config.
* @throws JAXBException if there is an error updating the entity config.
*/
public void removeFromEntityConfig(String realm, String cotName, String entityID) throws IDFFMetaException, JAXBException {
String classMethod = "IDFFCOTUtils.removeFromEntityConfig: ";
IDFFMetaManager idffMetaMgr = new IDFFMetaManager(callerSession);
// 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) {
List spConfigList = entityConfig.getSPDescriptorConfig();
List idpConfigList = entityConfig.getIDPDescriptorConfig();
removeCOTNameFromConfig(realm, spConfigList, cotName, entityConfig, idffMetaMgr);
removeCOTNameFromConfig(realm, idpConfigList, cotName, entityConfig, idffMetaMgr);
BaseConfigType affiConfig = entityConfig.getAffiliationDescriptorConfig();
if (affiConfig != null) {
List affiConfigList = new ArrayList();
affiConfigList.add(affiConfig);
removeCOTNameFromConfig(realm, affiConfigList, cotName, entityConfig, idffMetaMgr);
}
}
}
use of com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement in project OpenAM by OpenRock.
the class IDFFMetaCache method getEntityDescriptor.
/**
* Returns the Entity Descriptor representing the standard metadata under
* the realm from cache.
*
* @param realm The realm under which the entity resides.
* @param entityID the entity descriptor identifier.
* @return <code>EntityDescriptorElement</code> for the entity or null
* if not found.
*/
public static EntityDescriptorElement getEntityDescriptor(String realm, String entityID) {
String classMethod = "IDFFMetaCache:getEntityDescriptor";
String cacheKey = buildCacheKey(realm, entityID);
EntityDescriptorElement entityDescriptor = (EntityDescriptorElement) entityDescriptorCache.get(cacheKey);
if (debug.messageEnabled()) {
if (entityDescriptor != null) {
debug.message(classMethod + " Entity Descriptor found for : " + cacheKey);
} else {
debug.message(classMethod + "EntityDescriptor not found for :" + cacheKey);
}
}
return entityDescriptor;
}
use of com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement in project OpenAM by OpenRock.
the class IDFFMetaManager method createEntityDescriptor.
/**
* Creates the standard metadata entity descriptor.
* The metadata is created under the realm.
*
* @param realm The realm under which the entity resides.
* @param entityDescriptor The standard entity descriptor object to
* be created.
* @throws IDFFMetaException if unable to create the entity descriptor.
*/
public void createEntityDescriptor(String realm, EntityDescriptorElement entityDescriptor) throws IDFFMetaException {
String classMethod = "IDFFMetaManager.createEntityDescriptor:";
String entityId = null;
if (entityDescriptor == null) {
LogUtil.error(Level.INFO, LogUtil.NULL_ENTITY_DESCRIPTOR, null);
throw new IDFFMetaException("nullEntityDescriptor", null);
} else {
entityId = entityDescriptor.getProviderID();
if (entityId == null) {
debug.error(classMethod + "Entity ID is null");
LogUtil.error(Level.INFO, LogUtil.NULL_ENTITY_ID, null);
throw new IDFFMetaException("nullEntityID", null);
}
}
if ((realm == null) || (realm.length() == 0)) {
realm = ROOT_REALM;
}
String[] args = { entityId, realm };
EntityDescriptorElement descriptor = getEntityDescriptor(realm, entityId);
if (descriptor != null) {
List idps = descriptor.getIDPDescriptor();
boolean hasIDP = (idps != null) && !idps.isEmpty();
List sps = descriptor.getSPDescriptor();
boolean hasSP = (sps != null) && !sps.isEmpty();
List newIDPs = entityDescriptor.getIDPDescriptor();
List newSPs = entityDescriptor.getSPDescriptor();
if ((newIDPs != null) && !newIDPs.isEmpty() && hasIDP) {
LogUtil.error(Level.INFO, LogUtil.SET_ENTITY_FAILED, args);
throw new IDFFMetaException("idpAlreadyExisted", args);
}
if ((newSPs != null) && !newSPs.isEmpty() && hasSP) {
LogUtil.error(Level.INFO, LogUtil.SET_ENTITY_FAILED, args);
throw new IDFFMetaException("spAlreadyExisted", args);
}
idps.addAll(newIDPs);
sps.addAll(newSPs);
setEntityDescriptor(realm, descriptor);
} else {
try {
Map attrs = IDFFMetaUtils.convertJAXBToAttrMap(IDFF_METADATA_ATTR, entityDescriptor);
if (debug.messageEnabled()) {
debug.message(classMethod + attrs);
}
idffMetaConfigInstance.createConfiguration(realm, entityId, attrs);
LogUtil.access(Level.INFO, LogUtil.CREATE_ENTITY_SUCCEEDED, args);
} catch (ConfigurationException ce) {
debug.error("Cannot create entity descriptor", ce);
LogUtil.error(Level.INFO, LogUtil.CREATE_ENTITY_FAILED, args);
throw new IDFFMetaException(ce);
} catch (UnsupportedOperationException uoe) {
debug.error("Creating EntityDescriptor : Unsupported operation");
LogUtil.error(Level.INFO, LogUtil.UNSUPPORTED_OPERATION, null);
throw new IDFFMetaException("unsupportedOperation", null);
} catch (JAXBException jaxbe) {
debug.error(classMethod, jaxbe);
LogUtil.error(Level.INFO, LogUtil.INVALID_ENTITY_DESCRIPTOR, args);
throw new IDFFMetaException("invalidEntityDescriptor", args);
}
}
}
use of com.sun.identity.liberty.ws.meta.jaxb.EntityDescriptorElement 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));
}
}
Aggregations