alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Jetty example source code file (ServletSSL.java)

This example Jetty source code file (ServletSSL.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Jetty tags/keywords

servletssl, with_3des_ede_cbc_, with_aes_128_, with_aes_128_, with_aes_256_, with_aes_256_, with_des40_cbc_, with_des_cbc_, with_idea_cbc_, with_idea_cbc_, with_rc2_cbc_40_, with_rc4_128_, with_rc4_40_, with_rc4_40_

The Jetty ServletSSL.java source code

// ========================================================================
// Copyright 2001-2005 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at 
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ========================================================================

package org.mortbay.jetty.security;

/* --------------------------------------------------------------------- */
/**
 * Jetty Servlet SSL support utilities.
 * <p>
 * A collection of utilities required to support the SSL requirements of the Servlet 2.2 and 2.3
 * specs.
 * 
 * <p>
 * Used by the SSL listener classes.
 * 
 * @author Brett Sealey
 */
public class ServletSSL
{
    /* ------------------------------------------------------------ */
    /**
     * Given the name of a TLS/SSL cipher suite, return an int representing it effective stream
     * cipher key strength. i.e. How much entropy material is in the key material being fed into the
     * encryption routines.
     * 
     * <p>
     * This is based on the information on effective key lengths in RFC 2246 - The TLS Protocol
     * Version 1.0, Appendix C. CipherSuite definitions:
     * 
     * <pre>
     *                         Effective 
     *     Cipher       Type    Key Bits 
     * 		       	       
     *     NULL       * Stream     0     
     *     IDEA_CBC     Block    128     
     *     RC2_CBC_40 * Block     40     
     *     RC4_40     * Stream    40     
     *     RC4_128      Stream   128     
     *     DES40_CBC  * Block     40     
     *     DES_CBC      Block     56     
     *     3DES_EDE_CBC Block    168     
     * </pre>
     * 
     * @param cipherSuite String name of the TLS cipher suite.
     * @return int indicating the effective key entropy bit-length.
     */
    public static final int deduceKeyLength(String cipherSuite)
    {
        // Roughly ordered from most common to least common.
        if (cipherSuite == null)
            return 0;
        else if (cipherSuite.indexOf("WITH_AES_256_") >= 0)
            return 256;
        else if (cipherSuite.indexOf("WITH_RC4_128_") >= 0)
            return 128;
        else if (cipherSuite.indexOf("WITH_AES_128_") >= 0)
            return 128;
        else if (cipherSuite.indexOf("WITH_RC4_40_") >= 0)
            return 40;
        else if (cipherSuite.indexOf("WITH_3DES_EDE_CBC_") >= 0)
            return 168;
        else if (cipherSuite.indexOf("WITH_IDEA_CBC_") >= 0)
            return 128;
        else if (cipherSuite.indexOf("WITH_RC2_CBC_40_") >= 0)
            return 40;
        else if (cipherSuite.indexOf("WITH_DES40_CBC_") >= 0)
            return 40;
        else if (cipherSuite.indexOf("WITH_DES_CBC_") >= 0)
            return 56;
        else
            return 0;
    }
}

Other Jetty examples (source code examples)

Here is a short list of links related to this Jetty ServletSSL.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.