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);
}
}
}
}
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);
}
}
}
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);
}
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);
}
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);
}
}
Aggregations