View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2007 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
10   *  See the GNU Lesser General Public License for more details at gnu.org.
11   */
12  
13  package com.eviware.soapui.impl.wsdl.submit.transports.http;
14  
15  import java.security.Principal;
16  import java.security.cert.Certificate;
17  
18  import javax.net.ssl.SSLPeerUnverifiedException;
19  import javax.net.ssl.SSLSession;
20  import javax.net.ssl.SSLSocket;
21  
22  public class SSLInfo
23  {
24  	private String cipherSuite;
25  	private Principal localPrincipal;
26  	private Certificate[] localCertificates;
27  	private Principal peerPrincipal;
28  	private Certificate[] peerCertificates;
29  	private boolean peerUnverified;
30  
31  	public SSLInfo( SSLSocket socket )
32  	{
33  		SSLSession session = socket.getSession();
34  		
35  		cipherSuite = session.getCipherSuite();
36  		localPrincipal = session.getLocalPrincipal();
37  		localCertificates = session.getLocalCertificates();
38  		try
39  		{
40  			peerPrincipal = session.getPeerPrincipal();
41  			peerCertificates = session.getPeerCertificates();
42  		}
43  		catch( SSLPeerUnverifiedException e )
44  		{
45  			peerUnverified = true;
46  		}
47  	}
48  
49  	public String getCipherSuite()
50  	{
51  		return cipherSuite;
52  	}
53  
54  	public Certificate[] getLocalCertificates()
55  	{
56  		return localCertificates;
57  	}
58  
59  	public Principal getLocalPrincipal()
60  	{
61  		return localPrincipal;
62  	}
63  
64  	public Certificate[] getPeerCertificates()
65  	{
66  		return peerCertificates;
67  	}
68  
69  	public Principal getPeerPrincipal()
70  	{
71  		return peerPrincipal;
72  	}
73  
74  	public boolean isPeerUnverified()
75  	{
76  		return peerUnverified;
77  	}
78  }