1 package eu
.alefzero
.owncloud
.authenticator
; 
   4  * Licensed to the Apache Software Foundation (ASF) under one 
   5  * or more contributor license agreements.  See the NOTICE file 
   6  * distributed with this work for additional information 
   7  * regarding copyright ownership.  The ASF licenses this file 
   8  * to you under the Apache License, Version 2.0 (the 
   9  * "License"); you may not use this file except in compliance 
  10  * with the License.  You may obtain a copy of the License at 
  12  *   http://www.apache.org/licenses/LICENSE-2.0 
  14  * Unless required by applicable law or agreed to in writing, 
  15  * software distributed under the License is distributed on an 
  16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
  17  * KIND, either express or implied.  See the License for the 
  18  * specific language governing permissions and limitations 
  22 import java
.security
.KeyStore
; 
  23 import java
.security
.KeyStoreException
; 
  24 import java
.security
.NoSuchAlgorithmException
; 
  25 import java
.security
.cert
.CertificateException
; 
  26 import java
.security
.cert
.X509Certificate
; 
  28 import javax
.net
.ssl
.TrustManager
; 
  29 import javax
.net
.ssl
.TrustManagerFactory
; 
  30 import javax
.net
.ssl
.X509TrustManager
; 
  34  * @version $Id: EasyX509TrustManager.java 765355 2009-04-15 20:59:07Z evenisse $ 
  37 public class EasyX509TrustManager
 
  38     implements X509TrustManager
 
  41     private X509TrustManager standardTrustManager 
= null
; 
  44      * Constructor for EasyX509TrustManager. 
  46     public EasyX509TrustManager( KeyStore keystore 
) 
  47         throws NoSuchAlgorithmException
, KeyStoreException
 
  50         TrustManagerFactory factory 
= TrustManagerFactory
.getInstance( TrustManagerFactory
.getDefaultAlgorithm() ); 
  51         factory
.init( keystore 
); 
  52         TrustManager
[] trustmanagers 
= factory
.getTrustManagers(); 
  53         if ( trustmanagers
.length 
== 0 ) 
  55             throw new NoSuchAlgorithmException( "no trust manager found" ); 
  57         this.standardTrustManager 
= (X509TrustManager
) trustmanagers
[0]; 
  61      * @see javax.net.ssl.X509TrustManager#checkClientTrusted(X509Certificate[],String authType) 
  63     public void checkClientTrusted( X509Certificate
[] certificates
, String authType 
) 
  64         throws CertificateException
 
  66         standardTrustManager
.checkClientTrusted( certificates
, authType 
); 
  70      * @see javax.net.ssl.X509TrustManager#checkServerTrusted(X509Certificate[],String authType) 
  72     public void checkServerTrusted( X509Certificate
[] certificates
, String authType 
) 
  73         throws CertificateException
 
  75         if ( ( certificates 
!= null 
) && ( certificates
.length 
== 1 ) ) 
  77             certificates
[0].checkValidity(); 
  81             //standardTrustManager.checkServerTrusted( certificates, authType ); 
  86      * @see javax.net.ssl.X509TrustManager#getAcceptedIssuers() 
  88     public X509Certificate
[] getAcceptedIssuers() 
  90         return this.standardTrustManager
.getAcceptedIssuers();