提交 a03ef49f 编写于 作者: X xuelei

8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl

Reviewed-by: xuelei
Contributed-by: NFlorian Weimer <fweimer@redhat.com>
上级 b58040be
......@@ -55,6 +55,7 @@ class AppInputStream extends InputStream {
* Return the minimum number of bytes that can be read without blocking.
* Currently not synchronized.
*/
@Override
public int available() throws IOException {
if (c.checkEOF() || (r.isAppDataValid() == false)) {
return 0;
......@@ -65,6 +66,7 @@ class AppInputStream extends InputStream {
/**
* Read a single byte, returning -1 on non-fault EOF status.
*/
@Override
public synchronized int read() throws IOException {
int n = read(oneByte, 0, 1);
if (n <= 0) { // EOF
......@@ -79,6 +81,7 @@ class AppInputStream extends InputStream {
* are responsible only for blocking to fill at most one buffer,
* and returning "-1" on non-fault EOF status.
*/
@Override
public synchronized int read(byte b[], int off, int len)
throws IOException {
if (b == null) {
......@@ -124,6 +127,7 @@ class AppInputStream extends InputStream {
* is static and may garbled by concurrent use, but we are not interested
* in the data anyway.
*/
@Override
public synchronized long skip(long n) throws IOException {
long skipped = 0;
while (n > 0) {
......@@ -141,6 +145,7 @@ class AppInputStream extends InputStream {
/*
* Socket close is already synchronized, no need to block here.
*/
@Override
public void close() throws IOException {
c.close();
}
......
......@@ -56,6 +56,7 @@ class AppOutputStream extends OutputStream {
/**
* Write the data out, NOW.
*/
@Override
synchronized public void write(byte b[], int off, int len)
throws IOException {
if (b == null) {
......@@ -131,6 +132,7 @@ class AppOutputStream extends OutputStream {
/**
* Write one byte now.
*/
@Override
synchronized public void write(int i) throws IOException {
oneByte[0] = (byte)i;
write(oneByte, 0, 1);
......@@ -139,6 +141,7 @@ class AppOutputStream extends OutputStream {
/*
* Socket close is already synchronized, no need to block here.
*/
@Override
public void close() throws IOException {
c.close();
}
......
......@@ -102,6 +102,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* associated with this socket, if any.
* @see java.net.Socket#getChannel
*/
@Override
public final SocketChannel getChannel() {
if (self == this) {
return super.getChannel();
......@@ -114,6 +115,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* Binds the address to the socket.
* @see java.net.Socket#bind
*/
@Override
public void bind(SocketAddress bindpoint) throws IOException {
/*
* Bind to this socket
......@@ -131,6 +133,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* Returns the address of the endpoint this socket is connected to
* @see java.net.Socket#getLocalSocketAddress
*/
@Override
public SocketAddress getLocalSocketAddress() {
if (self == this) {
return super.getLocalSocketAddress();
......@@ -143,6 +146,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* Returns the address of the endpoint this socket is connected to
* @see java.net.Socket#getRemoteSocketAddress
*/
@Override
public SocketAddress getRemoteSocketAddress() {
if (self == this) {
return super.getRemoteSocketAddress();
......@@ -164,6 +168,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* @param endpoint the <code>SocketAddress</code>
* @throws IOException if an error occurs during the connection
*/
@Override
public final void connect(SocketAddress endpoint) throws IOException {
connect(endpoint, 0);
}
......@@ -172,6 +177,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* Returns the connection state of the socket.
* @see java.net.Socket#isConnected
*/
@Override
public final boolean isConnected() {
if (self == this) {
return super.isConnected();
......@@ -184,6 +190,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* Returns the binding state of the socket.
* @see java.net.Socket#isBound
*/
@Override
public final boolean isBound() {
if (self == this) {
return super.isBound();
......@@ -203,6 +210,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
*
* @throws UnsupportedOperationException
*/
@Override
public final void shutdownInput() throws IOException {
throw new UnsupportedOperationException("The method shutdownInput()" +
" is not supported in SSLSocket");
......@@ -215,6 +223,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
*
* @throws UnsupportedOperationException
*/
@Override
public final void shutdownOutput() throws IOException {
throw new UnsupportedOperationException("The method shutdownOutput()" +
" is not supported in SSLSocket");
......@@ -225,6 +234,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* Returns the input state of the socket
* @see java.net.Socket#isInputShutdown
*/
@Override
public final boolean isInputShutdown() {
if (self == this) {
return super.isInputShutdown();
......@@ -237,6 +247,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* Returns the output state of the socket
* @see java.net.Socket#isOutputShutdown
*/
@Override
public final boolean isOutputShutdown() {
if (self == this) {
return super.isOutputShutdown();
......@@ -252,6 +263,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* rather than forcing them to be explicitly reclaimed at
* the penalty of prematurly killing SSL sessions.
*/
@Override
protected final void finalize() throws Throwable {
try {
close();
......@@ -281,6 +293,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
/**
* Returns the address of the remote peer for this connection.
*/
@Override
public final InetAddress getInetAddress() {
if (self == this) {
return super.getInetAddress();
......@@ -295,6 +308,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* @return the local address to which the socket is bound.
* @since JDK1.1
*/
@Override
public final InetAddress getLocalAddress() {
if (self == this) {
return super.getLocalAddress();
......@@ -306,6 +320,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
/**
* Returns the number of the remote port that this connection uses.
*/
@Override
public final int getPort() {
if (self == this) {
return super.getPort();
......@@ -317,6 +332,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
/**
* Returns the number of the local port that this connection uses.
*/
@Override
public final int getLocalPort() {
if (self == this) {
return super.getLocalPort();
......@@ -333,6 +349,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* Enables or disables the Nagle optimization.
* @see java.net.Socket#setTcpNoDelay
*/
@Override
public final void setTcpNoDelay(boolean value) throws SocketException {
if (self == this) {
super.setTcpNoDelay(value);
......@@ -348,6 +365,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
*
* @see java.net.Socket#getTcpNoDelay
*/
@Override
public final boolean getTcpNoDelay() throws SocketException {
if (self == this) {
return super.getTcpNoDelay();
......@@ -360,6 +378,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* Assigns the socket's linger timeout.
* @see java.net.Socket#setSoLinger
*/
@Override
public final void setSoLinger(boolean flag, int linger)
throws SocketException {
if (self == this) {
......@@ -373,6 +392,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* Returns the socket's linger timeout.
* @see java.net.Socket#getSoLinger
*/
@Override
public final int getSoLinger() throws SocketException {
if (self == this) {
return super.getSoLinger();
......@@ -388,6 +408,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* this for an SSLSocket. An implementation can be provided if a need
* arises in future.
*/
@Override
public final void sendUrgentData(int data) throws SocketException {
throw new SocketException("This method is not supported "
+ "by SSLSockets");
......@@ -401,6 +422,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* Setting OOBInline does not have any effect on SSLSocket,
* since currently we don't support sending urgent data.
*/
@Override
public final void setOOBInline(boolean on) throws SocketException {
throw new SocketException("This method is ineffective, since"
+ " sending urgent data is not supported by SSLSockets");
......@@ -410,6 +432,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* Tests if OOBINLINE is enabled.
* @see java.net.Socket#getOOBInline
*/
@Override
public final boolean getOOBInline() throws SocketException {
throw new SocketException("This method is ineffective, since"
+ " sending urgent data is not supported by SSLSockets");
......@@ -419,6 +442,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* Returns the socket timeout.
* @see java.net.Socket#getSoTimeout
*/
@Override
public final int getSoTimeout() throws SocketException {
if (self == this) {
return super.getSoTimeout();
......@@ -427,6 +451,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
}
}
@Override
public final void setSendBufferSize(int size) throws SocketException {
if (self == this) {
super.setSendBufferSize(size);
......@@ -435,6 +460,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
}
}
@Override
public final int getSendBufferSize() throws SocketException {
if (self == this) {
return super.getSendBufferSize();
......@@ -443,6 +469,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
}
}
@Override
public final void setReceiveBufferSize(int size) throws SocketException {
if (self == this) {
super.setReceiveBufferSize(size);
......@@ -451,6 +478,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
}
}
@Override
public final int getReceiveBufferSize() throws SocketException {
if (self == this) {
return super.getReceiveBufferSize();
......@@ -463,6 +491,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* Enable/disable SO_KEEPALIVE.
* @see java.net.Socket#setKeepAlive
*/
@Override
public final void setKeepAlive(boolean on) throws SocketException {
if (self == this) {
super.setKeepAlive(on);
......@@ -475,6 +504,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* Tests if SO_KEEPALIVE is enabled.
* @see java.net.Socket#getKeepAlive
*/
@Override
public final boolean getKeepAlive() throws SocketException {
if (self == this) {
return super.getKeepAlive();
......@@ -488,6 +518,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* packets sent from this Socket.
* @see java.net.Socket#setTrafficClass
*/
@Override
public final void setTrafficClass(int tc) throws SocketException {
if (self == this) {
super.setTrafficClass(tc);
......@@ -501,6 +532,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* sent from this Socket.
* @see java.net.Socket#getTrafficClass
*/
@Override
public final int getTrafficClass() throws SocketException {
if (self == this) {
return super.getTrafficClass();
......@@ -513,6 +545,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* Enable/disable SO_REUSEADDR.
* @see java.net.Socket#setReuseAddress
*/
@Override
public final void setReuseAddress(boolean on) throws SocketException {
if (self == this) {
super.setReuseAddress(on);
......@@ -525,6 +558,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
* Tests if SO_REUSEADDR is enabled.
* @see java.net.Socket#getReuseAddress
*/
@Override
public final boolean getReuseAddress() throws SocketException {
if (self == this) {
return super.getReuseAddress();
......@@ -538,6 +572,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket {
*
* @see java.net.Socket#setPerformancePreferences(int, int, int)
*/
@Override
public void setPerformancePreferences(int connectionTime,
int latency, int bandwidth) {
if (self == this) {
......
......@@ -50,6 +50,7 @@ class ByteBufferInputStream extends InputStream {
*
* Increments position().
*/
@Override
public int read() throws IOException {
if (bb == null) {
......@@ -67,6 +68,7 @@ class ByteBufferInputStream extends InputStream {
*
* Increments position().
*/
@Override
public int read(byte b[]) throws IOException {
if (bb == null) {
......@@ -81,6 +83,7 @@ class ByteBufferInputStream extends InputStream {
*
* Increments position().
*/
@Override
public int read(byte b[], int off, int len) throws IOException {
if (bb == null) {
......@@ -108,6 +111,7 @@ class ByteBufferInputStream extends InputStream {
* Skips over and discards <code>n</code> bytes of data from this input
* stream.
*/
@Override
public long skip(long n) throws IOException {
if (bb == null) {
......@@ -135,6 +139,7 @@ class ByteBufferInputStream extends InputStream {
* from this input stream without blocking by the next caller of a
* method for this input stream.
*/
@Override
public int available() throws IOException {
if (bb == null) {
......@@ -150,6 +155,7 @@ class ByteBufferInputStream extends InputStream {
*
* @exception IOException if an I/O error occurs.
*/
@Override
public void close() throws IOException {
bb = null;
}
......@@ -157,12 +163,14 @@ class ByteBufferInputStream extends InputStream {
/**
* Marks the current position in this input stream.
*/
@Override
public synchronized void mark(int readlimit) {}
/**
* Repositions this stream to the position at the time the
* <code>mark</code> method was last called on this input stream.
*/
@Override
public synchronized void reset() throws IOException {
throw new IOException("mark/reset not supported");
}
......@@ -171,6 +179,7 @@ class ByteBufferInputStream extends InputStream {
* Tests if this input stream supports the <code>mark</code> and
* <code>reset</code> methods.
*/
@Override
public boolean markSupported() {
return false;
}
......
......@@ -32,7 +32,6 @@ import java.util.Hashtable;
import java.security.*;
import javax.crypto.*;
import javax.crypto.spec.SecretKeySpec;
import javax.crypto.spec.IvParameterSpec;
import java.nio.*;
......
......@@ -37,7 +37,6 @@ import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import sun.security.ssl.CipherSuite.*;
import static sun.security.ssl.CipherSuite.KeyExchange.*;
import static sun.security.ssl.CipherSuite.PRF.*;
import static sun.security.ssl.JsseJce.*;
......@@ -203,6 +202,7 @@ final class CipherSuite implements Comparable<CipherSuite> {
* Note that for unsupported CipherSuites parsed from a handshake
* message we violate the equals() contract.
*/
@Override
public int compareTo(CipherSuite o) {
return o.priority - priority;
}
......@@ -210,6 +210,7 @@ final class CipherSuite implements Comparable<CipherSuite> {
/**
* Returns this.name.
*/
@Override
public String toString() {
return name;
}
......@@ -378,6 +379,7 @@ final class CipherSuite implements Comparable<CipherSuite> {
}
}
@Override
public String toString() {
return name;
}
......@@ -527,6 +529,7 @@ final class CipherSuite implements Comparable<CipherSuite> {
return b.booleanValue();
}
@Override
public String toString() {
return description;
}
......@@ -562,6 +565,7 @@ final class CipherSuite implements Comparable<CipherSuite> {
return new MAC(this, protocolVersion, secret);
}
@Override
public String toString() {
return name;
}
......
......@@ -177,6 +177,7 @@ final class CipherSuiteList {
return suiteNames.clone();
}
@Override
public String toString() {
return cipherSuites.toString();
}
......
......@@ -45,7 +45,6 @@ import javax.net.ssl.*;
import javax.security.auth.Subject;
import sun.security.ssl.HandshakeMessage.*;
import sun.security.ssl.CipherSuite.*;
import static sun.security.ssl.CipherSuite.KeyExchange.*;
/**
......@@ -128,6 +127,7 @@ final class ClientHandshaker extends Handshaker {
* is processed, and writes responses as needed using the connection
* in the constructor.
*/
@Override
void processMessage(byte type, int messageLen) throws IOException {
if (state > type
&& (type != HandshakeMessage.ht_hello_request
......@@ -505,6 +505,7 @@ final class ClientHandshaker extends Handshaker {
try {
subject = AccessController.doPrivileged(
new PrivilegedExceptionAction<Subject>() {
@Override
public Subject run() throws Exception {
return Krb5Helper.getClientSubject(getAccSE());
}});
......@@ -1104,6 +1105,7 @@ final class ClientHandshaker extends Handshaker {
/*
* Returns a ClientHello message to kickstart renegotiations
*/
@Override
HandshakeMessage getKickstartMessage() throws SSLException {
// session ID of the ClientHello message
SessionId sessionId = SSLSessionImpl.nullSession.getSessionId();
......@@ -1279,6 +1281,7 @@ final class ClientHandshaker extends Handshaker {
/*
* Fault detected during handshake.
*/
@Override
void handshakeAlert(byte description) throws SSLProtocolException {
String message = Alerts.alertDescription(description);
......
......@@ -39,6 +39,7 @@ import java.math.BigInteger;
*/
final class DHClientKeyExchange extends HandshakeMessage {
@Override
int messageType() {
return ht_client_key_exchange;
}
......@@ -75,6 +76,7 @@ final class DHClientKeyExchange extends HandshakeMessage {
dh_Yc = input.getBytes16();
}
@Override
int messageLength() {
if (dh_Yc == null) {
return 0;
......@@ -83,10 +85,12 @@ final class DHClientKeyExchange extends HandshakeMessage {
}
}
@Override
void send(HandshakeOutStream s) throws IOException {
s.putBytes16(dh_Yc);
}
@Override
void print(PrintStream s) throws IOException {
s.println("*** ClientKeyExchange, DH");
......
......@@ -41,6 +41,7 @@ import java.security.spec.*;
*/
final class ECDHClientKeyExchange extends HandshakeMessage {
@Override
int messageType() {
return ht_client_key_exchange;
}
......@@ -63,14 +64,17 @@ final class ECDHClientKeyExchange extends HandshakeMessage {
encodedPoint = input.getBytes8();
}
@Override
int messageLength() {
return encodedPoint.length + 1;
}
@Override
void send(HandshakeOutStream s) throws IOException {
s.putBytes8(encodedPoint);
}
@Override
void print(PrintStream s) throws IOException {
s.println("*** ECDHClientKeyExchange");
......
......@@ -31,7 +31,6 @@ import java.security.spec.*;
import javax.crypto.SecretKey;
import javax.crypto.KeyAgreement;
import javax.crypto.spec.*;
/**
* Helper class for the ECDH key exchange. It generates the appropriate
......
......@@ -64,6 +64,7 @@ final class EngineInputRecord extends InputRecord {
this.engine = engine;
}
@Override
byte contentType() {
if (internalData) {
return super.contentType();
......@@ -271,6 +272,7 @@ final class EngineInputRecord extends InputRecord {
* data to be generated/output before the exception is ever
* generated.
*/
@Override
void writeBuffer(OutputStream s, byte [] buf, int off, int len)
throws IOException {
/*
......
......@@ -29,9 +29,6 @@ package sun.security.ssl;
import java.io.*;
import java.nio.*;
import javax.net.ssl.SSLException;
import sun.misc.HexDumpEncoder;
/**
* A OutputRecord class extension which uses external ByteBuffers
......@@ -95,6 +92,7 @@ final class EngineOutputRecord extends OutputRecord {
finishedMsg = true;
}
@Override
public void flush() throws IOException {
finishedMsg = false;
}
......
......@@ -25,7 +25,6 @@
package sun.security.ssl;
import javax.net.ssl.*;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.LinkedList;
......
......@@ -38,6 +38,7 @@ final class ExtensionType {
this.name = name;
}
@Override
public String toString() {
return name;
}
......
......@@ -28,9 +28,6 @@ package sun.security.ssl;
import java.io.ByteArrayOutputStream;
import java.security.*;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Set;
......@@ -391,11 +388,13 @@ final class CloneableDigest extends MessageDigest implements Cloneable {
// }
}
@Override
protected int engineGetDigestLength() {
checkState();
return digests[0].getDigestLength();
}
@Override
protected void engineUpdate(byte b) {
checkState();
for (int i = 0; (i < digests.length) && (digests[i] != null); i++) {
......@@ -403,6 +402,7 @@ final class CloneableDigest extends MessageDigest implements Cloneable {
}
}
@Override
protected void engineUpdate(byte[] b, int offset, int len) {
checkState();
for (int i = 0; (i < digests.length) && (digests[i] != null); i++) {
......@@ -410,6 +410,7 @@ final class CloneableDigest extends MessageDigest implements Cloneable {
}
}
@Override
protected byte[] engineDigest() {
checkState();
byte[] digest = digests[0].digest();
......@@ -417,6 +418,7 @@ final class CloneableDigest extends MessageDigest implements Cloneable {
return digest;
}
@Override
protected int engineDigest(byte[] buf, int offset, int len)
throws DigestException {
checkState();
......@@ -436,6 +438,7 @@ final class CloneableDigest extends MessageDigest implements Cloneable {
}
}
@Override
protected void engineReset() {
checkState();
for (int i = 0; (i < digests.length) && (digests[i] != null); i++) {
......@@ -443,6 +446,7 @@ final class CloneableDigest extends MessageDigest implements Cloneable {
}
}
@Override
public Object clone() {
checkState();
for (int i = digests.length - 1; i >= 0; i--) {
......
......@@ -28,7 +28,6 @@ package sun.security.ssl;
import java.io.InputStream;
import java.io.IOException;
import java.security.MessageDigest;
import javax.net.ssl.SSLException;
......@@ -74,6 +73,7 @@ public class HandshakeInStream extends InputStream {
* Note that this returns the bytes remaining in the buffer, not
* the bytes remaining in the current handshake message.
*/
@Override
public int available() {
return r.available();
}
......@@ -81,6 +81,7 @@ public class HandshakeInStream extends InputStream {
/*
* Get a byte of handshake data.
*/
@Override
public int read() throws IOException {
int n = r.read();
if (n == -1) {
......@@ -92,6 +93,7 @@ public class HandshakeInStream extends InputStream {
/*
* Get a bunch of bytes of handshake data.
*/
@Override
public int read(byte b [], int off, int len) throws IOException {
// we read from a ByteArrayInputStream, it always returns the
// data in a single read if enough is available
......@@ -105,6 +107,7 @@ public class HandshakeInStream extends InputStream {
/*
* Skip some handshake data.
*/
@Override
public long skip(long n) throws IOException {
return r.skip(n);
}
......@@ -117,6 +120,7 @@ public class HandshakeInStream extends InputStream {
* read, data that has already been consumed is lost even if marked).
*/
@Override
public void mark(int readlimit) {
r.mark(readlimit);
}
......@@ -126,6 +130,7 @@ public class HandshakeInStream extends InputStream {
r.reset();
}
@Override
public boolean markSupported() {
return true;
}
......
......@@ -170,6 +170,7 @@ public abstract class HandshakeMessage {
* session parameters after a connection has been (re)established.
*/
static final class HelloRequest extends HandshakeMessage {
@Override
int messageType() { return ht_hello_request; }
HelloRequest() { }
......@@ -179,13 +180,16 @@ static final class HelloRequest extends HandshakeMessage {
// nothing in this message
}
@Override
int messageLength() { return 0; }
@Override
void send(HandshakeOutStream out) throws IOException
{
// nothing in this messaage
}
@Override
void print(PrintStream out) throws IOException
{
out.println("*** HelloRequest (empty)");
......@@ -329,6 +333,7 @@ static final class ClientHello extends HandshakeMessage {
static final
class ServerHello extends HandshakeMessage
{
@Override
int messageType() { return ht_server_hello; }
ProtocolVersion protocolVersion;
......@@ -355,6 +360,7 @@ class ServerHello extends HandshakeMessage
}
}
@Override
int messageLength()
{
// almost fixed size, except session ID and extensions:
......@@ -366,6 +372,7 @@ class ServerHello extends HandshakeMessage
return 38 + sessionId.length() + extensions.length();
}
@Override
void send(HandshakeOutStream s) throws IOException
{
s.putInt8(protocolVersion.major);
......@@ -378,6 +385,7 @@ class ServerHello extends HandshakeMessage
extensions.send(s);
}
@Override
void print(PrintStream s) throws IOException
{
s.println("*** ServerHello, " + protocolVersion);
......@@ -416,6 +424,7 @@ class ServerHello extends HandshakeMessage
static final
class CertificateMsg extends HandshakeMessage
{
@Override
int messageType() { return ht_certificate; }
private X509Certificate[] chain;
......@@ -450,6 +459,7 @@ class CertificateMsg extends HandshakeMessage
chain = v.toArray(new X509Certificate[v.size()]);
}
@Override
int messageLength() {
if (encodedChain == null) {
messageLength = 3;
......@@ -468,6 +478,7 @@ class CertificateMsg extends HandshakeMessage
return messageLength;
}
@Override
void send(HandshakeOutStream s) throws IOException {
s.putInt24(messageLength() - 3);
for (byte[] b : encodedChain) {
......@@ -475,6 +486,7 @@ class CertificateMsg extends HandshakeMessage
}
}
@Override
void print(PrintStream s) throws IOException {
s.println("*** Certificate chain");
......@@ -528,6 +540,7 @@ class CertificateMsg extends HandshakeMessage
*/
static abstract class ServerKeyExchange extends HandshakeMessage
{
@Override
int messageType() { return ht_server_key_exchange; }
}
......@@ -635,17 +648,20 @@ class RSA_ServerKeyExchange extends ServerKeyExchange
return signature.verify(signatureBytes);
}
@Override
int messageLength() {
return 6 + rsa_modulus.length + rsa_exponent.length
+ signatureBytes.length;
}
@Override
void send(HandshakeOutStream s) throws IOException {
s.putBytes16(rsa_modulus);
s.putBytes16(rsa_exponent);
s.putBytes16(signatureBytes);
}
@Override
void print(PrintStream s) throws IOException {
s.println("*** RSA ServerKeyExchange");
......@@ -874,6 +890,7 @@ class DH_ServerKeyExchange extends ServerKeyExchange
dh_Ys = toByteArray(obj.getPublicKey());
}
@Override
int messageLength() {
int temp = 6; // overhead for p, g, y(s) values.
......@@ -895,6 +912,7 @@ class DH_ServerKeyExchange extends ServerKeyExchange
return temp;
}
@Override
void send(HandshakeOutStream s) throws IOException {
s.putBytes16(dh_p);
s.putBytes16(dh_g);
......@@ -914,6 +932,7 @@ class DH_ServerKeyExchange extends ServerKeyExchange
}
}
@Override
void print(PrintStream s) throws IOException {
s.println("*** Diffie-Hellman ServerKeyExchange");
......@@ -1118,6 +1137,7 @@ class ECDH_ServerKeyExchange extends ServerKeyExchange {
sig.update(pointBytes);
}
@Override
int messageLength() {
int sigLen = 0;
if (signatureBytes != null) {
......@@ -1130,6 +1150,7 @@ class ECDH_ServerKeyExchange extends ServerKeyExchange {
return 4 + pointBytes.length + sigLen;
}
@Override
void send(HandshakeOutStream s) throws IOException {
s.putInt8(CURVE_NAMED_CURVE);
s.putInt16(curveId);
......@@ -1145,6 +1166,7 @@ class ECDH_ServerKeyExchange extends ServerKeyExchange {
}
}
@Override
void print(PrintStream s) throws IOException {
s.println("*** ECDH ServerKeyExchange");
......@@ -1479,6 +1501,7 @@ class CertificateRequest extends HandshakeMessage
static final
class ServerHelloDone extends HandshakeMessage
{
@Override
int messageType() { return ht_server_hello_done; }
ServerHelloDone() { }
......@@ -1488,16 +1511,19 @@ class ServerHelloDone extends HandshakeMessage
// nothing to do
}
@Override
int messageLength()
{
return 0;
}
@Override
void send(HandshakeOutStream s) throws IOException
{
// nothing to send
}
@Override
void print(PrintStream s) throws IOException
{
s.println("*** ServerHelloDone");
......@@ -1712,6 +1738,7 @@ static final class CertificateVerify extends HandshakeMessage {
private static void makeAccessible(final AccessibleObject o) {
AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
public Object run() {
o.setAccessible(true);
return null;
......
......@@ -28,7 +28,6 @@ package sun.security.ssl;
import java.io.OutputStream;
import java.io.IOException;
import java.security.MessageDigest;
/**
* Output stream for handshake data. This is used only internally
......@@ -87,6 +86,7 @@ public class HandshakeOutStream extends OutputStream {
* Hashes are updated automatically if something gets flushed to the
* network (e.g. a big cert message etc).
*/
@Override
public void write(byte buf[], int off, int len) throws IOException {
while (len > 0) {
int howmuch = Math.min(len, r.availableDataBytes());
......@@ -104,6 +104,7 @@ public class HandshakeOutStream extends OutputStream {
/*
* write-a-byte
*/
@Override
public void write(int i) throws IOException {
if (r.availableDataBytes() < 1) {
flush();
......@@ -111,6 +112,7 @@ public class HandshakeOutStream extends OutputStream {
r.write(i);
}
@Override
public void flush() throws IOException {
if (socket != null) {
try {
......
......@@ -820,6 +820,7 @@ abstract class Handshaker {
processLoop();
} else {
delegateTask(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
processLoop();
return null;
......
......@@ -40,6 +40,7 @@ abstract class HelloExtension {
abstract void send(HandshakeOutStream s) throws IOException;
@Override
public abstract String toString();
}
......@@ -29,8 +29,6 @@ import java.io.IOException;
import java.io.PrintStream;
import java.util.*;
import javax.net.ssl.*;
import java.nio.charset.StandardCharsets;
import java.security.spec.ECParameterSpec;
/**
* This file contains all the classes relevant to TLS Extensions for the
......
......@@ -28,8 +28,6 @@ package sun.security.ssl;
import java.io.*;
import java.nio.*;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import javax.crypto.BadPaddingException;
......@@ -285,6 +283,7 @@ class InputRecord extends ByteArrayInputStream implements Record {
* Prevent any more data from being read into this record,
* and flag the record as holding no data.
*/
@Override
public void close() {
appDataValid = false;
isClosed = true;
......
......@@ -71,6 +71,7 @@ final class JsseJce {
try {
AccessController.doPrivileged(
new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
// Test for Kerberos using the bootstrap class loader
Class.forName("sun.security.krb5.PrincipalName", true,
......@@ -114,6 +115,7 @@ final class JsseJce {
SunCertificates(final Provider p) {
super("SunCertificates", 1.0d, "SunJSSE internal");
AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
public Object run() {
// copy certificate related services from the Sun provider
for (Map.Entry<Object,Object> entry : p.entrySet()) {
......
......@@ -44,6 +44,7 @@ public class KerberosClientKeyExchange extends HandshakeMessage {
private static final Class<?> implClass = AccessController.doPrivileged(
new PrivilegedAction<Class<?>>() {
@Override
public Class<?> run() {
try {
return Class.forName(IMPL_CLASS, true, null);
......
......@@ -45,6 +45,7 @@ abstract class KeyManagerFactoryImpl extends KeyManagerFactorySpi {
/**
* Returns one key manager for each type of key material.
*/
@Override
protected KeyManager[] engineGetKeyManagers() {
if (!isInitialized) {
throw new IllegalStateException(
......@@ -56,6 +57,7 @@ abstract class KeyManagerFactoryImpl extends KeyManagerFactorySpi {
// Factory for the SunX509 keymanager
public static final class SunX509 extends KeyManagerFactoryImpl {
@Override
protected void engineInit(KeyStore ks, char[] password) throws
KeyStoreException, NoSuchAlgorithmException,
UnrecoverableKeyException {
......@@ -69,6 +71,7 @@ abstract class KeyManagerFactoryImpl extends KeyManagerFactorySpi {
isInitialized = true;
}
@Override
protected void engineInit(ManagerFactoryParameters spec) throws
InvalidAlgorithmParameterException {
throw new InvalidAlgorithmParameterException(
......@@ -80,6 +83,7 @@ abstract class KeyManagerFactoryImpl extends KeyManagerFactorySpi {
// Factory for the X509 keymanager
public static final class X509 extends KeyManagerFactoryImpl {
@Override
protected void engineInit(KeyStore ks, char[] password) throws
KeyStoreException, NoSuchAlgorithmException,
UnrecoverableKeyException {
......@@ -102,6 +106,7 @@ abstract class KeyManagerFactoryImpl extends KeyManagerFactorySpi {
isInitialized = true;
}
@Override
protected void engineInit(ManagerFactoryParameters params) throws
InvalidAlgorithmParameterException {
if (params instanceof KeyStoreBuilderParameters == false) {
......
......@@ -47,6 +47,7 @@ public final class Krb5Helper {
private static final Krb5Proxy proxy =
AccessController.doPrivileged(new PrivilegedAction<Krb5Proxy>() {
@Override
public Krb5Proxy run() {
try {
Class<?> c = Class.forName(IMPL_CLASS, true, null);
......
......@@ -116,6 +116,7 @@ class OutputRecord extends ByteArrayOutputStream implements Record {
* Reset the record so that it can be refilled, starting
* immediately after the header.
*/
@Override
public synchronized void reset() {
super.reset();
count = headerSize;
......
......@@ -147,6 +147,7 @@ final class ProtocolList {
return protocolNames.clone();
}
@Override
public String toString() {
return protocols.toString();
}
......
......@@ -165,6 +165,7 @@ public final class ProtocolVersion implements Comparable<ProtocolVersion> {
}
}
@Override
public String toString() {
return name;
}
......@@ -172,6 +173,7 @@ public final class ProtocolVersion implements Comparable<ProtocolVersion> {
/**
* Compares this object with the specified object for order.
*/
@Override
public int compareTo(ProtocolVersion protocolVersion) {
return this.v - protocolVersion.v;
}
......
......@@ -28,10 +28,8 @@ package sun.security.ssl;
import java.io.*;
import java.security.*;
import java.security.interfaces.*;
import javax.crypto.*;
import javax.crypto.spec.*;
import javax.net.ssl.*;
......
......@@ -26,8 +26,6 @@
package sun.security.ssl;
import java.util.Arrays;
import java.security.*;
/**
......@@ -106,6 +104,7 @@ public final class RSASignature extends SignatureSpi {
}
}
@Override
protected void engineInitVerify(PublicKey publicKey)
throws InvalidKeyException {
checkNull(publicKey);
......@@ -113,11 +112,13 @@ public final class RSASignature extends SignatureSpi {
rawRsa.initVerify(publicKey);
}
@Override
protected void engineInitSign(PrivateKey privateKey)
throws InvalidKeyException {
engineInitSign(privateKey, null);
}
@Override
protected void engineInitSign(PrivateKey privateKey, SecureRandom random)
throws InvalidKeyException {
checkNull(privateKey);
......@@ -133,6 +134,7 @@ public final class RSASignature extends SignatureSpi {
}
}
@Override
protected void engineUpdate(byte b) {
initDigests();
isReset = false;
......@@ -140,6 +142,7 @@ public final class RSASignature extends SignatureSpi {
sha.update(b);
}
@Override
protected void engineUpdate(byte[] b, int off, int len) {
initDigests();
isReset = false;
......@@ -161,21 +164,25 @@ public final class RSASignature extends SignatureSpi {
}
}
@Override
protected byte[] engineSign() throws SignatureException {
rawRsa.update(getDigest());
return rawRsa.sign();
}
@Override
protected boolean engineVerify(byte[] sigBytes) throws SignatureException {
return engineVerify(sigBytes, 0, sigBytes.length);
}
@Override
protected boolean engineVerify(byte[] sigBytes, int offset, int length)
throws SignatureException {
rawRsa.update(getDigest());
return rawRsa.verify(sigBytes, offset, length);
}
@Override
protected void engineSetParameter(String param, Object value)
throws InvalidParameterException {
if (param.equals("hashes") == false) {
......@@ -191,6 +198,7 @@ public final class RSASignature extends SignatureSpi {
sha = digests[1];
}
@Override
protected Object engineGetParameter(String param)
throws InvalidParameterException {
throw new InvalidParameterException("Parameters not supported");
......
......@@ -85,10 +85,12 @@ final class RenegotiationInfoExtension extends HelloExtension {
// Length of the encoded extension, including the type and length fields
@Override
int length() {
return 5 + renegotiated_connection.length;
}
@Override
void send(HandshakeOutStream s) throws IOException {
s.putInt16(type.id);
s.putInt16(renegotiated_connection.length + 1);
......@@ -103,6 +105,7 @@ final class RenegotiationInfoExtension extends HelloExtension {
return renegotiated_connection;
}
@Override
public String toString() {
return "Extension " + type + ", renegotiated_connection: " +
(renegotiated_connection.length == 0 ? "<empty>" :
......
......@@ -111,6 +111,7 @@ final class SSLAlgorithmConstraints implements AlgorithmConstraints {
}
}
@Override
public boolean permits(Set<CryptoPrimitive> primitives,
String algorithm, AlgorithmParameters parameters) {
......@@ -139,6 +140,7 @@ final class SSLAlgorithmConstraints implements AlgorithmConstraints {
return permitted;
}
@Override
public boolean permits(Set<CryptoPrimitive> primitives, Key key) {
boolean permitted = true;
......@@ -162,6 +164,7 @@ final class SSLAlgorithmConstraints implements AlgorithmConstraints {
return permitted;
}
@Override
public boolean permits(Set<CryptoPrimitive> primitives,
String algorithm, Key key, AlgorithmParameters parameters) {
......@@ -204,6 +207,7 @@ final class SSLAlgorithmConstraints implements AlgorithmConstraints {
}
}
@Override
public boolean permits(Set<CryptoPrimitive> primitives,
String algorithm, AlgorithmParameters parameters) {
......@@ -237,10 +241,12 @@ final class SSLAlgorithmConstraints implements AlgorithmConstraints {
return false;
}
@Override
final public boolean permits(Set<CryptoPrimitive> primitives, Key key) {
return true;
}
@Override
final public boolean permits(Set<CryptoPrimitive> primitives,
String algorithm, Key key, AlgorithmParameters parameters) {
......
......@@ -71,6 +71,7 @@ public abstract class SSLContextImpl extends SSLContextSpi {
serverCache = new SSLSessionContextImpl();
}
@Override
protected void engineInit(KeyManager[] km, TrustManager[] tm,
SecureRandom sr) throws KeyManagementException {
isInitialized = false;
......@@ -177,6 +178,7 @@ public abstract class SSLContextImpl extends SSLContextSpi {
return DummyX509KeyManager.INSTANCE;
}
@Override
protected SSLSocketFactory engineGetSocketFactory() {
if (!isInitialized) {
throw new IllegalStateException(
......@@ -185,6 +187,7 @@ public abstract class SSLContextImpl extends SSLContextSpi {
return new SSLSocketFactoryImpl(this);
}
@Override
protected SSLServerSocketFactory engineGetServerSocketFactory() {
if (!isInitialized) {
throw new IllegalStateException("SSLContext is not initialized");
......@@ -192,6 +195,7 @@ public abstract class SSLContextImpl extends SSLContextSpi {
return new SSLServerSocketFactoryImpl(this);
}
@Override
protected SSLEngine engineCreateSSLEngine() {
if (!isInitialized) {
throw new IllegalStateException(
......@@ -200,6 +204,7 @@ public abstract class SSLContextImpl extends SSLContextSpi {
return new SSLEngineImpl(this);
}
@Override
protected SSLEngine engineCreateSSLEngine(String host, int port) {
if (!isInitialized) {
throw new IllegalStateException(
......@@ -208,10 +213,12 @@ public abstract class SSLContextImpl extends SSLContextSpi {
return new SSLEngineImpl(this, host, port);
}
@Override
protected SSLSessionContext engineGetClientSessionContext() {
return clientCache;
}
@Override
protected SSLSessionContext engineGetServerSessionContext() {
return serverCache;
}
......@@ -463,14 +470,17 @@ public abstract class SSLContextImpl extends SSLContextSpi {
}
}
@Override
SSLParameters getDefaultServerSSLParams() {
return defaultServerSSLParams;
}
@Override
SSLParameters getDefaultClientSSLParams() {
return defaultClientSSLParams;
}
@Override
SSLParameters getSupportedSSLParams() {
return supportedSSLParams;
}
......@@ -506,6 +516,7 @@ public abstract class SSLContextImpl extends SSLContextSpi {
}
}
@Override
protected void engineInit(KeyManager[] km, TrustManager[] tm,
SecureRandom sr) throws KeyManagementException {
throw new KeyManagementException
......@@ -544,6 +555,7 @@ public abstract class SSLContextImpl extends SSLContextSpi {
final Map<String,String> props = new HashMap<>();
AccessController.doPrivileged(
new PrivilegedExceptionAction<Object>() {
@Override
public Object run() throws Exception {
props.put("keyStore", System.getProperty(
"javax.net.ssl.keyStore", ""));
......@@ -583,6 +595,7 @@ public abstract class SSLContextImpl extends SSLContextSpi {
!NONE.equals(defaultKeyStore)) {
fs = AccessController.doPrivileged(
new PrivilegedExceptionAction<FileInputStream>() {
@Override
public FileInputStream run() throws Exception {
return new FileInputStream(defaultKeyStore);
}
......@@ -697,14 +710,17 @@ public abstract class SSLContextImpl extends SSLContextSpi {
}
}
@Override
SSLParameters getDefaultServerSSLParams() {
return defaultServerSSLParams;
}
@Override
SSLParameters getDefaultClientSSLParams() {
return defaultClientSSLParams;
}
@Override
SSLParameters getSupportedSSLParams() {
return supportedSSLParams;
}
......@@ -761,14 +777,17 @@ public abstract class SSLContextImpl extends SSLContextSpi {
}
}
@Override
SSLParameters getDefaultServerSSLParams() {
return defaultServerSSLParams;
}
@Override
SSLParameters getDefaultClientSSLParams() {
return defaultClientSSLParams;
}
@Override
SSLParameters getSupportedSSLParams() {
return supportedSSLParams;
}
......@@ -1041,28 +1060,34 @@ final class AbstractKeyManagerWrapper extends X509ExtendedKeyManager {
this.km = km;
}
@Override
public String[] getClientAliases(String keyType, Principal[] issuers) {
return km.getClientAliases(keyType, issuers);
}
@Override
public String chooseClientAlias(String[] keyType, Principal[] issuers,
Socket socket) {
return km.chooseClientAlias(keyType, issuers, socket);
}
@Override
public String[] getServerAliases(String keyType, Principal[] issuers) {
return km.getServerAliases(keyType, issuers);
}
@Override
public String chooseServerAlias(String keyType, Principal[] issuers,
Socket socket) {
return km.chooseServerAlias(keyType, issuers, socket);
}
@Override
public X509Certificate[] getCertificateChain(String alias) {
return km.getCertificateChain(alias);
}
@Override
public PrivateKey getPrivateKey(String alias) {
return km.getPrivateKey(alias);
}
......@@ -1087,6 +1112,7 @@ final class DummyX509KeyManager extends X509ExtendedKeyManager {
* socket given the public key type and the list of
* certificate issuer authorities recognized by the peer (if any).
*/
@Override
public String[] getClientAliases(String keyType, Principal[] issuers) {
return null;
}
......@@ -1096,6 +1122,7 @@ final class DummyX509KeyManager extends X509ExtendedKeyManager {
* socket given the public key type and the list of
* certificate issuer authorities recognized by the peer (if any).
*/
@Override
public String chooseClientAlias(String[] keyTypes, Principal[] issuers,
Socket socket) {
return null;
......@@ -1106,6 +1133,7 @@ final class DummyX509KeyManager extends X509ExtendedKeyManager {
* engine given the public key type and the list of
* certificate issuer authorities recognized by the peer (if any).
*/
@Override
public String chooseEngineClientAlias(
String[] keyTypes, Principal[] issuers, SSLEngine engine) {
return null;
......@@ -1116,6 +1144,7 @@ final class DummyX509KeyManager extends X509ExtendedKeyManager {
* socket given the public key type and the list of
* certificate issuer authorities recognized by the peer (if any).
*/
@Override
public String[] getServerAliases(String keyType, Principal[] issuers) {
return null;
}
......@@ -1125,6 +1154,7 @@ final class DummyX509KeyManager extends X509ExtendedKeyManager {
* socket given the public key type and the list of
* certificate issuer authorities recognized by the peer (if any).
*/
@Override
public String chooseServerAlias(String keyType, Principal[] issuers,
Socket socket) {
return null;
......@@ -1135,6 +1165,7 @@ final class DummyX509KeyManager extends X509ExtendedKeyManager {
* given the public key type and the list of
* certificate issuer authorities recognized by the peer (if any).
*/
@Override
public String chooseEngineServerAlias(
String keyType, Principal[] issuers, SSLEngine engine) {
return null;
......@@ -1148,6 +1179,7 @@ final class DummyX509KeyManager extends X509ExtendedKeyManager {
* @return the certificate chain (ordered with the user's certificate first
* and the root certificate authority last)
*/
@Override
public X509Certificate[] getCertificateChain(String alias) {
return null;
}
......@@ -1160,6 +1192,7 @@ final class DummyX509KeyManager extends X509ExtendedKeyManager {
*
* @return the requested key
*/
@Override
public PrivateKey getPrivateKey(String alias) {
return null;
}
......
......@@ -553,6 +553,7 @@ final public class SSLEngineImpl extends SSLEngine {
/*
* Is a handshake currently underway?
*/
@Override
public SSLEngineResult.HandshakeStatus getHandshakeStatus() {
return getHSStatus(null);
}
......@@ -736,6 +737,7 @@ final public class SSLEngineImpl extends SSLEngine {
/*
* Start a SSLEngine handshake
*/
@Override
public void beginHandshake() throws SSLException {
try {
kickstartHandshake();
......@@ -755,6 +757,7 @@ final public class SSLEngineImpl extends SSLEngine {
* Unwraps a buffer. Does a variety of checks before grabbing
* the unwrapLock, which blocks multiple unwraps from occuring.
*/
@Override
public SSLEngineResult unwrap(ByteBuffer netData, ByteBuffer [] appData,
int offset, int length) throws SSLException {
......@@ -1155,6 +1158,7 @@ final public class SSLEngineImpl extends SSLEngine {
* Wraps a buffer. Does a variety of checks before grabbing
* the wrapLock, which blocks multiple wraps from occuring.
*/
@Override
public SSLEngineResult wrap(ByteBuffer [] appData,
int offset, int length, ByteBuffer netData) throws SSLException {
......@@ -1476,6 +1480,7 @@ final public class SSLEngineImpl extends SSLEngine {
connectionState = cs_CLOSED;
}
@Override
synchronized public void closeOutbound() {
/*
* Dump out a close_notify to the remote side
......@@ -1491,6 +1496,7 @@ final public class SSLEngineImpl extends SSLEngine {
/**
* Returns the outbound application data closure state
*/
@Override
public boolean isOutboundDone() {
return writer.isOutboundDone();
}
......@@ -1527,6 +1533,7 @@ final public class SSLEngineImpl extends SSLEngine {
* lock here, and do the real work in the internal verison.
* We do check for truncation attacks.
*/
@Override
synchronized public void closeInbound() throws SSLException {
/*
* Currently closes the outbound side as well. The IETF TLS
......@@ -1559,6 +1566,7 @@ final public class SSLEngineImpl extends SSLEngine {
/**
* Returns the network inbound data closure state
*/
@Override
synchronized public boolean isInboundDone() {
return inboundDone;
}
......@@ -1576,6 +1584,7 @@ final public class SSLEngineImpl extends SSLEngine {
* These can be long lived, and frequently correspond to an
* entire login session for some user.
*/
@Override
synchronized public SSLSession getSession() {
return sess;
}
......@@ -1593,6 +1602,7 @@ final public class SSLEngineImpl extends SSLEngine {
* Returns a delegated <code>Runnable</code> task for
* this <code>SSLEngine</code>.
*/
@Override
synchronized public Runnable getDelegatedTask() {
if (handshaker != null) {
return handshaker.getTask();
......@@ -1847,6 +1857,7 @@ final public class SSLEngineImpl extends SSLEngine {
* whether we enable session creations. Otherwise,
* we will need to wait for the next handshake.
*/
@Override
synchronized public void setEnableSessionCreation(boolean flag) {
enableSessionCreation = flag;
......@@ -1859,6 +1870,7 @@ final public class SSLEngineImpl extends SSLEngine {
* Returns true if new connections may cause creation of new SSL
* sessions.
*/
@Override
synchronized public boolean getEnableSessionCreation() {
return enableSessionCreation;
}
......@@ -1872,6 +1884,7 @@ final public class SSLEngineImpl extends SSLEngine {
* whether client authentication is needed. Otherwise,
* we will need to wait for the next handshake.
*/
@Override
synchronized public void setNeedClientAuth(boolean flag) {
doClientAuth = (flag ?
SSLEngineImpl.clauth_required : SSLEngineImpl.clauth_none);
......@@ -1883,6 +1896,7 @@ final public class SSLEngineImpl extends SSLEngine {
}
}
@Override
synchronized public boolean getNeedClientAuth() {
return (doClientAuth == SSLEngineImpl.clauth_required);
}
......@@ -1895,6 +1909,7 @@ final public class SSLEngineImpl extends SSLEngine {
* whether client authentication is requested. Otherwise,
* we will need to wait for the next handshake.
*/
@Override
synchronized public void setWantClientAuth(boolean flag) {
doClientAuth = (flag ?
SSLEngineImpl.clauth_requested : SSLEngineImpl.clauth_none);
......@@ -1906,6 +1921,7 @@ final public class SSLEngineImpl extends SSLEngine {
}
}
@Override
synchronized public boolean getWantClientAuth() {
return (doClientAuth == SSLEngineImpl.clauth_requested);
}
......@@ -1916,6 +1932,7 @@ final public class SSLEngineImpl extends SSLEngine {
* client or server mode. Must be called before any SSL
* traffic has started.
*/
@Override
@SuppressWarnings("fallthrough")
synchronized public void setUseClientMode(boolean flag) {
switch (connectionState) {
......@@ -1979,6 +1996,7 @@ final public class SSLEngineImpl extends SSLEngine {
}
}
@Override
synchronized public boolean getUseClientMode() {
return !roleIsServer;
}
......@@ -1994,6 +2012,7 @@ final public class SSLEngineImpl extends SSLEngine {
*
* @return an array of cipher suite names
*/
@Override
public String[] getSupportedCipherSuites() {
return sslContext.getSupportedCipherSuiteList().toStringArray();
}
......@@ -2007,6 +2026,7 @@ final public class SSLEngineImpl extends SSLEngine {
*
* @param suites Names of all the cipher suites to enable.
*/
@Override
synchronized public void setEnabledCipherSuites(String[] suites) {
enabledCipherSuites = new CipherSuiteList(suites);
if ((handshaker != null) && !handshaker.activated()) {
......@@ -2024,6 +2044,7 @@ final public class SSLEngineImpl extends SSLEngine {
*
* @return an array of cipher suite names
*/
@Override
synchronized public String[] getEnabledCipherSuites() {
return enabledCipherSuites.toStringArray();
}
......@@ -2034,6 +2055,7 @@ final public class SSLEngineImpl extends SSLEngine {
* A subset of the supported protocols may be enabled for this connection
* @return an array of protocol names.
*/
@Override
public String[] getSupportedProtocols() {
return sslContext.getSuportedProtocolList().toStringArray();
}
......@@ -2047,6 +2069,7 @@ final public class SSLEngineImpl extends SSLEngine {
* @exception IllegalArgumentException when one of the protocols
* named by the parameter is not supported.
*/
@Override
synchronized public void setEnabledProtocols(String[] protocols) {
enabledProtocols = new ProtocolList(protocols);
if ((handshaker != null) && !handshaker.activated()) {
......@@ -2054,6 +2077,7 @@ final public class SSLEngineImpl extends SSLEngine {
}
}
@Override
synchronized public String[] getEnabledProtocols() {
return enabledProtocols.toStringArray();
}
......@@ -2061,6 +2085,7 @@ final public class SSLEngineImpl extends SSLEngine {
/**
* Returns the SSLParameters in effect for this SSLEngine.
*/
@Override
synchronized public SSLParameters getSSLParameters() {
SSLParameters params = super.getSSLParameters();
......@@ -2076,6 +2101,7 @@ final public class SSLEngineImpl extends SSLEngine {
/**
* Applies SSLParameters to this engine.
*/
@Override
synchronized public void setSSLParameters(SSLParameters params) {
super.setSSLParameters(params);
......@@ -2107,6 +2133,7 @@ final public class SSLEngineImpl extends SSLEngine {
/**
* Returns a printable representation of this end of the connection.
*/
@Override
public String toString() {
StringBuilder retval = new StringBuilder(80);
......
......@@ -67,10 +67,12 @@ public class SSLServerSocketFactoryImpl extends SSLServerSocketFactory
* @throws IOException if the socket cannot be created
* @see java.net.Socket#bind(java.net.SocketAddress)
*/
@Override
public ServerSocket createServerSocket() throws IOException {
return new SSLServerSocketImpl(context);
}
@Override
public ServerSocket createServerSocket (int port)
throws IOException
{
......@@ -78,12 +80,14 @@ public class SSLServerSocketFactoryImpl extends SSLServerSocketFactory
}
@Override
public ServerSocket createServerSocket (int port, int backlog)
throws IOException
{
return new SSLServerSocketImpl (port, backlog, context);
}
@Override
public ServerSocket
createServerSocket (int port, int backlog, InetAddress ifAddress)
throws IOException
......@@ -98,6 +102,7 @@ public class SSLServerSocketFactoryImpl extends SSLServerSocketFactory
* (preventing person-in-the-middle attacks) and where traffic
* is encrypted to provide confidentiality.
*/
@Override
public String[] getDefaultCipherSuites() {
return context.getDefaultCipherSuiteList(true).toStringArray();
}
......@@ -112,6 +117,7 @@ public class SSLServerSocketFactoryImpl extends SSLServerSocketFactory
*
* @return an array of cipher suite names
*/
@Override
public String[] getSupportedCipherSuites() {
return context.getSupportedCipherSuiteList().toStringArray();
}
......
......@@ -29,13 +29,11 @@ package sun.security.ssl;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.ServerSocket;
import java.security.AlgorithmConstraints;
import java.util.*;
import javax.net.ServerSocketFactory;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLServerSocket;
import javax.net.ssl.SSLParameters;
......@@ -172,6 +170,7 @@ class SSLServerSocketImpl extends SSLServerSocket
*
* @return an array of cipher suite names
*/
@Override
public String[] getSupportedCipherSuites() {
return sslContext.getSupportedCipherSuiteList().toStringArray();
}
......@@ -181,6 +180,7 @@ class SSLServerSocketImpl extends SSLServerSocket
* for use by newly accepted connections. A null return indicates
* that the system defaults are in effect.
*/
@Override
synchronized public String[] getEnabledCipherSuites() {
return enabledCipherSuites.toStringArray();
}
......@@ -192,11 +192,13 @@ class SSLServerSocketImpl extends SSLServerSocket
* @param suites Names of all the cipher suites to enable; null
* means to accept system defaults.
*/
@Override
synchronized public void setEnabledCipherSuites(String[] suites) {
enabledCipherSuites = new CipherSuiteList(suites);
checkedEnabled = false;
}
@Override
public String[] getSupportedProtocols() {
return sslContext.getSuportedProtocolList().toStringArray();
}
......@@ -210,10 +212,12 @@ class SSLServerSocketImpl extends SSLServerSocket
* @exception IllegalArgumentException when one of the protocols
* named by the parameter is not supported.
*/
@Override
synchronized public void setEnabledProtocols(String[] protocols) {
enabledProtocols = new ProtocolList(protocols);
}
@Override
synchronized public String[] getEnabledProtocols() {
return enabledProtocols.toStringArray();
}
......@@ -222,11 +226,13 @@ class SSLServerSocketImpl extends SSLServerSocket
* Controls whether the connections which are accepted must include
* client authentication.
*/
@Override
public void setNeedClientAuth(boolean flag) {
doClientAuth = (flag ?
SSLEngineImpl.clauth_required : SSLEngineImpl.clauth_none);
}
@Override
public boolean getNeedClientAuth() {
return (doClientAuth == SSLEngineImpl.clauth_required);
}
......@@ -235,11 +241,13 @@ class SSLServerSocketImpl extends SSLServerSocket
* Controls whether the connections which are accepted should request
* client authentication.
*/
@Override
public void setWantClientAuth(boolean flag) {
doClientAuth = (flag ?
SSLEngineImpl.clauth_requested : SSLEngineImpl.clauth_none);
}
@Override
public boolean getWantClientAuth() {
return (doClientAuth == SSLEngineImpl.clauth_requested);
}
......@@ -250,6 +258,7 @@ class SSLServerSocketImpl extends SSLServerSocket
* FTP clients, which accept connections from servers and should be
* rejoining the already-negotiated SSL connection.
*/
@Override
public void setUseClientMode(boolean flag) {
/*
* If we need to change the socket mode and the enabled
......@@ -264,6 +273,7 @@ class SSLServerSocketImpl extends SSLServerSocket
useServerMode = !flag;
}
@Override
public boolean getUseClientMode() {
return !useServerMode;
}
......@@ -273,6 +283,7 @@ class SSLServerSocketImpl extends SSLServerSocket
* Controls whether new connections may cause creation of new SSL
* sessions.
*/
@Override
public void setEnableSessionCreation(boolean flag) {
enableSessionCreation = flag;
}
......@@ -281,6 +292,7 @@ class SSLServerSocketImpl extends SSLServerSocket
* Returns true if new connections may cause creation of new SSL
* sessions.
*/
@Override
public boolean getEnableSessionCreation() {
return enableSessionCreation;
}
......@@ -288,6 +300,7 @@ class SSLServerSocketImpl extends SSLServerSocket
/**
* Returns the SSLParameters in effect for newly accepted connections.
*/
@Override
synchronized public SSLParameters getSSLParameters() {
SSLParameters params = super.getSSLParameters();
......@@ -302,6 +315,7 @@ class SSLServerSocketImpl extends SSLServerSocket
/**
* Applies SSLParameters to newly accepted connections.
*/
@Override
synchronized public void setSSLParameters(SSLParameters params) {
super.setSSLParameters(params);
......@@ -319,6 +333,7 @@ class SSLServerSocketImpl extends SSLServerSocket
* information provided in the authentication context which was
* presented during construction.
*/
@Override
public Socket accept() throws IOException {
SSLSocketImpl s = new SSLSocketImpl(sslContext, useServerMode,
enabledCipherSuites, doClientAuth, enableSessionCreation,
......@@ -333,6 +348,7 @@ class SSLServerSocketImpl extends SSLServerSocket
/**
* Provides a brief description of this SSL socket.
*/
@Override
public String toString() {
return "[SSL: "+ super.toString() + "]";
}
......
......@@ -26,24 +26,14 @@
package sun.security.ssl;
import java.io.*;
import java.net.*;
import java.util.Date;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.NoSuchElementException;
import java.util.Vector;
import java.util.Locale;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSessionContext;
import javax.net.ssl.SSLSessionBindingListener;
import javax.net.ssl.SSLSessionBindingEvent;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession;
import sun.security.util.Cache;
import sun.security.util.Cache.CacheVisitor;
final class SSLSessionContextImpl implements SSLSessionContext {
......@@ -69,6 +59,7 @@ final class SSLSessionContextImpl implements SSLSessionContext {
/**
* Returns the <code>SSLSession</code> bound to the specified session id.
*/
@Override
public SSLSession getSession(byte[] sessionId) {
if (sessionId == null) {
throw new NullPointerException("session id cannot be null");
......@@ -85,6 +76,7 @@ final class SSLSessionContextImpl implements SSLSessionContext {
/**
* Returns an enumeration of the active SSL sessions.
*/
@Override
public Enumeration<byte[]> getIds() {
SessionCacheVisitor scVisitor = new SessionCacheVisitor();
sessionCache.accept(scVisitor);
......@@ -99,6 +91,7 @@ final class SSLSessionContextImpl implements SSLSessionContext {
* should be timed within the shorter one of the old timeout and the
* new timeout.
*/
@Override
public void setSessionTimeout(int seconds)
throws IllegalArgumentException {
if (seconds < 0) {
......@@ -115,6 +108,7 @@ final class SSLSessionContextImpl implements SSLSessionContext {
/**
* Gets the timeout limit for cached <code>SSLSession</code> objects
*/
@Override
public int getSessionTimeout() {
return timeout;
}
......@@ -123,6 +117,7 @@ final class SSLSessionContextImpl implements SSLSessionContext {
* Sets the size of the cache used for storing
* <code>SSLSession</code> objects.
*/
@Override
public void setSessionCacheSize(int size)
throws IllegalArgumentException {
if (size < 0)
......@@ -139,6 +134,7 @@ final class SSLSessionContextImpl implements SSLSessionContext {
* Gets the size of the cache used for storing
* <code>SSLSession</code> objects.
*/
@Override
public int getSessionCacheSize() {
return cacheLimit;
}
......@@ -207,6 +203,7 @@ final class SSLSessionContextImpl implements SSLSessionContext {
try {
String s = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<String>() {
@Override
public String run() {
return System.getProperty(
"javax.net.ssl.sessionCacheSize");
......@@ -238,6 +235,7 @@ final class SSLSessionContextImpl implements SSLSessionContext {
Vector<byte[]> ids = null;
// public void visit(java.util.Map<K,V> map) {}
@Override
public void visit(java.util.Map<SessionId, SSLSessionImpl> map) {
ids = new Vector<>(map.size());
......
......@@ -26,12 +26,10 @@
package sun.security.ssl;
import java.io.*;
import java.net.*;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
......@@ -45,20 +43,14 @@ import java.security.cert.CertificateEncodingException;
import javax.crypto.SecretKey;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSessionContext;
import javax.net.ssl.SSLSessionBindingListener;
import javax.net.ssl.SSLSessionBindingEvent;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLPermission;
import javax.net.ssl.SSLException;
import javax.net.ssl.ExtendedSSLSession;
import javax.net.ssl.SNIServerName;
import javax.security.auth.x500.X500Principal;
import static sun.security.ssl.CipherSuite.*;
import static sun.security.ssl.CipherSuite.KeyExchange.*;
/**
......@@ -250,6 +242,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
!invalidated && isLocalAuthenticationValid();
}
@Override
public synchronized boolean isValid() {
return isRejoinable();
}
......@@ -277,6 +270,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
* Returns the ID for this session. The ID is fixed for the
* duration of the session; neither it, nor its value, changes.
*/
@Override
public byte[] getId() {
return sessionId.getId();
}
......@@ -286,6 +280,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
* are currently valid in this process. For client sessions,
* this returns null.
*/
@Override
public SSLSessionContext getSessionContext() {
/*
* An interim security policy until we can do something
......@@ -332,6 +327,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
/**
* Returns the name of the cipher suite in use on this session
*/
@Override
public String getCipherSuite() {
return getSuite().name;
}
......@@ -343,6 +339,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
/**
* Returns the standard name of the protocol in use on this session
*/
@Override
public String getProtocol() {
return getProtocolVersion().name;
}
......@@ -357,6 +354,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
/**
* Returns the hashcode for this session
*/
@Override
public int hashCode() {
return sessionId.hashCode();
}
......@@ -365,6 +363,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
/**
* Returns true if sessions have same ids, false otherwise.
*/
@Override
public boolean equals(Object obj) {
if (obj == this) {
......@@ -391,6 +390,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
* @return array of peer X.509 certs, with the peer's own cert
* first in the chain, and with the "root" CA last.
*/
@Override
public java.security.cert.Certificate[] getPeerCertificates()
throws SSLPeerUnverifiedException {
//
......@@ -421,6 +421,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
* @return array of peer X.509 certs, with the peer's own cert
* first in the chain, and with the "root" CA last.
*/
@Override
public java.security.cert.Certificate[] getLocalCertificates() {
//
// clone to preserve integrity of session ... caller can't
......@@ -440,6 +441,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
* @return array of peer X.509 certs, with the peer's own cert
* first in the chain, and with the "root" CA last.
*/
@Override
public javax.security.cert.X509Certificate[] getPeerCertificateChain()
throws SSLPeerUnverifiedException {
//
......@@ -511,6 +513,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
* @throws SSLPeerUnverifiedException if the peer's identity has not
* been verified
*/
@Override
public Principal getPeerPrincipal()
throws SSLPeerUnverifiedException
{
......@@ -537,6 +540,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
* Principal for Kerberos cipher suites. If no principal was
* sent, then null is returned.
*/
@Override
public Principal getLocalPrincipal() {
if ((cipherSuite.keyExchange == K_KRB5) ||
......@@ -551,6 +555,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
/**
* Returns the time this session was created.
*/
@Override
public long getCreationTime() {
return creationTime;
}
......@@ -559,6 +564,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
* Returns the last time this session was used to initialize
* a connection.
*/
@Override
public long getLastAccessedTime() {
return (lastUsedTime != 0) ? lastUsedTime : creationTime;
}
......@@ -582,6 +588,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
}
}
@Override
public String getPeerHost() {
return host;
}
......@@ -590,6 +597,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
* Need to provide the port info for caching sessions based on
* host and port. Accessed by SSLSessionContextImpl
*/
@Override
public int getPeerPort() {
return port;
}
......@@ -604,6 +612,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
* Invalidate a session. Active connections may still exist, but
* no connections will be able to rejoin this session.
*/
@Override
synchronized public void invalidate() {
//
// Can't invalidate the NULL session -- this would be
......@@ -634,6 +643,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
* Assigns a session value. Session change events are given if
* appropriate, to any original value as well as the new value.
*/
@Override
public void putValue(String key, Object value) {
if ((key == null) || (value == null)) {
throw new IllegalArgumentException("arguments can not be null");
......@@ -660,6 +670,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
/**
* Returns the specified session value.
*/
@Override
public Object getValue(String key) {
if (key == null) {
throw new IllegalArgumentException("argument can not be null");
......@@ -674,6 +685,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
* Removes the specified session value, delivering a session changed
* event as appropriate.
*/
@Override
public void removeValue(String key) {
if (key == null) {
throw new IllegalArgumentException("argument can not be null");
......@@ -694,6 +706,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
/**
* Lists the names of the session values.
*/
@Override
public String[] getValueNames() {
Enumeration<SecureKey> e;
Vector<Object> v = new Vector<>();
......@@ -741,6 +754,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
* Gets the current size of the largest SSL/TLS packet that is expected
* when using this session.
*/
@Override
public synchronized int getPacketBufferSize() {
return acceptLargeFragments ?
Record.maxLargeRecordSize : Record.maxRecordSize;
......@@ -750,6 +764,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
* Gets the current size of the largest application data that is
* expected when using this session.
*/
@Override
public synchronized int getApplicationBufferSize() {
return getPacketBufferSize() - Record.headerSize;
}
......@@ -795,6 +810,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
}
/** Returns a string representation of this SSL session */
@Override
public String toString() {
return "[Session-" + sessionCount
+ ", " + getCipherSuite()
......@@ -805,6 +821,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
* When SSL sessions are finalized, all values bound to
* them are removed.
*/
@Override
public void finalize() {
String[] names = getValueNames();
for (int i = 0; i < names.length; i++) {
......@@ -847,10 +864,12 @@ class SecureKey {
return securityCtx;
}
@Override
public int hashCode() {
return appKey.hashCode() ^ securityCtx.hashCode();
}
@Override
public boolean equals(Object o) {
return o instanceof SecureKey && ((SecureKey)o).appKey.equals(appKey)
&& ((SecureKey)o).securityCtx.equals(securityCtx);
......
......@@ -28,7 +28,6 @@ package sun.security.ssl;
import java.io.*;
import java.net.*;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.SSLSocket;
/**
......@@ -69,6 +68,7 @@ final public class SSLSocketFactoryImpl extends SSLSocketFactory {
* @return the unconnected socket
* @see java.net.Socket#connect(java.net.SocketAddress, int)
*/
@Override
public Socket createSocket() {
return new SSLSocketImpl(context);
}
......@@ -82,6 +82,7 @@ final public class SSLSocketFactoryImpl extends SSLSocketFactory {
* @param host name of the host with which to connect
* @param port number of the server's port
*/
@Override
public Socket createSocket(String host, int port)
throws IOException, UnknownHostException
{
......@@ -104,6 +105,7 @@ final public class SSLSocketFactoryImpl extends SSLSocketFactory {
* @exception IOException if the connection can't be established
* @exception UnknownHostException if the host is not known
*/
@Override
public Socket createSocket(Socket s, String host, int port,
boolean autoClose) throws IOException {
return new SSLSocketImpl(context, s, host, port, autoClose);
......@@ -129,6 +131,7 @@ final public class SSLSocketFactoryImpl extends SSLSocketFactory {
* @param address the server's host
* @param port its port
*/
@Override
public Socket createSocket(InetAddress address, int port)
throws IOException
{
......@@ -143,6 +146,7 @@ final public class SSLSocketFactoryImpl extends SSLSocketFactory {
* has been configured. The socket will also bind() to the local
* address and port supplied.
*/
@Override
public Socket createSocket(String host, int port,
InetAddress clientAddress, int clientPort)
throws IOException
......@@ -158,6 +162,7 @@ final public class SSLSocketFactoryImpl extends SSLSocketFactory {
* context which has been configured. The socket will also bind() to
* the local address and port supplied.
*/
@Override
public Socket createSocket(InetAddress address, int port,
InetAddress clientAddress, int clientPort)
throws IOException
......@@ -174,6 +179,7 @@ final public class SSLSocketFactoryImpl extends SSLSocketFactory {
* (preventing person-in-the-middle attacks) and where traffic
* is encrypted to provide confidentiality.
*/
@Override
public String[] getDefaultCipherSuites() {
return context.getDefaultCipherSuiteList(false).toStringArray();
}
......@@ -186,6 +192,7 @@ final public class SSLSocketFactoryImpl extends SSLSocketFactory {
* which do not protect data confidentiality. Servers may also need
* certain kinds of certificates to use certain cipher suites.
*/
@Override
public String[] getSupportedCipherSuites() {
return context.getSupportedCipherSuiteList().toStringArray();
}
......
......@@ -36,7 +36,6 @@ import java.security.AlgorithmConstraints;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
import java.nio.charset.StandardCharsets;
import javax.crypto.BadPaddingException;
import javax.net.ssl.*;
......@@ -626,6 +625,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
* @throws IOException if an error occurs during the connection
* @throws SocketTimeoutException if timeout expires before connecting
*/
@Override
public void connect(SocketAddress endpoint, int timeout)
throws IOException {
......@@ -1357,6 +1357,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
/**
* Starts an SSL handshake on this connection.
*/
@Override
public void startHandshake() throws IOException {
// start an ssl handshake that could be resumed from timeout exception
startHandshake(true);
......@@ -1481,6 +1482,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
/**
* Return whether the socket has been explicitly closed by the application.
*/
@Override
public boolean isClosed() {
return getConnectionState() == cs_APP_CLOSED;
}
......@@ -1567,6 +1569,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
* rather than leaving it for finalization, so that your remote
* peer does not experience a protocol error.
*/
@Override
public void close() throws IOException {
if ((debug != null) && Debug.isOn("ssl")) {
System.out.println(Thread.currentThread().getName() +
......@@ -2155,6 +2158,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
* Data read from this stream was always integrity protected in
* transit, and will usually have been confidentiality protected.
*/
@Override
synchronized public InputStream getInputStream() throws IOException {
if (isClosed()) {
throw new SocketException("Socket is closed");
......@@ -2176,6 +2180,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
* Data written on this stream is always integrity protected, and
* will usually be confidentiality protected.
*/
@Override
synchronized public OutputStream getOutputStream() throws IOException {
if (isClosed()) {
throw new SocketException("Socket is closed");
......@@ -2197,6 +2202,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
* be long lived, and frequently correspond to an entire login session
* for some user.
*/
@Override
public SSLSession getSession() {
/*
* Force a synchronous handshake, if appropriate.
......@@ -2235,6 +2241,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
* whether we enable session creations. Otherwise,
* we will need to wait for the next handshake.
*/
@Override
synchronized public void setEnableSessionCreation(boolean flag) {
enableSessionCreation = flag;
......@@ -2247,6 +2254,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
* Returns true if new connections may cause creation of new SSL
* sessions.
*/
@Override
synchronized public boolean getEnableSessionCreation() {
return enableSessionCreation;
}
......@@ -2260,6 +2268,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
* whether client authentication is needed. Otherwise,
* we will need to wait for the next handshake.
*/
@Override
synchronized public void setNeedClientAuth(boolean flag) {
doClientAuth = (flag ?
SSLEngineImpl.clauth_required : SSLEngineImpl.clauth_none);
......@@ -2271,6 +2280,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
}
}
@Override
synchronized public boolean getNeedClientAuth() {
return (doClientAuth == SSLEngineImpl.clauth_required);
}
......@@ -2283,6 +2293,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
* whether client authentication is requested. Otherwise,
* we will need to wait for the next handshake.
*/
@Override
synchronized public void setWantClientAuth(boolean flag) {
doClientAuth = (flag ?
SSLEngineImpl.clauth_requested : SSLEngineImpl.clauth_none);
......@@ -2294,6 +2305,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
}
}
@Override
synchronized public boolean getWantClientAuth() {
return (doClientAuth == SSLEngineImpl.clauth_requested);
}
......@@ -2304,6 +2316,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
* client or server mode. Must be called before any SSL
* traffic has started.
*/
@Override
@SuppressWarnings("fallthrough")
synchronized public void setUseClientMode(boolean flag) {
switch (connectionState) {
......@@ -2359,6 +2372,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
}
}
@Override
synchronized public boolean getUseClientMode() {
return !roleIsServer;
}
......@@ -2374,6 +2388,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
*
* @return an array of cipher suite names
*/
@Override
public String[] getSupportedCipherSuites() {
return sslContext.getSupportedCipherSuiteList().toStringArray();
}
......@@ -2387,6 +2402,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
*
* @param suites Names of all the cipher suites to enable.
*/
@Override
synchronized public void setEnabledCipherSuites(String[] suites) {
enabledCipherSuites = new CipherSuiteList(suites);
if ((handshaker != null) && !handshaker.activated()) {
......@@ -2404,6 +2420,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
*
* @return an array of cipher suite names
*/
@Override
synchronized public String[] getEnabledCipherSuites() {
return enabledCipherSuites.toStringArray();
}
......@@ -2414,6 +2431,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
* A subset of the supported protocols may be enabled for this connection
* @return an array of protocol names.
*/
@Override
public String[] getSupportedProtocols() {
return sslContext.getSuportedProtocolList().toStringArray();
}
......@@ -2427,6 +2445,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
* @exception IllegalArgumentException when one of the protocols
* named by the parameter is not supported.
*/
@Override
synchronized public void setEnabledProtocols(String[] protocols) {
enabledProtocols = new ProtocolList(protocols);
if ((handshaker != null) && !handshaker.activated()) {
......@@ -2434,6 +2453,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
}
}
@Override
synchronized public String[] getEnabledProtocols() {
return enabledProtocols.toStringArray();
}
......@@ -2442,6 +2462,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
* Assigns the socket timeout.
* @see java.net.Socket#setSoTimeout
*/
@Override
public void setSoTimeout(int timeout) throws SocketException {
if ((debug != null) && Debug.isOn("ssl")) {
System.out.println(Thread.currentThread().getName() +
......@@ -2455,6 +2476,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
* Registers an event listener to receive notifications that an
* SSL handshake has completed on this connection.
*/
@Override
public synchronized void addHandshakeCompletedListener(
HandshakeCompletedListener listener) {
if (listener == null) {
......@@ -2471,6 +2493,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
/**
* Removes a previously registered handshake completion listener.
*/
@Override
public synchronized void removeHandshakeCompletedListener(
HandshakeCompletedListener listener) {
if (handshakeListeners == null) {
......@@ -2487,6 +2510,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
/**
* Returns the SSLParameters in effect for this SSLSocket.
*/
@Override
synchronized public SSLParameters getSSLParameters() {
SSLParameters params = super.getSSLParameters();
......@@ -2502,6 +2526,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
/**
* Applies SSLParameters to this socket.
*/
@Override
synchronized public void setSSLParameters(SSLParameters params) {
super.setSSLParameters(params);
......@@ -2550,6 +2575,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
event = e;
}
@Override
public void run() {
// Don't need to synchronize, as it only runs in one thread.
for (Map.Entry<HandshakeCompletedListener,AccessControlContext>
......@@ -2558,6 +2584,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
final HandshakeCompletedListener l = entry.getKey();
AccessControlContext acc = entry.getValue();
AccessController.doPrivileged(new PrivilegedAction<Void>() {
@Override
public Void run() {
l.handshakeCompleted(event);
return null;
......@@ -2570,6 +2597,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
/**
* Returns a printable representation of this end of the connection.
*/
@Override
public String toString() {
StringBuffer retval = new StringBuffer(80);
......
......@@ -43,7 +43,6 @@ import javax.security.auth.Subject;
import sun.security.ssl.HandshakeMessage.*;
import sun.security.ssl.CipherSuite.*;
import sun.security.ssl.SignatureAndHashAlgorithm.*;
import static sun.security.ssl.CipherSuite.*;
import static sun.security.ssl.CipherSuite.KeyExchange.*;
/**
......@@ -144,6 +143,7 @@ final class ServerHandshaker extends Handshaker {
* It updates the state machine as each message is processed, and writes
* responses as needed using the connection in the constructor.
*/
@Override
void processMessage(byte type, int message_len)
throws IOException {
//
......@@ -526,6 +526,7 @@ final class ServerHandshaker extends Handshaker {
try {
subject = AccessController.doPrivileged(
new PrivilegedExceptionAction<Subject>() {
@Override
public Subject run() throws Exception {
return
Krb5Helper.getServerSubject(getAccSE());
......@@ -1329,6 +1330,7 @@ final class ServerHandshaker extends Handshaker {
kerberosKeys = AccessController.doPrivileged(
// Eliminate dependency on KerberosKey
new PrivilegedExceptionAction<SecretKey[]>() {
@Override
public SecretKey[] run() throws Exception {
// get kerberos key for the default principal
return Krb5Helper.getServerKeys(acc);
......@@ -1600,6 +1602,7 @@ final class ServerHandshaker extends Handshaker {
/*
* Returns a HelloRequest message to kickstart renegotiations
*/
@Override
HandshakeMessage getKickstartMessage() {
return new HelloRequest();
}
......@@ -1608,6 +1611,7 @@ final class ServerHandshaker extends Handshaker {
/*
* Fault detected during handshake.
*/
@Override
void handshakeAlert(byte description) throws SSLProtocolException {
String message = Alerts.alertDescription(description);
......
......@@ -243,10 +243,12 @@ final class ServerNameExtension extends HelloExtension {
return false;
}
@Override
int length() {
return listLength == 0 ? 4 : 6 + listLength;
}
@Override
void send(HandshakeOutStream s) throws IOException {
s.putInt16(type.id);
if (listLength == 0) {
......@@ -262,6 +264,7 @@ final class ServerNameExtension extends HelloExtension {
}
}
@Override
public String toString() {
StringBuffer buffer = new StringBuffer();
for (SNIServerName sniName : sniMap.values()) {
......
......@@ -68,6 +68,7 @@ class SessionId
}
/** Returns the ID as a string */
@Override
public String toString ()
{
int len = sessionId.length;
......@@ -85,6 +86,7 @@ class SessionId
/** Returns a value which is the same for session IDs which are equal */
@Override
public int hashCode ()
{
int retval = 0;
......@@ -95,6 +97,7 @@ class SessionId
}
/** Returns true if the parameter is the same session ID */
@Override
public boolean equals (Object obj)
{
if (!(obj instanceof SessionId))
......
......@@ -148,6 +148,7 @@ public abstract class SunJSSE extends java.security.Provider {
private void registerAlgorithms(final boolean isfips) {
AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
public Object run() {
doRegister(isfips);
return null;
......
......@@ -166,6 +166,7 @@ final class SunX509KeyManagerImpl extends X509ExtendedKeyManager {
* @return the certificate chain (ordered with the user's certificate first
* and the root certificate authority last)
*/
@Override
public X509Certificate[] getCertificateChain(String alias) {
if (alias == null) {
return null;
......@@ -181,6 +182,7 @@ final class SunX509KeyManagerImpl extends X509ExtendedKeyManager {
/*
* Returns the key associated with the given alias
*/
@Override
public PrivateKey getPrivateKey(String alias) {
if (alias == null) {
return null;
......@@ -198,6 +200,7 @@ final class SunX509KeyManagerImpl extends X509ExtendedKeyManager {
* socket given the public key type and the list of
* certificate issuer authorities recognized by the peer (if any).
*/
@Override
public String chooseClientAlias(String[] keyTypes, Principal[] issuers,
Socket socket) {
/*
......@@ -228,6 +231,7 @@ final class SunX509KeyManagerImpl extends X509ExtendedKeyManager {
*
* @since 1.5
*/
@Override
public String chooseEngineClientAlias(String[] keyType,
Principal[] issuers, SSLEngine engine) {
/*
......@@ -242,6 +246,7 @@ final class SunX509KeyManagerImpl extends X509ExtendedKeyManager {
* socket given the public key type and the list of
* certificate issuer authorities recognized by the peer (if any).
*/
@Override
public String chooseServerAlias(String keyType,
Principal[] issuers, Socket socket) {
/*
......@@ -283,6 +288,7 @@ final class SunX509KeyManagerImpl extends X509ExtendedKeyManager {
*
* @since 1.5
*/
@Override
public String chooseEngineServerAlias(String keyType,
Principal[] issuers, SSLEngine engine) {
/*
......@@ -297,6 +303,7 @@ final class SunX509KeyManagerImpl extends X509ExtendedKeyManager {
* socket given the public key type and the list of
* certificate issuer authorities recognized by the peer (if any).
*/
@Override
public String[] getClientAliases(String keyType, Principal[] issuers) {
return getAliases(keyType, issuers);
}
......@@ -306,6 +313,7 @@ final class SunX509KeyManagerImpl extends X509ExtendedKeyManager {
* socket given the public key type and the list of
* certificate issuer authorities recognized by the peer (if any).
*/
@Override
public String[] getServerAliases(String keyType, Principal[] issuers) {
return getAliases(keyType, issuers);
}
......
......@@ -94,10 +94,12 @@ final class SupportedEllipticCurvesExtension extends HelloExtension {
return curveIds;
}
@Override
int length() {
return 6 + (curveIds.length << 1);
}
@Override
void send(HandshakeOutStream s) throws IOException {
s.putInt16(type.id);
int k = curveIds.length << 1;
......@@ -108,6 +110,7 @@ final class SupportedEllipticCurvesExtension extends HelloExtension {
}
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Extension " + type + ", curve names: {");
......
......@@ -67,10 +67,12 @@ final class SupportedEllipticPointFormatsExtension extends HelloExtension {
}
}
@Override
int length() {
return 5 + formats.length;
}
@Override
void send(HandshakeOutStream s) throws IOException {
s.putInt16(type.id);
s.putInt16(formats.length + 1);
......@@ -91,6 +93,7 @@ final class SupportedEllipticPointFormatsExtension extends HelloExtension {
}
}
@Override
public String toString() {
List<String> list = new ArrayList<String>();
for (byte format : formats) {
......
......@@ -27,11 +27,9 @@ package sun.security.ssl;
import java.util.*;
import java.io.*;
import java.math.*;
import java.security.*;
import java.security.cert.*;
import javax.net.ssl.*;
import java.security.spec.AlgorithmParameterSpec;
import sun.security.validator.Validator;
......@@ -45,6 +43,7 @@ abstract class TrustManagerFactoryImpl extends TrustManagerFactorySpi {
// empty
}
@Override
protected void engineInit(KeyStore ks) throws KeyStoreException {
if (ks == null) {
try {
......@@ -85,6 +84,7 @@ abstract class TrustManagerFactoryImpl extends TrustManagerFactorySpi {
abstract X509TrustManager getInstance(ManagerFactoryParameters spec)
throws InvalidAlgorithmParameterException;
@Override
protected void engineInit(ManagerFactoryParameters spec) throws
InvalidAlgorithmParameterException {
trustManager = getInstance(spec);
......@@ -94,6 +94,7 @@ abstract class TrustManagerFactoryImpl extends TrustManagerFactorySpi {
/**
* Returns one trust manager for each type of trust material.
*/
@Override
protected TrustManager[] engineGetTrustManagers() {
if (!isInitialized) {
throw new IllegalStateException(
......@@ -109,6 +110,7 @@ abstract class TrustManagerFactoryImpl extends TrustManagerFactorySpi {
throws Exception {
return AccessController.doPrivileged(
new PrivilegedExceptionAction<FileInputStream>() {
@Override
public FileInputStream run() throws Exception {
try {
if (file.exists()) {
......@@ -139,6 +141,7 @@ abstract class TrustManagerFactoryImpl extends TrustManagerFactorySpi {
KeyStore ks = null;
AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
props.put("trustStore", System.getProperty(
"javax.net.ssl.trustStore"));
......@@ -239,9 +242,11 @@ abstract class TrustManagerFactoryImpl extends TrustManagerFactorySpi {
}
public static final class SimpleFactory extends TrustManagerFactoryImpl {
@Override
X509TrustManager getInstance(KeyStore ks) throws KeyStoreException {
return new X509TrustManagerImpl(Validator.TYPE_SIMPLE, ks);
}
@Override
X509TrustManager getInstance(ManagerFactoryParameters spec)
throws InvalidAlgorithmParameterException {
throw new InvalidAlgorithmParameterException
......@@ -251,9 +256,11 @@ abstract class TrustManagerFactoryImpl extends TrustManagerFactorySpi {
}
public static final class PKIXFactory extends TrustManagerFactoryImpl {
@Override
X509TrustManager getInstance(KeyStore ks) throws KeyStoreException {
return new X509TrustManagerImpl(Validator.TYPE_PKIX, ks);
}
@Override
X509TrustManager getInstance(ManagerFactoryParameters spec)
throws InvalidAlgorithmParameterException {
if (spec instanceof CertPathTrustManagerParameters == false) {
......
......@@ -41,15 +41,18 @@ final class UnknownExtension extends HelloExtension {
}
}
@Override
int length() {
return 4 + data.length;
}
@Override
void send(HandshakeOutStream s) throws IOException {
s.putInt16(type.id);
s.putBytes16(data);
}
@Override
public String toString() {
return "Unsupported extension " + type + ", data: " +
Debug.toString(data);
......
......@@ -102,29 +102,34 @@ final class X509KeyManagerImpl extends X509ExtendedKeyManager
// public methods
//
@Override
public X509Certificate[] getCertificateChain(String alias) {
PrivateKeyEntry entry = getEntry(alias);
return entry == null ? null :
(X509Certificate[])entry.getCertificateChain();
}
@Override
public PrivateKey getPrivateKey(String alias) {
PrivateKeyEntry entry = getEntry(alias);
return entry == null ? null : entry.getPrivateKey();
}
@Override
public String chooseClientAlias(String[] keyTypes, Principal[] issuers,
Socket socket) {
return chooseAlias(getKeyTypes(keyTypes), issuers, CheckType.CLIENT,
getAlgorithmConstraints(socket));
}
@Override
public String chooseEngineClientAlias(String[] keyTypes,
Principal[] issuers, SSLEngine engine) {
return chooseAlias(getKeyTypes(keyTypes), issuers, CheckType.CLIENT,
getAlgorithmConstraints(engine));
}
@Override
public String chooseServerAlias(String keyType,
Principal[] issuers, Socket socket) {
return chooseAlias(getKeyTypes(keyType), issuers, CheckType.SERVER,
......@@ -142,6 +147,7 @@ final class X509KeyManagerImpl extends X509ExtendedKeyManager
// It is not a really HTTPS endpoint identification.
}
@Override
public String chooseEngineServerAlias(String keyType,
Principal[] issuers, SSLEngine engine) {
return chooseAlias(getKeyTypes(keyType), issuers, CheckType.SERVER,
......@@ -159,10 +165,12 @@ final class X509KeyManagerImpl extends X509ExtendedKeyManager
// It is not a really HTTPS endpoint identification.
}
@Override
public String[] getClientAliases(String keyType, Principal[] issuers) {
return getAliases(keyType, issuers, CheckType.CLIENT, null);
}
@Override
public String[] getServerAliases(String keyType, Principal[] issuers) {
return getAliases(keyType, issuers, CheckType.SERVER, null);
}
......@@ -488,11 +496,13 @@ final class X509KeyManagerImpl extends X509ExtendedKeyManager
this.checkResult = checkResult;
}
@Override
public int compareTo(EntryStatus other) {
int result = this.checkResult.compareTo(other.checkResult);
return (result == 0) ? (this.keyIndex - other.keyIndex) : result;
}
@Override
public String toString() {
String s = alias + " (verified: " + checkResult + ")";
if (builderIndex == 0) {
......
......@@ -28,7 +28,6 @@ package sun.security.ssl;
import java.net.Socket;
import javax.net.ssl.SSLSession;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.security.*;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册