/*
 ************************************************************************
 ****  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.auth;

import java.io.Serializable;
import java.security.Principal;
import java.util.UUID;

/**
 * Class that represents a numeric Principal. This is useful for
 * representing an internal user key reference.
 */
public class NumericPrincipal implements Principal, Serializable
{
    private static final long serialVersionUID = 20140625143750l;
    private UUID numericID;

    /**
     * Ctor
     * @param numericID unique identifier
     */
    public NumericPrincipal(UUID numericID)
    {
        this.numericID = numericID;
    }
    
    @Override
    public String getName()
    {
        return numericID.toString();
    }

    /* (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode()
    {
        final int prime = 31;
        int result = 1;
        result = prime * result + numericID.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 NumericPrincipal))
        {
            return false;
        }
        NumericPrincipal other = (NumericPrincipal) obj;
        if (numericID.equals(other.numericID))
        {
            return true;
        }
        return false;
    }
       
    @Override
    public String toString()
    {
        return getClass().getSimpleName() + "[" + getName() + "]";
    }

}

@@ -3106,65 +3106,372 @@
     
-return getClass().getSimpleName() + %22%5B%22 + getName() + %22%5D%22
+StringBuilder sb = new StringBuilder();%0A        sb.append(getClass().getSimpleName());%0A        sb.append(%22%5B%22);%0A        if (numericID.getMostSignificantBits() == 0L)%0A        %7B%0A            sb.append(numericID.getLeastSignificantBits());%0A        %7D%0A        else%0A        %7B%0A            sb.append(getName());%0A        %7D%0A        sb.append(%22%5D%22);%0A        return sb.toString()
 ;%0A  

update toString output of NumericID