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=4193197676a5927fcad8e96cdabfb04da5e8b6c1;hb=refs%2Fchanges%2F51%2F56951%2F1;hp=522568a92b2132c2de56b7c7681b86097dabee94;hpb=4906c14f770e85452240fc8e04807b6114fab1ca;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 522568a9..41931976 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 @@ -38,6 +38,7 @@ import org.onap.aaf.cadi.Access.Level; import org.onap.aaf.cadi.CadiException; import org.onap.aaf.cadi.PropAccess; import org.onap.aaf.cadi.Symm; +import org.onap.aaf.cadi.aaf.Defaults; import org.onap.aaf.cadi.config.Config; import org.onap.aaf.cadi.util.MyConsole; import org.onap.aaf.cadi.util.SubStandardConsole; @@ -69,20 +70,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"); @@ -95,11 +104,6 @@ public class AAFSSO { } } -// String keyfile = diskprops.getProperty(Config.CADI_KEYFILE); -// if(keyfile==null) { -// keyfile = dot_aaf.getCanonicalPath()+".keyfile"; -// touchDiskprops=true; -// } File dot_aaf_kf = new File(dot_aaf, "keyfile"); if (removeSSO) { @@ -179,6 +183,13 @@ 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); + diskprops.setProperty(Config.AAF_APPPASS, app_pass); + } + String keystore=access.getProperty(Config.CADI_KEYSTORE); String keystore_pass=access.getProperty(Config.CADI_KEYSTORE_PASSWORD); @@ -188,6 +199,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(); @@ -287,22 +299,21 @@ 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); } - String aafUrl = "https://AAF_LOCATE_URL/AAF_NS.service/2.0"; - access.setProperty(Config.AAF_URL, aafUrl); - access.setProperty(Config.CM_URL, "https://AAF_LOCATE_URL/AAF_NS.cm/2.0"); + access.setProperty(Config.AAF_URL, Defaults.AAF_URL); + access.setProperty(Config.CM_URL, Defaults.CM_URL); String cadiLatitude = access.getProperty(Config.CADI_LATITUDE); if(cadiLatitude==null) { System.out.println("# If you do not know your Global Coordinates, we suggest bing.com/maps"); @@ -366,7 +377,7 @@ public class AAFSSO { public void setStdErrDefault() { access.setLogLevel(PropAccess.DEFAULT); - System.setOut(stdErrOrig); + System.setErr(stdErrOrig); } public void setLogDefault(Level level) { @@ -443,7 +454,7 @@ public class AAFSSO { private List parseArgs(String[] args) { - List larg = new ArrayList(args.length); + List larg = new ArrayList<>(args.length); // Cover for bash's need to escape *.. (\\*) // also, remove SSO if required @@ -475,4 +486,8 @@ public class AAFSSO { public boolean ok() { return ok; } + + public static interface ProcessArgs { + public Properties process(final String[] args, final Properties props); + } }