+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cadi.aaf.v2_0;\r
-\r
-import java.io.IOException;\r
-import java.net.HttpURLConnection;\r
-import java.net.URI;\r
-import java.security.GeneralSecurityException;\r
-import java.security.Principal;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.Locator;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.PropAccess;\r
-import org.onap.aaf.cadi.SecuritySetter;\r
-import org.onap.aaf.cadi.Locator.Item;\r
-import org.onap.aaf.cadi.client.AbsTransferSS;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.cadi.config.Config;\r
-import org.onap.aaf.cadi.config.SecurityInfoC;\r
-import org.onap.aaf.cadi.http.HBasicAuthSS;\r
-import org.onap.aaf.cadi.http.HMangr;\r
-import org.onap.aaf.cadi.http.HRcli;\r
-import org.onap.aaf.cadi.http.HTransferSS;\r
-import org.onap.aaf.cadi.http.HX509SS;\r
-import org.onap.aaf.cadi.principal.BasicPrincipal;\r
-\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-public class AAFConHttp extends AAFCon<HttpURLConnection> {\r
- private final HMangr hman;\r
-\r
- public AAFConHttp(PropAccess access) throws CadiException, GeneralSecurityException, IOException {\r
- super(access,Config.AAF_URL,new SecurityInfoC<HttpURLConnection>(access));\r
- hman = new HMangr(access,Config.loadLocator(access, access.getProperty(Config.AAF_URL,null)));\r
- }\r
-\r
- public AAFConHttp(PropAccess access, String tag) throws CadiException, GeneralSecurityException, IOException {\r
- super(access,tag,new SecurityInfoC<HttpURLConnection>(access));\r
- hman = new HMangr(access,Config.loadLocator(access, access.getProperty(tag,null)));\r
- }\r
-\r
- public AAFConHttp(PropAccess access, String urlTag, SecurityInfoC<HttpURLConnection> si) throws CadiException {\r
- super(access,urlTag,si);\r
- hman = new HMangr(access,Config.loadLocator(access, access.getProperty(urlTag,null)));\r
- }\r
-\r
- public AAFConHttp(PropAccess access, Locator<URI> locator) throws CadiException, GeneralSecurityException, IOException {\r
- super(access,Config.AAF_URL,new SecurityInfoC<HttpURLConnection>(access));\r
- hman = new HMangr(access,locator);\r
- }\r
-\r
- public AAFConHttp(PropAccess access, Locator<URI> locator, SecurityInfoC<HttpURLConnection> si) throws CadiException {\r
- super(access,Config.AAF_URL,si);\r
- hman = new HMangr(access,locator);\r
- }\r
-\r
- public AAFConHttp(PropAccess access, Locator<URI> locator, SecurityInfoC<HttpURLConnection> si, String tag) throws CadiException {\r
- super(access,tag,si);\r
- hman = new HMangr(access, locator);\r
- }\r
- \r
- private AAFConHttp(AAFCon<HttpURLConnection> aafcon, String url) {\r
- super(aafcon);\r
- hman = new HMangr(aafcon.access,Config.loadLocator(access, url));\r
- }\r
-\r
- @Override\r
- public AAFCon<HttpURLConnection> clone(String url) {\r
- return new AAFConHttp(this,url);\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see com.att.cadi.aaf.v2_0.AAFCon#basicAuth(java.lang.String, java.lang.String)\r
- */\r
- @Override\r
- public SecuritySetter<HttpURLConnection> basicAuth(String user, String password) throws CadiException {\r
- if(password.startsWith("enc:???")) {\r
- try {\r
- password = access.decrypt(password, true);\r
- } catch (IOException e) {\r
- throw new CadiException("Error decrypting password",e);\r
- }\r
- }\r
- try {\r
- return new HBasicAuthSS(user,password,si);\r
- } catch (IOException e) {\r
- throw new CadiException("Error creating HBasicAuthSS",e);\r
- }\r
- }\r
-\r
- public SecuritySetter<HttpURLConnection> x509Alias(String alias) throws APIException, CadiException {\r
- try {\r
- return set(new HX509SS(alias,si));\r
- } catch (Exception e) {\r
- throw new CadiException("Error creating X509SS",e);\r
- }\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see com.att.cadi.aaf.v2_0.AAFCon#rclient(java.net.URI, com.att.cadi.SecuritySetter)\r
- */\r
- @Override\r
- protected Rcli<HttpURLConnection> rclient(URI ignoredURI, SecuritySetter<HttpURLConnection> ss) throws CadiException {\r
- if(hman.loc==null) {\r
- throw new CadiException("No Locator set in AAFConHttp"); \r
- }\r
- try {\r
- return new HRcli(hman, hman.loc.best() ,ss);\r
- } catch (Exception e) {\r
- throw new CadiException(e);\r
- }\r
- }\r
-\r
- @Override\r
- public AbsTransferSS<HttpURLConnection> transferSS(Principal principal) throws CadiException {\r
- return new HTransferSS(principal, app,si);\r
- }\r
- \r
- /* (non-Javadoc)\r
- * @see com.att.cadi.aaf.v2_0.AAFCon#basicAuthSS(java.security.Principal)\r
- */\r
- @Override\r
- public SecuritySetter<HttpURLConnection> basicAuthSS(BasicPrincipal principal) throws CadiException {\r
- try {\r
- return new HBasicAuthSS(principal,si);\r
- } catch (IOException e) {\r
- throw new CadiException("Error creating HBasicAuthSS",e);\r
- }\r
- }\r
-\r
- public HMangr hman() {\r
- return hman;\r
- }\r
-\r
- @Override\r
- public <RET> RET best(Retryable<RET> retryable) throws LocatorException, CadiException, APIException {\r
- return hman.best(ss, (Retryable<RET>)retryable);\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see com.att.cadi.aaf.v2_0.AAFCon#initURI()\r
- */\r
- @Override\r
- protected URI initURI() {\r
- try {\r
- Item item = hman.loc.best();\r
- if(item!=null) {\r
- return hman.loc.get(item);\r
- }\r
- } catch (LocatorException e) {\r
- access.log(e, "Error in AAFConHttp obtaining initial URI");\r
- }\r
- return null;\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see com.att.cadi.aaf.v2_0.AAFCon#setInitURI(java.lang.String)\r
- */\r
- @Override\r
- protected void setInitURI(String uriString) throws CadiException {\r
- // TODO Auto-generated method stub\r
- \r
- }\r
- \r
-}\r