Ejemplo n.º 1
0
 public List<Roles> getRoles(Roles roles) {
   LOG.info("Inside getRoles");
   List<Roles> rolesList = new ArrayList<Roles>();
   DirContext ctx = LDAPConstants.getLdapContext();
   String baseDN = PropertyFileReader.getProperty(IAMApplicationConstants.BASEDN_ROLES);
   SearchControls sc = new SearchControls();
   sc.setSearchScope(SearchControls.SUBTREE_SCOPE);
   String retAttrs[] = {
     "whenCreated",
     "whenChanged",
     "cn",
     "name",
     "distinguishedName",
     "groupType",
     "ibRolesName",
     "ibRolesAppSelection",
     "ibRolesOwner",
     "ibRolesIsIBIS",
     "ibRolesReqBy",
     "ibRolesBusArea",
     "ibRolesStartDate",
     "ibRolesType",
     "ibRolesIsOwner",
     "ibRolesAuthBy",
     "ibRolesDescription",
     "member",
     "ibRolesStatus",
     "ibRolesCode",
     "ibRolesEndDate",
     "ibRolesCVReq"
   };
   sc.setReturningAttributes(retAttrs);
   String filter = buildFilter(roles);
   LOG.info("Filter--" + filter);
   NamingEnumeration results = null;
   try {
     results = ctx.search(baseDN, filter, sc);
     while (results.hasMore()) {
       SearchResult sr = (SearchResult) results.next();
       Attributes attrs = sr.getAttributes();
       NamingEnumeration e = attrs.getAll();
       Roles ioRoles = new Roles();
       while (e.hasMoreElements()) {
         Attribute attr = (Attribute) e.nextElement();
         ioRoles = (Roles) getResults(attr, ioRoles);
       }
       rolesList.add(ioRoles);
     }
     ctx.close();
   } catch (NamingException e) {
     e.printStackTrace();
   }
   return rolesList;
 }
Ejemplo n.º 2
0
 public List<Users> getUsers(Users user) {
   LOG.info("Inside getUsers");
   List<Users> userList = new ArrayList<Users>();
   DirContext ctx = LDAPConstants.getLdapContext();
   String baseDN = PropertyFileReader.getProperty(IAMApplicationConstants.BASEDN_USERS);
   SearchControls sc = new SearchControls();
   sc.setSearchScope(SearchControls.SUBTREE_SCOPE);
   String retAttrs[] = {
     "whenChanged",
     "whenCreated",
     "name",
     "distinguishedName",
     "givenName",
     "cn",
     "initials",
     "displayName",
     "iboIsEmail",
     "iboCountryOfCitizenship2",
     "iboCountryOfCitizenship1",
     "iboIsIBIS",
     "iboPrefCommunicationMethod",
     "iboAuthorizedDate",
     "iboIsNetwork",
     "iboUserStatus",
     "iboIBSchoolCode",
     "iboPrefCommunicationLang",
     "iboRoles",
     "iboUserName",
     "iboSex",
     "iboStartDate",
     "iboUserGUID",
     "iboCountryOfBirth",
     "iboLanguagesSpoken",
     "iboEndDate",
     "iboAuthorizedBy",
     "iboEmailHome",
     "iboCountryCode",
     "iboMobileWork",
     "iboSchoolConnections",
     "iboEmailWork",
     "iboPhoneWork",
     "iboIBRegion",
     "iboPreferredName",
     "iboMiddlename",
     "physicalDeliveryOfficeName",
     "iboSource"
   };
   sc.setReturningAttributes(retAttrs);
   String filter = buildFilter(user);
   LOG.info("Filter--" + filter);
   NamingEnumeration results = null;
   String isIboSource = null;
   try {
     results = ctx.search(baseDN, filter, sc);
     while (results.hasMore()) {
       SearchResult sr = (SearchResult) results.next();
       Attributes attrs = sr.getAttributes();
       if (null != attrs && null != attrs.get("iboSource"))
         isIboSource = attrs.get("iboSource").toString();
       if (null != isIboSource && isIboSource.length() > 0) {
         NamingEnumeration e = attrs.getAll();
         Users ioUser = new Users();
         while (e.hasMoreElements()) {
           Attribute attr = (Attribute) e.nextElement();
           if (attr.getID().toString().length() > 0
               && attr.getID().toString().equalsIgnoreCase("ibosource")) {
             if (attr.get().toString().length() > 0) {
               if (attr.get().toString().equalsIgnoreCase("sharepoint")) {
                 LOG.trace("External");
                 ioUser.setIboUserType(LDAPConstants.IBOUSERTYPE_EXTERNAL);
               } else if (attr.get().toString().equalsIgnoreCase("UserApp")
                   || attr.get().toString().equalsIgnoreCase("OracleHR")
                   || attr.get().toString().equalsIgnoreCase("userapp Generic")) {
                 LOG.trace("Internal");
                 ioUser.setIboUserType(LDAPConstants.IBOUSERTYPE_INTERNAL);
               }
             }
           }
           ioUser = (Users) getResults(attr, ioUser);
         }
         userList.add(ioUser);
       }
     }
     ctx.close();
   } catch (NamingException e) {
     e.printStackTrace();
   }
   return userList;
 }