X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cadi%2Faaf%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2Fsso%2FAAFSSO.java;h=c197be2639126cebe0312706d26cddb350ddc9f0;hb=2c0dd5c5136e249f63f1d3296063795cde30c399;hp=7d01b70bea0bfc11e21566b17a56dec41df7694e;hpb=5f1a6a0ab09ea3fa4199a8d413af75d4378e2a8e;p=aaf%2Fauthz.git diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/sso/AAFSSO.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/sso/AAFSSO.java index 7d01b70b..c197be26 100644 --- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/sso/AAFSSO.java +++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/sso/AAFSSO.java @@ -69,20 +69,28 @@ public class AAFSSO { private boolean ok; public AAFSSO(String[] args) throws IOException, CadiException { + this(args,new Properties()); + } + + public AAFSSO(String[] args, ProcessArgs pa) throws IOException, CadiException { + this(args,pa.process(args, new Properties())); + } + + public AAFSSO(String[] args, Properties dp) throws IOException, CadiException { + stdOutOrig = System.out; + stdErrOrig = System.err; ok = true; List nargs = parseArgs(args); - diskprops = new Properties(); + diskprops = dp; touchDiskprops = false; dot_aaf = new File(System.getProperty("user.home") + "/.aaf"); if (!dot_aaf.exists()) { dot_aaf.mkdirs(); } - stdOutOrig = System.out; - stdErrOrig = System.err; File f = new File(dot_aaf, "sso.out"); os = new PrintStream(new FileOutputStream(f, true)); - System.setOut(os); + //System.setOut(os); System.setErr(os); sso = new File(dot_aaf, "sso.props"); @@ -174,6 +182,12 @@ public class AAFSSO { appID=null; } + if(appID!=null && access.getProperty(Config.AAF_APPPASS)==null) { + char[] password = cons.readPassword("Password for %s: ", appID); + String app_pass = access.encrypt(new String(password)); + access.setProperty(Config.AAF_APPPASS,app_pass); + } + String keystore=access.getProperty(Config.CADI_KEYSTORE); String keystore_pass=access.getProperty(Config.CADI_KEYSTORE_PASSWORD); @@ -183,6 +197,7 @@ public class AAFSSO { for (File tsf : dot_aaf.listFiles()) { name = tsf.getName(); if (!name.contains("trust") && (name.endsWith(".jks") || name.endsWith(".p12"))) { + setLogDefault(); select = cons.readLine("Use %s for Identity? (y/n): ",tsf.getName()); if("y".equalsIgnoreCase(select)) { keystore = tsf.getCanonicalPath(); @@ -282,14 +297,14 @@ public class AAFSSO { String locateUrl = access.getProperty(Config.AAF_LOCATE_URL); if(locateUrl==null) { - locateUrl=AAFSSO.cons.readLine("AAF Locator FQDN/machine[:port]=https://"); + locateUrl=AAFSSO.cons.readLine("AAF Locator URL=https://"); if(locateUrl==null || locateUrl.length()==0) { err = new StringBuilder(Config.AAF_LOCATE_URL); err.append(" is required."); ok = false; return; } else { - locateUrl="https://"+locateUrl+"/locate"; + locateUrl="https://"+locateUrl; } access.setProperty(Config.AAF_LOCATE_URL, locateUrl); addProp(Config.AAF_LOCATE_URL, locateUrl); @@ -470,4 +485,8 @@ public class AAFSSO { public boolean ok() { return ok; } + + public static interface ProcessArgs { + public Properties process(final String[] args, final Properties props); + } }