Package com.esri.gpt.framework.security.identity

Examples of com.esri.gpt.framework.security.identity.IdentityAdapter


  if(filter.length() == 0) {
    response.getWriter().write("{ \"response\" : \"noResults\" }");
    return;
  }
 
  IdentityAdapter idAdapter = context.newIdentityAdapter();
 
  /*User selectableUser = new User();
    selectableUser.setDistinguishedName("*");
    idAdapter.readUserGroups(selectableUser);
    selectableGroups = selectableUser.getGroups();*/
   
  Groups groups = idAdapter.readGroups(filter);
  for (Group g : groups.values()){
    if(isAddAttributeRequest){
      try{
        idAdapter.addAttribute(g.getDistinguishedName(), attributeName, attributeValue);
      }catch(AttributeInUseException aiue){
        // TODO : do nothing if attribute exists ? or overwrite ?
      }
    }else {
      idAdapter.removeAttribute(g.getDistinguishedName(), attributeName, attributeValue);
    }
  }
 
   writeCharacterResponse(response,"{ \"response\" : \"Group attribute modification was successful.\" }","UTF-8",mimeType+";charset=UTF-8");
}
View Full Code Here


  throws Exception {
  try {
  String[] parts = request.getRequestURI().toString().split("/");
    String member = Val.chkStr(request.getParameter("member"));
    String attempt = Val.chkStr(request.getParameter("attempt"));
    IdentityAdapter idAdapter = context.newIdentityAdapter();
    User user = new User();
    user.setDistinguishedName(member);
    idAdapter.readUserProfile(user);
    boolean isSelf = checkSelf(context,member);
    if((isSelf && attempt.equals("2")) || !isSelf){     
      if(parts.length > 0) {
        String groupIdentifier = URLDecoder.decode(parts[5].trim(),"UTF-8");
        boolean checkGroupConfigured = true;
        if(checkIfAllowConfigured(context)){
          checkGroupConfigured = checkIfConfigured(context,groupIdentifier);
        }
        boolean isAllowedToManage = true;
        isAllowedToManage = checkIfAllowedToManage(context, groupIdentifier);
        if(checkGroupConfigured){
          if(isAllowedToManage){
            if(groupIdentifier.endsWith(groupDIT)){
              idAdapter.addUserToGroup(user, groupIdentifier);          
            }else{       
              idAdapter.addUserToRole(user, groupIdentifier);     
            }
          }else{
              response.sendError(HttpServletResponse.SC_BAD_REQUEST, "{ \"error\":\""+ groupIdentifier +" is not allowed to be managed in geoportal. \"}");
              return;
            }
View Full Code Here

  throws Exception {
  try {
  String[] parts = request.getRequestURI().toString().split("/")
  String member = Val.chkStr(request.getParameter("member"));
    String attempt = Val.chkStr(request.getParameter("attempt"));
    IdentityAdapter idAdapter = context.newIdentityAdapter();
    User user = new User();
    user.setDistinguishedName(member);
    idAdapter.readUserProfile(user);
    if(parts.length > 0) {
    String groupIdentifier = URLDecoder.decode(parts[5].trim(),"UTF-8");
    if(!groupIdentifier.endsWith(groupDIT)){
        IdentityConfiguration idConfig = context.getIdentityConfiguration();  
        Roles configuredRoles = idConfig.getConfiguredRoles();    
      Role roleRegistered = configuredRoles.get(groupIdentifier);   
      groupIdentifier = roleRegistered.getDistinguishedName();
    }
      boolean isSelf = checkSelf(context,member);
      if((isSelf && attempt.equals("2")) || !isSelf){
       
        boolean checkGroupConfigured = true;
        if(checkIfAllowConfigured(context)){
          checkGroupConfigured = checkIfConfigured(context,groupIdentifier);
        }
        boolean isAllowedToManage = true;
        isAllowedToManage = checkIfAllowedToManage(context, groupIdentifier);
        if(checkGroupConfigured){
          if(isAllowedToManage){
            idAdapter.removeUserFromGroup(user, groupIdentifier);
              response.getWriter().write(msgBroker.retrieveMessage("catalog.identity.removeRole.success"));
          }else{
              response.sendError(HttpServletResponse.SC_BAD_REQUEST, "{ \"error\":\""+ groupIdentifier +" is not allowed to be managed in geoportal. \"}");
              return;
            }
View Full Code Here

  String[] parts = request.getRequestURI().toString().split("/");
  if(parts.length > 0) {
    String userIdentifier = URLDecoder.decode(parts[5].trim(),"UTF-8");
    if(userIdentifier.endsWith(userDIT)){ 
      String attempt = Val.chkStr(request.getParameter("attempt"));
        IdentityAdapter idAdapter = context.newIdentityAdapter();
        User user = new User();
        user.setDistinguishedName(userIdentifier);
        idAdapter.readUserProfile(user);   
        idAdapter.readUserGroups(user);
       
        boolean isSelf = checkSelf(context,userIdentifier);
        if((isSelf && attempt.equals("2")) || !isSelf){
          idAdapter.deleteUser(user);
          response.getWriter().write(msgBroker.retrieveMessage("catalog.identity.deleteUser.success"));
        }else{
          response.getWriter().write("prompt");
        }
    }
View Full Code Here

    totalMatches = (Integer) resultsMap.get("totalMatches");
  }else if(isMemberSearch && attributeName != null){
    Roles configuredRoles = context.getIdentityConfiguration().getConfiguredRoles();
    Role role = configuredRoles.get(attributeName);
    String sDn = role.getDistinguishedName();
    IdentityAdapter idAdapter = context.newIdentityAdapter();
    users = idAdapter.readGroupMembers(sDn);
    totalMatches = users.size();
    users.sort();
  }else{
    IdentityAdapter idAdapter = context.newIdentityAdapter();
    Users members = idAdapter.readGroupMembers(filter);
      for (User u: members.values()) {
        users.add(u);     
      }
      users.sort();
      totalMatches = users.size();
View Full Code Here

* @throws NamingException if an LDAP naming exception occurs
*/
protected HashMap<String,Object> buildUsersList(RequestContext context,String filter, String attributeName)
    throws IdentityException, NamingException {
  HashMap<String,Object> resultsMap = new HashMap<String,Object>();
  IdentityAdapter idAdapter = context.newIdentityAdapter();
  String searchLimit = Val.chkStr(context.getCatalogConfiguration().getParameters().getValue("ldap.identity.search.maxResults"));
  int srchLimit = -1;
  if(searchLimit.length() > 0){
    srchLimit = Integer.parseInt(searchLimit);
  }
  Users users = idAdapter.readUsers(filter,attributeName);
  users.sort();
  int totalMatches = users.size();
  resultsMap.put("totalMatches", totalMatches);
  if(srchLimit == -1) {
    resultsMap.put("topUserMatches", users);
View Full Code Here

* @throws UnsupportedEncodingException
*/
protected User readUserProfile(RequestContext context,HttpServletRequest request)
    throws Exception {
 
  IdentityAdapter idAdapter = context.newIdentityAdapter();
  User user = new User();
  String[] parts = request.getRequestURI().toString().split("/");   
  String sEncoding = request.getCharacterEncoding();
    if ((sEncoding == null) || (sEncoding.trim().length() == 0)) {
       sEncoding = "UTF-8";
View Full Code Here

*          the current request context (contains the active user)
* @return the collection of groups that can be selected
*/
public static Groups buildSelectableGroups(RequestContext context) {

  IdentityAdapter idAdapter = context.newIdentityAdapter();
  IdentityConfiguration idConfig = context.getIdentityConfiguration();
  Groups selectableGroups = null;

  User user = context.getUser();
  RoleSet roles = user.getAuthenticationStatus().getAuthenticatedRoles();
  boolean bIsAdministrator = roles.hasRole("gptAdministrator");

  try {
    if (bIsAdministrator) {
      User selectableUser = new User();
      selectableUser.setDistinguishedName("*");
      idAdapter.readUserGroups(selectableUser);
      selectableGroups = selectableUser.getGroups();
    } else {
      selectableGroups = user.getGroups();
    }
    Groups mgmtGroups = idConfig.getMetadataManagementGroups();
View Full Code Here

* @param forManagement true if the list to build is in support of the metadata management page
* @return the collection of publishers that can be selected
*/
public static Users buildSelectablePublishers(RequestContext context,
                                              boolean forManagement) {
  IdentityAdapter idAdapter = context.newIdentityAdapter();
  IdentityConfiguration idConfig = context.getIdentityConfiguration();
 
  // add the current user to the list
  Users users = new Users();
  User user = context.getUser();
  users.add(user);
  RoleSet roles = user.getAuthenticationStatus().getAuthenticatedRoles();
  boolean bIsAdministrator = roles.hasRole("gptAdministrator");
     
  try {
    if (bIsAdministrator && forManagement) {
     
      // add the administrators
      Role adminRole = idConfig.getConfiguredRoles().get("gptAdministrator");
      if (adminRole != null) {
        Users admins = idAdapter.readGroupMembers(adminRole.getDistinguishedName());
        for (User u: admins.values()) users.add(u);
      }
     
      // add the publishers
      Role pubRole = idConfig.getConfiguredRoles().get("gptPublisher");
      if (pubRole != null) {
        Users publishers = idAdapter.readGroupMembers(pubRole.getDistinguishedName());
        for (User u: publishers.values()) users.add(u);
      }
      users.sort();
    }
   
View Full Code Here

        // get distingushed name for the record owner
        LocalDao localDao = new LocalDao(context);
        String uDN = localDao.readDN(record.getOwnerId());

        // obtain LDAP adapter
        IdentityAdapter ldapAdapter = context.newIdentityAdapter();

        // declare users
        Users users = new Users();
        // check if the owner is a group
        Group group = null;
        IdentityConfiguration idConfig = context.getIdentityConfiguration();
        Groups mgmtGroups = idConfig.getMetadataManagementGroups();
        if (mgmtGroups != null) {
          group = mgmtGroups.get(uDN);
        }
        if (group != null) {
          // read all members of the group
          users = ldapAdapter.readGroupMembers(uDN);
          for (User user : users.values()) {
            ldapAdapter.readUserProfile(user);
            String emailAddress = user.getProfile().getEmailAddress();
            if (emailAddress.length() > 0) {
              emailAddresses.add(emailAddress);
            }
          }
        } else {
          User user = new User();
          user.setDistinguishedName(uDN);
          ldapAdapter.readUserProfile(user);
          String emailAddress = user.getProfile().getEmailAddress();
          if (emailAddress.length() > 0) {
            emailAddresses.add(emailAddress);
          }
        }
View Full Code Here

TOP

Related Classes of com.esri.gpt.framework.security.identity.IdentityAdapter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.