EMMA Coverage Report (generated Sun Sep 18 11:34:27 PHT 2011)
[all classes][org.apache.maven.continuum.project.builder]

COVERAGE SUMMARY FOR SOURCE FILE [EasyX509TrustManager.java]

nameclass, %method, %block, %line, %
EasyX509TrustManager.java0%   (0/1)0%   (0/5)0%   (0/92)0%   (0/21)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class EasyX509TrustManager0%   (0/1)0%   (0/5)0%   (0/92)0%   (0/21)
<static initializer> 0%   (0/1)0%   (0/4)0%   (0/1)
EasyX509TrustManager (KeyStore): void 0%   (0/1)0%   (0/29)0%   (0/9)
checkClientTrusted (X509Certificate [], String): void 0%   (0/1)0%   (0/6)0%   (0/2)
checkServerTrusted (X509Certificate [], String): void 0%   (0/1)0%   (0/49)0%   (0/8)
getAcceptedIssuers (): X509Certificate [] 0%   (0/1)0%   (0/4)0%   (0/1)

1package org.apache.maven.continuum.project.builder;
2 
3/*
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
11 *
12 *   http://www.apache.org/licenses/LICENSE-2.0
13 *
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
19 * under the License.
20 */
21 
22import java.security.KeyStore;
23import java.security.KeyStoreException;
24import java.security.NoSuchAlgorithmException;
25import java.security.cert.CertificateException;
26import java.security.cert.X509Certificate;
27 
28import javax.net.ssl.TrustManager;
29import javax.net.ssl.TrustManagerFactory;
30import javax.net.ssl.X509TrustManager;
31 
32import org.slf4j.Logger;
33import org.slf4j.LoggerFactory;
34 
35/**
36 * @author olamy
37 * @version $Id: EasyX509TrustManager.java 764863 2009-04-14 16:28:12Z evenisse $
38 * @since 1.2.3
39 */
40public class EasyX509TrustManager
41    implements X509TrustManager
42{
43    private static final Logger log = LoggerFactory.getLogger( EasyX509TrustManager.class );
44 
45    private X509TrustManager standardTrustManager = null;
46 
47    /**
48     * Constructor for EasyX509TrustManager.
49     */
50    public EasyX509TrustManager( KeyStore keystore )
51        throws NoSuchAlgorithmException, KeyStoreException
52    {
53        super();
54        TrustManagerFactory factory = TrustManagerFactory.getInstance( TrustManagerFactory.getDefaultAlgorithm() );
55        factory.init( keystore );
56        TrustManager[] trustmanagers = factory.getTrustManagers();
57        if ( trustmanagers.length == 0 )
58        {
59            throw new NoSuchAlgorithmException( "no trust manager found" );
60        }
61        this.standardTrustManager = (X509TrustManager) trustmanagers[0];
62    }
63 
64    /**
65     * @see javax.net.ssl.X509TrustManager#checkClientTrusted(X509Certificate[],String authType)
66     */
67    public void checkClientTrusted( X509Certificate[] certificates, String authType )
68        throws CertificateException
69    {
70        standardTrustManager.checkClientTrusted( certificates, authType );
71    }
72 
73    /**
74     * @see javax.net.ssl.X509TrustManager#checkServerTrusted(X509Certificate[],String authType)
75     */
76    public void checkServerTrusted( X509Certificate[] certificates, String authType )
77        throws CertificateException
78    {
79        if ( ( certificates != null ) && log.isDebugEnabled() )
80        {
81            log.debug( "Server certificate chain:" );
82            for ( int i = 0; i < certificates.length; i++ )
83            {
84                log.debug( "X509Certificate[" + i + "]=" + certificates[i] );
85            }
86        }
87        if ( ( certificates != null ) && ( certificates.length == 1 ) )
88        {
89            certificates[0].checkValidity();
90        }
91        else
92        {
93            standardTrustManager.checkServerTrusted( certificates, authType );
94        }
95    }
96 
97    /**
98     * @see javax.net.ssl.X509TrustManager#getAcceptedIssuers()
99     */
100    public X509Certificate[] getAcceptedIssuers()
101    {
102        return this.standardTrustManager.getAcceptedIssuers();
103    }
104 
105}

[all classes][org.apache.maven.continuum.project.builder]
EMMA 2.0.5312 (C) Vladimir Roubtsov