Search in sources :

Example 21 with AMIdentityRepository

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

the class IdRepoSample method doCurrentRealm.

/*
     *  for the current Realm, get:
     *    1. its AMIdentityRepository object
     *    2. its AMIdentity (via getRealmIdentity())
     *    3. realm for the AMIdentity (via getRealm())
     *    4. name for the AMIdentity (via getName())
     *    5. its subrealms (via
     *         OrganizationConfigManager.getSubOrganizationNames())
     */
private void doCurrentRealm() {
    String currentAMIdName = null;
    String currentRealmAMIdName = null;
    try {
        idRepo = new AMIdentityRepository(ssoToken, currentRealm);
        AMIdentity currentRealmAMId = idRepo.getRealmIdentity();
        currentRealmAMIdName = currentRealmAMId.getRealm();
        currentAMIdName = currentRealmAMId.getName();
    } catch (IdRepoException ire) {
        System.err.println("doCurrentRealm:IdRepoException getting AMIdentityRepository" + " object for '" + currentRealm + "': " + ire.getMessage());
        System.exit(7);
    } catch (SSOException sse) {
        System.err.println("doCurrentRealm: SSOException getting AMIdentityRepository" + " object for '" + currentRealm + "': " + sse.getMessage());
        System.exit(8);
    }
    System.out.println("AMIdentity realm name for realm '" + currentRealm + "' is '" + currentRealmAMIdName + "'");
    System.out.println("getting subrealms");
    try {
        currentSubRealms = (idRepo.searchIdentities(IdType.REALM, "*", new IdSearchControl())).getSearchResults();
    } catch (SSOException ssoe) {
        System.err.println("doCurrentRealm: SSOException getting subrealms for '" + currentRealm + "': " + ssoe.getMessage());
    } catch (IdRepoException ire) {
        System.err.println("doCurrentRealm: IdRepoException getting subrealms for '" + currentRealm + "': " + ire.getMessage());
    }
    sampleUtils.printResultsRealm("Realm '" + currentRealm + "'", currentSubRealms, "subrealms");
}
Also used : AMIdentity(com.sun.identity.idm.AMIdentity) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) IdRepoException(com.sun.identity.idm.IdRepoException) IdSearchControl(com.sun.identity.idm.IdSearchControl) SSOException(com.iplanet.sso.SSOException)

Example 22 with AMIdentityRepository

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

the class ApplicationPrivilegeCLITest method cleanup.

@AfterClass
public void cleanup() throws Exception {
    AMIdentityRepository amir = new AMIdentityRepository(adminToken, "/");
    Set<AMIdentity> identities = new HashSet<AMIdentity>();
    identities.add(user1);
    identities.add(user2);
    amir.deleteIdentities(identities);
}
Also used : AMIdentity(com.sun.identity.idm.AMIdentity) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) HashSet(java.util.HashSet) AfterClass(org.testng.annotations.AfterClass)

Example 23 with AMIdentityRepository

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

the class IdRepoTest method deleteDummyGroup.

private void deleteDummyGroup(String realm) throws IdRepoException, SSOException {
    SSOToken adminSSOToken = getAdminSSOToken();
    AMIdentityRepository amir = new AMIdentityRepository(adminSSOToken, realm);
    AMIdentity amid = new AMIdentity(adminSSOToken, DUMMY_GROUP, IdType.GROUP, realm, null);
    Set<AMIdentity> set = new HashSet<AMIdentity>(2);
    set.add(amid);
    amir.deleteIdentities(set);
}
Also used : SSOToken(com.iplanet.sso.SSOToken) AMIdentity(com.sun.identity.idm.AMIdentity) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) HashSet(java.util.HashSet)

Example 24 with AMIdentityRepository

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

the class PrivilegeUtilsTest method deleteUsers.

private void deleteUsers(SSOToken adminToken, String... names) throws IdRepoException, SSOException {
    AMIdentityRepository amir = new AMIdentityRepository(adminToken, "/");
    Set identities = new HashSet();
    for (String name : names) {
        String uuid = "id=" + name + ",ou=user," + ServiceManager.getBaseDN();
        identities.add(IdUtils.getIdentity(adminToken, uuid));
    }
    amir.deleteIdentities(identities);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) HashSet(java.util.HashSet)

Example 25 with AMIdentityRepository

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

the class ProxyPETest 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);
    AMIdentityRepository amir = new AMIdentityRepository(adminToken, "/");
    Set<AMIdentity> identities = new HashSet<AMIdentity>();
    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)

Aggregations

AMIdentityRepository (com.sun.identity.idm.AMIdentityRepository)138 IdRepoException (com.sun.identity.idm.IdRepoException)103 SSOException (com.iplanet.sso.SSOException)94 AMIdentity (com.sun.identity.idm.AMIdentity)85 Set (java.util.Set)82 HashSet (java.util.HashSet)58 SSOToken (com.iplanet.sso.SSOToken)56 IdSearchControl (com.sun.identity.idm.IdSearchControl)36 IdSearchResults (com.sun.identity.idm.IdSearchResults)36 Iterator (java.util.Iterator)32 CLIException (com.sun.identity.cli.CLIException)29 HashMap (java.util.HashMap)29 IdType (com.sun.identity.idm.IdType)28 Map (java.util.Map)27 IOutput (com.sun.identity.cli.IOutput)26 SMSException (com.sun.identity.sm.SMSException)24 OrganizationConfigManager (com.sun.identity.sm.OrganizationConfigManager)20 List (java.util.List)13 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)12 Callback (javax.security.auth.callback.Callback)6