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 Diff line number Diff line
@@ -14,7 +14,7 @@ sourceCompatibility = 1.7

group = 'org.opencadc'

version = '1.1'
version = '1.1.1'

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

import ca.nrc.cadc.auth.X509CertificateChain;
import java.io.IOException;
import java.io.Writer;
import java.security.GeneralSecurityException;
@@ -60,7 +61,7 @@ public abstract class Delegations
     */
    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
     * property is set to null.
     * 
     * @param identity
     * @return The hash of the distinguished name.
     * @throws java.security.GeneralSecurityException
     */
    public abstract String initializeIdentity(String identity)
            throws GeneralSecurityException;
@@ -83,6 +86,7 @@ public abstract class Delegations
     * @param principal
     *            The distinguished name on which to base the identity.
     * @return The hash key corresponding to the distinguished name.
     * @throws java.security.GeneralSecurityException
     */
    public abstract String initializeIdentity(X500Principal principal)
        throws GeneralSecurityException;
@@ -104,8 +108,12 @@ public abstract class Delegations
     * Stores a certificate for the given identity. Any previous
     * certificate is overwritten. This operation is thread-safe against
     * 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();

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

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