0N/A/*
2998N/A * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage sun.security.ssl;
0N/A
0N/Aimport java.io.IOException;
0N/Aimport java.io.PrintStream;
0N/Aimport java.security.AccessController;
0N/Aimport java.security.AccessControlContext;
1870N/Aimport java.security.Principal;
1870N/Aimport java.security.PrivilegedAction;
0N/Aimport java.security.SecureRandom;
1870N/Aimport javax.crypto.SecretKey;
0N/A
0N/A/**
1870N/A * A helper class that calls the KerberosClientKeyExchange implementation.
0N/A */
1870N/Apublic class KerberosClientKeyExchange extends HandshakeMessage {
1870N/A
1870N/A private static final String IMPL_CLASS =
1870N/A "sun.security.ssl.krb5.KerberosClientKeyExchangeImpl";
0N/A
1870N/A private static final Class<?> implClass = AccessController.doPrivileged(
1870N/A new PrivilegedAction<Class<?>>() {
1870N/A public Class<?> run() {
1870N/A try {
1870N/A return Class.forName(IMPL_CLASS, true, null);
1870N/A } catch (ClassNotFoundException cnf) {
1870N/A return null;
1870N/A }
1870N/A }
1870N/A }
1870N/A );
1870N/A private final KerberosClientKeyExchange impl = createImpl();
0N/A
1870N/A private KerberosClientKeyExchange createImpl() {
1870N/A if (getClass() == KerberosClientKeyExchange.class) {
1870N/A try {
1870N/A return (KerberosClientKeyExchange)implClass.newInstance();
1870N/A } catch (InstantiationException e) {
1870N/A throw new AssertionError(e);
1870N/A } catch (IllegalAccessException e) {
1870N/A throw new AssertionError(e);
1870N/A }
1870N/A }
1870N/A return null;
1870N/A }
1870N/A
1870N/A public KerberosClientKeyExchange() {
2998N/A // empty
1870N/A }
1870N/A
1870N/A public KerberosClientKeyExchange(String serverName, boolean isLoopback,
0N/A AccessControlContext acc, ProtocolVersion protocolVersion,
0N/A SecureRandom rand) throws IOException {
0N/A
1870N/A if (impl != null) {
1870N/A init(serverName, isLoopback, acc, protocolVersion, rand);
1870N/A } else {
1870N/A throw new IllegalStateException("Kerberos is unavailable");
1870N/A }
0N/A }
0N/A
1870N/A public KerberosClientKeyExchange(ProtocolVersion protocolVersion,
1870N/A ProtocolVersion clientVersion, SecureRandom rand,
1870N/A HandshakeInStream input, SecretKey[] serverKeys) throws IOException {
0N/A
1870N/A if (impl != null) {
1870N/A init(protocolVersion, clientVersion, rand, input, serverKeys);
0N/A } else {
1870N/A throw new IllegalStateException("Kerberos is unavailable");
0N/A }
0N/A }
0N/A
2998N/A @Override
0N/A int messageType() {
0N/A return ht_client_key_exchange;
0N/A }
0N/A
2998N/A @Override
1870N/A public int messageLength() {
1870N/A return impl.messageLength();
1870N/A }
1870N/A
2998N/A @Override
1870N/A public void send(HandshakeOutStream s) throws IOException {
1870N/A impl.send(s);
0N/A }
0N/A
1870N/A @Override
1870N/A public void print(PrintStream p) throws IOException {
1870N/A impl.print(p);
0N/A }
0N/A
1870N/A public void init(String serverName, boolean isLoopback,
1870N/A AccessControlContext acc, ProtocolVersion protocolVersion,
1870N/A SecureRandom rand) throws IOException {
0N/A
1870N/A if (impl != null) {
1870N/A impl.init(serverName, isLoopback, acc, protocolVersion, rand);
0N/A }
0N/A }
0N/A
1870N/A public void init(ProtocolVersion protocolVersion,
1870N/A ProtocolVersion clientVersion, SecureRandom rand,
1870N/A HandshakeInStream input, SecretKey[] serverKeys) throws IOException {
0N/A
1870N/A if (impl != null) {
1870N/A impl.init(protocolVersion, clientVersion, rand, input, serverKeys);
0N/A }
0N/A }
0N/A
1870N/A public byte[] getUnencryptedPreMasterSecret() {
1870N/A return impl.getUnencryptedPreMasterSecret();
0N/A }
0N/A
1870N/A public Principal getPeerPrincipal(){
1870N/A return impl.getPeerPrincipal();
1870N/A }
1870N/A
1870N/A public Principal getLocalPrincipal(){
1870N/A return impl.getLocalPrincipal();
0N/A }
0N/A}