Commit 966ea7a5 authored by Patrick Dowler's avatar Patrick Dowler Committed by GitHub
Browse files

Merge pull request #12 from pdowler/master

fix Delegations hashCode generation (issue #8)
parents b381dbb8 654d1b39
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -14,7 +14,7 @@ sourceCompatibility = 1.7


group = 'org.opencadc'
group = 'org.opencadc'


version = '1.1'
version = '1.1.1'


dependencies {
dependencies {
    compile 'log4j:log4j:1.+'
    compile 'log4j:log4j:1.+'
+13 −3
Original line number Original line Diff line number Diff line
package org.astrogrid.security.delegation;
package org.astrogrid.security.delegation;


import ca.nrc.cadc.auth.X509CertificateChain;
import java.io.IOException;
import java.io.IOException;
import java.io.Writer;
import java.io.Writer;
import java.security.GeneralSecurityException;
import java.security.GeneralSecurityException;
@@ -60,7 +61,7 @@ public abstract class Delegations
     */
     */
    public String hash(X500Principal principal)
    public String hash(X500Principal principal)
    {
    {
        return Integer.toString(principal.hashCode());
        return X509CertificateChain.genHashKey(principal);
    }
    }


    /**
    /**
@@ -69,7 +70,9 @@ public abstract class Delegations
     * a key pair and a CSR are generated and stored; the certificate
     * a key pair and a CSR are generated and stored; the certificate
     * property is set to null.
     * property is set to null.
     * 
     * 
     * @param identity
     * @return The hash of the distinguished name.
     * @return The hash of the distinguished name.
     * @throws java.security.GeneralSecurityException
     */
     */
    public abstract String initializeIdentity(String identity)
    public abstract String initializeIdentity(String identity)
            throws GeneralSecurityException;
            throws GeneralSecurityException;
@@ -83,6 +86,7 @@ public abstract class Delegations
     * @param principal
     * @param principal
     *            The distinguished name on which to base the identity.
     *            The distinguished name on which to base the identity.
     * @return The hash key corresponding to the distinguished name.
     * @return The hash key corresponding to the distinguished name.
     * @throws java.security.GeneralSecurityException
     */
     */
    public abstract String initializeIdentity(X500Principal principal)
    public abstract String initializeIdentity(X500Principal principal)
        throws GeneralSecurityException;
        throws GeneralSecurityException;
@@ -104,8 +108,12 @@ public abstract class Delegations
     * Stores a certificate for the given identity. Any previous
     * Stores a certificate for the given identity. Any previous
     * certificate is overwritten. This operation is thread-safe against
     * certificate is overwritten. This operation is thread-safe against
     * concurrent reading of the certificate.
     * concurrent reading of the certificate.
     * @param hashKey
     * @param certificates
     * @throws java.security.InvalidKeyException
     */
     */
    public abstract void setCertificates(String hashKey, X509Certificate[] certificates) throws InvalidKeyException;
    public abstract void setCertificates(String hashKey, X509Certificate[] certificates) 
        throws InvalidKeyException;


    public abstract Object[] getPrincipals();
    public abstract Object[] getPrincipals();


@@ -125,6 +133,7 @@ public abstract class Delegations
     * 
     * 
     * @param hashKey
     * @param hashKey
     *            The hash key identifying the user.
     *            The hash key identifying the user.
     * @return 
     */
     */
    public abstract boolean hasCertificate(String hashKey);
    public abstract boolean hasCertificate(String hashKey);


@@ -135,6 +144,7 @@ public abstract class Delegations
     *            The hash key identifying the user.
     *            The hash key identifying the user.
     * @param out
     * @param out
     *            The destination for the certificate.
     *            The destination for the certificate.
     * @throws java.io.IOException
     */
     */
    public abstract void writeCertificate(String hashKey, Writer out)
    public abstract void writeCertificate(String hashKey, Writer out)
            throws IOException;
            throws IOException;