Commit 6f7c2fa0 authored by Patrick Dowler's avatar Patrick Dowler
Browse files

fix command-line help, added one-arg delegate method so self-delegation (IVOA)...

fix command-line help, added one-arg delegate method so self-delegation (IVOA) is clear; added remvoal of expired chain from subject in CredUtil
parent 50f7157f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ sourceCompatibility = 1.7

group = 'org.opencadc'

version = '1.1'
version = '1.1.1'

mainClassName = 'ca.nrc.cadc.cred.client.Main'

+30 −2
Original line number Diff line number Diff line
@@ -210,9 +210,37 @@ public class CredClient
    }

    /**
     * Delegate credentials to the service (IVOA CDP-1.0).
     * Delegate current subject credentials to the service (IVOA CDP-1.0).
     * 
     * @param userDN
     * @param days
     * @throws MalformedURLException
     * @throws IOException
     * @throws InvalidKeyException
     * @throws NoSuchProviderException
     * @throws NoSuchAlgorithmException
     * @throws SignatureException
     * @throws CertificateEncodingException
     * @throws CertificateParsingException
     * @throws CertificateExpiredException
     * @throws CertificateNotYetValidException 
     * @throws ca.nrc.cadc.net.ResourceNotFoundException 
     */
    public void delegate(double days)
            throws MalformedURLException, IOException,
            InvalidKeyException, NoSuchProviderException,
            NoSuchAlgorithmException, SignatureException,
            CertificateEncodingException, CertificateParsingException,
            CertificateExpiredException, CertificateNotYetValidException, ResourceNotFoundException
    {
        delegate(null, days);
    }
    
    /**
     * Custom delegation method that allows the caller to have a different DN from
     * the created certificate DN. This feature allows the caller/signer to use the
     * CDP service as a certificate authority (see: cadc-cert-gen).
     * 
     * @param userDN target DN to create; null for self-delegation
     * @param days
     * @throws MalformedURLException
     * @throws IOException
+9 −1
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ import java.security.PrivilegedExceptionAction;
import java.security.cert.CertificateException;
import java.security.cert.CertificateExpiredException;
import java.security.cert.CertificateNotYetValidException;
import java.util.Iterator;
import javax.security.auth.Subject;
import org.apache.log4j.Logger;

@@ -196,7 +197,14 @@ public class CredUtil
                }

                privateKeyChain.getChain()[0].checkValidity();

                // carefully remove the previous chain
                Iterator iter = subject.getPublicCredentials().iterator();
                while ( iter.hasNext() )
                {
                    Object o = iter.next();
                    if (o instanceof X509CertificateChain)
                        iter.remove();
                }
                subject.getPublicCredentials().add(privateKeyChain);
            }
        }
+4 −4
Original line number Diff line number Diff line
@@ -229,7 +229,7 @@ public class Main implements PrivilegedAction<Boolean>
    {
        try
        {
            client.delegate(null, daysValid);
            client.delegate(daysValid);
            msg("Certificate updated");
        }
        catch (Exception e)
@@ -425,10 +425,10 @@ public class Main implements PrivilegedAction<Boolean>
    public static void usage()
    {
        String[] um = {
                "Usage: java -jar cadcCDP.jar [-v|--verbose|-d|--debug] --resourceID=<CDP service to use> <op> ...",
                "Usage: cadc-cdp [-v|--verbose|-d|--debug] --resourceID=<CDP service to use> <op> ...",
                CertCmdArgUtil.getCertArgUsage(),
                "",
                "Help: java -jar cadcCDP.jar <-h | --help>",
                "Help: cadc-cdp <-h|--help>",
                "",
                "  --resourceID specifies the CDP service to use (e.g. ivo://cadc.nrc.ca/cred)",
                "",
@@ -439,7 +439,7 @@ public class Main implements PrivilegedAction<Boolean>
                "  --get --userdn=<user distinguished name> [--out=<file>] [--daysValid=<days>] ",
                "          get a new (shorter) proxy certificate from the server;",
                "  --view",
                "          view the currently deleagted proxy certificate",
                "          view the currently delegated proxy certificate",
        };

        for (String line : um)