use of com.sun.identity.idm.IdRepoException 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);
}
use of com.sun.identity.idm.IdRepoException in project OpenAM by OpenRock.
the class AgentIdentityImpl method getAgentServiceConfig.
private ServiceConfig getAgentServiceConfig(SSOToken token) {
AMIdentity identity;
try {
identity = IdUtils.getIdentity(token);
} catch (IdRepoException | SSOException e) {
debug.error("Exception while obtaining identity corresponding to SSOToken: {}", e, e);
return null;
}
// before instantiating a ServiceConfigManager.
if (!IdType.AGENT.equals(identity.getType())) {
debug.message("Not an agent");
return null;
}
ServiceConfig agentService;
try {
agentService = new ServiceConfigManager(AGENT_SERVICE_NAME, getAdminToken()).getOrganizationConfig(identity.getRealm(), null);
} catch (Exception e) {
debug.error("Exception while obtaining base AgentService ServiceConfig instance: {}", e, e);
return null;
}
try {
return agentService.getSubConfig(identity.getName());
} catch (SSOException | SMSException e) {
// Should only enter this block if the return from getAdminToken is an invalid token
// or if an error occurs accessing LDAP.
debug.error("Exception while obtaining AgentService SubConfig {}: {}", identity.getName(), e, e);
return null;
}
}
use of com.sun.identity.idm.IdRepoException in project OpenAM by OpenRock.
the class IdRemoteServicesImpl method getFullyQualifiedNames.
public Set getFullyQualifiedNames(SSOToken token, IdType type, String name, String org) throws IdRepoException, SSOException {
Set answer = null;
try {
Object[] objs = { getTokenString(token), type.getName(), name, org };
Set set = (Set) client.send(client.encodeMessage("getFullyQualifiedNames_idrepo", objs), sessionCookies.getLBCookie(token.getTokenID().toString()), null);
if (set != null) {
// Convert to CaseInsensitiveHashSet
answer = new CaseInsensitiveHashSet(set);
}
} catch (Exception ex) {
if (DEBUG.warningEnabled()) {
DEBUG.warning("IdRemoteServicesImpl.getFullyQualifiedNames_idrepo: " + "caught exception=", ex);
}
if (ex instanceof IdRepoException) {
throw ((IdRepoException) ex);
}
throw new IdRepoException(AMSDKBundle.getString("1000"), "1000");
}
return (answer);
}
use of com.sun.identity.idm.IdRepoException in project OpenAM by OpenRock.
the class IdRepoAttributeValidatorManager method getIdRepoAttributeValidator.
/**
* Returns an instance of <code>IdRepoAttributeValidator</code> for
* specified realm.
* @param realm the realm
* @return an instance of <code>IdRepoAttributeValidator</code>
* @throws IdRepoException if there are repository related error conditions.
*/
public IdRepoAttributeValidator getIdRepoAttributeValidator(String realm) throws IdRepoException {
IdRepoAttributeValidator validator = validatorCache.get(realm);
if (validator != null) {
return validator;
}
Map<String, Set<String>> configParams = new HashMap();
synchronized (validatorCache) {
try {
ServiceConfig orgConfig = idRepoServiceConfigManager.getOrganizationConfig(realm, null);
Map<String, Set<String>> attrMap = orgConfig.getAttributesForRead();
Set<String> attrValues = attrMap.get(ATTR_IDREPO_ATTRIBUTE_VALIDATOR);
String className = null;
for (String attrValue : attrValues) {
int index = attrValue.indexOf("=");
if (index != -1) {
String name = attrValue.substring(0, index).trim();
String value = attrValue.substring(index + 1).trim();
if (name.equals("class")) {
className = value;
} else {
Set<String> values = configParams.get(name);
if (values == null) {
values = new HashSet();
configParams.put(name, values);
}
values.add(value);
}
}
}
Class validatorClass = Class.forName(className);
validator = (IdRepoAttributeValidator) validatorClass.newInstance();
} catch (Exception ex) {
if (debug.warningEnabled()) {
debug.warning("IdRepoAttributeValidatorManager." + "initializeListeners:", ex);
}
}
if (validator == null) {
validator = new IdRepoAttributeValidatorImpl();
}
validator.initialize(configParams);
}
return validator;
}
use of com.sun.identity.idm.IdRepoException in project OpenAM by OpenRock.
the class IdRemoteServicesImpl method getServiceAttributes.
public Map getServiceAttributes(SSOToken token, IdType type, String name, String serviceName, Set attrNames, String amOrgName, String amsdkDN) throws IdRepoException, SSOException {
Map resultMap = null;
try {
if (DEBUG.messageEnabled()) {
DEBUG.message("IdRemoteServicesImpl.getServiceAttributes type=" + type + "; name=" + name + "; serviceName=" + serviceName + "; attrNames=" + attrNames + "; amOrgName=" + amOrgName + "; amsdkDN=" + amsdkDN);
}
Object[] objs = { getTokenString(token), type.getName(), name, serviceName, attrNames, amOrgName, amsdkDN };
resultMap = ((Map) client.send(client.encodeMessage("getServiceAttributes_idrepo", objs), sessionCookies.getLBCookie(token.getTokenID().toString()), null));
} catch (Exception ex) {
processException(ex);
}
return resultMap;
}
Aggregations