001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020 021package org.apache.directory.ldap.client.api; 022 023 024import java.net.Socket; 025import java.security.cert.CertificateException; 026import java.security.cert.X509Certificate; 027 028import javax.net.ssl.SSLEngine; 029import javax.net.ssl.X509ExtendedTrustManager; 030 031import org.slf4j.Logger; 032import org.slf4j.LoggerFactory; 033 034 035/** 036 * An implementation of {@link X509TrustManager} which trusts the given certificates without verifying them. 037 * 038 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 039 */ 040public class NoVerificationTrustManager extends X509ExtendedTrustManager 041{ 042 /** The logger. */ 043 private static final Logger LOG = LoggerFactory.getLogger( NoVerificationTrustManager.class ); 044 045 046 /** 047 * {@inheritDoc} 048 */ 049 @Override 050 public void checkClientTrusted( X509Certificate[] x509Certificates, String s ) throws CertificateException 051 { 052 LOG.debug( "checkClientTrusted {}", x509Certificates[0] ); 053 } 054 055 056 /** 057 * {@inheritDoc} 058 */ 059 @Override 060 public void checkClientTrusted( X509Certificate[] x509Certificates, String authType, Socket socket ) 061 throws CertificateException 062 { 063 LOG.debug( "checkClientTrusted {}", x509Certificates[0] ); 064 } 065 066 067 /** 068 * {@inheritDoc} 069 */ 070 @Override 071 public void checkClientTrusted( X509Certificate[] x509Certificates, String authType, SSLEngine engine ) 072 throws CertificateException 073 { 074 LOG.debug( "checkClientTrusted {}", x509Certificates[0] ); 075 } 076 077 078 /** 079 * {@inheritDoc} 080 */ 081 @Override 082 public void checkServerTrusted( X509Certificate[] x509Certificates, String s ) throws CertificateException 083 { 084 LOG.debug( "checkServerTrusted {}", x509Certificates[0] ); 085 } 086 087 088 /** 089 * {@inheritDoc} 090 */ 091 @Override 092 public void checkServerTrusted( X509Certificate[] x509Certificates, String authType, Socket socket ) 093 throws CertificateException 094 { 095 LOG.debug( "checkServerTrusted {}", x509Certificates[0] ); 096 } 097 098 /** 099 * {@inheritDoc} 100 */ 101 @Override 102 public void checkServerTrusted( X509Certificate[] x509Certificates, String authType, SSLEngine engine ) 103 throws CertificateException 104 { 105 LOG.debug( "checkServerTrusted {}", x509Certificates[0] ); 106 } 107 108 109 /** 110 * {@inheritDoc} 111 */ 112 @Override 113 public X509Certificate[] getAcceptedIssuers() 114 { 115 return new X509Certificate[0]; 116 } 117}