use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.
the class EntitiesModelImpl method createEntity.
/**
* Creates an entity.
*
* @param realmName Name of Realm.
* @param entityName Name of Entity.
* @param idType Type of Entity.
* @param values Map of attribute name to Set of attribute values.
* @throws AMConsoleException if entity cannot be created.
*/
public void createEntity(String realmName, String entityName, String idType, Map values) throws AMConsoleException {
if (entityName.trim().length() == 0) {
String msg = getLocalizedString("entities.missing.entityName");
String[] param = { getLocalizedString(idType) };
throw new AMConsoleException(MessageFormat.format(msg, (Object[]) param));
}
if (realmName == null) {
realmName = "/";
}
validateAttributes(values);
setAgentDefaultValues(values);
try {
String[] params = { entityName, idType, realmName };
logEvent("ATTEMPT_IDENTITY_CREATION", params);
AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), realmName);
beforeCreate(idType, entityName, values);
repo.createIdentity(IdUtils.getType(idType), entityName, values);
logEvent("IDENTITY_CREATED", params);
} catch (IdRepoException e) {
String strError = getErrorString(e);
String[] params = { entityName, idType, realmName, strError };
logEvent("IDM_EXCEPTION_IDENTITY_CREATION", params);
throw new AMConsoleException(strError);
} catch (SSOException e) {
String strError = getErrorString(e);
String[] params = { entityName, idType, realmName, strError };
logEvent("SSO_EXCEPTION_IDENTITY_CREATION", params);
throw new AMConsoleException(strError);
}
}
use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.
the class EntitiesModelImpl method deleteEntities.
/**
* Deletes entities.
*
* @param realmName Name of Realm.
* @param names Name of Entities to be deleted.
* @throws AMConsoleException if entity cannot be deleted.
*/
public void deleteEntities(String realmName, Set names) throws AMConsoleException {
if ((names != null) && !names.isEmpty()) {
String idNames = AMFormatUtils.toCommaSeparatedFormat(names);
String[] params = { realmName, idNames };
logEvent("ATTEMPT_DELETE_IDENTITY", params);
try {
AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), realmName);
repo.deleteIdentities(getAMIdentity(names));
logEvent("SUCCEED_DELETE_IDENTITY", params);
} catch (IdRepoException e) {
String[] paramsEx = { realmName, idNames, getErrorString(e) };
logEvent("IDM_EXCEPTION_DELETE_IDENTITY", paramsEx);
throw new AMConsoleException(getErrorString(e));
} catch (SSOException e) {
String[] paramsEx = { realmName, idNames, getErrorString(e) };
logEvent("SSO_EXCEPTION_DELETE_IDENTITY", paramsEx);
throw new AMConsoleException(getErrorString(e));
}
}
}
use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.
the class IdRepoUtils method createUser.
public static AMIdentity createUser(String realm, String id, Map<String, Set<String>> properties) throws SSOException, IdRepoException {
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
AMIdentityRepository amir = new AMIdentityRepository(adminToken, realm);
Map<String, Set<String>> attrValues = new HashMap<String, Set<String>>();
Set<String> set = new HashSet<String>();
set.add(id);
attrValues.put("givenname", set);
attrValues.put("sn", set);
attrValues.put("cn", set);
attrValues.put("userpassword", set);
if (properties != null) {
attrValues.putAll(properties);
}
return amir.createIdentity(IdType.USER, id, attrValues);
}
use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.
the class MetaDataTest method deleteUser.
private void deleteUser(SSOToken adminToken) throws IdRepoException, SSOException {
AMIdentityRepository amir = new AMIdentityRepository(adminToken, "/");
Set<AMIdentity> identities = new HashSet<AMIdentity>();
identities.add(testUser);
amir.deleteIdentities(identities);
}
use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.
the class PolicyEvaluatorTest method cleanup.
@AfterClass
public void cleanup() throws PolicyException, SSOException, IdRepoException {
try {
lc.logout();
} catch (Exception e) {
//ignore
}
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
PolicyManager pm = new PolicyManager(adminToken, "/");
pm.removePolicy(POLICY_NAME1);
pm.removePolicy(POLICY_NAME2);
pm.removePolicy(POLICY_NAME3);
pm.removePolicy(POLICY_NAME4);
AMIdentityRepository amir = new AMIdentityRepository(adminToken, "/");
Set<AMIdentity> identities = new HashSet<AMIdentity>();
identities.add(testGroup);
identities.add(testUser);
amir.deleteIdentities(identities);
}
Aggregations