b11680b29bf3f48cf9ae337a9e1fe28565ce690b
[dcaegen2/analytics/tca.git] / dcae-analytics-aai / src / main / java / org / openecomp / dcae / apod / analytics / aai / utils / ssl / AlwaysTrustingTrustStrategy.java
1 /*
2  * ===============================LICENSE_START======================================
3  *  dcae-analytics
4  * ================================================================================
5  *    Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  *  Licensed under the Apache License, Version 2.0 (the "License");
8  *  you may not use this file except in compliance with the License.
9  *   You may obtain a copy of the License at
10  *
11  *          http://www.apache.org/licenses/LICENSE-2.0
12  *
13  *  Unless required by applicable law or agreed to in writing, software
14  *  distributed under the License is distributed on an "AS IS" BASIS,
15  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  *  See the License for the specific language governing permissions and
17  *  limitations under the License.
18  *  ============================LICENSE_END===========================================
19  */
20
21 package org.openecomp.dcae.apod.analytics.aai.utils.ssl;
22
23 import org.apache.http.ssl.TrustStrategy;
24
25 import java.security.cert.CertificateException;
26 import java.security.cert.X509Certificate;
27
28 /**
29  * An implementation of SSL Trust Strategy which does no SSL certificate validation effectively
30  * bypassing any SSL certificate related issues
31  *
32  * @author Rajiv Singla . Creation Date: 9/19/2017.
33  */
34 public class AlwaysTrustingTrustStrategy implements TrustStrategy {
35     /**
36      * Determines whether the certificate chain can be trusted without consulting the trust manager
37      * configured in the actual SSL context. This method can be used to override the standard JSSE
38      * certificate verification process.
39      * <p>
40      * Please note that, if this method returns {@code false}, the trust manager configured
41      * in the actual SSL context can still clear the certificate as trusted.
42      *
43      * @param chain the peer certificate chain
44      * @param authType the authentication type based on the client certificate
45      *
46      * @return {@code true} if the certificate can be trusted without verification by
47      * the trust manager, {@code false} otherwise.
48      *
49      * @throws CertificateException thrown if the certificate is not trusted or invalid.
50      */
51     @Override
52     public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
53         return true;
54     }
55 }