X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cadi%2Faaf%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2Foauth%2FTokenClientFactory.java;h=6d2fd7fc07ff44b431682d3f9db3fb2a55ad3758;hb=1296352d8eafee57f982a4342ad79ada4aa56d28;hp=14cf0f6217be148c9471e5d5d2cdb9660924a9f3;hpb=9f1388eb5ac3f9aab5fe617eae55b08fd2a57059;p=aaf%2Fauthz.git diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/oauth/TokenClientFactory.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/oauth/TokenClientFactory.java index 14cf0f62..6d2fd7fc 100644 --- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/oauth/TokenClientFactory.java +++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/oauth/TokenClientFactory.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -65,40 +65,40 @@ public class TokenClientFactory extends Persist { private TokenClientFactory(Access pa) throws APIException, GeneralSecurityException, IOException, CadiException { super(pa, new RosettaEnv(pa.getProperties()),Token.class,"outgoing"); - + Map aaf_urls = Agent.loadURLs(pa); alts = new TreeSet<>(); - + if (access.getProperty(Config.AAF_OAUTH2_TOKEN_URL,null)==null) { access.getProperties().put(Config.AAF_OAUTH2_TOKEN_URL, aaf_urls.get(Config.AAF_OAUTH2_TOKEN_URL)); // Default to AAF } - + if (access.getProperty(Config.AAF_OAUTH2_INTROSPECT_URL,null)==null) { access.getProperties().put(Config.AAF_OAUTH2_INTROSPECT_URL, aaf_urls.get(Config.AAF_OAUTH2_INTROSPECT_URL)); // Default to AAF); } - + for(String tag : new String[] {Config.AAF_ALT_OAUTH2_TOKEN_URL, Config.AAF_ALT_OAUTH2_INTROSPECT_URL}) { - String value = access.getProperty(tag, null); - if(value!=null) { - alts.add(tag); - alts.add(value); - } + String value = access.getProperty(tag, null); + if(value!=null) { + alts.add(tag); + alts.add(value); + } } - + symm = Symm.encrypt.obtain(); hsi = SecurityInfoC.instance(access, HttpURLConnection.class); } - + public synchronized static final TokenClientFactory instance(Access access) throws APIException, GeneralSecurityException, IOException, CadiException { if (instance==null) { instance = new TokenClientFactory(access); } return instance; } - + /** * Pickup Timeout from Properties - * + * * @param tagOrURL * @return * @throws CadiException @@ -108,7 +108,7 @@ public class TokenClientFactory extends Persist { public TokenClient newClient(final String tagOrURL) throws CadiException, LocatorException, APIException { return newClient(tagOrURL,Integer.parseInt(access.getProperty(Config.AAF_CONN_TIMEOUT, Config.AAF_CONN_TIMEOUT_DEF))); } - + public TokenClient newClient(final String tagOrURL, final int timeout) throws CadiException, LocatorException, APIException { AAFConHttp ach; if (tagOrURL==null) { @@ -121,7 +121,7 @@ public class TokenClientFactory extends Persist { } char okind; if (alts.contains(tagOrURL)) { - okind = Kind.OAUTH; + okind = Kind.OAUTH; } else { okind = Kind.AAF_OAUTH; } @@ -134,7 +134,7 @@ public class TokenClientFactory extends Persist { tci.client_creds(access); return tci; } - + public TzClient newTzClient(final String locatorURL) throws CadiException, LocatorException { try { return new TzHClient(access,hsi,bestLocator(locatorURL)); @@ -180,7 +180,7 @@ public class TokenClientFactory extends Persist { put(key,tt); return tt; } - + private static final Pattern locatePattern = Pattern.compile("https://.*/locate/.*"); public Locator bestLocator(final String locatorURL ) throws LocatorException, URISyntaxException { if (locatorURL==null) {