Commit 24fbe061 authored by Jeff Burke's avatar Jeff Burke
Browse files

s1890: use a numericID instead of a Principal as a Users unique identity.

parent bab3a305
Loading
Loading
Loading
Loading
+25 −1
Original line number Diff line number Diff line
@@ -123,7 +123,31 @@
                <pathelement path="${build}/test/class"/>
                <pathelement path="${testingJars}"/>
            </classpath>
            <test name="ca.nrc.cadc.ac.json.JsonGroupReaderWriterTest" />
            <test name="ca.nrc.cadc.ac.client.GMSClientTest" />
            <!--<test name="ca.nrc.cadc.ac.client.JsonUserListInputStreamWrapperTest" />-->
            <!--<test name="ca.nrc.cadc.ac.client.UserClientTest" />-->

            <!--<test name="ca.nrc.cadc.ac.GroupPropertyTest" />-->
            <!--<test name="ca.nrc.cadc.ac.GroupTest" />-->
            <!--<test name="ca.nrc.cadc.ac.PersonalDetailsTest" />-->
            <!--<test name="ca.nrc.cadc.ac.PosixDetailsTest" />-->
            <!--<test name="ca.nrc.cadc.ac.RoleTest" />-->
            <!--<test name="ca.nrc.cadc.ac.UserRequestTest" />-->
            <!--<test name="ca.nrc.cadc.ac.UserTest" />-->

            <!--<test name="ca.nrc.cadc.ac.json.JsonGroupReaderWriterTest" />-->
            <!--<test name="ca.nrc.cadc.ac.json.JsonUserReaderWriterTest" />-->
            <!--<test name="ca.nrc.cadc.ac.json.JsonUserListReaderWriterTest" />-->
            <!--<test name="ca.nrc.cadc.ac.json.JsonUserRequestReaderWriterTest" />-->

            <!--<test name="ca.nrc.cadc.ac.xml.GroupListReaderWriterTest" />-->
            <!--<test name="ca.nrc.cadc.ac.xml.GroupPropertyReaderWriterTest" />-->
            <!--<test name="ca.nrc.cadc.ac.xml.GroupReaderWriterTest" />-->
            <!--<test name="ca.nrc.cadc.ac.xml.IdentityReaderWriterTest" />-->
            <!--<test name="ca.nrc.cadc.ac.xml.UserDetailsReaderWriterTest" />-->
            <!--<test name="ca.nrc.cadc.ac.xml.UserListReaderWriterTest" />-->
            <!--<test name="ca.nrc.cadc.ac.xml.UserReaderWriterTest" />-->
            <!--<test name="ca.nrc.cadc.ac.xml.UserRequestReaderWriterTest" />-->
            <formatter type="plain" usefile="false" />
        </junit>
    </target>
+8 −9
Original line number Diff line number Diff line
@@ -68,7 +68,6 @@
 */
package ca.nrc.cadc.ac;

