Search in sources :

Example 31 with AMIdentity

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

the class IdentityServicesImpl method setMembers.

private void setMembers(AMIdentityRepository repo, AMIdentity amIdentity, Set<String> members, IdType idType) throws IdRepoException, SSOException, ObjectNotFound, ForbiddenException {
    Set<String> membershipsToAdd = members;
    Set<String> membershipsToRemove = null;
    Set<String> currentMembers = getMemberNames(amIdentity, idType);
    if ((currentMembers != null) && (currentMembers.size() > 0)) {
        membershipsToRemove = removeAllIgnoreCase(currentMembers, members);
        membershipsToAdd = removeAllIgnoreCase(members, currentMembers);
    }
    if (membershipsToRemove != null) {
        for (String memberName : membershipsToRemove) {
            AMIdentity identity = fetchAMIdentity(repo, idType, memberName, false);
            if (identity != null) {
                removeMember(repo, amIdentity, identity);
            }
        }
    }
    if (membershipsToAdd != null) {
        for (String memberName : membershipsToAdd) {
            AMIdentity identity = fetchAMIdentity(repo, idType, memberName, false);
            if (identity != null) {
                addMember(repo, amIdentity, identity);
            }
        }
    }
}
Also used : AMIdentity(com.sun.identity.idm.AMIdentity)

Example 32 with AMIdentity

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

the class IdentityServicesImpl method setMemberships.

private void setMemberships(AMIdentityRepository repo, AMIdentity amIdentity, Set<String> memberships, IdType idType) throws IdRepoException, SSOException, ObjectNotFound, ForbiddenException {
    Set<String> membershipsToAdd = memberships;
    Set<String> membershipsToRemove = null;
    Set<String> currentMemberships = getMembershipNames(amIdentity, idType);
    if (currentMemberships != null && !currentMemberships.isEmpty()) {
        membershipsToRemove = removeAllIgnoreCase(currentMemberships, memberships);
        membershipsToAdd = removeAllIgnoreCase(memberships, currentMemberships);
    }
    if (membershipsToRemove != null) {
        for (String idName : membershipsToRemove) {
            AMIdentity container = fetchAMIdentity(repo, idType, idName, false);
            removeMember(repo, container, amIdentity);
        }
    }
    if (membershipsToAdd != null) {
        for (String idName : membershipsToAdd) {
            AMIdentity container = fetchAMIdentity(repo, idType, idName, false);
            addMember(repo, container, amIdentity);
        }
    }
}
Also used : AMIdentity(com.sun.identity.idm.AMIdentity)

Example 33 with AMIdentity

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

the class DelegationPrivilegeIdRepoAccessTest method cleanup.

@AfterTest
public void cleanup() throws Exception {
    Set<AMIdentity> identities = new HashSet<AMIdentity>();
    identities.add(delegatedUser);
    identities.add(delegatedUser1);
    IdRepoUtils.deleteIdentities(SUB_REALM, identities);
    ApplicationManager.deleteApplication(SubjectUtils.createSuperAdminSubject(), SUB_REALM, APPLICATION_NAME);
    OrganizationConfigManager orgMgr = new OrganizationConfigManager(adminToken, "/");
    orgMgr.deleteSubOrganization(SUB_REALM, true);
}
Also used : AMIdentity(com.sun.identity.idm.AMIdentity) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) HashSet(java.util.HashSet) AfterTest(org.testng.annotations.AfterTest)

Example 34 with AMIdentity

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

the class SubRealmGroupTest method removeOrganization.

