1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\r
4 * * ===========================================================================
\r
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * * ===========================================================================
\r
7 * * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * * you may not use this file except in compliance with the License.
\r
9 * * You may obtain a copy of the License at
\r
11 * * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * * Unless required by applicable law or agreed to in writing, software
\r
14 * * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * * See the License for the specific language governing permissions and
\r
17 * * limitations under the License.
\r
18 * * ============LICENSE_END====================================================
\r
20 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
22 ******************************************************************************/
\r
23 package org.onap.aaf.cadi.http;
\r
25 import java.io.IOException;
\r
26 import java.net.HttpURLConnection;
\r
28 import javax.net.ssl.HttpsURLConnection;
\r
30 import org.onap.aaf.cadi.Access;
\r
31 import org.onap.aaf.cadi.CadiException;
\r
32 import org.onap.aaf.cadi.client.AbsBasicAuth;
\r
33 import org.onap.aaf.cadi.config.Config;
\r
34 import org.onap.aaf.cadi.config.SecurityInfoC;
\r
35 import org.onap.aaf.cadi.principal.BasicPrincipal;
\r
37 public class HBasicAuthSS extends AbsBasicAuth<HttpURLConnection> {
\r
38 public HBasicAuthSS(Access access, SecurityInfoC<HttpURLConnection> si) throws IOException {
\r
39 super(access.getProperty(Config.AAF_MECHID, null),
\r
40 access.decrypt(access.getProperty(Config.AAF_MECHPASS, null), false),
\r
44 public HBasicAuthSS(String user, String pass, SecurityInfoC<HttpURLConnection> si) throws IOException {
\r
45 super(user,pass,si);
\r
48 public HBasicAuthSS(String user, String pass, SecurityInfoC<HttpURLConnection> si, boolean asDefault) throws IOException {
\r
49 super(user,pass,si);
\r
55 public HBasicAuthSS(BasicPrincipal bp, SecurityInfoC<HttpURLConnection> si) throws IOException {
\r
56 super(bp.getName(),new String(bp.getCred()),si);
\r
59 public HBasicAuthSS(BasicPrincipal bp, SecurityInfoC<HttpURLConnection> si, boolean asDefault) throws IOException {
\r
60 super(bp.getName(),new String(bp.getCred()),si);
\r
67 public void setSecurity(HttpURLConnection huc) throws CadiException {
\r
69 throw new CadiException(REPEAT_OFFENDER);
\r
71 huc.addRequestProperty("Authorization" , headValue);
\r
72 if(securityInfo!=null && huc instanceof HttpsURLConnection) {
\r
73 securityInfo.setSocketFactoryOn((HttpsURLConnection)huc);
\r