import java.security.Principal;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
@@ -77,19 +76,19 @@ public class Group
{
    private String groupID;
    
    private User<? extends Principal> owner;
    private User owner;
    
    // group's properties
    protected Set<GroupProperty> properties = new HashSet<GroupProperty>();

    // group's user members
    private Set<User<? extends Principal>> userMembers = new HashSet<User<? extends Principal>>();
    private Set<User> userMembers = new HashSet<User>();

    // group's group members
    private Set<Group> groupMembers = new HashSet<Group>();
    
    // group's user admins
    private Set<User<? extends Principal>> userAdmins = new HashSet<User<? extends Principal>>();
    private Set<User> userAdmins = new HashSet<User>();
    
    // group's group admins
    private Set<Group> groupAdmins = new HashSet<Group>();
@@ -119,7 +118,7 @@ public class Group
     *                  and "-", ".","_","~" characters.
     * @param owner     Owner/Creator of the group.
     */
    public Group(String groupID, User<? extends Principal> owner)
    public Group(String groupID, User owner)
    {
        if (groupID == null)
        {
@@ -150,12 +149,12 @@ public class Group
     * Obtain this group's owner
     * @return owner of the group
     */
    public User<? extends Principal> getOwner()
    public User getOwner()
    {
        return owner;
    }

    public void setOwner(User<? extends Principal> owner)
    public void setOwner(User owner)
    {
        this.owner = owner;
    }
@@ -173,7 +172,7 @@ public class Group
     * 
     * @return individual user members of this group
     */
    public Set<User<? extends Principal>> getUserMembers()
    public Set<User> getUserMembers()
    {
        return userMembers;
    }
@@ -191,7 +190,7 @@ public class Group
     * 
     * @return individual user admins of this group
     */
    public Set<User<? extends Principal>> getUserAdmins()
    public Set<User> getUserAdmins()
    {
        return userAdmins;
    }
+0 −26
Original line number Diff line number Diff line
@@ -74,32 +74,6 @@ package ca.nrc.cadc.ac;
 */
public class GroupProperty
{
    /**
     * Name of the GroupProperty element.
     */
    public static final String NAME = "property";
    
    /**
     * Name of the property key attribute in the GroupProperty element.
     */
    public static final String KEY_ATTRIBUTE = "key";
    
    /**
     * Name of the property type attribute in the GroupProperty element.
     */
    public static final String TYPE_ATTRIBUTE = "type";
    
    /**
     * Name of the property readOnly attribute in the GroupProperty element.
     */
    public static final String READONLY_ATTRIBUTE = "readOnly";
    
    /**
     * Allowed types.
     */
    public static final String STRING_TYPE = "String";
    public static final String INTEGER_TYPE = "Integer";
    
    // The property identifier
    private String key;
    
+123 −0
Original line number Diff line number Diff line
/*
 ************************************************************************
 ****  C A N A D I A N   A S T R O N O M Y   D A T A   C E N T R E  *****
 *
 * (c) 2014.                            (c) 2014.
 * National Research Council            Conseil national de recherches
 * Ottawa, Canada, K1A 0R6              Ottawa, Canada, K1A 0R6
 * All rights reserved                  Tous droits reserves
 *
 * NRC disclaims any warranties         Le CNRC denie toute garantie
 * expressed, implied, or statu-        enoncee, implicite ou legale,
 * tory, of any kind with respect       de quelque nature que se soit,
 * to the software, including           concernant le logiciel, y com-
 * without limitation any war-          pris sans restriction toute
 * ranty of merchantability or          garantie de valeur marchande
 * fitness for a particular pur-        ou de pertinence pour un usage
 * pose.  NRC shall not be liable       particulier.  Le CNRC ne
 * in any event for any damages,        pourra en aucun cas etre tenu
 * whether direct or indirect,          responsable de tout dommage,
 * special or general, consequen-       direct ou indirect, particul-
 * tial or incidental, arising          ier ou general, accessoire ou
 * from the use of the software.        fortuit, resultant de l'utili-
 *                                      sation du logiciel.
 *
 *
 * @author adriand
 *
 * @version $Revision: $
 *
 *
 ****  C A N A D I A N   A S T R O N O M Y   D A T A   C E N T R E  *****
 ************************************************************************
 */

package ca.nrc.cadc.ac;

import java.util.UUID;

/**
 * Class that represents a numeric id. This is useful for
 * representing an internal user key reference.
 */
public class InternalID
{
    private UUID id;
    private String authority;

    /**
     * Ctor
     * @param id unique identifier
     */
    public InternalID(UUID id, String authority)
    {
        if (id == null)
        {
            throw new IllegalArgumentException("id is null");
        }
        if (authority == null || authority.isEmpty())
        {
            throw new IllegalArgumentException("authority is null or empty");
        }

        this.id = id;
        this.authority = authority;
    }

    public UUID getId()
    {
        return id;
    }

    public String getAuthority()
    {
        return authority;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode()
    {
        int prime = 31;
        int result = 1;
        result = prime * result + id.hashCode();
        result = prime * result + authority.toLowerCase().hashCode();
        return result;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj)
    {
        if (this == obj)
        {
            return true;
        }
        if (obj == null)
        {
            return false;
        }
        if (!(obj instanceof InternalID))
        {
            return false;
        }
        InternalID other = (InternalID) obj;
        if (id.equals(other.id) &&
            authority.equalsIgnoreCase(other.authority))
        {
            return true;
        }
        return false;
    }

    @Override
    public String toString()
    {
        return getClass().getSimpleName() + "[" + id + "," + authority + "]";
    }

}
+9 −49
Original line number Diff line number Diff line
@@ -68,48 +68,8 @@
 */
package ca.nrc.cadc.ac;

public class PersonalDetails implements UserDetails
public class PersonalDetails
{
    /**
     * Name of the PersonalDetails element.
     */
    public static final String NAME = "personalDetails";
    
    /**
     * Name of the firstName element.
     */
    public static final String FIRSTNAME = "firstName";
    
    /**
     * Name of the lastName element.
     */
    public static final String LASTNAME = "lastName";
    
    /**
     * Name of the email element.
     */
    public static final String EMAIL = "email";
    
    /**
     * Name of the email element.
     */
    public static final String ADDRESS = "address";
    
    /**
     * Name of the email element.
     */
    public static final String INSTITUTE = "institute";
    
    /**
     * Name of the email element.
     */
    public static final String CITY = "city";
    
    /**
     * Name of the email element.
     */
    public static final String COUNTRY = "country";
        
    private String firstName;
    private String lastName;
    public String email;
@@ -205,14 +165,14 @@ public class PersonalDetails implements UserDetails
     */
    public String toStringFormatted()
    {
    	StringBuffer sb = new StringBuffer(NAME + "\n");
    	sb.append(FIRSTNAME + ": " + firstName +"\n");
    	sb.append(LASTNAME + ": " + lastName +"\n");
    	sb.append(EMAIL + ": " + email +"\n");
    	sb.append(ADDRESS + ": " + address +"\n");
    	sb.append(INSTITUTE + ": " + institute +"\n");
    	sb.append(CITY + ": " + city +"\n");
    	sb.append(COUNTRY + ": " + country +"\n");
    	StringBuffer sb = new StringBuffer("PersonalDetails" + "\n");
    	sb.append("firstName" + ": " + firstName +"\n");
    	sb.append("lastName" + ": " + lastName +"\n");
    	sb.append("email" + ": " + email +"\n");
    	sb.append("address" + ": " + address +"\n");
    	sb.append("institute" + ": " + institute +"\n");
    	sb.append("city" + ": " + city +"\n");
    	sb.append("country" + ": " + country +"\n");
	
    	
    	return sb.toString();
Loading