View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2008 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  /***
23   * Holder for SSL-Related details for a request/response interchange
24   * 
25   * @author ole.matzura
26   */
27  
28  public class SSLInfo
29  {
30  	private String cipherSuite;
31  	private Principal localPrincipal;
32  	private Certificate[] localCertificates;
33  	private Principal peerPrincipal;
34  	private Certificate[] peerCertificates;
35  	private boolean peerUnverified;
36  
37  	public SSLInfo( SSLSocket socket )
38  	{
39  		SSLSession session = socket.getSession();
40  		
41  		cipherSuite = session.getCipherSuite();
42  		localPrincipal = session.getLocalPrincipal();
43  		localCertificates = session.getLocalCertificates();
44  		try
45  		{
46  			peerPrincipal = session.getPeerPrincipal();
47  			peerCertificates = session.getPeerCertificates();
48  		}
49  		catch( SSLPeerUnverifiedException e )
50  		{
51  			peerUnverified = true;
52  		}
53  	}
54  
55  	public String getCipherSuite()
56  	{
57  		return cipherSuite;
58  	}
59  
60  	public Certificate[] getLocalCertificates()
61  	{
62  		return localCertificates;
63  	}
64  
65  	public Principal getLocalPrincipal()
66  	{
67  		return localPrincipal;
68  	}
69  
70  	public Certificate[] getPeerCertificates()
71  	{
72  		return peerCertificates;
73  	}
74  
75  	public Principal getPeerPrincipal()
76  	{
77  		return peerPrincipal;
78  	}
79  
80  	public boolean isPeerUnverified()
81  	{
82  		return peerUnverified;
83  	}
84  }