/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* using the static factory methods or by referencing the static members
* in this class. Member variables are final and can be accessed without
* accessor methods.
*
* There is only ever one instance per supported protocol version, this
* means == can be used for comparision instead of equals() if desired.
*
* Checks for a particular version number should generally take this form:
*
* if (protocolVersion.v >= ProtocolVersion.TLS10) {
* // TLS 1.0 code goes here
* } else {
* // SSL 3.0 code here
* }
*
* @author Andreas Sterbenz
* @since 1.4.1
*/
// The limit of maximum protocol version
// The limit of minimum protocol version
// Dummy protocol version value for invalid SSLSession
// If enabled, send/ accept SSLv2 hello messages
"SSLv2Hello");
// SSL 3.0
// TLS 1.0
// TLS 1.1
// TLS 1.2
// minimum version we implement (SSL 3.0)
// maximum version we implement (TLS 1.2)
// ProtocolVersion to use by default (TLS 1.0)
// Default version for hello messages (SSLv2Hello)
// version in 16 bit MSB format as it appears in records and
// messages, i.e. 0x0301 for TLS 1.0
public final int v;
// major and minor version
// name used in JSSE (e.g. TLSv1 for TLS 1.0)
// private
this.v = v;
major = (byte)(v >>> 8);
minor = (byte)(v & 0xff);
}
// private
if (v == SSL30.v) {
return SSL30;
} else if (v == TLS10.v) {
return TLS10;
} else if (v == TLS11.v) {
return TLS11;
} else if (v == TLS12.v) {
return TLS12;
} else if (v == SSL20Hello.v) {
return SSL20Hello;
} else {
int minor = v & 0xff;
}
}
/**
* Return a ProtocolVersion with the specified major and minor version
* numbers. Never throws exceptions.
*/
major &= 0xff;
minor &= 0xff;
return valueOf(v);
}
/**
* Return a ProtocolVersion for the given name.
*
* @exception IllegalArgumentException if name is null or does not
* identify a supported protocol
*/
throw new IllegalArgumentException("Protocol cannot be null");
}
throw new IllegalArgumentException
("Only TLS 1.0 or later allowed in FIPS mode");
}
return SSL30;
return TLS10;
return TLS11;
return TLS12;
return SSL20Hello;
} else {
throw new IllegalArgumentException(name);
}
}
return name;
}
/**
* Compares this object with the specified object for order.
*/
return this.v - protocolVersion.v;
}
}