X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-core%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Fserver%2FAbsService.java;h=02d9351274e375e2406135d1e50922ba46e70075;hb=aae5c072bcb4608ae87c70fd1edf7ac5b1794ccf;hp=0c28c7caeddbb9be6735bb28519e331fc7bb8be1;hpb=ca76fbda94492f1b0c895ff0f4070381f17472f0;p=aaf%2Fauthz.git diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java index 0c28c7ca..02d93512 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java @@ -34,6 +34,7 @@ import org.onap.aaf.cadi.Access; import org.onap.aaf.cadi.Access.Level; import org.onap.aaf.cadi.CadiException; import org.onap.aaf.cadi.LocatorException; +import org.onap.aaf.cadi.aaf.Defaults; import org.onap.aaf.cadi.aaf.v2_0.AAFConHttp; import org.onap.aaf.cadi.client.Rcli; import org.onap.aaf.cadi.client.Retryable; @@ -47,88 +48,91 @@ import org.onap.aaf.misc.env.Trans; import org.onap.aaf.misc.env.impl.BasicEnv; public abstract class AbsService extends RServlet { - public final Access access; - public final ENV env; - private AAFConHttp aafCon; - - public final String app_name; - public final String app_version; - public final String app_interface_version; - public final String ROOT_NS; + public final Access access; + public final ENV env; + private AAFConHttp aafCon; + public final String app_name; + public final String app_version; + public final String ROOT_NS; + public AbsService(final Access access, final ENV env) throws CadiException { - Define.set(access); - ROOT_NS = Define.ROOT_NS(); - this.access = access; - this.env = env; + Define.set(access); + ROOT_NS = Define.ROOT_NS(); + this.access = access; + this.env = env; - String component = access.getProperty(Config.AAF_COMPONENT, null); - final String[] locator_deploy; - - if(component == null) { - locator_deploy = null; - } else { - locator_deploy = Split.splitTrim(':', component); - } - - if(component == null || locator_deploy==null || locator_deploy.length<2) { - throw new CadiException("AAF Component must include the " + Config.AAF_COMPONENT + " property, :[] registrants(final int port) throws CadiException, LocatorException; + public abstract Registrant[] registrants(final int actualPort) throws CadiException, LocatorException; - // Lazy Instantiation + // Lazy Instantiation public synchronized AAFConHttp aafCon() throws CadiException, LocatorException { - if(aafCon==null) { - if(access.getProperty(Config.AAF_URL,null)!=null) { - aafCon = _newAAFConHttp(); - } else { - throw new CadiException("AAFCon cannot be constructed without " + Config.AAF_URL); - } - } - return aafCon; + if (aafCon==null) { + if (access.getProperty(Config.AAF_URL,null)!=null) { + aafCon = _newAAFConHttp(); + } else { + throw new CadiException("AAFCon cannot be constructed without " + Config.AAF_URL); + } + } + return aafCon; } /** @@ -136,55 +140,51 @@ public abstract class AbsService exte * @return * @throws LocatorException */ - protected synchronized AAFConHttp _newAAFConHttp() throws CadiException, LocatorException { - try { - if(aafCon==null) { - aafCon = new AAFConHttp(access); - } - return aafCon; - } catch (APIException e) { - throw new CadiException(e); - } - } + protected synchronized AAFConHttp _newAAFConHttp() throws CadiException, LocatorException { + if (aafCon==null) { + aafCon = new AAFConHttp(access); + } + return aafCon; + + } // This is a method, so we can overload for AAFAPI public String aaf_url() { - return access.getProperty(Config.AAF_URL, null); + return access.getProperty(Config.AAF_URL, null); } - public Rcli client() throws CadiException { - return aafCon.client(Config.AAF_DEFAULT_VERSION); - } - - public Rcli clientAsUser(TaggedPrincipal p) throws CadiException { - return aafCon.client(Config.AAF_DEFAULT_VERSION).forUser( - new HTransferSS(p,app_name, aafCon.securityInfo())); - } + public Rcli client() throws CadiException { + return aafCon.client(); + } - public RET clientAsUser(TaggedPrincipal p,Retryable retryable) throws APIException, LocatorException, CadiException { - return aafCon.hman().best(new HTransferSS(p,app_name, aafCon.securityInfo()), retryable); - } - - protected static final String loadFromArgOrSystem(final Properties props, final String tag, final String args[], final String def) { - String tagEQ = tag + '='; - String value; - for(String arg : args) { - if(arg.startsWith(tagEQ)) { - props.put(tag, value=arg.substring(tagEQ.length())); - return value; - } - } - // check System.properties - value = System.getProperty(tag); - if(value!=null) { - props.put(tag, value); - return value; - } - - if(def!=null) { - props.put(tag,def); - } - return def; - } + public Rcli clientAsUser(TaggedPrincipal p) throws CadiException { + return aafCon.client().forUser( + new HTransferSS(p,app_name, aafCon.securityInfo())); + } + public RET clientAsUser(TaggedPrincipal p,Retryable retryable) throws APIException, LocatorException, CadiException { + return aafCon.hman().best(new HTransferSS(p,app_name, aafCon.securityInfo()), retryable); + } + + protected static final String loadFromArgOrSystem(final Properties props, final String tag, final String args[], final String def) { + String tagEQ = tag + '='; + String value; + for (String arg : args) { + if (arg.startsWith(tagEQ)) { + props.put(tag, value=arg.substring(tagEQ.length())); + return value; + } + } + // check System.properties + value = System.getProperty(tag); + if (value!=null) { + props.put(tag, value); + return value; + } + + if (def!=null) { + props.put(tag,def); + } + return def; + } }