EMMA Coverage Report (generated Mon Jul 11 13:15:38 KST 2005)
[all classes][org.apache.mina.examples.echoserver.ssl]

COVERAGE SUMMARY FOR SOURCE FILE [SSLServerSocketFactory.java]

nameclass, %method, %block, %line, %
SSLServerSocketFactory.java100% (1/1)50%  (4/8)36%  (23/64)48%  (11/23)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SSLServerSocketFactory100% (1/1)50%  (4/8)36%  (23/64)48%  (11/23)
SSLServerSocketFactory (): void 0%   (0/1)0%   (0/3)0%   (0/2)
createServerSocket (int): ServerSocket 0%   (0/1)0%   (0/5)0%   (0/1)
createServerSocket (int, int): ServerSocket 0%   (0/1)0%   (0/6)0%   (0/1)
createServerSocket (int, int, InetAddress): ServerSocket 0%   (0/1)0%   (0/7)0%   (0/1)
getServerSocketFactory (): ServerSocketFactory 100% (1/1)35%  (11/31)42%  (5/12)
<static initializer> 100% (1/1)100% (7/7)100% (3/3)
isSslEnabled (): boolean 100% (1/1)100% (2/2)100% (1/1)
setSslEnabled (boolean): void 100% (1/1)100% (3/3)100% (2/2)

1/*
2 *   @(#) $Id: SSLServerSocketFactory.java 210062 2005-07-11 03:52:38Z trustin $
3 *
4 *   Copyright 2004 The Apache Software Foundation
5 *
6 *   Licensed under the Apache License, Version 2.0 (the "License");
7 *   you may not use this file except in compliance with the License.
8 *   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 */
19package org.apache.mina.examples.echoserver.ssl;
20 
21import java.io.IOException;
22import java.net.InetAddress;
23import java.net.ServerSocket;
24import java.security.GeneralSecurityException;
25 
26import javax.net.ServerSocketFactory;
27 
28/**
29 * Simple Server Socket factory to create sockets with or without SSL enabled.
30 * If SSL enabled a "bougus" SSL Context is used (suitable for test purposes)
31 * 
32 * @version $Rev: 210062 $, $Date: 2005-07-11 12:52:38 +0900 $
33 */
34public class SSLServerSocketFactory extends javax.net.ServerSocketFactory
35{
36    private static boolean sslEnabled = false;
37 
38    private static javax.net.ServerSocketFactory sslFactory = null;
39 
40    private static ServerSocketFactory factory = null;
41 
42    public SSLServerSocketFactory()
43    {
44        super();
45    }
46 
47    public ServerSocket createServerSocket( int port ) throws IOException
48    {
49        return new ServerSocket( port );
50    }
51 
52    public ServerSocket createServerSocket( int port, int backlog )
53            throws IOException
54    {
55        return new ServerSocket( port, backlog );
56    }
57 
58    public ServerSocket createServerSocket( int port, int backlog,
59                                           InetAddress ifAddress )
60            throws IOException
61    {
62        return new ServerSocket( port, backlog, ifAddress );
63    }
64 
65    public static javax.net.ServerSocketFactory getServerSocketFactory()
66            throws IOException
67    {
68        if( isSslEnabled() )
69        {
70            if( sslFactory == null )
71            {
72                try
73                {
74                    sslFactory = BogusSSLContextFactory.getInstance( true )
75                            .getServerSocketFactory();
76                }
77                catch( GeneralSecurityException e )
78                {
79                    IOException ioe = new IOException(
80                            "could not create SSL socket" );
81                    ioe.initCause( e );
82                    throw ioe;
83                }
84            }
85            return sslFactory;
86        }
87        else
88        {
89            if( factory == null )
90            {
91                factory = new SSLServerSocketFactory();
92            }
93            return factory;
94        }
95 
96    }
97 
98    public static boolean isSslEnabled()
99    {
100        return sslEnabled;
101    }
102 
103    public static void setSslEnabled( boolean newSslEnabled )
104    {
105        sslEnabled = newSslEnabled;
106    }
107}

[all classes][org.apache.mina.examples.echoserver.ssl]
EMMA 2.0.4217 (C) Vladimir Roubtsov