X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cadi%2Faaf%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2Foauth%2FTzHClient.java;h=241abf41ddb80b3fb9bbd827e02307de08152ac9;hb=1296352d8eafee57f982a4342ad79ada4aa56d28;hp=c565fa8478b2f4c6d4d824593b3bf38c12abde18;hpb=a20accc73189d8e5454cd26049c0e6fae75da16f;p=aaf%2Fauthz.git diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/oauth/TzHClient.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/oauth/TzHClient.java index c565fa84..241abf41 100644 --- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/oauth/TzHClient.java +++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/oauth/TzHClient.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. @@ -40,43 +40,43 @@ import org.onap.aaf.misc.env.APIException; /** * Tokenized HClient - * + * * @author Jonathan * */ public class TzHClient extends TzClient { - private HMangr hman; - public SecurityInfoC si; - private TimedToken token; - private SecuritySetter tokenSS; + private HMangr hman; + public SecurityInfoC si; + private TimedToken token; + private SecuritySetter tokenSS; + + public TzHClient(Access access, String tagOrURL) throws CadiException, LocatorException { + try { + si = SecurityInfoC.instance(access, HttpURLConnection.class); + hman = new HMangr(access, new AAFLocator(si,new URI(access.getProperty(tagOrURL, tagOrURL)))); + } catch (URISyntaxException e) { + throw new CadiException(e); + } + } + public TzHClient(Access access, SecurityInfoC hsi, Locator loc) throws LocatorException { + si = hsi; + hman = new HMangr(access, loc); + } - public TzHClient(Access access, String tagOrURL) throws CadiException, LocatorException { - try { - si = SecurityInfoC.instance(access, HttpURLConnection.class); - hman = new HMangr(access, new AAFLocator(si,new URI(access.getProperty(tagOrURL, tagOrURL)))); - } catch (URISyntaxException e) { - throw new CadiException(e); - } - } - public TzHClient(Access access, SecurityInfoC hsi, Locator loc) throws LocatorException { - si = hsi; - hman = new HMangr(access, loc); - } - - public void setToken(final String client_id, TimedToken token) throws IOException { - this.token = token; - tokenSS = new HTokenSS(si, client_id, token.getAccessToken()); - } + public void setToken(final String client_id, TimedToken token) throws IOException { + this.token = token; + tokenSS = new HTokenSS(si, client_id, token.getAccessToken()); + } - public RET best (Retryable retryable) throws CadiException, LocatorException, APIException { - if(token == null || tokenSS==null) { - throw new CadiException("OAuth2 Token has not been set"); - } - if(token.expired()) { - //TODO Refresh? - throw new CadiException("Expired Token"); - } else { - return hman.best(tokenSS, retryable); - } - } + public RET best (Retryable retryable) throws CadiException, LocatorException, APIException { + if (token == null || tokenSS==null) { + throw new CadiException("OAuth2 Token has not been set"); + } + if (token.expired()) { + //TODO Refresh? + throw new CadiException("Expired Token"); + } else { + return hman.best(tokenSS, retryable); + } + } }