private void removeOrganization() throws Exception {
    SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
    Set<AMIdentity> identities = new HashSet<AMIdentity>();
    identities.add(user1);
    identities.add(group1);
    IdRepoUtils.deleteIdentities("/", identities);
    OrganizationConfigManager orgMgr = new OrganizationConfigManager(adminToken, "/");
    orgMgr.deleteSubOrganization(SUB_REALM1, true);
    orgMgr.deleteSubOrganization(SUB_REALM2, true);
    EntitlementConfiguration ec = EntitlementConfiguration.getInstance(adminSubject, "/");
    Map<String, Set<String>> saccMap = ec.getSubjectAttributesCollectorConfiguration("OpenSSO");
    Set<String> tmpSet = saccMap.get("groupMembershipSearchIndexEnabled");
    tmpSet.clear();
    tmpSet.add(origGroupMembershipSearchIndexEnabled);
    ec.setSubjectAttributesCollectorConfiguration("OpenSSO", saccMap);
}
Also used : SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) HashSet(java.util.HashSet) AMIdentity(com.sun.identity.idm.AMIdentity) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) HashSet(java.util.HashSet)

Example 35 with AMIdentity

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

the class FirstTimeLogin method onLoginSuccess.

/** 
     * Post processing on successful authentication.
     * @param requestParamsMap contains HttpServletRequest parameters
     * @param request HttpServlet  request
     * @param response HttpServlet response
     * @param ssoToken user's session
     * @throws AuthenticationException if there is an error
     */
public void onLoginSuccess(Map requestParamsMap, HttpServletRequest request, HttpServletResponse response, SSOToken ssoToken) throws AuthenticationException {
    if (debug.messageEnabled()) {
        debug.message("FirstTimeLogin.onLoginSuccess called: Req:" + request.getRequestURL());
    }
    String strAttributeName = SystemProperties.get(FIRSTTIME_LOGIN_ATTR_NAME);
    try {
        if (strAttributeName != null && !strAttributeName.trim().equals("")) {
            AMIdentity amIdentityUser = IdUtils.getIdentity(ssoToken);
            Map attrMap = amIdentityUser.getAttributes();
            String strAttributeValue = Misc.getMapAttr(attrMap, strAttributeName, null);
            if (debug.messageEnabled()) {
                debug.message("FirstTimeLogin.onLoginSuccess: " + strAttributeName + "=" + strAttributeValue);
            }
            // in the 'goto' parameter
            if (strAttributeValue != null && strAttributeValue.equalsIgnoreCase("true")) {
                if (request != null) {
                    //Change the IDM url so that it points to the correct IDM application
                    request.setAttribute(AMPostAuthProcessInterface.POST_PROCESS_LOGIN_SUCCESS_URL, "http://localhost:8081/idm/user/main.jsp?goto=http://mail.yahoo.com");
                }
            }
        }
        if (debug.messageEnabled()) {
            debug.message("FirstTimeLogin.onLoginSuccess: FirstTimeLogin " + "concluded successfully");
        }
    } catch (IdRepoException ire) {
        debug.error("FirstTimeLogin.onLoginSuccess: IOException while " + "fetching user attributes: " + ire);
    } catch (SSOException sse) {
        debug.error("FirstTimeLogin.onLoginSuccess: SSOException " + sse);
    }
}
Also used : AMIdentity(com.sun.identity.idm.AMIdentity) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) Map(java.util.Map)

Aggregations

AMIdentity (com.sun.identity.idm.AMIdentity)373 IdRepoException (com.sun.identity.idm.IdRepoException)243 SSOException (com.iplanet.sso.SSOException)215 Set (java.util.Set)170 HashSet (java.util.HashSet)150 SSOToken (com.iplanet.sso.SSOToken)112 Iterator (java.util.Iterator)91 AMIdentityRepository (com.sun.identity.idm.AMIdentityRepository)85 Map (java.util.Map)83 HashMap (java.util.HashMap)78 IdType (com.sun.identity.idm.IdType)52 SMSException (com.sun.identity.sm.SMSException)52 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)44 CLIException (com.sun.identity.cli.CLIException)43 IOutput (com.sun.identity.cli.IOutput)42 IdSearchResults (com.sun.identity.idm.IdSearchResults)39 IdSearchControl (com.sun.identity.idm.IdSearchControl)35 OrganizationConfigManager (com.sun.identity.sm.OrganizationConfigManager)23 Test (org.testng.annotations.Test)23 List (java.util.List)22