Search in sources :

Example 46 with IdSearchControl

use of com.sun.identity.idm.IdSearchControl in project OpenAM by OpenRock.

the class OpenAMScopeValidator method getTimestamps.

private AMHashMap getTimestamps(String username, String realm, String modifyTimestamp, String createTimestamp) throws IdRepoException, SSOException {
    final SSOToken token = AccessController.doPrivileged(AdminTokenAction.getInstance());
    final AMIdentityRepository amIdRepo = new AMIdentityRepository(token, realm);
    final IdSearchControl searchConfig = new IdSearchControl();
    searchConfig.setReturnAttributes(new HashSet<String>(Arrays.asList(modifyTimestamp, createTimestamp)));
    searchConfig.setMaxResults(0);
    final IdSearchResults searchResults = amIdRepo.searchIdentities(IdType.USER, username, searchConfig);
    final Iterator searchResultsItr = searchResults.getResultAttributes().values().iterator();
    if (searchResultsItr.hasNext()) {
        return (AMHashMap) searchResultsItr.next();
    } else {
        logger.warning("Error retrieving timestamps from datastore");
        throw new IdRepoException();
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) AMHashMap(com.iplanet.am.sdk.AMHashMap) IdSearchResults(com.sun.identity.idm.IdSearchResults) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) IdSearchControl(com.sun.identity.idm.IdSearchControl) Iterator(java.util.Iterator) IdRepoException(com.sun.identity.idm.IdRepoException)

Example 47 with IdSearchControl

use of com.sun.identity.idm.IdSearchControl in project OpenAM by OpenRock.

the class IdRepoTest method deleteIdentity.

@Parameters({ "realm", "uid" })
@AfterTest(groups = { "cli-idrepo", "delete-identities" })
public void deleteIdentity(String realm, String uid) throws CLIException, IdRepoException, SSOException {
    String[] param = { realm, uid };
    entering("deleteRealm", param);
    String[] args = { "delete-identities", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME, realm, CLIConstants.PREFIX_ARGUMENT_LONG + IdentityCommand.ARGUMENT_ID_TYPE, "User", CLIConstants.PREFIX_ARGUMENT_LONG + IdentityCommand.ARGUMENT_ID_NAMES, uid };
    SSOToken adminSSOToken = getAdminSSOToken();
    CLIRequest req = new CLIRequest(null, args, adminSSOToken);
    cmdManager.addToRequestQueue(req);
    cmdManager.serviceRequestQueue();
    AMIdentityRepository amir = new AMIdentityRepository(adminSSOToken, realm);
    IdSearchControl isCtl = new IdSearchControl();
    IdSearchResults isr = amir.searchIdentities(IdType.USER, uid, isCtl);
    Set results = isr.getSearchResults();
    assert (results.isEmpty());
    exiting("deleteIdentities");
}
Also used : SSOToken(com.iplanet.sso.SSOToken) HashSet(java.util.HashSet) Set(java.util.Set) IdSearchResults(com.sun.identity.idm.IdSearchResults) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) IdSearchControl(com.sun.identity.idm.IdSearchControl) CLIRequest(com.sun.identity.cli.CLIRequest) Parameters(org.testng.annotations.Parameters) AfterTest(org.testng.annotations.AfterTest)

Example 48 with IdSearchControl

use of com.sun.identity.idm.IdSearchControl in project OpenAM by OpenRock.

the class UmaPolicyApplicationListener method getIdentityAttributes.

@SuppressWarnings("unchecked")
private Map<String, Set<String>> getIdentityAttributes(AMIdentity identity) throws IdRepoException, SSOException {
    IdSearchControl searchControl = new IdSearchControl();
    searchControl.setAllReturnAttributes(true);
    searchControl.setMaxResults(0);
    SSOToken adminToken = AccessController.doPrivileged(AdminTokenAction.getInstance());
    IdSearchResults searchResults = idRepoFactory.create(identity.getRealm(), adminToken).searchIdentities(IdType.AGENT, identity.getName(), searchControl);
    if (searchResults.getSearchResults().size() != 1) {
        throw new IdRepoException("UmaPolicyApplicationListener.getIdentityAttributes : More than one agent found");
    }
    return new HashMap<String, Set<String>>((Map) searchResults.getResultAttributes().values().iterator().next());
}
Also used : SSOToken(com.iplanet.sso.SSOToken) IdSearchResults(com.sun.identity.idm.IdSearchResults) HashMap(java.util.HashMap) IdSearchControl(com.sun.identity.idm.IdSearchControl) IdRepoException(com.sun.identity.idm.IdRepoException)

Aggregations

IdSearchControl (com.sun.identity.idm.IdSearchControl)48 IdSearchResults (com.sun.identity.idm.IdSearchResults)43 IdRepoException (com.sun.identity.idm.IdRepoException)41 SSOException (com.iplanet.sso.SSOException)36 AMIdentityRepository (com.sun.identity.idm.AMIdentityRepository)36 AMIdentity (com.sun.identity.idm.AMIdentity)35 Set (java.util.Set)25 HashSet (java.util.HashSet)20 SSOToken (com.iplanet.sso.SSOToken)15 Iterator (java.util.Iterator)14 IdType (com.sun.identity.idm.IdType)9 HashMap (java.util.HashMap)8 Map (java.util.Map)6 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)4 UnauthorizedClientException (org.forgerock.oauth2.core.exceptions.UnauthorizedClientException)4 CLIException (com.sun.identity.cli.CLIException)3 IOutput (com.sun.identity.cli.IOutput)3 AuthLoginException (com.sun.identity.authentication.spi.AuthLoginException)2 DelegationException (com.sun.identity.delegation.DelegationException)2 TreeSet (java.util.TreeSet)2