Search in sources :

Example 96 with IdRepoException

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);
}
Also used : SSOToken(com.iplanet.sso.SSOToken) AMIdentity(com.sun.identity.idm.AMIdentity) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) HashSet(java.util.HashSet) AfterClass(org.testng.annotations.AfterClass)

Example 97 with IdRepoException

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;
    }
}
Also used : ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) AMIdentity(com.sun.identity.idm.AMIdentity) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager) SMSException(com.sun.identity.sm.SMSException) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException)

Example 98 with IdRepoException

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);
}
Also used : CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) Set(java.util.Set) IdRepoException(com.sun.identity.idm.IdRepoException) SMSJAXRPCObject(com.sun.identity.sm.jaxrpc.SMSJAXRPCObject) IdRepoException(com.sun.identity.idm.IdRepoException) SMSException(com.sun.identity.sm.SMSException) RemoteException(java.rmi.RemoteException) SSOException(com.iplanet.sso.SSOException)

Example 99 with IdRepoException

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;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) HashSet(java.util.HashSet)

Example 100 with IdRepoException

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;
}
Also used : SMSJAXRPCObject(com.sun.identity.sm.jaxrpc.SMSJAXRPCObject) AMHashMap(com.iplanet.am.sdk.AMHashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Map(java.util.Map) IdRepoException(com.sun.identity.idm.IdRepoException) SMSException(com.sun.identity.sm.SMSException) RemoteException(java.rmi.RemoteException) SSOException(com.iplanet.sso.SSOException)

Aggregations

IdRepoException (com.sun.identity.idm.IdRepoException)403 SSOException (com.iplanet.sso.SSOException)275 Set (java.util.Set)224 AMIdentity (com.sun.identity.idm.AMIdentity)221 HashSet (java.util.HashSet)183 Map (java.util.Map)121 Iterator (java.util.Iterator)118 SSOToken (com.iplanet.sso.SSOToken)112 HashMap (java.util.HashMap)110 SMSException (com.sun.identity.sm.SMSException)103 AMIdentityRepository (com.sun.identity.idm.AMIdentityRepository)96 CaseInsensitiveHashSet (com.sun.identity.common.CaseInsensitiveHashSet)67 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)58 IdType (com.sun.identity.idm.IdType)57 CaseInsensitiveHashMap (com.sun.identity.common.CaseInsensitiveHashMap)51 CLIException (com.sun.identity.cli.CLIException)48 IOutput (com.sun.identity.cli.IOutput)45 IdSearchResults (com.sun.identity.idm.IdSearchResults)44 IdSearchControl (com.sun.identity.idm.IdSearchControl)39 IdRepoUnsupportedOpException (com.sun.identity.idm.IdRepoUnsupportedOpException)35