Loading cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapUserDAO.java +12 −12 Original line number Original line Diff line number Diff line Loading @@ -225,7 +225,7 @@ public class LdapUserDAO extends LdapDAO { { HttpPrincipal httpPrincipal = new HttpPrincipal(username); HttpPrincipal httpPrincipal = new HttpPrincipal(username); User user = getUser(httpPrincipal); User user = getUser(httpPrincipal); String uuid = uuid2string(user.getID().getUUID()); long uuid = uuid2long(user.getID().getUUID()); BindRequest bindRequest = new SimpleBindRequest( BindRequest bindRequest = new SimpleBindRequest( getUserDN(uuid, config.getUsersDN()), new String(password)); getUserDN(uuid, config.getUsersDN()), new String(password)); Loading Loading @@ -298,14 +298,14 @@ public class LdapUserDAO extends LdapDAO try try { { String numericID = String.valueOf(genNextNumericId()); long numericID = genNextNumericId(); String password = UUID.randomUUID().toString(); String password = UUID.randomUUID().toString(); List<Attribute> attributes = new ArrayList<Attribute>(); List<Attribute> attributes = new ArrayList<Attribute>(); addAttribute(attributes, LDAP_OBJECT_CLASS, LDAP_INET_ORG_PERSON); addAttribute(attributes, LDAP_OBJECT_CLASS, LDAP_INET_ORG_PERSON); addAttribute(attributes, LDAP_OBJECT_CLASS, LDAP_INET_USER); addAttribute(attributes, LDAP_OBJECT_CLASS, LDAP_INET_USER); addAttribute(attributes, LDAP_OBJECT_CLASS, LDAP_CADC_ACCOUNT); addAttribute(attributes, LDAP_OBJECT_CLASS, LDAP_CADC_ACCOUNT); addAttribute(attributes, LDAP_UID, numericID); addAttribute(attributes, LDAP_UID, String.valueOf(numericID)); addAttribute(attributes, LDAP_USER_NAME, EXTERNAL_USER_CN); addAttribute(attributes, LDAP_USER_NAME, EXTERNAL_USER_CN); addAttribute(attributes, LDAP_LAST_NAME, EXTERNAL_USER_SN); addAttribute(attributes, LDAP_LAST_NAME, EXTERNAL_USER_SN); addAttribute(attributes, LADP_USER_PASSWORD, password); addAttribute(attributes, LADP_USER_PASSWORD, password); Loading Loading @@ -409,13 +409,13 @@ public class LdapUserDAO extends LdapDAO try try { { String numericID = String.valueOf(genNextNumericId()); long numericID = genNextNumericId(); List<Attribute> attributes = new ArrayList<Attribute>(); List<Attribute> attributes = new ArrayList<Attribute>(); addAttribute(attributes, LDAP_OBJECT_CLASS, LDAP_INET_ORG_PERSON); addAttribute(attributes, LDAP_OBJECT_CLASS, LDAP_INET_ORG_PERSON); addAttribute(attributes, LDAP_OBJECT_CLASS, LDAP_INET_USER); addAttribute(attributes, LDAP_OBJECT_CLASS, LDAP_INET_USER); addAttribute(attributes, LDAP_OBJECT_CLASS, LDAP_CADC_ACCOUNT); addAttribute(attributes, LDAP_OBJECT_CLASS, LDAP_CADC_ACCOUNT); addAttribute(attributes, LDAP_UID, numericID); addAttribute(attributes, LDAP_UID, String.valueOf(numericID)); addAttribute(attributes, LDAP_USER_NAME, userID.getName()); addAttribute(attributes, LDAP_USER_NAME, userID.getName()); addAttribute(attributes, LDAP_LAST_NAME, user.personalDetails.getLastName()); addAttribute(attributes, LDAP_LAST_NAME, user.personalDetails.getLastName()); addAttribute(attributes, LADP_USER_PASSWORD, new String(userRequest.getPassword())); addAttribute(attributes, LADP_USER_PASSWORD, new String(userRequest.getPassword())); Loading Loading @@ -508,7 +508,7 @@ public class LdapUserDAO extends LdapDAO String name; String name; if (userID instanceof NumericPrincipal) if (userID instanceof NumericPrincipal) { { name = uuid2string(UUID.fromString(userID.getName())); name = String.valueOf(uuid2long(UUID.fromString(userID.getName()))); } } else else { { Loading Loading @@ -859,7 +859,7 @@ public class LdapUserDAO extends LdapDAO { { throw new RuntimeException("BUG: missing HttpPrincipal for " + userID.getName()); throw new RuntimeException("BUG: missing HttpPrincipal for " + userID.getName()); } } String uid = "uid=" + uuid2string(userRequest.getID().getUUID()); String uid = "uid=" + uuid2long(userRequest.getID().getUUID()); String dn = uid + "," + config.getUserRequestsDN(); String dn = uid + "," + config.getUserRequestsDN(); try try Loading Loading @@ -1066,7 +1066,7 @@ public class LdapUserDAO extends LdapDAO User user2Delete = getUser(userID, usersDN); User user2Delete = getUser(userID, usersDN); try try { { String uuid = uuid2string(user2Delete.getID().getUUID()); long uuid = uuid2long(user2Delete.getID().getUUID()); DN userDN = getUserDN(uuid, usersDN); DN userDN = getUserDN(uuid, usersDN); if (markDelete) if (markDelete) { { Loading Loading @@ -1137,7 +1137,7 @@ public class LdapUserDAO extends LdapDAO // DN can be formulated if it is the numeric id // DN can be formulated if it is the numeric id if (p instanceof NumericPrincipal) if (p instanceof NumericPrincipal) return this.getUserDN(p.getName(), config.getUsersDN()); return this.getUserDN(uuid2long(UUID.fromString(p.getName())), config.getUsersDN()); // Otherwise we need to search for the numeric id // Otherwise we need to search for the numeric id String searchField = userLdapAttrib.get(p.getClass()); String searchField = userLdapAttrib.get(p.getClass()); Loading Loading @@ -1180,7 +1180,7 @@ public class LdapUserDAO extends LdapDAO return searchResult.getAttributeValueAsDN(LDAP_ENTRYDN); return searchResult.getAttributeValueAsDN(LDAP_ENTRYDN); } } protected DN getUserDN(String numericID, String usersDN) protected DN getUserDN(long numericID, String usersDN) throws LDAPException, TransientException throws LDAPException, TransientException { { return new DN(LDAP_UID + "=" + numericID + "," + usersDN); return new DN(LDAP_UID + "=" + numericID + "," + usersDN); Loading Loading @@ -1241,9 +1241,9 @@ public class LdapUserDAO extends LdapDAO return rand.nextInt(Integer.MAX_VALUE - 10000) + 10000; return rand.nextInt(Integer.MAX_VALUE - 10000) + 10000; } } protected String uuid2string(UUID uuid) protected long uuid2long(UUID uuid) { { return String.valueOf(uuid.getLeastSignificantBits()); return uuid.getLeastSignificantBits(); } } protected InternalID getInternalID(String numericID) protected InternalID getInternalID(String numericID) Loading Loading
cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapUserDAO.java +12 −12 Original line number Original line Diff line number Diff line Loading @@ -225,7 +225,7 @@ public class LdapUserDAO extends LdapDAO { { HttpPrincipal httpPrincipal = new HttpPrincipal(username); HttpPrincipal httpPrincipal = new HttpPrincipal(username); User user = getUser(httpPrincipal); User user = getUser(httpPrincipal); String uuid = uuid2string(user.getID().getUUID()); long uuid = uuid2long(user.getID().getUUID()); BindRequest bindRequest = new SimpleBindRequest( BindRequest bindRequest = new SimpleBindRequest( getUserDN(uuid, config.getUsersDN()), new String(password)); getUserDN(uuid, config.getUsersDN()), new String(password)); Loading Loading @@ -298,14 +298,14 @@ public class LdapUserDAO extends LdapDAO try try { { String numericID = String.valueOf(genNextNumericId()); long numericID = genNextNumericId(); String password = UUID.randomUUID().toString(); String password = UUID.randomUUID().toString(); List<Attribute> attributes = new ArrayList<Attribute>(); List<Attribute> attributes = new ArrayList<Attribute>(); addAttribute(attributes, LDAP_OBJECT_CLASS, LDAP_INET_ORG_PERSON); addAttribute(attributes, LDAP_OBJECT_CLASS, LDAP_INET_ORG_PERSON); addAttribute(attributes, LDAP_OBJECT_CLASS, LDAP_INET_USER); addAttribute(attributes, LDAP_OBJECT_CLASS, LDAP_INET_USER); addAttribute(attributes, LDAP_OBJECT_CLASS, LDAP_CADC_ACCOUNT); addAttribute(attributes, LDAP_OBJECT_CLASS, LDAP_CADC_ACCOUNT); addAttribute(attributes, LDAP_UID, numericID); addAttribute(attributes, LDAP_UID, String.valueOf(numericID)); addAttribute(attributes, LDAP_USER_NAME, EXTERNAL_USER_CN); addAttribute(attributes, LDAP_USER_NAME, EXTERNAL_USER_CN); addAttribute(attributes, LDAP_LAST_NAME, EXTERNAL_USER_SN); addAttribute(attributes, LDAP_LAST_NAME, EXTERNAL_USER_SN); addAttribute(attributes, LADP_USER_PASSWORD, password); addAttribute(attributes, LADP_USER_PASSWORD, password); Loading Loading @@ -409,13 +409,13 @@ public class LdapUserDAO extends LdapDAO try try { { String numericID = String.valueOf(genNextNumericId()); long numericID = genNextNumericId(); List<Attribute> attributes = new ArrayList<Attribute>(); List<Attribute> attributes = new ArrayList<Attribute>(); addAttribute(attributes, LDAP_OBJECT_CLASS, LDAP_INET_ORG_PERSON); addAttribute(attributes, LDAP_OBJECT_CLASS, LDAP_INET_ORG_PERSON); addAttribute(attributes, LDAP_OBJECT_CLASS, LDAP_INET_USER); addAttribute(attributes, LDAP_OBJECT_CLASS, LDAP_INET_USER); addAttribute(attributes, LDAP_OBJECT_CLASS, LDAP_CADC_ACCOUNT); addAttribute(attributes, LDAP_OBJECT_CLASS, LDAP_CADC_ACCOUNT); addAttribute(attributes, LDAP_UID, numericID); addAttribute(attributes, LDAP_UID, String.valueOf(numericID)); addAttribute(attributes, LDAP_USER_NAME, userID.getName()); addAttribute(attributes, LDAP_USER_NAME, userID.getName()); addAttribute(attributes, LDAP_LAST_NAME, user.personalDetails.getLastName()); addAttribute(attributes, LDAP_LAST_NAME, user.personalDetails.getLastName()); addAttribute(attributes, LADP_USER_PASSWORD, new String(userRequest.getPassword())); addAttribute(attributes, LADP_USER_PASSWORD, new String(userRequest.getPassword())); Loading Loading @@ -508,7 +508,7 @@ public class LdapUserDAO extends LdapDAO String name; String name; if (userID instanceof NumericPrincipal) if (userID instanceof NumericPrincipal) { { name = uuid2string(UUID.fromString(userID.getName())); name = String.valueOf(uuid2long(UUID.fromString(userID.getName()))); } } else else { { Loading Loading @@ -859,7 +859,7 @@ public class LdapUserDAO extends LdapDAO { { throw new RuntimeException("BUG: missing HttpPrincipal for " + userID.getName()); throw new RuntimeException("BUG: missing HttpPrincipal for " + userID.getName()); } } String uid = "uid=" + uuid2string(userRequest.getID().getUUID()); String uid = "uid=" + uuid2long(userRequest.getID().getUUID()); String dn = uid + "," + config.getUserRequestsDN(); String dn = uid + "," + config.getUserRequestsDN(); try try Loading Loading @@ -1066,7 +1066,7 @@ public class LdapUserDAO extends LdapDAO User user2Delete = getUser(userID, usersDN); User user2Delete = getUser(userID, usersDN); try try { { String uuid = uuid2string(user2Delete.getID().getUUID()); long uuid = uuid2long(user2Delete.getID().getUUID()); DN userDN = getUserDN(uuid, usersDN); DN userDN = getUserDN(uuid, usersDN); if (markDelete) if (markDelete) { { Loading Loading @@ -1137,7 +1137,7 @@ public class LdapUserDAO extends LdapDAO // DN can be formulated if it is the numeric id // DN can be formulated if it is the numeric id if (p instanceof NumericPrincipal) if (p instanceof NumericPrincipal) return this.getUserDN(p.getName(), config.getUsersDN()); return this.getUserDN(uuid2long(UUID.fromString(p.getName())), config.getUsersDN()); // Otherwise we need to search for the numeric id // Otherwise we need to search for the numeric id String searchField = userLdapAttrib.get(p.getClass()); String searchField = userLdapAttrib.get(p.getClass()); Loading Loading @@ -1180,7 +1180,7 @@ public class LdapUserDAO extends LdapDAO return searchResult.getAttributeValueAsDN(LDAP_ENTRYDN); return searchResult.getAttributeValueAsDN(LDAP_ENTRYDN); } } protected DN getUserDN(String numericID, String usersDN) protected DN getUserDN(long numericID, String usersDN) throws LDAPException, TransientException throws LDAPException, TransientException { { return new DN(LDAP_UID + "=" + numericID + "," + usersDN); return new DN(LDAP_UID + "=" + numericID + "," + usersDN); Loading Loading @@ -1241,9 +1241,9 @@ public class LdapUserDAO extends LdapDAO return rand.nextInt(Integer.MAX_VALUE - 10000) + 10000; return rand.nextInt(Integer.MAX_VALUE - 10000) + 10000; } } protected String uuid2string(UUID uuid) protected long uuid2long(UUID uuid) { { return String.valueOf(uuid.getLeastSignificantBits()); return uuid.getLeastSignificantBits(); } } protected InternalID getInternalID(String numericID) protected InternalID getInternalID(String numericID) Loading