KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > transport > tcp > StubSSLSession


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 package org.apache.activemq.transport.tcp;
20
21 import java.security.Principal JavaDoc;
22 import java.security.cert.Certificate JavaDoc;
23 import java.security.cert.X509Certificate JavaDoc;
24
25 import javax.net.ssl.SSLPeerUnverifiedException;
26 import javax.net.ssl.SSLSession;
27 import javax.net.ssl.SSLSessionContext;
28
29 class StubSSLSession implements SSLSession {
30     
31     X509Certificate JavaDoc cert;
32     boolean isVerified = false;
33     
34     public StubSSLSession(X509Certificate JavaDoc cert) {
35         if ( cert != null ) {
36             this.isVerified = true;
37             this.cert = cert;
38         } else {
39             this.isVerified = false;
40             this.cert = null;
41         }
42     }
43     
44     public void setIsVerified( boolean verified ) {
45         this.isVerified = verified;
46     }
47     
48     public Certificate JavaDoc[] getPeerCertificates() throws SSLPeerUnverifiedException {
49         if ( this.isVerified )
50             return new X509Certificate JavaDoc[] { this.cert };
51         else
52             throw new SSLPeerUnverifiedException("Socket is unverified.");
53     }
54     
55     
56     // --- Stubbed methods ---
57

58     public byte[] getId() {
59         return null;
60     }
61
62     public SSLSessionContext getSessionContext() {
63         return null;
64     }
65
66     public long getCreationTime() {
67         return 0;
68     }
69
70     public long getLastAccessedTime() {
71         return 0;
72     }
73
74     public void invalidate() {
75     }
76
77     public boolean isValid() {
78         return false;
79     }
80
81     public void putValue(String JavaDoc arg0, Object JavaDoc arg1) {
82     }
83
84     public Object JavaDoc getValue(String JavaDoc arg0) {
85         return null;
86     }
87
88     public void removeValue(String JavaDoc arg0) {
89     }
90
91     public String JavaDoc[] getValueNames() {
92         return null;
93     }
94
95     public Certificate JavaDoc[] getLocalCertificates() {
96         return null;
97     }
98
99     public javax.security.cert.X509Certificate[] getPeerCertificateChain()
100             throws SSLPeerUnverifiedException {
101         return null;
102     }
103
104     public Principal JavaDoc getPeerPrincipal() throws SSLPeerUnverifiedException {
105         return null;
106     }
107
108     public Principal JavaDoc getLocalPrincipal() {
109         return null;
110     }
111
112     public String JavaDoc getCipherSuite() {
113         return null;
114     }
115
116     public String JavaDoc getProtocol() {
117         return null;
118     }
119
120     public String JavaDoc getPeerHost() {
121         return null;
122     }
123
124     public int getPeerPort() {
125         return 0;
126     }
127
128     public int getPacketBufferSize() {
129         return 0;
130     }
131
132     public int getApplicationBufferSize() {
133         return 0;
134     }
135 }
136
Popular Tags