/** * Init a subject from the command line and throw an exception if not * successful. * * @see initSubject(ArgumentMap) * @param argMap * @return */ public static Subject initSubject(ArgumentMap argMap) { return initSubject(argMap, false); }
private static Subject initSubjectByCertKey(String fnCert, String fnKey, boolean nullOnNotFound) { File certFile = loadFile(fnCert, nullOnNotFound); File keyFile = loadFile(fnKey, nullOnNotFound); if (nullOnNotFound && certFile == null && keyFile == null) return null; return SSLUtil.createSubject(certFile, keyFile); }
/** * Formats the usage message. */ public static void usage() { String[] um = { "Usage: cadc-cdp [-v|--verbose|-d|--debug] --resourceID=<CDP service to use> <op> ...", CertCmdArgUtil.getCertArgUsage(), "", "Help: cadc-cdp <-h|--help>", "", " --resourceID specifies the CDP service to use (e.g. ivo://cadc.nrc.ca/cred)", "", " <op> is one of: ", " --delegate [--daysValid=<days>]", " create new proxy certificate on the server", " --get --userid=<username> [--out=<file>] [--daysValid=<days>] ", " --get --userdn=<user distinguished name> [--out=<file>] [--daysValid=<days>] ", " get a new (shorter) proxy certificate from the server;", " --view", " view the currently delegated proxy certificate", }; for (String line : um) msg(line); }
subject = initSubjectByCertKey(strCert, strKey, false); subject = initSubjectByPem(strCertKey, false); try subject = initSubjectByPem(strCertKey, returnNullOnNotFound); try subject = initSubjectByCertKey(strCert, strKey, returnNullOnNotFound);
CertCmdArgUtil.getCertArgUsage(), "", " Note: --xsv=off disables XML schema validation; use at your own risk ",
subject = CertCmdArgUtil.initSubject(argMap);
private static Subject initSubjectByPem(String fnPem, boolean nullOnNotFound) { File certKeyFile = loadFile(fnPem, nullOnNotFound); if (nullOnNotFound && certKeyFile == null) return null; return SSLUtil.createSubject(certKeyFile); }
} else if (argMap.isSet("cert")) { this.subject = CertCmdArgUtil.initSubject(argMap);
public static void main(String[] args) { ArgumentMap argMap = new ArgumentMap(args); if (argMap.isSet(ARG_HELP) || argMap.isSet(ARG_H)) { usage(); System.exit(0); } // Set debug mode if (argMap.isSet(ARG_DEBUG) || argMap.isSet(ARG_D)) { Log4jInit.setLevel("ca.nrc.cadc.ac.client", Level.DEBUG); Log4jInit.setLevel("ca.nrc.cadc.net", Level.DEBUG); } else if (argMap.isSet(ARG_VERBOSE) || argMap.isSet(ARG_V)) { Log4jInit.setLevel("ca.nrc.cadc.ac.client", Level.INFO); } else Log4jInit.setLevel("ca", Level.WARN); Main main = new Main(argMap); Subject subject = CertCmdArgUtil.initSubject(argMap, true); final Object response; if (subject != null) response = Subject.doAs(subject, main); else response = main.run(); log.debug("Response: " + response); }