Loading cadcAccessControl-Admin/src/ca/nrc/cadc/ac/admin/AbstractListUsers.java +29 −13 Original line number Diff line number Diff line Loading @@ -70,14 +70,15 @@ package ca.nrc.cadc.ac.admin; import java.security.AccessControlException; import java.security.Principal; import java.util.Collection; import java.util.Set; import javax.security.auth.x500.X500Principal; import org.apache.log4j.Logger; import ca.nrc.cadc.ac.PersonalDetails; import ca.nrc.cadc.ac.User; import ca.nrc.cadc.auth.HttpPrincipal; import ca.nrc.cadc.net.TransientException; /** Loading @@ -89,14 +90,14 @@ public abstract class AbstractListUsers extends AbstractCommand { private static final Logger log = Logger.getLogger(AbstractListUsers.class); protected abstract Collection<User<Principal>> getUsers() protected abstract Collection<User> getUsers() throws AccessControlException, TransientException; protected void doRun() throws AccessControlException, TransientException { Collection<User<Principal>> users = this.getUsers(); Collection<User> users = this.getUsers(); for (User<Principal> user : users) for (User user : users) { this.systemOut.println(getUserString(user)); } Loading @@ -106,21 +107,36 @@ public abstract class AbstractListUsers extends AbstractCommand private String getUserString(User user) { StringBuilder sb = new StringBuilder(user.getUserID().getName()); StringBuilder sb = new StringBuilder(); HttpPrincipal username = user.getHttpPrincipal(); if (username != null) { sb.append(username.getName()); } else { Set<X500Principal> x500Principals = user.getIdentities(X500Principal.class); if (!x500Principals.isEmpty()) { sb.append(x500Principals.iterator().next().getName()); } else { sb.append("Internal ID: " + user.getID().getURI()); } } Set<PersonalDetails> detailSet = user.getDetails(PersonalDetails.class); if (detailSet.size() > 0) if (user.personalDetails != null) { sb.append(" ["); PersonalDetails details = detailSet.iterator().next(); sb.append(details.getFirstName()); sb.append(user.personalDetails.getFirstName()); sb.append(" "); sb.append(details.getLastName()); sb.append(user.personalDetails.getLastName()); sb.append("]"); if (details.institute != null) if (user.personalDetails.institute != null) { sb.append(" ["); sb.append(details.institute); sb.append(user.personalDetails.institute); sb.append("]"); } } Loading cadcAccessControl-Admin/src/ca/nrc/cadc/ac/admin/AbstractUserCommand.java +14 −16 Original line number Diff line number Diff line Loading @@ -75,7 +75,6 @@ import java.util.Set; import org.apache.log4j.Logger; import ca.nrc.cadc.ac.PersonalDetails; import ca.nrc.cadc.ac.User; import ca.nrc.cadc.ac.UserNotFoundException; import ca.nrc.cadc.auth.HttpPrincipal; Loading Loading @@ -121,7 +120,7 @@ public abstract class AbstractUserCommand extends AbstractCommand } } protected void printUser(final User<Principal> user) protected void printUser(final User user) { if (user != null) { Loading @@ -136,10 +135,9 @@ public abstract class AbstractUserCommand extends AbstractCommand // print user's personal details this.systemOut.println(); PersonalDetails personalDetails = user.getUserDetail(PersonalDetails.class); if (personalDetails != null) if (user.personalDetails != null) { this.systemOut.println(personalDetails.toStringFormatted()); this.systemOut.println(user.personalDetails.toStringFormatted()); } } } Loading cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/GroupPersistence.java +1 −2 Original line number Diff line number Diff line Loading @@ -69,7 +69,6 @@ package ca.nrc.cadc.ac.server; import java.security.AccessControlException; import java.security.Principal; import java.util.Collection; import ca.nrc.cadc.ac.Group; Loading @@ -79,7 +78,7 @@ import ca.nrc.cadc.ac.Role; import ca.nrc.cadc.ac.UserNotFoundException; import ca.nrc.cadc.net.TransientException; public interface GroupPersistence<T extends Principal> public interface GroupPersistence { /** * Call if this object is to be shut down. Loading cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/PluginFactory.java +8 −12 Original line number Diff line number Diff line Loading @@ -68,18 +68,14 @@ */ package ca.nrc.cadc.ac.server; import ca.nrc.cadc.ac.server.ldap.LdapGroupPersistence; import ca.nrc.cadc.ac.server.ldap.LdapUserPersistence; import java.lang.reflect.Constructor; import java.net.URL; import java.security.AccessControlException; import java.security.Principal; import java.util.Properties; import java.util.Set; import org.apache.log4j.Logger; import com.unboundid.ldap.sdk.LDAPException; import ca.nrc.cadc.ac.server.ldap.LdapGroupPersistence; import ca.nrc.cadc.ac.server.ldap.LdapUserPersistence; public class PluginFactory { Loading Loading @@ -118,20 +114,20 @@ public class PluginFactory } @SuppressWarnings("unchecked") public <T extends Principal> GroupPersistence<T> createGroupPersistence() public <T extends Principal> GroupPersistence createGroupPersistence() { String name = GroupPersistence.class.getName(); String cname = config.getProperty(name); if (cname == null) { return new LdapGroupPersistence<T>(); return new LdapGroupPersistence(); } else { try { Class<?> c = Class.forName(cname); return (GroupPersistence<T>) c.newInstance(); return (GroupPersistence) c.newInstance(); } catch (Exception ex) { Loading @@ -141,14 +137,14 @@ public class PluginFactory } @SuppressWarnings("unchecked") public <T extends Principal> UserPersistence<T> createUserPersistence() public <T extends Principal> UserPersistence createUserPersistence() { String name = UserPersistence.class.getName(); String cname = config.getProperty(name); if (cname == null) { return new LdapUserPersistence<T>(); return new LdapUserPersistence(); } else { Loading cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/UserPersistence.java +18 −18 Original line number Diff line number Diff line Loading @@ -68,6 +68,10 @@ */ package ca.nrc.cadc.ac.server; import java.security.AccessControlException; import java.security.Principal; import java.util.Collection; import ca.nrc.cadc.ac.User; import ca.nrc.cadc.ac.UserAlreadyExistsException; import ca.nrc.cadc.ac.UserNotFoundException; Loading @@ -75,11 +79,7 @@ import ca.nrc.cadc.ac.UserRequest; import ca.nrc.cadc.auth.HttpPrincipal; import ca.nrc.cadc.net.TransientException; import java.security.AccessControlException; import java.security.Principal; import java.util.Collection; public interface UserPersistence<T extends Principal> public interface UserPersistence { /** Loading @@ -96,7 +96,7 @@ public interface UserPersistence<T extends Principal> * @throws AccessControlException If the operation is not permitted. * @throws ca.nrc.cadc.ac.UserAlreadyExistsException */ void addUser(UserRequest<T> user) void addUser(UserRequest user) throws TransientException, AccessControlException, UserAlreadyExistsException; Loading @@ -109,7 +109,7 @@ public interface UserPersistence<T extends Principal> * @throws AccessControlException If the operation is not permitted. * @throws ca.nrc.cadc.ac.UserAlreadyExistsException */ void addPendingUser(UserRequest<T> user) void addPendingUser(UserRequest user) throws TransientException, AccessControlException, UserAlreadyExistsException; Loading @@ -124,7 +124,7 @@ public interface UserPersistence<T extends Principal> * @throws TransientException If an temporary, unexpected problem occurred. * @throws AccessControlException If the operation is not permitted. */ User<T> getUser(T userID) User getUser(Principal userID) throws UserNotFoundException, TransientException, AccessControlException; Loading @@ -140,7 +140,7 @@ public interface UserPersistence<T extends Principal> * @throws TransientException If an temporary, unexpected problem occurred. * @throws AccessControlException If the operation is not permitted. */ User<Principal> getUserByEmailAddress(String emailAddress) User getUserByEmailAddress(String emailAddress) throws UserNotFoundException, UserAlreadyExistsException, TransientException, AccessControlException; Loading @@ -155,7 +155,7 @@ public interface UserPersistence<T extends Principal> * @throws TransientException If an temporary, unexpected problem occurred. * @throws AccessControlException If the operation is not permitted. */ User<T> getPendingUser(T userID) User getPendingUser(Principal userID) throws UserNotFoundException, TransientException, AccessControlException; Loading @@ -170,7 +170,7 @@ public interface UserPersistence<T extends Principal> * @throws TransientException If an temporary, unexpected problem occurred. * @throws AccessControlException If the operation is not permitted. */ User<T> getAugmentedUser(T userID) User getAugmentedUser(Principal userID) throws UserNotFoundException, TransientException, AccessControlException; Loading @@ -181,7 +181,7 @@ public interface UserPersistence<T extends Principal> * @throws TransientException If an temporary, unexpected problem occurred. * @throws AccessControlException If the operation is not permitted. */ Collection<User<Principal>> getUsers() Collection<User> getUsers() throws TransientException, AccessControlException; /** Loading @@ -191,7 +191,7 @@ public interface UserPersistence<T extends Principal> * @throws TransientException If an temporary, unexpected problem occurred. * @throws AccessControlException If the operation is not permitted. */ Collection<User<Principal>> getPendingUsers() Collection<User> getPendingUsers() throws TransientException, AccessControlException; /** Loading @@ -206,7 +206,7 @@ public interface UserPersistence<T extends Principal> * @throws TransientException If an temporary, unexpected problem occurred. * @throws AccessControlException If the operation is not permitted. */ User<T> approvePendingUser(T userID) User approvePendingUser(Principal userID) throws UserNotFoundException, TransientException, AccessControlException; Loading @@ -221,7 +221,7 @@ public interface UserPersistence<T extends Principal> * @throws TransientException If an temporary, unexpected problem occurred. * @throws AccessControlException If the operation is not permitted. */ User<T> modifyUser(User<T> user) User modifyUser(User user) throws UserNotFoundException, TransientException, AccessControlException; Loading @@ -234,7 +234,7 @@ public interface UserPersistence<T extends Principal> * @throws TransientException If an temporary, unexpected problem occurred. * @throws AccessControlException If the operation is not permitted. */ void deleteUser(T userID) void deleteUser(Principal userID) throws UserNotFoundException, TransientException, AccessControlException; Loading @@ -247,7 +247,7 @@ public interface UserPersistence<T extends Principal> * @throws TransientException If an temporary, unexpected problem occurred. * @throws AccessControlException If the operation is not permitted. */ void deletePendingUser(T userID) void deletePendingUser(Principal userID) throws UserNotFoundException, TransientException, AccessControlException; Loading Loading
cadcAccessControl-Admin/src/ca/nrc/cadc/ac/admin/AbstractListUsers.java +29 −13 Original line number Diff line number Diff line Loading @@ -70,14 +70,15 @@ package ca.nrc.cadc.ac.admin; import java.security.AccessControlException; import java.security.Principal; import java.util.Collection; import java.util.Set; import javax.security.auth.x500.X500Principal; import org.apache.log4j.Logger; import ca.nrc.cadc.ac.PersonalDetails; import ca.nrc.cadc.ac.User; import ca.nrc.cadc.auth.HttpPrincipal; import ca.nrc.cadc.net.TransientException; /** Loading @@ -89,14 +90,14 @@ public abstract class AbstractListUsers extends AbstractCommand { private static final Logger log = Logger.getLogger(AbstractListUsers.class); protected abstract Collection<User<Principal>> getUsers() protected abstract Collection<User> getUsers() throws AccessControlException, TransientException; protected void doRun() throws AccessControlException, TransientException { Collection<User<Principal>> users = this.getUsers(); Collection<User> users = this.getUsers(); for (User<Principal> user : users) for (User user : users) { this.systemOut.println(getUserString(user)); } Loading @@ -106,21 +107,36 @@ public abstract class AbstractListUsers extends AbstractCommand private String getUserString(User user) { StringBuilder sb = new StringBuilder(user.getUserID().getName()); StringBuilder sb = new StringBuilder(); HttpPrincipal username = user.getHttpPrincipal(); if (username != null) { sb.append(username.getName()); } else { Set<X500Principal> x500Principals = user.getIdentities(X500Principal.class); if (!x500Principals.isEmpty()) { sb.append(x500Principals.iterator().next().getName()); } else { sb.append("Internal ID: " + user.getID().getURI()); } } Set<PersonalDetails> detailSet = user.getDetails(PersonalDetails.class); if (detailSet.size() > 0) if (user.personalDetails != null) { sb.append(" ["); PersonalDetails details = detailSet.iterator().next(); sb.append(details.getFirstName()); sb.append(user.personalDetails.getFirstName()); sb.append(" "); sb.append(details.getLastName()); sb.append(user.personalDetails.getLastName()); sb.append("]"); if (details.institute != null) if (user.personalDetails.institute != null) { sb.append(" ["); sb.append(details.institute); sb.append(user.personalDetails.institute); sb.append("]"); } } Loading
cadcAccessControl-Admin/src/ca/nrc/cadc/ac/admin/AbstractUserCommand.java +14 −16 Original line number Diff line number Diff line Loading @@ -75,7 +75,6 @@ import java.util.Set; import org.apache.log4j.Logger; import ca.nrc.cadc.ac.PersonalDetails; import ca.nrc.cadc.ac.User; import ca.nrc.cadc.ac.UserNotFoundException; import ca.nrc.cadc.auth.HttpPrincipal; Loading Loading @@ -121,7 +120,7 @@ public abstract class AbstractUserCommand extends AbstractCommand } } protected void printUser(final User<Principal> user) protected void printUser(final User user) { if (user != null) { Loading @@ -136,10 +135,9 @@ public abstract class AbstractUserCommand extends AbstractCommand // print user's personal details this.systemOut.println(); PersonalDetails personalDetails = user.getUserDetail(PersonalDetails.class); if (personalDetails != null) if (user.personalDetails != null) { this.systemOut.println(personalDetails.toStringFormatted()); this.systemOut.println(user.personalDetails.toStringFormatted()); } } } Loading
cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/GroupPersistence.java +1 −2 Original line number Diff line number Diff line Loading @@ -69,7 +69,6 @@ package ca.nrc.cadc.ac.server; import java.security.AccessControlException; import java.security.Principal; import java.util.Collection; import ca.nrc.cadc.ac.Group; Loading @@ -79,7 +78,7 @@ import ca.nrc.cadc.ac.Role; import ca.nrc.cadc.ac.UserNotFoundException; import ca.nrc.cadc.net.TransientException; public interface GroupPersistence<T extends Principal> public interface GroupPersistence { /** * Call if this object is to be shut down. Loading
cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/PluginFactory.java +8 −12 Original line number Diff line number Diff line Loading @@ -68,18 +68,14 @@ */ package ca.nrc.cadc.ac.server; import ca.nrc.cadc.ac.server.ldap.LdapGroupPersistence; import ca.nrc.cadc.ac.server.ldap.LdapUserPersistence; import java.lang.reflect.Constructor; import java.net.URL; import java.security.AccessControlException; import java.security.Principal; import java.util.Properties; import java.util.Set; import org.apache.log4j.Logger; import com.unboundid.ldap.sdk.LDAPException; import ca.nrc.cadc.ac.server.ldap.LdapGroupPersistence; import ca.nrc.cadc.ac.server.ldap.LdapUserPersistence; public class PluginFactory { Loading Loading @@ -118,20 +114,20 @@ public class PluginFactory } @SuppressWarnings("unchecked") public <T extends Principal> GroupPersistence<T> createGroupPersistence() public <T extends Principal> GroupPersistence createGroupPersistence() { String name = GroupPersistence.class.getName(); String cname = config.getProperty(name); if (cname == null) { return new LdapGroupPersistence<T>(); return new LdapGroupPersistence(); } else { try { Class<?> c = Class.forName(cname); return (GroupPersistence<T>) c.newInstance(); return (GroupPersistence) c.newInstance(); } catch (Exception ex) { Loading @@ -141,14 +137,14 @@ public class PluginFactory } @SuppressWarnings("unchecked") public <T extends Principal> UserPersistence<T> createUserPersistence() public <T extends Principal> UserPersistence createUserPersistence() { String name = UserPersistence.class.getName(); String cname = config.getProperty(name); if (cname == null) { return new LdapUserPersistence<T>(); return new LdapUserPersistence(); } else { Loading
cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/UserPersistence.java +18 −18 Original line number Diff line number Diff line Loading @@ -68,6 +68,10 @@ */ package ca.nrc.cadc.ac.server; import java.security.AccessControlException; import java.security.Principal; import java.util.Collection; import ca.nrc.cadc.ac.User; import ca.nrc.cadc.ac.UserAlreadyExistsException; import ca.nrc.cadc.ac.UserNotFoundException; Loading @@ -75,11 +79,7 @@ import ca.nrc.cadc.ac.UserRequest; import ca.nrc.cadc.auth.HttpPrincipal; import ca.nrc.cadc.net.TransientException; import java.security.AccessControlException; import java.security.Principal; import java.util.Collection; public interface UserPersistence<T extends Principal> public interface UserPersistence { /** Loading @@ -96,7 +96,7 @@ public interface UserPersistence<T extends Principal> * @throws AccessControlException If the operation is not permitted. * @throws ca.nrc.cadc.ac.UserAlreadyExistsException */ void addUser(UserRequest<T> user) void addUser(UserRequest user) throws TransientException, AccessControlException, UserAlreadyExistsException; Loading @@ -109,7 +109,7 @@ public interface UserPersistence<T extends Principal> * @throws AccessControlException If the operation is not permitted. * @throws ca.nrc.cadc.ac.UserAlreadyExistsException */ void addPendingUser(UserRequest<T> user) void addPendingUser(UserRequest user) throws TransientException, AccessControlException, UserAlreadyExistsException; Loading @@ -124,7 +124,7 @@ public interface UserPersistence<T extends Principal> * @throws TransientException If an temporary, unexpected problem occurred. * @throws AccessControlException If the operation is not permitted. */ User<T> getUser(T userID) User getUser(Principal userID) throws UserNotFoundException, TransientException, AccessControlException; Loading @@ -140,7 +140,7 @@ public interface UserPersistence<T extends Principal> * @throws TransientException If an temporary, unexpected problem occurred. * @throws AccessControlException If the operation is not permitted. */ User<Principal> getUserByEmailAddress(String emailAddress) User getUserByEmailAddress(String emailAddress) throws UserNotFoundException, UserAlreadyExistsException, TransientException, AccessControlException; Loading @@ -155,7 +155,7 @@ public interface UserPersistence<T extends Principal> * @throws TransientException If an temporary, unexpected problem occurred. * @throws AccessControlException If the operation is not permitted. */ User<T> getPendingUser(T userID) User getPendingUser(Principal userID) throws UserNotFoundException, TransientException, AccessControlException; Loading @@ -170,7 +170,7 @@ public interface UserPersistence<T extends Principal> * @throws TransientException If an temporary, unexpected problem occurred. * @throws AccessControlException If the operation is not permitted. */ User<T> getAugmentedUser(T userID) User getAugmentedUser(Principal userID) throws UserNotFoundException, TransientException, AccessControlException; Loading @@ -181,7 +181,7 @@ public interface UserPersistence<T extends Principal> * @throws TransientException If an temporary, unexpected problem occurred. * @throws AccessControlException If the operation is not permitted. */ Collection<User<Principal>> getUsers() Collection<User> getUsers() throws TransientException, AccessControlException; /** Loading @@ -191,7 +191,7 @@ public interface UserPersistence<T extends Principal> * @throws TransientException If an temporary, unexpected problem occurred. * @throws AccessControlException If the operation is not permitted. */ Collection<User<Principal>> getPendingUsers() Collection<User> getPendingUsers() throws TransientException, AccessControlException; /** Loading @@ -206,7 +206,7 @@ public interface UserPersistence<T extends Principal> * @throws TransientException If an temporary, unexpected problem occurred. * @throws AccessControlException If the operation is not permitted. */ User<T> approvePendingUser(T userID) User approvePendingUser(Principal userID) throws UserNotFoundException, TransientException, AccessControlException; Loading @@ -221,7 +221,7 @@ public interface UserPersistence<T extends Principal> * @throws TransientException If an temporary, unexpected problem occurred. * @throws AccessControlException If the operation is not permitted. */ User<T> modifyUser(User<T> user) User modifyUser(User user) throws UserNotFoundException, TransientException, AccessControlException; Loading @@ -234,7 +234,7 @@ public interface UserPersistence<T extends Principal> * @throws TransientException If an temporary, unexpected problem occurred. * @throws AccessControlException If the operation is not permitted. */ void deleteUser(T userID) void deleteUser(Principal userID) throws UserNotFoundException, TransientException, AccessControlException; Loading @@ -247,7 +247,7 @@ public interface UserPersistence<T extends Principal> * @throws TransientException If an temporary, unexpected problem occurred. * @throws AccessControlException If the operation is not permitted. */ void deletePendingUser(T userID) void deletePendingUser(Principal userID) throws UserNotFoundException, TransientException, AccessControlException; Loading