This commit is contained in:
Lana Steuck 2014-12-30 13:19:59 -08:00
commit a20b846cab
201 changed files with 2720 additions and 994 deletions
jdk/src
java.base
java.desktop
macosx
share/classes

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,6 +26,8 @@
package com.sun.crypto.provider;
import java.security.InvalidKeyException;
import java.security.ProviderException;
/**
* This class represents ciphers in cipher block chaining (CBC) mode.
@ -122,31 +124,31 @@ class CipherBlockChaining extends FeedbackCipher {
*
* <p>The input plain text <code>plain</code>, starting at
* <code>plainOffset</code> and ending at
* <code>(plainOffset + len - 1)</code>, is encrypted.
* <code>(plainOffset + plainLen - 1)</code>, is encrypted.
* The result is stored in <code>cipher</code>, starting at
* <code>cipherOffset</code>.
*
* <p>It is the application's responsibility to make sure that
* <code>plainLen</code> is a multiple of the embedded cipher's block size,
* as any excess bytes are ignored.
*
* @param plain the buffer with the input data to be encrypted
* @param plainOffset the offset in <code>plain</code>
* @param plainLen the length of the input data
* @param cipher the buffer for the result
* @param cipherOffset the offset in <code>cipher</code>
* @exception ProviderException if <code>len</code> is not
* a multiple of the block size
* @return the length of the encrypted data
*/
int encrypt(byte[] plain, int plainOffset, int plainLen,
byte[] cipher, int cipherOffset)
{
int i;
if ((plainLen % blockSize) != 0) {
throw new ProviderException("Internal error in input buffering");
}
int endIndex = plainOffset + plainLen;
for (; plainOffset < endIndex;
plainOffset+=blockSize, cipherOffset += blockSize) {
for (i=0; i<blockSize; i++) {
k[i] = (byte)(plain[i+plainOffset] ^ r[i]);
for (int i = 0; i < blockSize; i++) {
k[i] = (byte)(plain[i + plainOffset] ^ r[i]);
}
embeddedCipher.encryptBlock(k, 0, cipher, cipherOffset);
System.arraycopy(cipher, cipherOffset, r, 0, blockSize);
@ -159,14 +161,10 @@ class CipherBlockChaining extends FeedbackCipher {
*
* <p>The input cipher text <code>cipher</code>, starting at
* <code>cipherOffset</code> and ending at
* <code>(cipherOffset + len - 1)</code>, is decrypted.
* <code>(cipherOffset + cipherLen - 1)</code>, is decrypted.
* The result is stored in <code>plain</code>, starting at
* <code>plainOffset</code>.
*
* <p>It is the application's responsibility to make sure that
* <code>cipherLen</code> is a multiple of the embedded cipher's block
* size, as any excess bytes are ignored.
*
* <p>It is also the application's responsibility to make sure that
* <code>init</code> has been called before this method is called.
* (This check is omitted here, to avoid double checking.)
@ -176,23 +174,23 @@ class CipherBlockChaining extends FeedbackCipher {
* @param cipherLen the length of the input data
* @param plain the buffer for the result
* @param plainOffset the offset in <code>plain</code>
* @exception ProviderException if <code>len</code> is not
* a multiple of the block size
* @return the length of the decrypted data
*
* @exception IllegalBlockSizeException if input data whose length does
* not correspond to the embedded cipher's block size is passed to the
* embedded cipher
*/
int decrypt(byte[] cipher, int cipherOffset, int cipherLen,
byte[] plain, int plainOffset)
{
int i;
if ((cipherLen % blockSize) != 0) {
throw new ProviderException("Internal error in input buffering");
}
int endIndex = cipherOffset + cipherLen;
for (; cipherOffset < endIndex;
cipherOffset += blockSize, plainOffset += blockSize) {
embeddedCipher.decryptBlock(cipher, cipherOffset, k, 0);
for (i = 0; i < blockSize; i++) {
plain[i+plainOffset] = (byte)(k[i] ^ r[i]);
for (int i = 0; i < blockSize; i++) {
plain[i + plainOffset] = (byte)(k[i] ^ r[i]);
}
System.arraycopy(cipher, cipherOffset, r, 0, blockSize);
}

@ -708,7 +708,7 @@ final class CipherCore {
len -= blockSize;
}
// do not count the trailing bytes which do not make up a unit
len = (len > 0 ? (len - (len%unitBytes)) : 0);
len = (len > 0 ? (len - (len % unitBytes)) : 0);
// check output buffer capacity
if ((output == null) ||
@ -747,6 +747,9 @@ final class CipherCore {
int bufferCapacity = buffer.length - buffered;
if (bufferCapacity != 0) {
temp = Math.min(bufferCapacity, inputConsumed);
if (unitBytes != blockSize) {
temp -= ((buffered + temp) % unitBytes);
}
System.arraycopy(input, inputOffset, buffer, buffered, temp);
inputOffset += temp;
inputConsumed -= temp;

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,6 +26,7 @@
package com.sun.crypto.provider;
import java.security.InvalidKeyException;
import java.security.ProviderException;
/**
* This class represents ciphers in cipher-feedback (CFB) mode.
@ -133,66 +134,72 @@ final class CipherFeedback extends FeedbackCipher {
*
* <p>The input plain text <code>plain</code>, starting at
* <code>plainOffset</code> and ending at
* <code>(plainOffset + len - 1)</code>, is encrypted.
* <code>(plainOffset + plainLen - 1)</code>, is encrypted.
* The result is stored in <code>cipher</code>, starting at
* <code>cipherOffset</code>.
*
* <p>It is the application's responsibility to make sure that
* <code>plainLen</code> is a multiple of the stream unit size
* <code>numBytes</code>, as any excess bytes are ignored.
*
* <p>It is also the application's responsibility to make sure that
* <code>init</code> has been called before this method is called.
* (This check is omitted here, to avoid double checking.)
*
* @param plain the buffer with the input data to be encrypted
* @param plainOffset the offset in <code>plain</code>
* @param plainLen the length of the input data
* @param cipher the buffer for the result
* @param cipherOffset the offset in <code>cipher</code>
* @exception ProviderException if <code>plainLen</code> is not
* a multiple of the <code>numBytes</code>
* @return the length of the encrypted data
*/
int encrypt(byte[] plain, int plainOffset, int plainLen,
byte[] cipher, int cipherOffset)
{
int i, len;
len = blockSize - numBytes;
byte[] cipher, int cipherOffset) {
if ((plainLen % numBytes) != 0) {
throw new ProviderException("Internal error in input buffering");
}
int nShift = blockSize - numBytes;
int loopCount = plainLen / numBytes;
for (; loopCount > 0 ;
plainOffset += numBytes, cipherOffset += numBytes,
loopCount--) {
embeddedCipher.encryptBlock(register, 0, k, 0);
if (nShift != 0) {
System.arraycopy(register, numBytes, register, 0, nShift);
}
for (int i = 0; i < numBytes; i++) {
register[nShift + i] = cipher[i + cipherOffset] =
(byte)(k[i] ^ plain[i + plainOffset]);
}
}
return plainLen;
}
/**
* Performs the last encryption operation.
*
* <p>The input plain text <code>plain</code>, starting at
* <code>plainOffset</code> and ending at
* <code>(plainOffset + plainLen - 1)</code>, is encrypted.
* The result is stored in <code>cipher</code>, starting at
* <code>cipherOffset</code>.
*
* @param plain the buffer with the input data to be encrypted
* @param plainOffset the offset in <code>plain</code>
* @param plainLen the length of the input data
* @param cipher the buffer for the result
* @param cipherOffset the offset in <code>cipher</code>
* @return the number of bytes placed into <code>cipher</code>
*/
int encryptFinal(byte[] plain, int plainOffset, int plainLen,
byte[] cipher, int cipherOffset) {
int oddBytes = plainLen % numBytes;
if (len == 0) {
for (; loopCount > 0 ;
plainOffset += numBytes, cipherOffset += numBytes,
loopCount--) {
embeddedCipher.encryptBlock(register, 0, k, 0);
for (i = 0; i < blockSize; i++)
register[i] = cipher[i+cipherOffset] =
(byte)(k[i] ^ plain[i+plainOffset]);
}
if (oddBytes > 0) {
embeddedCipher.encryptBlock(register, 0, k, 0);
for (i=0; i<oddBytes; i++)
register[i] = cipher[i+cipherOffset] =
(byte)(k[i] ^ plain[i+plainOffset]);
}
} else {
for (; loopCount > 0 ;
plainOffset += numBytes, cipherOffset += numBytes,
loopCount--) {
embeddedCipher.encryptBlock(register, 0, k, 0);
System.arraycopy(register, numBytes, register, 0, len);
for (i=0; i<numBytes; i++)
register[i+len] = cipher[i+cipherOffset] =
(byte)(k[i] ^ plain[i+plainOffset]);
}
if (oddBytes != 0) {
embeddedCipher.encryptBlock(register, 0, k, 0);
System.arraycopy(register, numBytes, register, 0, len);
for (i=0; i<oddBytes; i++) {
register[i+len] = cipher[i+cipherOffset] =
(byte)(k[i] ^ plain[i+plainOffset]);
}
int len = encrypt(plain, plainOffset, (plainLen - oddBytes),
cipher, cipherOffset);
plainOffset += len;
cipherOffset += len;
if (oddBytes != 0) {
embeddedCipher.encryptBlock(register, 0, k, 0);
for (int i = 0; i < oddBytes; i++) {
cipher[i + cipherOffset] =
(byte)(k[i] ^ plain[i + plainOffset]);
}
}
return plainLen;
@ -203,17 +210,52 @@ final class CipherFeedback extends FeedbackCipher {
*
* <p>The input cipher text <code>cipher</code>, starting at
* <code>cipherOffset</code> and ending at
* <code>(cipherOffset + len - 1)</code>, is decrypted.
* <code>(cipherOffset + cipherLen - 1)</code>, is decrypted.
* The result is stored in <code>plain</code>, starting at
* <code>plainOffset</code>.
*
* <p>It is the application's responsibility to make sure that
* <code>cipherLen</code> is a multiple of the stream unit size
* <code>numBytes</code>, as any excess bytes are ignored.
* @param cipher the buffer with the input data to be decrypted
* @param cipherOffset the offset in <code>cipherOffset</code>
* @param cipherLen the length of the input data
* @param plain the buffer for the result
* @param plainOffset the offset in <code>plain</code>
* @exception ProviderException if <code>cipherLen</code> is not
* a multiple of the <code>numBytes</code>
* @return the length of the decrypted data
*/
int decrypt(byte[] cipher, int cipherOffset, int cipherLen,
byte[] plain, int plainOffset) {
if ((cipherLen % numBytes) != 0) {
throw new ProviderException("Internal error in input buffering");
}
int nShift = blockSize - numBytes;
int loopCount = cipherLen / numBytes;
for (; loopCount > 0;
plainOffset += numBytes, cipherOffset += numBytes,
loopCount--) {
embeddedCipher.encryptBlock(register, 0, k, 0);
if (nShift != 0) {
System.arraycopy(register, numBytes, register, 0, nShift);
}
for (int i = 0; i < numBytes; i++) {
register[i + nShift] = cipher[i + cipherOffset];
plain[i + plainOffset]
= (byte)(cipher[i + cipherOffset] ^ k[i]);
}
}
return cipherLen;
}
/**
* Performs the last decryption operation.
*
* <p>It is also the application's responsibility to make sure that
* <code>init</code> has been called before this method is called.
* (This check is omitted here, to avoid double checking.)
* <p>The input cipher text <code>cipher</code>, starting at
* <code>cipherOffset</code> and ending at
* <code>(cipherOffset + cipherLen - 1)</code>, is decrypted.
* The result is stored in <code>plain</code>, starting at
* <code>plainOffset</code>.
*
* @param cipher the buffer with the input data to be decrypted
* @param cipherOffset the offset in <code>cipherOffset</code>
@ -222,53 +264,19 @@ final class CipherFeedback extends FeedbackCipher {
* @param plainOffset the offset in <code>plain</code>
* @return the length of the decrypted data
*/
int decrypt(byte[] cipher, int cipherOffset, int cipherLen,
byte[] plain, int plainOffset)
{
int i, len;
len = blockSize - numBytes;
int loopCount = cipherLen / numBytes;
int oddBytes = cipherLen % numBytes;
int decryptFinal(byte[] cipher, int cipherOffset, int cipherLen,
byte[] plain, int plainOffset) {
if (len == 0) {
for (; loopCount > 0;
plainOffset += numBytes, cipherOffset += numBytes,
loopCount--) {
embeddedCipher.encryptBlock(register, 0, k, 0);
for (i = 0; i < blockSize; i++) {
register[i] = cipher[i+cipherOffset];
plain[i+plainOffset]
= (byte)(cipher[i+cipherOffset] ^ k[i]);
}
}
if (oddBytes > 0) {
embeddedCipher.encryptBlock(register, 0, k, 0);
for (i=0; i<oddBytes; i++) {
register[i] = cipher[i+cipherOffset];
plain[i+plainOffset]
= (byte)(cipher[i+cipherOffset] ^ k[i]);
}
}
} else {
for (; loopCount > 0;
plainOffset += numBytes, cipherOffset += numBytes,
loopCount--) {
embeddedCipher.encryptBlock(register, 0, k, 0);
System.arraycopy(register, numBytes, register, 0, len);
for (i=0; i<numBytes; i++) {
register[i+len] = cipher[i+cipherOffset];
plain[i+plainOffset]
= (byte)(cipher[i+cipherOffset] ^ k[i]);
}
}
if (oddBytes != 0) {
embeddedCipher.encryptBlock(register, 0, k, 0);
System.arraycopy(register, numBytes, register, 0, len);
for (i=0; i<oddBytes; i++) {
register[i+len] = cipher[i+cipherOffset];
plain[i+plainOffset]
= (byte)(cipher[i+cipherOffset] ^ k[i]);
}
int oddBytes = cipherLen % numBytes;
int len = decrypt(cipher, cipherOffset, (cipherLen - oddBytes),
plain, plainOffset);
cipherOffset += len;
plainOffset += len;
if (oddBytes != 0) {
embeddedCipher.encryptBlock(register, 0, k, 0);
for (int i = 0; i < oddBytes; i++) {
plain[i + plainOffset]
= (byte)(cipher[i + cipherOffset] ^ k[i]);
}
}
return cipherLen;

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 201313, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -27,6 +27,7 @@ package com.sun.crypto.provider;
import java.security.InvalidKeyException;
/**
* This class represents ciphers in counter (CTR) mode.
*
@ -136,14 +137,6 @@ final class CounterMode extends FeedbackCipher {
* The result is stored in <code>cipher</code>, starting at
* <code>cipherOffset</code>.
*
* <p>It is the application's responsibility to make sure that
* <code>plainLen</code> is a multiple of the embedded cipher's block size,
* as any excess bytes are ignored.
*
* <p>It is also the application's responsibility to make sure that
* <code>init</code> has been called before this method is called.
* (This check is omitted here, to avoid double checking.)
*
* @param in the buffer with the input data to be encrypted
* @param inOffset the offset in <code>plain</code>
* @param len the length of the input data
@ -155,30 +148,7 @@ final class CounterMode extends FeedbackCipher {
return crypt(in, inOff, len, out, outOff);
}
/**
* Performs decryption operation.
*
* <p>The input cipher text <code>cipher</code>, starting at
* <code>cipherOffset</code> and ending at
* <code>(cipherOffset + len - 1)</code>, is decrypted.
* The result is stored in <code>plain</code>, starting at
* <code>plainOffset</code>.
*
* <p>It is the application's responsibility to make sure that
* <code>cipherLen</code> is a multiple of the embedded cipher's block
* size, as any excess bytes are ignored.
*
* <p>It is also the application's responsibility to make sure that
* <code>init</code> has been called before this method is called.
* (This check is omitted here, to avoid double checking.)
*
* @param in the buffer with the input data to be decrypted
* @param inOff the offset in <code>cipherOffset</code>
* @param len the length of the input data
* @param out the buffer for the result
* @param outOff the offset in <code>plain</code>
* @return the length of the decrypted data
*/
// CTR encrypt and decrypt are identical
int decrypt(byte[] in, int inOff, int len, byte[] out, int outOff) {
return crypt(in, inOff, len, out, outOff);
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,6 +26,7 @@
package com.sun.crypto.provider;
import java.security.InvalidKeyException;
import java.security.ProviderException;
/**
* This class represents ciphers in electronic codebook (ECB) mode.
@ -96,28 +97,24 @@ final class ElectronicCodeBook extends FeedbackCipher {
/**
* Performs encryption operation.
*
* <p>The input plain text <code>plain</code>, starting at
* <code>plainOffset</code> and ending at
* <code>(plainOffset + len - 1)</code>, is encrypted.
* The result is stored in <code>cipher</code>, starting at
* <code>cipherOffset</code>.
*
* <p>It is the application's responsibility to make sure that
* <code>plainLen</code> is a multiple of the embedded cipher's block size,
* as any excess bytes are ignored.
*
* <p>It is also the application's responsibility to make sure that
* <code>init</code> has been called before this method is called.
* (This check is omitted here, to avoid double checking.)
* <p>The input plain text <code>in</code>, starting at
* <code>inOff</code> and ending at * <code>(inOff + len - 1)</code>,
* is encrypted. The result is stored in <code>out</code>, starting at
* <code>outOff</code>.
*
* @param in the buffer with the input data to be encrypted
* @param inOffset the offset in <code>plain</code>
* @param inOff the offset in <code>plain</code>
* @param len the length of the input data
* @param out the buffer for the result
* @param outOff the offset in <code>cipher</code>
* @exception ProviderException if <code>len</code> is not
* a multiple of the block size
* @return the length of the encrypted data
*/
int encrypt(byte[] in, int inOff, int len, byte[] out, int outOff) {
if ((len % blockSize) != 0) {
throw new ProviderException("Internal error in input buffering");
}
for (int i = len; i >= blockSize; i -= blockSize) {
embeddedCipher.encryptBlock(in, inOff, out, outOff);
inOff += blockSize;
@ -129,28 +126,24 @@ final class ElectronicCodeBook extends FeedbackCipher {
/**
* Performs decryption operation.
*
* <p>The input cipher text <code>cipher</code>, starting at
* <code>cipherOffset</code> and ending at
* <code>(cipherOffset + len - 1)</code>, is decrypted.
* The result is stored in <code>plain</code>, starting at
* <code>plainOffset</code>.
*
* <p>It is the application's responsibility to make sure that
* <code>cipherLen</code> is a multiple of the embedded cipher's block
* size, as any excess bytes are ignored.
*
* <p>It is also the application's responsibility to make sure that
* <code>init</code> has been called before this method is called.
* (This check is omitted here, to avoid double checking.)
* <p>The input cipher text <code>in</code>, starting at
* <code>inOff</code> and ending at * <code>(inOff + len - 1)</code>,
* is decrypted.The result is stored in <code>out</code>, starting at
* <code>outOff</code>.
*
* @param in the buffer with the input data to be decrypted
* @param inOff the offset in <code>cipherOffset</code>
* @param len the length of the input data
* @param out the buffer for the result
* @param outOff the offset in <code>plain</code>
* @exception ProviderException if <code>len</code> is not
* a multiple of the block size
* @return the length of the decrypted data
*/
int decrypt(byte[] in, int inOff, int len, byte[] out, int outOff) {
if ((len % blockSize) != 0) {
throw new ProviderException("Internal error in input buffering");
}
for (int i = len; i >= blockSize; i -= blockSize) {
embeddedCipher.decryptBlock(in, inOff, out, outOff);
inOff += blockSize;

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -371,21 +371,19 @@ final class GaloisCounterMode extends FeedbackCipher {
* and ending at <code>(inOff + len - 1)</code>, is encrypted. The result
* is stored in <code>out</code>, starting at <code>outOfs</code>.
*
* <p>It is the application's responsibility to make sure that
* <code>len</code> is a multiple of the embedded cipher's block size,
* otherwise, a ProviderException will be thrown.
*
* <p>It is also the application's responsibility to make sure that
* <code>init</code> has been called before this method is called.
* (This check is omitted here, to avoid double checking.)
*
* @param in the buffer with the input data to be encrypted
* @param inOfs the offset in <code>in</code>
* @param len the length of the input data
* @param out the buffer for the result
* @param outOfs the offset in <code>out</code>
* @exception ProviderException if <code>len</code> is not
* a multiple of the block size
* @return the number of bytes placed into the <code>out</code> buffer
*/
int encrypt(byte[] in, int inOfs, int len, byte[] out, int outOfs) {
if ((len % blockSize) != 0) {
throw new ProviderException("Internal error in input buffering");
}
processAAD();
if (len > 0) {
gctrPAndC.update(in, inOfs, len, out, outOfs);
@ -398,9 +396,6 @@ final class GaloisCounterMode extends FeedbackCipher {
/**
* Performs encryption operation for the last time.
*
* <p>NOTE: <code>len</code> may not be multiple of the embedded
* cipher's block size for this call.
*
* @param in the input buffer with the data to be encrypted
* @param inOfs the offset in <code>in</code>
* @param len the length of the input data
@ -439,21 +434,19 @@ final class GaloisCounterMode extends FeedbackCipher {
* is decrypted. The result is stored in <code>out</code>, starting at
* <code>outOfs</code>.
*
* <p>It is the application's responsibility to make sure that
* <code>len</code> is a multiple of the embedded cipher's block
* size, as any excess bytes are ignored.
*
* <p>It is also the application's responsibility to make sure that
* <code>init</code> has been called before this method is called.
* (This check is omitted here, to avoid double checking.)
*
* @param in the buffer with the input data to be decrypted
* @param inOfs the offset in <code>in</code>
* @param len the length of the input data
* @param out the buffer for the result
* @param outOfs the offset in <code>out</code>
* @exception ProviderException if <code>len</code> is not
* a multiple of the block size
* @return the number of bytes placed into the <code>out</code> buffer
*/
int decrypt(byte[] in, int inOfs, int len, byte[] out, int outOfs) {
if ((len % blockSize) != 0) {
throw new ProviderException("Internal error in input buffering");
}
processAAD();
if (len > 0) {

@ -898,4 +898,20 @@ public final class JceKeyStore extends KeyStoreSpi {
md.update("Mighty Aphrodite".getBytes("UTF8"));
return md;
}
/**
* Probe the first few bytes of the keystore data stream for a valid
* JCEKS keystore encoding.
*/
@Override
public boolean engineProbe(InputStream stream) throws IOException {
DataInputStream dataStream;
if (stream instanceof DataInputStream) {
dataStream = (DataInputStream)stream;
} else {
dataStream = new DataInputStream(stream);
}
return JCEKS_MAGIC == dataStream.readInt();
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,6 +26,7 @@
package com.sun.crypto.provider;
import java.security.InvalidKeyException;
import java.security.ProviderException;
/**
* This class represents ciphers in output-feedback (OFB) mode.
@ -132,17 +133,52 @@ final class OutputFeedback extends FeedbackCipher {
*
* <p>The input plain text <code>plain</code>, starting at
* <code>plainOffset</code> and ending at
* <code>(plainOffset + len - 1)</code>, is encrypted.
* <code>(plainOffset + plainLen - 1)</code>, is encrypted.
* The result is stored in <code>cipher</code>, starting at
* <code>cipherOffset</code>.
*
* <p>It is the application's responsibility to make sure that
* <code>plainLen</code> is a multiple of the stream unit size
* <code>numBytes</code>, as any excess bytes are ignored.
* @param plain the buffer with the input data to be encrypted
* @param plainOffset the offset in <code>plain</code>
* @param plainLen the length of the input data
* @param cipher the buffer for the result
* @param cipherOffset the offset in <code>cipher</code>
* @exception ProviderException if <code>plainLen</code> is not
* a multiple of the <code>numBytes</code>
* @return the length of the encrypted data
*/
int encrypt(byte[] plain, int plainOffset, int plainLen,
byte[] cipher, int cipherOffset) {
if ((plainLen % numBytes) != 0) {
throw new ProviderException("Internal error in input buffering");
}
int nShift = blockSize - numBytes;
int loopCount = plainLen / numBytes;
for (; loopCount > 0;
plainOffset += numBytes, cipherOffset += numBytes,
loopCount--) {
embeddedCipher.encryptBlock(register, 0, k, 0);
for (int i = 0; i < numBytes; i++) {
cipher[i + cipherOffset] =
(byte)(k[i] ^ plain[i + plainOffset]);
if (nShift != 0) {
System.arraycopy(register, numBytes, register, 0, nShift);
}
System.arraycopy(k, 0, register, nShift, numBytes);
}
}
return plainLen;
}
/**
* Performs last encryption operation.
*
* <p>It is also the application's responsibility to make sure that
* <code>init</code> has been called before this method is called.
* (This check is omitted here, to avoid double checking.)
* <p>The input plain text <code>plain</code>, starting at
* <code>plainOffset</code> and ending at
* <code>(plainOffset + plainLen - 1)</code>, is encrypted.
* The result is stored in <code>cipher</code>, starting at
* <code>cipherOffset</code>.
*
* @param plain the buffer with the input data to be encrypted
* @param plainOffset the offset in <code>plain</code>
@ -151,82 +187,34 @@ final class OutputFeedback extends FeedbackCipher {
* @param cipherOffset the offset in <code>cipher</code>
* @return the length of the encrypted data
*/
int encrypt(byte[] plain, int plainOffset, int plainLen,
byte[] cipher, int cipherOffset)
{
int i;
int len = blockSize - numBytes;
int loopCount = plainLen / numBytes;
int encryptFinal(byte[] plain, int plainOffset, int plainLen,
byte[] cipher, int cipherOffset) {
int oddBytes = plainLen % numBytes;
int len = encrypt(plain, plainOffset, (plainLen - oddBytes),
cipher, cipherOffset);
plainOffset += len;
cipherOffset += len;
if (len == 0) {
for (; loopCount > 0;
plainOffset += numBytes, cipherOffset += numBytes,
loopCount--) {
embeddedCipher.encryptBlock(register, 0, k, 0);
for (i=0; i<numBytes; i++)
cipher[i+cipherOffset] =
(byte)(k[i] ^ plain[i+plainOffset]);
System.arraycopy(k, 0, register, 0, numBytes);
}
if (oddBytes > 0) {
embeddedCipher.encryptBlock(register, 0, k, 0);
for (i=0; i<oddBytes; i++)
cipher[i+cipherOffset] =
(byte)(k[i] ^ plain[i+plainOffset]);
System.arraycopy(k, 0, register, 0, numBytes);
}
} else {
for (; loopCount > 0;
plainOffset += numBytes, cipherOffset += numBytes,
loopCount--) {
embeddedCipher.encryptBlock(register, 0, k, 0);
for (i=0; i<numBytes; i++)
cipher[i+cipherOffset] =
(byte)(k[i] ^ plain[i+plainOffset]);
System.arraycopy(register, numBytes, register, 0, len);
System.arraycopy(k, 0, register, len, numBytes);
}
if (oddBytes > 0) {
embeddedCipher.encryptBlock(register, 0, k, 0);
for (i=0; i<oddBytes; i++)
cipher[i+cipherOffset] =
(byte)(k[i] ^ plain[i+plainOffset]);
System.arraycopy(register, numBytes, register, 0, len);
System.arraycopy(k, 0, register, len, numBytes);
if (oddBytes != 0) {
embeddedCipher.encryptBlock(register, 0, k, 0);
for (int i = 0; i < oddBytes; i++) {
cipher[i + cipherOffset] =
(byte)(k[i] ^ plain[ i + plainOffset]);
}
}
return plainLen;
}
/**
* Performs decryption operation.
*
* <p>The input cipher text <code>cipher</code>, starting at
* <code>cipherOffset</code> and ending at
* <code>(cipherOffset + len - 1)</code>, is decrypted.
* The result is stored in <code>plain</code>, starting at
* <code>plainOffset</code>.
*
* <p>It is the application's responsibility to make sure that
* <code>cipherLen</code> is a multiple of the stream unit size
* <code>numBytes</code>, as any excess bytes are ignored.
*
* <p>It is also the application's responsibility to make sure that
* <code>init</code> has been called before this method is called.
* (This check is omitted here, to avoid double checking.)
*
* @param cipher the buffer with the input data to be decrypted
* @param cipherOffset the offset in <code>cipherOffset</code>
* @param cipherLen the length of the input data
* @param plain the buffer for the result
* @param plainOffset the offset in <code>plain</code>
* @return the length of the decrypted data
*/
// OFB encrypt and decrypt are identical
int decrypt(byte[] cipher, int cipherOffset, int cipherLen,
byte[] plain, int plainOffset)
{
// OFB encrypt and decrypt are identical
byte[] plain, int plainOffset) {
return encrypt(cipher, cipherOffset, cipherLen, plain, plainOffset);
}
// OFB encrypt and decrypt are identical
int decryptFinal(byte[] cipher, int cipherOffset, int cipherLen,
byte[] plain, int plainOffset) {
// OFB encrypt and decrypt are identical
return encryptFinal(cipher, cipherOffset, cipherLen, plain, plainOffset);
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,6 +26,8 @@
package com.sun.crypto.provider;
import java.security.InvalidKeyException;
import java.security.ProviderException;
/**
* This class represents ciphers in Plaintext Cipher Block Chaining (PCBC)
@ -118,38 +120,36 @@ final class PCBC extends FeedbackCipher {
*
* <p>The input plain text <code>plain</code>, starting at
* <code>plainOffset</code> and ending at
* <code>(plainOffset + len - 1)</code>, is encrypted.
* <code>(plainOffset + plainLen - 1)</code>, is encrypted.
* The result is stored in <code>cipher</code>, starting at
* <code>cipherOffset</code>.
*
* <p>It is the application's responsibility to make sure that
* <code>plainLen</code> is a multiple of the embedded cipher's block size,
* as any excess bytes are ignored.
*
* <p>It is also the application's responsibility to make sure that
* <code>init</code> has been called before this method is called.
* (This check is omitted here, to avoid double checking.)
*
* @param plain the buffer with the input data to be encrypted
* @param plainOffset the offset in <code>plain</code>
* @param plainLen the length of the input data
* @param cipher the buffer for the result
* @param cipherOffset the offset in <code>cipher</code>
* @exception ProviderException if <code>plainLen</code> is not
* a multiple of the block size
* @return the length of the encrypted data
*/
int encrypt(byte[] plain, int plainOffset, int plainLen,
byte[] cipher, int cipherOffset)
{
if ((plainLen % blockSize) != 0) {
throw new ProviderException("Internal error in input buffering");
}
int i;
int endIndex = plainOffset + plainLen;
for (; plainOffset < endIndex;
plainOffset += blockSize, cipherOffset += blockSize) {
for (i=0; i<blockSize; i++) {
k[i] ^= plain[i+plainOffset];
for (i = 0; i < blockSize; i++) {
k[i] ^= plain[i + plainOffset];
}
embeddedCipher.encryptBlock(k, 0, cipher, cipherOffset);
for (i = 0; i < blockSize; i++) {
k[i] = (byte)(plain[i+plainOffset] ^ cipher[i+cipherOffset]);
k[i] = (byte)(plain[i + plainOffset] ^ cipher[i + cipherOffset]);
}
}
return plainLen;
@ -160,27 +160,25 @@ final class PCBC extends FeedbackCipher {
*
* <p>The input cipher text <code>cipher</code>, starting at
* <code>cipherOffset</code> and ending at
* <code>(cipherOffset + len - 1)</code>, is decrypted.
* <code>(cipherOffset + cipherLen - 1)</code>, is decrypted.
* The result is stored in <code>plain</code>, starting at
* <code>plainOffset</code>.
*
* <p>It is the application's responsibility to make sure that
* <code>cipherLen</code> is a multiple of the embedded cipher's block
* size, as any excess bytes are ignored.
*
* <p>It is also the application's responsibility to make sure that
* <code>init</code> has been called before this method is called.
* (This check is omitted here, to avoid double checking.)
*
* @param cipher the buffer with the input data to be decrypted
* @param cipherOffset the offset in <code>cipherOffset</code>
* @param cipherLen the length of the input data
* @param plain the buffer for the result
* @param plainOffset the offset in <code>plain</code>
* @exception ProviderException if <code>cipherLen</code> is not
* a multiple of the block size
* @return the length of the decrypted data
*/
int decrypt(byte[] cipher, int cipherOffset, int cipherLen,
byte[] plain, int plainOffset)
{
if ((cipherLen % blockSize) != 0) {
throw new ProviderException("Internal error in input buffering");
}
int i;
int endIndex = cipherOffset + cipherLen;
@ -189,10 +187,10 @@ final class PCBC extends FeedbackCipher {
embeddedCipher.decryptBlock(cipher, cipherOffset,
plain, plainOffset);
for (i = 0; i < blockSize; i++) {
plain[i+plainOffset] ^= k[i];
plain[i + plainOffset] ^= k[i];
}
for (i = 0; i < blockSize; i++) {
k[i] = (byte)(plain[i+plainOffset] ^ cipher[i+cipherOffset]);
k[i] = (byte)(plain[i + plainOffset] ^ cipher[i + cipherOffset]);
}
}
return cipherLen;

@ -29,6 +29,7 @@ import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.Iterator;
import java.util.NoSuchElementException;
/**
* An object that may be used to locate a file in a file system. It will
@ -246,6 +247,12 @@ public interface Path
* "{@code foo/bar}" starts with "{@code foo}" and "{@code foo/bar}". It
* does not start with "{@code f}" or "{@code fo}".
*
* @implSpec
* The default implementation is equivalent for this path to:
* <pre>{@code
* startsWith(getFileSystem().getPath(other));
* }</pre>
*
* @param other
* the given path string
*
@ -255,7 +262,9 @@ public interface Path
* @throws InvalidPathException
* If the path string cannot be converted to a Path.
*/
boolean startsWith(String other);
default boolean startsWith(String other) {
return startsWith(getFileSystem().getPath(other));
}
/**
* Tests if this path ends with the given path.
@ -294,6 +303,12 @@ public interface Path
* Path}"{@code foo/bar}" with the {@code String} "{@code bar/}" returns
* {@code true}.
*
* @implSpec
* The default implementation is equivalent for this path to:
* <pre>{@code
* endsWith(getFileSystem().getPath(other));
* }</pre>
*
* @param other
* the given path string
*
@ -303,7 +318,9 @@ public interface Path
* @throws InvalidPathException
* If the path string cannot be converted to a Path.
*/
boolean endsWith(String other);
default boolean endsWith(String other) {
return endsWith(getFileSystem().getPath(other));
}
/**
* Returns a path that is this path with redundant name elements eliminated.
@ -365,6 +382,12 @@ public interface Path
* invoking this method with the path string "{@code gus}" will result in
* the {@code Path} "{@code foo/bar/gus}".
*
* @implSpec
* The default implementation is equivalent for this path to:
* <pre>{@code
* resolve(getFileSystem().getPath(other));
* }</pre>
*
* @param other
* the path string to resolve against this path
*
@ -375,7 +398,9 @@ public interface Path
*
* @see FileSystem#getPath
*/
Path resolve(String other);
default Path resolve(String other) {
return resolve(getFileSystem().getPath(other));
}
/**
* Resolves the given path against this path's {@link #getParent parent}
@ -389,6 +414,14 @@ public interface Path
* returns this path's parent, or where this path doesn't have a parent, the
* empty path.
*
* @implSpec
* The default implementation is equivalent for this path to:
* <pre>{@code
* (getParent() == null) ? other : getParent().resolve(other);
* }</pre>
* unless {@code other == null}, in which case a
* {@code NullPointerException} is thrown.
*
* @param other
* the path to resolve against this path's parent
*
@ -396,13 +429,24 @@ public interface Path
*
* @see #resolve(Path)
*/
Path resolveSibling(Path other);
default Path resolveSibling(Path other) {
if (other == null)
throw new NullPointerException();
Path parent = getParent();
return (parent == null) ? other : parent.resolve(other);
}
/**
* Converts a given path string to a {@code Path} and resolves it against
* this path's {@link #getParent parent} path in exactly the manner
* specified by the {@link #resolveSibling(Path) resolveSibling} method.
*
* @implSpec
* The default implementation is equivalent for this path to:
* <pre>{@code
* resolveSibling(getFileSystem().getPath(other));
* }</pre>
*
* @param other
* the path string to resolve against this path's parent
*
@ -413,7 +457,9 @@ public interface Path
*
* @see FileSystem#getPath
*/
Path resolveSibling(String other);
default Path resolveSibling(String other) {
return resolveSibling(getFileSystem().getPath(other));
}
/**
* Constructs a relative path between this path and a given path.
@ -590,12 +636,28 @@ public interface Path
* File} object returned by this method is {@link #equals equal} to the
* original {@code File}.
*
* @implSpec
* The default implementation is equivalent for this path to:
* <pre>{@code
* new File(toString());
* }</pre>
* if the {@code FileSystem} which created this {@code Path} is the default
* file system; otherwise an {@code UnsupportedOperationException} is
* thrown.
*
* @return a {@code File} object representing this path
*
* @throws UnsupportedOperationException
* if this {@code Path} is not associated with the default provider
*/
File toFile();
default File toFile() {
if (getFileSystem() == FileSystems.getDefault()) {
return new File(toString());
} else {
throw new UnsupportedOperationException("Path not associated with "
+ "default file system.");
}
}
// -- watchable --
@ -681,6 +743,13 @@ public interface Path
*
* WatchKey key = dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY);
* </pre>
*
* @implSpec
* The default implementation is equivalent for this path to:
* <pre>{@code
* register(watcher, events, new WatchEvent.Modifier[0]);
* }</pre>
*
* @param watcher
* The watch service to which this object is to be registered
* @param events
@ -706,9 +775,10 @@ public interface Path
* method is invoked to check read access to the file.
*/
@Override
WatchKey register(WatchService watcher,
WatchEvent.Kind<?>... events)
throws IOException;
default WatchKey register(WatchService watcher,
WatchEvent.Kind<?>... events) throws IOException {
return register(watcher, events, new WatchEvent.Modifier[0]);
}
// -- Iterable --
@ -721,10 +791,36 @@ public interface Path
* is the name of the file or directory denoted by this path. The {@link
* #getRoot root} component, if present, is not returned by the iterator.
*
* @implSpec
* The default implementation returns an {@code Iterator<Path>} which, for
* this path, traverses the {@code Path}s returned by
* {@code getName(index)}, where {@code index} ranges from zero to
* {@code getNameCount() - 1}, inclusive.
*
* @return an iterator over the name elements of this path.
*/
@Override
Iterator<Path> iterator();
default Iterator<Path> iterator() {
return new Iterator<Path>() {
private int i = 0;
@Override
public boolean hasNext() {
return (i < getNameCount());
}
@Override
public Path next() {
if (i < getNameCount()) {
Path result = getName(i);
i++;
return result;
} else {
throw new NoSuchElementException();
}
}
};
}
// -- compareTo/equals/hashCode --

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -92,9 +92,23 @@ import sun.security.util.Debug;
* be used (in a variety of formats).
*
* <p> Typical ways to request a KeyStore object include
* specifying an existing keystore file,
* relying on the default type and providing a specific keystore type.
*
* <ul>
* <li>To specify an existing keystore file:
* <pre>
* // get keystore password
* char[] password = getPassword();
*
* // probe the keystore file and load the keystore entries
* KeyStore ks = KeyStore.getInstance(new File("keyStoreName"), password);
*</pre>
* The system will probe the specified file to determine its keystore type
* and return a keystore implementation with its entries already loaded.
* When this approach is used there is no need to call the keystore's
* {@link #load(java.io.InputStream, char[]) load} method.
*
* <li>To rely on the default type:
* <pre>
* KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
@ -110,7 +124,8 @@ import sun.security.util.Debug;
* </ul>
*
* <p> Before a keystore can be accessed, it must be
* {@link #load(java.io.InputStream, char[]) loaded}.
* {@link #load(java.io.InputStream, char[]) loaded}
* (unless it was already loaded during instantiation).
* <pre>
* KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
*
@ -179,6 +194,7 @@ import sun.security.util.Debug;
public class KeyStore {
private static final Debug kdebug = Debug.getInstance("keystore");
private static final Debug pdebug =
Debug.getInstance("provider", "Provider");
private static final boolean skipDebug =
@ -1593,6 +1609,188 @@ public class KeyStore {
return keyStoreSpi.engineEntryInstanceOf(alias, entryClass);
}
/**
* Returns a loaded keystore object of the appropriate keystore type.
* First the keystore type is determined by probing the specified file.
* Then a keystore object is instantiated and loaded using the data from
* that file.
* A password may be supplied to unlock the keystore data or perform an
* integrity check.
*
* <p>
* This method traverses the list of registered security {@link Providers},
* starting with the most preferred Provider.
* For each {@link KeyStoreSpi} implementation supported by a Provider,
* it invokes the {@link engineProbe} method to determine if it supports
* the specified keystore.
* A new KeyStore object is returned that encapsulates the KeyStoreSpi
* implementation from the first Provider that supports the specified file.
*
* <p> Note that the list of registered providers may be retrieved via
* the {@link Security#getProviders() Security.getProviders()} method.
*
* @param file the keystore file
* @param password the keystore password, which may be {@code null}
*
* @return a keystore object loaded with keystore data
*
* @throws KeyStoreException if no Provider supports a KeyStoreSpi
* implementation for the specified keystore file.
* @throws IOException if there is an I/O or format problem with the
* keystore data, if a password is required but not given,
* or if the given password was incorrect. If the error is
* due to a wrong password, the {@link Throwable#getCause cause}
* of the {@code IOException} should be an
* {@code UnrecoverableKeyException}.
* @throws NoSuchAlgorithmException if the algorithm used to check the
* integrity of the keystore cannot be found.
* @throws CertificateException if any of the certificates in the
* keystore could not be loaded.
* @throws IllegalArgumentException if file does not exist or does not
* refer to a normal file.
* @throws NullPointerException if file is {@code null}.
* @throws SecurityException if a security manager exists and its
* {@link java.lang.SecurityManager#checkRead} method denies
* read access to the specified file.
*
* @see Provider
*
* @since 1.9
*/
public static final KeyStore getInstance(File file, char[] password)
throws KeyStoreException, IOException, NoSuchAlgorithmException,
CertificateException {
return getInstance(file, password, null, true);
}
/**
* Returns a loaded keystore object of the appropriate keystore type.
* First the keystore type is determined by probing the specified file.
* Then a keystore object is instantiated and loaded using the data from
* that file.
* A {@code LoadStoreParameter} may be supplied which specifies how to
* unlock the keystore data or perform an integrity check.
*
* <p>
* This method traverses the list of registered security {@link Providers},
* starting with the most preferred Provider.
* For each {@link KeyStoreSpi} implementation supported by a Provider,
* it invokes the {@link engineProbe} method to determine if it supports
* the specified keystore.
* A new KeyStore object is returned that encapsulates the KeyStoreSpi
* implementation from the first Provider that supports the specified file.
*
* <p> Note that the list of registered providers may be retrieved via
* the {@link Security#getProviders() Security.getProviders()} method.
*
* @param file the keystore file
* @param param the {@code LoadStoreParameter} that specifies how to load
* the keystore, which may be {@code null}
*
* @return a keystore object loaded with keystore data
*
* @throws KeyStoreException if no Provider supports a KeyStoreSpi
* implementation for the specified keystore file.
* @throws IOException if there is an I/O or format problem with the
* keystore data. If the error is due to an incorrect
* {@code ProtectionParameter} (e.g. wrong password)
* the {@link Throwable#getCause cause} of the
* {@code IOException} should be an
* {@code UnrecoverableKeyException}.
* @throws NoSuchAlgorithmException if the algorithm used to check the
* integrity of the keystore cannot be found.
* @throws CertificateException if any of the certificates in the
* keystore could not be loaded.
* @throws IllegalArgumentException if file does not exist or does not
* refer to a normal file, or if param is not recognized.
* @throws NullPointerException if file is {@code null}.
* @throws SecurityException if a security manager exists and its
* {@link java.lang.SecurityManager#checkRead} method denies
* read access to the specified file.
*
* @see Provider
*
* @since 1.9
*/
public static final KeyStore getInstance(File file,
LoadStoreParameter param) throws KeyStoreException, IOException,
NoSuchAlgorithmException, CertificateException {
return getInstance(file, null, param, false);
}
// Used by getInstance(File, char[]) & getInstance(File, LoadStoreParameter)
private static final KeyStore getInstance(File file, char[] password,
LoadStoreParameter param, boolean hasPassword)
throws KeyStoreException, IOException, NoSuchAlgorithmException,
CertificateException {
if (file == null) {
throw new NullPointerException();
}
if (file.isFile() == false) {
throw new IllegalArgumentException(
"File does not exist or it does not refer to a normal file: " +
file);
}
KeyStore keystore = null;
try (DataInputStream dataStream =
new DataInputStream(
new BufferedInputStream(
new FileInputStream(file)))) {
dataStream.mark(Integer.MAX_VALUE);
// Detect the keystore type
for (String type : Security.getAlgorithms("KeyStore")) {
Object[] objs = null;
try {
objs = Security.getImpl(type, "KeyStore", (String)null);
KeyStoreSpi impl = (KeyStoreSpi)objs[0];
if (impl.engineProbe(dataStream)) {
if (kdebug != null) {
kdebug.println(type + " keystore detected: " +
file);
}
keystore = new KeyStore(impl, (Provider)objs[1], type);
break;
}
} catch (NoSuchAlgorithmException | NoSuchProviderException e) {
// ignore
if (kdebug != null) {
kdebug.println(type + " not found - " + e);
}
} catch (IOException e) {
// ignore
if (kdebug != null) {
kdebug.println("I/O error in " + file + " - " + e);
}
}
dataStream.reset(); // prepare the stream for the next probe
}
// Load the keystore data
if (keystore != null) {
if (hasPassword) {
dataStream.reset(); // prepare the stream for loading
keystore.load(dataStream, password);
} else {
keystore.load(param);
}
return keystore;
}
}
throw new KeyStoreException("Unrecognized keystore format: " +
keystore);
}
/**
* A description of a to-be-instantiated KeyStore object.
*
@ -1713,7 +1911,7 @@ public class KeyStore {
* by invoking the CallbackHandler.
*
* <p>Subsequent calls to {@link #getKeyStore} return the same object
* as the initial call. If the initial call to failed with a
* as the initial call. If the initial call failed with a
* KeyStoreException, subsequent calls also throw a
* KeyStoreException.
*
@ -1760,6 +1958,50 @@ public class KeyStore {
AccessController.getContext());
}
/**
* Returns a new Builder object.
*
* <p>The first call to the {@link #getKeyStore} method on the returned
* builder will create a KeyStore using {@code file} to detect the
* keystore type and then call its {@link KeyStore#load load()} method.
* It uses the same algorithm to determine the keystore type as
* described in {@link KeyStore#getInstance(File, LoadStoreParameter)}.
* The {@code inputStream} argument is constructed from {@code file}.
* If {@code protection} is a {@code PasswordProtection}, the password
* is obtained by calling the {@code getPassword} method.
* Otherwise, if {@code protection} is a
* {@code CallbackHandlerProtection},
* the password is obtained by invoking the CallbackHandler.
*
* <p>Subsequent calls to {@link #getKeyStore} return the same object
* as the initial call. If the initial call failed with a
* KeyStoreException, subsequent calls also throw a KeyStoreException.
*
* <p>Calls to {@link #getProtectionParameter getProtectionParameter()}
* will return a {@link KeyStore.PasswordProtection PasswordProtection}
* object encapsulating the password that was used to invoke the
* {@code load} method.
*
* <p><em>Note</em> that the {@link #getKeyStore} method is executed
* within the {@link AccessControlContext} of the code invoking this
* method.
*
* @return a new Builder object
* @param file the File that contains the KeyStore data
* @param protection the ProtectionParameter securing the KeyStore data
* @throws NullPointerException if file or protection is null
* @throws IllegalArgumentException if protection is not an instance
* of either PasswordProtection or CallbackHandlerProtection; or
* if file does not exist or does not refer to a normal file
*
* @since 1.9
*/
public static Builder newInstance(File file,
ProtectionParameter protection) {
return newInstance("", null, file, protection);
}
private static final class FileBuilder extends Builder {
private final String type;
@ -1817,42 +2059,46 @@ public class KeyStore {
}
public KeyStore run0() throws Exception {
KeyStore ks;
if (provider == null) {
ks = KeyStore.getInstance(type);
} else {
ks = KeyStore.getInstance(type, provider);
}
InputStream in = null;
char[] password = null;
try {
in = new FileInputStream(file);
if (protection instanceof PasswordProtection) {
password =
// Acquire keystore password
if (protection instanceof PasswordProtection) {
password =
((PasswordProtection)protection).getPassword();
keyProtection = protection;
} else {
CallbackHandler handler =
((CallbackHandlerProtection)protection)
keyProtection = protection;
} else {
CallbackHandler handler =
((CallbackHandlerProtection)protection)
.getCallbackHandler();
PasswordCallback callback = new PasswordCallback
("Password for keystore " + file.getName(),
PasswordCallback callback = new PasswordCallback
("Password for keystore " + file.getName(),
false);
handler.handle(new Callback[] {callback});
password = callback.getPassword();
if (password == null) {
throw new KeyStoreException("No password" +
" provided");
}
callback.clearPassword();
keyProtection = new PasswordProtection(password);
handler.handle(new Callback[] {callback});
password = callback.getPassword();
if (password == null) {
throw new KeyStoreException("No password" +
" provided");
}
ks.load(in, password);
return ks;
} finally {
if (in != null) {
in.close();
callback.clearPassword();
keyProtection = new PasswordProtection(password);
}
if (type.isEmpty()) {
// Instantiate keystore and load keystore data
ks = KeyStore.getInstance(file, password);
} else {
// Instantiate keystore
if (provider == null) {
ks = KeyStore.getInstance(type);
} else {
ks = KeyStore.getInstance(type, provider);
}
// Load keystore data
try (InputStream in = new FileInputStream(file)) {
ks.load(in, password);
}
}
return ks;
}
};
try {
@ -1998,5 +2244,4 @@ public class KeyStore {
return protection;
}
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -590,4 +590,27 @@ public abstract class KeyStoreSpi {
}
return false;
}
/**
* Probes the specified input stream to determine whether it contains a
* keystore that is supported by this implementation, or not.
*
* <p>
* @implSpec
* This method returns false by default. Keystore implementations should
* override this method to peek at the data stream directly or to use other
* content detection mechanisms.
*
* @param stream the keystore data to be probed
*
* @return true if the keystore data is supported, otherwise false
*
* @throws IOException if there is an I/O problem with the keystore data.
* @throws NullPointerException if stream is {@code null}.
*
* @since 1.9
*/
public boolean engineProbe(InputStream stream) throws IOException {
return false;
}
}

@ -1,106 +0,0 @@
/*
* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.nio.fs;
import java.nio.file.*;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.NoSuchElementException;
/**
* Base implementation class of {@code Path}.
*/
abstract class AbstractPath implements Path {
protected AbstractPath() { }
@Override
public final boolean startsWith(String other) {
return startsWith(getFileSystem().getPath(other));
}
@Override
public final boolean endsWith(String other) {
return endsWith(getFileSystem().getPath(other));
}
@Override
public final Path resolve(String other) {
return resolve(getFileSystem().getPath(other));
}
@Override
public final Path resolveSibling(Path other) {
if (other == null)
throw new NullPointerException();
Path parent = getParent();
return (parent == null) ? other : parent.resolve(other);
}
@Override
public final Path resolveSibling(String other) {
return resolveSibling(getFileSystem().getPath(other));
}
@Override
public final Iterator<Path> iterator() {
return new Iterator<Path>() {
private int i = 0;
@Override
public boolean hasNext() {
return (i < getNameCount());
}
@Override
public Path next() {
if (i < getNameCount()) {
Path result = getName(i);
i++;
return result;
} else {
throw new NoSuchElementException();
}
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
@Override
public final File toFile() {
return new File(toString());
}
@Override
public final WatchKey register(WatchService watcher,
WatchEvent.Kind<?>... events)
throws IOException
{
return register(watcher, events, new WatchEvent.Modifier[0]);
}
}

@ -69,6 +69,8 @@ import sun.security.util.ObjectIdentifier;
import sun.security.pkcs.ContentInfo;
import sun.security.x509.AlgorithmId;
import sun.security.pkcs.EncryptedPrivateKeyInfo;
import sun.security.provider.JavaKeyStore.JKS;
import sun.security.util.KeyStoreDelegator;
/**
@ -129,6 +131,13 @@ import sun.security.pkcs.EncryptedPrivateKeyInfo;
*/
public final class PKCS12KeyStore extends KeyStoreSpi {
// special PKCS12 keystore that supports PKCS12 and JKS file formats
public static final class DualFormatPKCS12 extends KeyStoreDelegator {
public DualFormatPKCS12() {
super("PKCS12", PKCS12KeyStore.class, "JKS", JKS.class);
}
}
public static final int VERSION_3 = 3;
private static final String[] KEY_PROTECTION_ALGORITHM = {
@ -1052,6 +1061,39 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
}
}
/**
* Determines if the keystore {@code Entry} for the specified
* {@code alias} is an instance or subclass of the specified
* {@code entryClass}.
*
* @param alias the alias name
* @param entryClass the entry class
*
* @return true if the keystore {@code Entry} for the specified
* {@code alias} is an instance or subclass of the
* specified {@code entryClass}, false otherwise
*
* @since 1.5
*/
@Override
public boolean
engineEntryInstanceOf(String alias,
Class<? extends KeyStore.Entry> entryClass)
{
if (entryClass == KeyStore.TrustedCertificateEntry.class) {
return engineIsCertificateEntry(alias);
}
Entry entry = entries.get(alias.toLowerCase(Locale.ENGLISH));
if (entryClass == KeyStore.PrivateKeyEntry.class) {
return (entry != null && entry instanceof PrivateKeyEntry);
}
if (entryClass == KeyStore.SecretKeyEntry.class) {
return (entry != null && entry instanceof SecretKeyEntry);
}
return false;
}
/**
* Returns the (alias) name of the first keystore entry whose certificate
* matches the given certificate.
@ -1084,7 +1126,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
} else {
continue;
}
if (certElem.equals(cert)) {
if (certElem != null && certElem.equals(cert)) {
return alias;
}
}
@ -1923,7 +1965,12 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
safeContentsData = safeContents.getData();
} else if (contentType.equals((Object)ContentInfo.ENCRYPTED_DATA_OID)) {
if (password == null) {
continue;
if (debug != null) {
debug.println("Warning: skipping PKCS#7 encryptedData" +
" content-type - no password was supplied");
}
continue;
}
if (debug != null) {
@ -1965,8 +2012,9 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
password = new char[1];
continue;
}
throw new IOException(
"failed to decrypt safe contents entry: " + e, e);
throw new IOException("keystore password was incorrect",
new UnrecoverableKeyException(
"failed to decrypt safe contents entry: " + e));
}
}
} else {
@ -2284,4 +2332,73 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
counter++;
return (String.valueOf(counter));
}
/*
* PKCS12 permitted first 24 bytes:
*
* 30 82 -- -- 02 01 03 30 82 -- -- 06 09 2A 86 48 86 F7 0D 01 07 01 A0 8-
* 30 -- 02 01 03 30 -- 06 09 2A 86 48 86 F7 0D 01 07 01 A0 -- 04 -- -- --
* 30 81 -- 02 01 03 30 81 -- 06 09 2A 86 48 86 F7 0D 01 07 01 A0 81 -- 04
* 30 82 -- -- 02 01 03 30 81 -- 06 09 2A 86 48 86 F7 0D 01 07 01 A0 81 --
* 30 83 -- -- -- 02 01 03 30 82 -- -- 06 09 2A 86 48 86 F7 0D 01 07 01 A0
* 30 83 -- -- -- 02 01 03 30 83 -- -- -- 06 09 2A 86 48 86 F7 0D 01 07 01
* 30 84 -- -- -- -- 02 01 03 30 83 -- -- -- 06 09 2A 86 48 86 F7 0D 01 07
* 30 84 -- -- -- -- 02 01 03 30 84 -- -- -- -- 06 09 2A 86 48 86 F7 0D 01
*/
private static final long[][] PKCS12_HEADER_PATTERNS = {
{ 0x3082000002010330L, 0x82000006092A8648L, 0x86F70D010701A080L },
{ 0x3000020103300006L, 0x092A864886F70D01L, 0x0701A00004000000L },
{ 0x3081000201033081L, 0x0006092A864886F7L, 0x0D010701A0810004L },
{ 0x3082000002010330L, 0x810006092A864886L, 0xF70D010701A08100L },
{ 0x3083000000020103L, 0x3082000006092A86L, 0x4886F70D010701A0L },
{ 0x3083000000020103L, 0x308200000006092AL, 0x864886F70D010701L },
{ 0x3084000000000201L, 0x0330820000000609L, 0x2A864886F70D0107L },
{ 0x3084000000000201L, 0x0330820000000006L, 0x092A864886F70D01L }
};
private static final long[][] PKCS12_HEADER_MASKS = {
{ 0xFFFF0000FFFFFFFFL, 0xFF0000FFFFFFFFFFL, 0xFFFFFFFFFFFFFFF0L },
{ 0xFF00FFFFFFFF00FFL, 0xFFFFFFFFFFFFFFFFL, 0xFFFFFF00FF000000L },
{ 0xFFFF00FFFFFFFFFFL, 0x00FFFFFFFFFFFFFFL, 0xFFFFFFFFFFFF00FFL },
{ 0xFFFF0000FFFFFFFFL, 0xFF00FFFFFFFFFFFFL, 0xFFFFFFFFFFFFFF00L },
{ 0xFFFF000000FFFFFFL, 0xFFFF0000FFFFFFFFL, 0xFFFFFFFFFFFFFFFFL },
{ 0xFFFF000000FFFFFFL, 0xFFFF000000FFFFFFL, 0xFFFFFFFFFFFFFFFFL },
{ 0xFFFF00000000FFFFL, 0xFFFFFF000000FFFFL, 0xFFFFFFFFFFFFFFFFL },
{ 0xFFFF00000000FFFFL, 0xFFFFFF00000000FFL, 0xFFFFFFFFFFFFFFFFL }
};
/**
* Probe the first few bytes of the keystore data stream for a valid
* PKCS12 keystore encoding.
*/
@Override
public boolean engineProbe(InputStream stream) throws IOException {
DataInputStream dataStream;
if (stream instanceof DataInputStream) {
dataStream = (DataInputStream)stream;
} else {
dataStream = new DataInputStream(stream);
}
long firstPeek = dataStream.readLong();
long nextPeek = dataStream.readLong();
long finalPeek = dataStream.readLong();
boolean result = false;
for (int i = 0; i < PKCS12_HEADER_PATTERNS.length; i++) {
if (PKCS12_HEADER_PATTERNS[i][0] ==
(firstPeek & PKCS12_HEADER_MASKS[i][0]) &&
(PKCS12_HEADER_PATTERNS[i][1] ==
(nextPeek & PKCS12_HEADER_MASKS[i][1])) &&
(PKCS12_HEADER_PATTERNS[i][2] ==
(finalPeek & PKCS12_HEADER_MASKS[i][2]))) {
result = true;
break;
}
}
return result;
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -31,9 +31,11 @@ import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
import java.security.cert.CertificateException;
import java.util.*;
import sun.misc.IOUtils;
import sun.misc.IOUtils;
import sun.security.pkcs.EncryptedPrivateKeyInfo;
import sun.security.pkcs12.PKCS12KeyStore;
import sun.security.util.KeyStoreDelegator;
/**
* This class provides the keystore implementation referred to as "JKS".
@ -49,7 +51,7 @@ import sun.security.pkcs.EncryptedPrivateKeyInfo;
* @since 1.2
*/
abstract class JavaKeyStore extends KeyStoreSpi {
public abstract class JavaKeyStore extends KeyStoreSpi {
// regular JKS
public static final class JKS extends JavaKeyStore {
@ -65,6 +67,13 @@ abstract class JavaKeyStore extends KeyStoreSpi {
}
}
// special JKS that supports JKS and PKCS12 file formats
public static final class DualFormatJKS extends KeyStoreDelegator {
public DualFormatJKS() {
super("JKS", JKS.class, "PKCS12", PKCS12KeyStore.class);
}
}
private static final int MAGIC = 0xfeedfeed;
private static final int VERSION_1 = 0x01;
private static final int VERSION_2 = 0x02;
@ -799,4 +808,20 @@ abstract class JavaKeyStore extends KeyStoreSpi {
md.update("Mighty Aphrodite".getBytes("UTF8"));
return md;
}
/**
* Probe the first few bytes of the keystore data stream for a valid
* JKS keystore encoding.
*/
@Override
public boolean engineProbe(InputStream stream) throws IOException {
DataInputStream dataStream;
if (stream instanceof DataInputStream) {
dataStream = (DataInputStream)stream;
} else {
dataStream = new DataInputStream(stream);
}
return MAGIC == dataStream.readInt();
}
}

@ -40,7 +40,7 @@ public final class Sun extends Provider {
private static final String INFO = "SUN " +
"(DSA key/parameter generation; DSA signing; SHA-1, MD5 digests; " +
"SecureRandom; X.509 certificates; JKS & DKS keystores; " +
"SecureRandom; X.509 certificates; PKCS12, JKS & DKS keystores; " +
"PKIX CertPathValidator; " +
"PKIX CertPathBuilder; LDAP, Collection CertStores, JavaPolicy Policy; " +
"JavaLoginConfig Configuration)";

@ -228,7 +228,10 @@ final class SunEntries {
/*
* KeyStore
*/
map.put("KeyStore.JKS", "sun.security.provider.JavaKeyStore$JKS");
map.put("KeyStore.PKCS12",
"sun.security.pkcs12.PKCS12KeyStore$DualFormatPKCS12");
map.put("KeyStore.JKS",
"sun.security.provider.JavaKeyStore$DualFormatJKS");
map.put("KeyStore.CaseExactJKS",
"sun.security.provider.JavaKeyStore$CaseExactJKS");
map.put("KeyStore.DKS", "sun.security.provider.DomainKeyStore$DKS");

@ -124,6 +124,7 @@ public final class Main {
private Set<Pair <String, String>> providers = null;
private String storetype = null;
private boolean hasStoretypeOption = false;
private String srcProviderName = null;
private String providerName = null;
private String pathlist = null;
@ -483,11 +484,13 @@ public final class Main {
} else if (collator.compare(flags, "-storetype") == 0 ||
collator.compare(flags, "-deststoretype") == 0) {
storetype = args[++i];
hasStoretypeOption = true;
} else if (collator.compare(flags, "-srcstorepass") == 0) {
srcstorePass = getPass(modifier, args[++i]);
passwords.add(srcstorePass);
} else if (collator.compare(flags, "-srcstoretype") == 0) {
srcstoretype = args[++i];
hasStoretypeOption = true;
} else if (collator.compare(flags, "-srckeypass") == 0) {
srckeyPass = getPass(modifier, args[++i]);
passwords.add(srckeyPass);
@ -809,36 +812,42 @@ public final class Main {
}
// Create new keystore
if (providerName == null) {
keyStore = KeyStore.getInstance(storetype);
// Probe for keystore type when filename is available
if (ksfile != null && ksStream != null && providerName == null &&
hasStoretypeOption == false) {
keyStore = KeyStore.getInstance(ksfile, storePass);
} else {
keyStore = KeyStore.getInstance(storetype, providerName);
}
if (providerName == null) {
keyStore = KeyStore.getInstance(storetype);
} else {
keyStore = KeyStore.getInstance(storetype, providerName);
}
/*
* Load the keystore data.
*
* At this point, it's OK if no keystore password has been provided.
* We want to make sure that we can load the keystore data, i.e.,
* the keystore data has the right format. If we cannot load the
* keystore, why bother asking the user for his or her password?
* Only if we were able to load the keystore, and no keystore
* password has been provided, will we prompt the user for the
* keystore password to verify the keystore integrity.
* This means that the keystore is loaded twice: first load operation
* checks the keystore format, second load operation verifies the
* keystore integrity.
*
* If the keystore password has already been provided (at the
* command line), however, the keystore is loaded only once, and the
* keystore format and integrity are checked "at the same time".
*
* Null stream keystores are loaded later.
*/
if (!nullStream) {
keyStore.load(ksStream, storePass);
if (ksStream != null) {
ksStream.close();
/*
* Load the keystore data.
*
* At this point, it's OK if no keystore password has been provided.
* We want to make sure that we can load the keystore data, i.e.,
* the keystore data has the right format. If we cannot load the
* keystore, why bother asking the user for his or her password?
* Only if we were able to load the keystore, and no keystore
* password has been provided, will we prompt the user for the
* keystore password to verify the keystore integrity.
* This means that the keystore is loaded twice: first load operation
* checks the keystore format, second load operation verifies the
* keystore integrity.
*
* If the keystore password has already been provided (at the
* command line), however, the keystore is loaded only once, and the
* keystore format and integrity are checked "at the same time".
*
* Null stream keystores are loaded later.
*/
if (!nullStream) {
keyStore.load(ksStream, storePass);
if (ksStream != null) {
ksStream.close();
}
}
}
@ -1881,6 +1890,7 @@ public final class Main {
boolean isPkcs11 = false;
InputStream is = null;
File srcksfile = null;
if (P11KEYSTORE.equalsIgnoreCase(srcstoretype) ||
KeyStoreUtil.isWindowsKeyStore(srcstoretype)) {
@ -1893,7 +1903,7 @@ public final class Main {
isPkcs11 = true;
} else {
if (srcksfname != null) {
File srcksfile = new File(srcksfname);
srcksfile = new File(srcksfname);
if (srcksfile.exists() && srcksfile.length() == 0) {
throw new Exception(rb.getString
("Source.keystore.file.exists.but.is.empty.") +
@ -1908,10 +1918,16 @@ public final class Main {
KeyStore store;
try {
if (srcProviderName == null) {
store = KeyStore.getInstance(srcstoretype);
// Probe for keystore type when filename is available
if (srcksfile != null && is != null && srcProviderName == null &&
hasStoretypeOption == false) {
store = KeyStore.getInstance(srcksfile, srcstorePass);
} else {
store = KeyStore.getInstance(srcstoretype, srcProviderName);
if (srcProviderName == null) {
store = KeyStore.getInstance(srcstoretype);
} else {
store = KeyStore.getInstance(srcstoretype, srcProviderName);
}
}
if (srcstorePass == null

@ -0,0 +1,306 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.security.util;
import java.io.*;
import java.security.*;
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
import java.security.cert.CertificateException;
import java.util.*;
import sun.security.util.Debug;
/**
* This class delegates to a primary or secondary keystore implementation.
*
* @since 1.9
*/
public class KeyStoreDelegator extends KeyStoreSpi {
private static final String KEYSTORE_TYPE_COMPAT = "keystore.type.compat";
private static final Debug debug = Debug.getInstance("keystore");
private String primaryType; // the primary keystore's type
private String secondaryType; // the secondary keystore's type
private Class<? extends KeyStoreSpi> primaryKeyStore;
// the primary keystore's class
private Class<? extends KeyStoreSpi> secondaryKeyStore;
// the secondary keystore's class
private String type; // the delegate's type
private KeyStoreSpi keystore; // the delegate
private boolean compatModeEnabled = true;
public KeyStoreDelegator(
String primaryType,
Class<? extends KeyStoreSpi> primaryKeyStore,
String secondaryType,
Class<? extends KeyStoreSpi> secondaryKeyStore) {
// Check whether compatibility mode has been disabled
compatModeEnabled = "true".equalsIgnoreCase(
AccessController.doPrivileged((PrivilegedAction<String>) () ->
Security.getProperty(KEYSTORE_TYPE_COMPAT)));
if (compatModeEnabled) {
this.primaryType = primaryType;
this.secondaryType = secondaryType;
this.primaryKeyStore = primaryKeyStore;
this.secondaryKeyStore = secondaryKeyStore;
} else {
this.primaryType = primaryType;
this.secondaryType = null;
this.primaryKeyStore = primaryKeyStore;
this.secondaryKeyStore = null;
if (debug != null) {
debug.println("WARNING: compatibility mode disabled for " +
primaryType + " and " + secondaryType + " keystore types");
}
}
}
@Override
public Key engineGetKey(String alias, char[] password)
throws NoSuchAlgorithmException, UnrecoverableKeyException {
return keystore.engineGetKey(alias, password);
}
@Override
public Certificate[] engineGetCertificateChain(String alias) {
return keystore.engineGetCertificateChain(alias);
}
@Override
public Certificate engineGetCertificate(String alias) {
return keystore.engineGetCertificate(alias);
}
@Override
public Date engineGetCreationDate(String alias) {
return keystore.engineGetCreationDate(alias);
}
@Override
public void engineSetKeyEntry(String alias, Key key, char[] password,
Certificate[] chain) throws KeyStoreException {
keystore.engineSetKeyEntry(alias, key, password, chain);
}
@Override
public void engineSetKeyEntry(String alias, byte[] key, Certificate[] chain)
throws KeyStoreException {
keystore.engineSetKeyEntry(alias, key, chain);
}
@Override
public void engineSetCertificateEntry(String alias, Certificate cert)
throws KeyStoreException {
keystore.engineSetCertificateEntry(alias, cert);
}
@Override
public void engineDeleteEntry(String alias) throws KeyStoreException {
keystore.engineDeleteEntry(alias);
}
@Override
public Enumeration<String> engineAliases() {
return keystore.engineAliases();
}
@Override
public boolean engineContainsAlias(String alias) {
return keystore.engineContainsAlias(alias);
}
@Override
public int engineSize() {
return keystore.engineSize();
}
@Override
public boolean engineIsKeyEntry(String alias) {
return keystore.engineIsKeyEntry(alias);
}
@Override
public boolean engineIsCertificateEntry(String alias) {
return keystore.engineIsCertificateEntry(alias);
}
@Override
public String engineGetCertificateAlias(Certificate cert) {
return keystore.engineGetCertificateAlias(cert);
}
@Override
public KeyStore.Entry engineGetEntry(String alias,
KeyStore.ProtectionParameter protParam)
throws KeyStoreException, NoSuchAlgorithmException,
UnrecoverableEntryException {
return keystore.engineGetEntry(alias, protParam);
}
@Override
public void engineSetEntry(String alias, KeyStore.Entry entry,
KeyStore.ProtectionParameter protParam)
throws KeyStoreException {
keystore.engineSetEntry(alias, entry, protParam);
}
@Override
public boolean engineEntryInstanceOf(String alias,
Class<? extends KeyStore.Entry> entryClass) {
return keystore.engineEntryInstanceOf(alias, entryClass);
}
@Override
public void engineStore(OutputStream stream, char[] password)
throws IOException, NoSuchAlgorithmException, CertificateException {
if (debug != null) {
debug.println("Storing keystore in " + type + " format");
}
keystore.engineStore(stream, password);
}
@Override
public void engineLoad(InputStream stream, char[] password)
throws IOException, NoSuchAlgorithmException, CertificateException {
// A new keystore is always created in the primary keystore format
if (stream == null) {
try {
keystore = primaryKeyStore.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
// can safely ignore
}
type = primaryType;
if (debug != null) {
debug.println("Creating a new keystore in " + type + " format");
}
keystore.engineLoad(stream, password);
} else {
// First try the primary keystore then try the secondary keystore
try (InputStream bufferedStream = new BufferedInputStream(stream)) {
bufferedStream.mark(Integer.MAX_VALUE);
try {
keystore = primaryKeyStore.newInstance();
type = primaryType;
keystore.engineLoad(bufferedStream, password);
} catch (Exception e) {
// incorrect password
if (e instanceof IOException &&
e.getCause() instanceof UnrecoverableKeyException) {
throw (IOException)e;
}
try {
// Ignore secondary keystore when no compatibility mode
if (!compatModeEnabled) {
throw e;
}
keystore = secondaryKeyStore.newInstance();
type = secondaryType;
bufferedStream.reset();
keystore.engineLoad(bufferedStream, password);
if (debug != null) {
debug.println("WARNING: switching from " +
primaryType + " to " + secondaryType +
" keystore file format has altered the " +
"keystore security level");
}
} catch (InstantiationException |
IllegalAccessException e2) {
// can safely ignore
} catch (IOException |
NoSuchAlgorithmException |
CertificateException e3) {
// incorrect password
if (e3 instanceof IOException &&
e3.getCause() instanceof
UnrecoverableKeyException) {
throw (IOException)e3;
}
// rethrow the outer exception
if (e instanceof IOException) {
throw (IOException)e;
} else if (e instanceof CertificateException) {
throw (CertificateException)e;
} else if (e instanceof NoSuchAlgorithmException) {
throw (NoSuchAlgorithmException)e;
}
}
}
}
if (debug != null) {
debug.println("Loaded a keystore in " + type + " format");
}
}
}
/**
* Probe the first few bytes of the keystore data stream for a valid
* keystore encoding. Only the primary keystore implementation is probed.
*/
@Override
public boolean engineProbe(InputStream stream) throws IOException {
boolean result = false;
try {
keystore = primaryKeyStore.newInstance();
type = primaryType;
result = keystore.engineProbe(stream);
} catch (Exception e) {
throw new IOException(e);
} finally {
// reset
if (result == false) {
type = null;
keystore = null;
}
}
return result;
}
}

@ -183,7 +183,17 @@ policy.ignoreIdentityScope=false
#
# Default keystore type.
#
keystore.type=jks
keystore.type=pkcs12
#
# Controls compatibility mode for JKS and PKCS12 keystore types.
#
# When set to 'true', both JKS and PKCS12 keystore types support loading
# keystore files in either JKS or PKCS12 format. When set to 'false' the
# JKS keystore type supports loading only JKS keystore files and the PKCS12
# keystore type supports loading only PKCS12 keystore files.
#
keystore.type.compat=true
#
# List of comma-separated packages that start with or equal this string

@ -333,15 +333,6 @@ JNIEXPORT jclass JNICALL
JVM_FindClassFromCaller(JNIEnv *env, const char *name, jboolean init,
jobject loader, jclass caller);
/*
* Find a class from a given class loader. Throw ClassNotFoundException
* or NoClassDefFoundError depending on the value of the last
* argument.
*/
JNIEXPORT jclass JNICALL
JVM_FindClassFromClassLoader(JNIEnv *env, const char *name, jboolean init,
jobject loader, jboolean throwError);
/*
* Find a class from a given class.
*/

@ -40,9 +40,7 @@ import static sun.nio.fs.UnixConstants.*;
* Solaris/Linux implementation of java.nio.file.Path
*/
class UnixPath
extends AbstractPath
{
class UnixPath implements Path {
private static ThreadLocal<SoftReference<CharsetEncoder>> encoder =
new ThreadLocal<SoftReference<CharsetEncoder>>();

@ -41,7 +41,7 @@ import static sun.nio.fs.WindowsConstants.*;
* Windows implementation of Path
*/
class WindowsPath extends AbstractPath {
class WindowsPath implements Path {
// The maximum path that does not require long path prefix. On Windows
// the maximum path is 260 minus 1 (NUL) but for directories it is 260

@ -70,6 +70,7 @@ class AquaComboBoxButton extends JButton {
return comboBox == null ? true : comboBox.isEnabled();
}
@SuppressWarnings("deprecation")
public boolean isFocusTraversable() {
return false;
}

@ -303,6 +303,7 @@ public class AquaInternalFrameDockIconUI extends DesktopIconUI implements MouseL
}
}
@SuppressWarnings("deprecation")
public void hide() {
final Container parent = getParent();
final Rectangle r = this.getBounds();

@ -2231,6 +2231,7 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing
return total;
}
@SuppressWarnings("deprecation")
public void layoutContainer(final Container parent) {
/* Some of the code in this method deals with changing the
* visibility of components to hide and show the contents for the
@ -2725,6 +2726,7 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing
return calculateMaxTabWidth(tabPlacement);
}
@SuppressWarnings("deprecation")
public void layoutContainer(final Container parent) {
/* Some of the code in this method deals with changing the
* visibility of components to hide and show the contents for the

@ -229,6 +229,7 @@ final class ScreenMenu extends Menu
}
@Override
@SuppressWarnings("deprecation")
public void addNotify() {
synchronized (getTreeLock()) {
super.addNotify();
@ -354,6 +355,7 @@ final class ScreenMenu extends Menu
public void setIndeterminate(boolean indeterminate) { }
@Override
@SuppressWarnings("deprecation")
public void setToolTipText(final String text) {
final MenuComponentPeer peer = getPeer();
if (!(peer instanceof CMenuItem)) return;
@ -363,6 +365,7 @@ final class ScreenMenu extends Menu
}
@Override
@SuppressWarnings("deprecation")
public void setIcon(final Icon i) {
final MenuComponentPeer peer = getPeer();
if (!(peer instanceof CMenuItem)) return;

@ -246,6 +246,7 @@ public class ScreenMenuBar extends MenuBar implements ContainerListener, ScreenM
fSubmenus.remove(menu);
}
@SuppressWarnings("deprecation")
public Menu add(final Menu m, final int index) {
synchronized (getTreeLock()) {
if (m.getParent() != null) {

@ -97,6 +97,7 @@ final class ScreenMenuItem extends MenuItem implements ActionListener, Component
fMenuItem.removeComponentListener(this);
}
@SuppressWarnings("deprecation")
static void syncLabelAndKS(MenuItem menuItem, String label, KeyStroke ks) {
final MenuComponentPeer peer = menuItem.getPeer();
if (!(peer instanceof CMenuItem)) {
@ -165,6 +166,7 @@ final class ScreenMenuItem extends MenuItem implements ActionListener, Component
}
}
@SuppressWarnings("deprecation")
public void setToolTipText(final String text) {
final MenuComponentPeer peer = getPeer();
if (!(peer instanceof CMenuItem)) return;
@ -173,6 +175,7 @@ final class ScreenMenuItem extends MenuItem implements ActionListener, Component
cmi.setToolTipText(text);
}
@SuppressWarnings("deprecation")
public void setIcon(final Icon i) {
final MenuComponentPeer peer = getPeer();
if (!(peer instanceof CMenuItem)) return;

@ -57,6 +57,7 @@ final class ScreenMenuItemCheckbox extends CheckboxMenuItem implements ActionLis
}
ScreenMenuPropertyListener fPropertyListener;
@SuppressWarnings("deprecation")
public void addNotify() {
super.addNotify();
@ -154,6 +155,7 @@ final class ScreenMenuItemCheckbox extends CheckboxMenuItem implements ActionLis
setVisible(false);
}
@SuppressWarnings("deprecation")
public void setToolTipText(final String text) {
final MenuComponentPeer peer = getPeer();
if (!(peer instanceof CMenuItem)) return;
@ -161,6 +163,7 @@ final class ScreenMenuItemCheckbox extends CheckboxMenuItem implements ActionLis
((CMenuItem)peer).setToolTipText(text);
}
@SuppressWarnings("deprecation")
public void setIcon(final Icon i) {
final MenuComponentPeer peer = getPeer();
if (!(peer instanceof CMenuItem)) return;
@ -205,6 +208,7 @@ final class ScreenMenuItemCheckbox extends CheckboxMenuItem implements ActionLis
}
}
@SuppressWarnings("deprecation")
public void setIndeterminate(final boolean indeterminate) {
final MenuComponentPeer peer = getPeer();
if (peer instanceof CCheckboxMenuItem) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -202,6 +202,7 @@ public final class CGraphicsDevice extends GraphicsDevice
return true;
}
@SuppressWarnings("deprecation")
private static void enterFullScreenExclusive(Window w) {
FullScreenCapable peer = (FullScreenCapable)w.getPeer();
if (peer != null) {
@ -209,6 +210,7 @@ public final class CGraphicsDevice extends GraphicsDevice
}
}
@SuppressWarnings("deprecation")
private static void exitFullScreenExclusive(Window w) {
FullScreenCapable peer = (FullScreenCapable)w.getPeer();
if (peer != null) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -125,6 +125,7 @@ public abstract class OSXSurfaceData extends BufImgSurfaceData {
return fConfig;
}
@SuppressWarnings("deprecation")
protected void setBounds(int x, int y, int w, int h) {
fBounds.reshape(x, y, w, y + h);
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -74,6 +74,7 @@ public class CGLVolatileSurfaceManager extends VolatileSurfaceManager {
* Create a pbuffer-based SurfaceData object (or init the backbuffer
* of an existing window if this is a double buffered GraphicsConfig)
*/
@SuppressWarnings("deprecation")
protected SurfaceData initAcceleratedSurface() {
SurfaceData sData = null;
Component comp = vImg.getComponent();

@ -1243,6 +1243,7 @@ public class LWWindowPeer
changeFocusedWindow(activate, null);
}
@SuppressWarnings("deprecation")
private boolean isOneOfOwnersOf(LWWindowPeer peer) {
Window owner = (peer != null ? peer.getTarget().getOwner() : null);
while (owner != null) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -88,6 +88,7 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
super.startDrag(dsc, cursor, dragImage, dragImageOffset);
}
@SuppressWarnings("deprecation")
protected void startDrag(Transferable transferable, long[] formats, Map<Long, DataFlavor> formatMap) {
DragGestureEvent trigger = getTrigger();
InputEvent triggerEvent = trigger.getTriggerEvent();

@ -46,6 +46,7 @@ public class CEmbeddedFrame extends EmbeddedFrame {
show();
}
@SuppressWarnings("deprecation")
public void addNotify() {
if (getPeer() == null) {
LWCToolkit toolkit = (LWCToolkit)Toolkit.getDefaultToolkit();
@ -60,6 +61,7 @@ public class CEmbeddedFrame extends EmbeddedFrame {
public void unregisterAccelerator(AWTKeyStroke stroke) {}
@SuppressWarnings("deprecation")
protected long getLayerPtr() {
LWWindowPeer peer = (LWWindowPeer)getPeer();
return peer.getLayerPtr();

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -385,6 +385,7 @@ public class CInputMethod extends InputMethodAdapter {
// java.awt.Toolkit#getNativeContainer() is not available
// from this package
@SuppressWarnings("deprecation")
private LWComponentPeer<?, ?> getNearestNativePeer(Component comp) {
if (comp==null)
return null;

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -43,6 +43,7 @@ public class CMenuBar extends CMenuComponent implements MenuBarPeer {
}
@Override
@SuppressWarnings("deprecation")
public void addHelpMenu(Menu m) {
CMenu cMenu = (CMenu)m.getPeer();
nativeSetHelpMenu(getModel(), cMenu.getModel());

@ -190,6 +190,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), filename);
}}
}) {
@SuppressWarnings("deprecation")
public CPlatformWindow convertJComponentToTarget(final JRootPane p) {
Component root = SwingUtilities.getRoot(p);
if (root == null || (LWWindowPeer)root.getPeer() == null) return null;
@ -519,6 +520,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
}
@Override // PlatformWindow
@SuppressWarnings("deprecation")
public void setVisible(boolean visible) {
final long nsWindowPtr = getNSWindowPtr();
@ -674,6 +676,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
}
@Override // PlatformWindow
@SuppressWarnings("deprecation")
public void toFront() {
final long nsWindowPtr = getNSWindowPtr();
LWCToolkit lwcToolkit = (LWCToolkit) Toolkit.getDefaultToolkit();

@ -68,6 +68,7 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer {
updateImage();
}
@SuppressWarnings("deprecation")
private CPopupMenu checkAndCreatePopupPeer() {
CPopupMenu menuPeer = null;
if (popup != null) {

@ -78,6 +78,7 @@ public class CViewEmbeddedFrame extends EmbeddedFrame {
* Synthetic event delivery for focus management
*/
@Override
@SuppressWarnings("deprecation")
public void synthesizeWindowActivation(boolean activated) {
if (isActive != activated) {
isActive = activated;

@ -104,6 +104,67 @@ static AWTWindow* lastKeyWindow = nil;
@implementation AWTWindow_Normal
AWT_NS_WINDOW_IMPLEMENTATION
// Gesture support
- (void)postGesture:(NSEvent *)event as:(jint)type a:(jdouble)a b:(jdouble)b {
AWT_ASSERT_APPKIT_THREAD;
JNIEnv *env = [ThreadUtilities getJNIEnv];
jobject platformWindow = [((AWTWindow *)self.delegate).javaPlatformWindow jObjectWithEnv:env];
if (platformWindow != NULL) {
// extract the target AWT Window object out of the CPlatformWindow
static JNF_MEMBER_CACHE(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;");
jobject awtWindow = JNFGetObjectField(env, platformWindow, jf_target);
if (awtWindow != NULL) {
// translate the point into Java coordinates
NSPoint loc = [event locationInWindow];
loc.y = [self frame].size.height - loc.y;
// send up to the GestureHandler to recursively dispatch on the AWT event thread
static JNF_CLASS_CACHE(jc_GestureHandler, "com/apple/eawt/event/GestureHandler");
static JNF_STATIC_MEMBER_CACHE(sjm_handleGestureFromNative, jc_GestureHandler, "handleGestureFromNative", "(Ljava/awt/Window;IDDDD)V");
JNFCallStaticVoidMethod(env, sjm_handleGestureFromNative, awtWindow, type, (jdouble)loc.x, (jdouble)loc.y, (jdouble)a, (jdouble)b);
(*env)->DeleteLocalRef(env, awtWindow);
}
(*env)->DeleteLocalRef(env, platformWindow);
}
}
- (void)beginGestureWithEvent:(NSEvent *)event {
[self postGesture:event
as:com_apple_eawt_event_GestureHandler_PHASE
a:-1.0
b:0.0];
}
- (void)endGestureWithEvent:(NSEvent *)event {
[self postGesture:event
as:com_apple_eawt_event_GestureHandler_PHASE
a:1.0
b:0.0];
}
- (void)magnifyWithEvent:(NSEvent *)event {
[self postGesture:event
as:com_apple_eawt_event_GestureHandler_MAGNIFY
a:[event magnification]
b:0.0];
}
- (void)rotateWithEvent:(NSEvent *)event {
[self postGesture:event
as:com_apple_eawt_event_GestureHandler_ROTATE
a:[event rotation]
b:0.0];
}
- (void)swipeWithEvent:(NSEvent *)event {
[self postGesture:event
as:com_apple_eawt_event_GestureHandler_SWIPE
a:[event deltaX]
b:[event deltaY]];
}
@end
@implementation AWTWindow_Panel
AWT_NS_WINDOW_IMPLEMENTATION
@ -399,67 +460,6 @@ AWT_ASSERT_APPKIT_THREAD;
}
// Gesture support
- (void)postGesture:(NSEvent *)event as:(jint)type a:(jdouble)a b:(jdouble)b {
AWT_ASSERT_APPKIT_THREAD;
JNIEnv *env = [ThreadUtilities getJNIEnv];
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
if (platformWindow != NULL) {
// extract the target AWT Window object out of the CPlatformWindow
static JNF_MEMBER_CACHE(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;");
jobject awtWindow = JNFGetObjectField(env, platformWindow, jf_target);
if (awtWindow != NULL) {
// translate the point into Java coordinates
NSPoint loc = [event locationInWindow];
loc.y = [self.nsWindow frame].size.height - loc.y;
// send up to the GestureHandler to recursively dispatch on the AWT event thread
static JNF_CLASS_CACHE(jc_GestureHandler, "com/apple/eawt/event/GestureHandler");
static JNF_STATIC_MEMBER_CACHE(sjm_handleGestureFromNative, jc_GestureHandler, "handleGestureFromNative", "(Ljava/awt/Window;IDDDD)V");
JNFCallStaticVoidMethod(env, sjm_handleGestureFromNative, awtWindow, type, (jdouble)loc.x, (jdouble)loc.y, (jdouble)a, (jdouble)b);
(*env)->DeleteLocalRef(env, awtWindow);
}
(*env)->DeleteLocalRef(env, platformWindow);
}
}
- (void)beginGestureWithEvent:(NSEvent *)event {
[self postGesture:event
as:com_apple_eawt_event_GestureHandler_PHASE
a:-1.0
b:0.0];
}
- (void)endGestureWithEvent:(NSEvent *)event {
[self postGesture:event
as:com_apple_eawt_event_GestureHandler_PHASE
a:1.0
b:0.0];
}
- (void)magnifyWithEvent:(NSEvent *)event {
[self postGesture:event
as:com_apple_eawt_event_GestureHandler_MAGNIFY
a:[event magnification]
b:0.0];
}
- (void)rotateWithEvent:(NSEvent *)event {
[self postGesture:event
as:com_apple_eawt_event_GestureHandler_ROTATE
a:[event rotation]
b:0.0];
}
- (void)swipeWithEvent:(NSEvent *)event {
[self postGesture:event
as:com_apple_eawt_event_GestureHandler_SWIPE
a:[event deltaX]
b:[event deltaY]];
}
// NSWindowDelegate methods
- (void) _deliverMoveResizeEvent {

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,14 +25,11 @@
#import <JavaNativeFoundation/JavaNativeFoundation.h>
#import "java_awt_geom_PathIterator.h"
#import "sun_awt_SunHints.h"
#import "sun_font_CStrike.h"
#import "sun_font_CStrikeDisposer.h"
#import "CGGlyphImages.h"
#import "CGGlyphOutlines.h"
#import "AWTStrike.h"
#import "CoreTextSupport.h"
//#import "jni_util.h"
#include "fontscalerdefs.h"
/* Use THIS_FILE when it is available. */
@ -65,10 +62,10 @@ static CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 };
invDevTx.b *= -1;
invDevTx.c *= -1;
fFontTx = CGAffineTransformConcat(CGAffineTransformConcat(tx, invDevTx), sInverseTX);
fDevTx = CGAffineTransformInvert(invDevTx);
fDevTx = CGAffineTransformInvert(CGAffineTransformConcat(invDevTx, sInverseTX));
// the "font size" is the square root of the determinant of the matrix
fSize = sqrt(abs(fFontTx.a * fFontTx.d - fFontTx.b * fFontTx.c));
fSize = sqrt(fabs(fFontTx.a * fFontTx.d - fFontTx.b * fFontTx.c));
}
return self;
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -31,6 +31,7 @@ import java.beans.*;
public class ColorEditor extends Panel implements PropertyEditor {
private static final long serialVersionUID = 1781257185164716054L;
@SuppressWarnings("deprecation")
public ColorEditor() {
setLayout(null);
@ -69,10 +70,12 @@ public class ColorEditor extends Panel implements PropertyEditor {
changeColor(c);
}
@SuppressWarnings("deprecation")
public Dimension preferredSize() {
return new Dimension(ourWidth, 40);
}
@SuppressWarnings("deprecation")
public boolean keyUp(Event e, int key) {
if (e.target == text) {
try {
@ -107,6 +110,7 @@ public class ColorEditor extends Panel implements PropertyEditor {
}
@SuppressWarnings("deprecation")
public boolean action(Event e, Object arg) {
if (e.target == choser) {
changeColor(colors[choser.getSelectedIndex()]);

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -31,6 +31,7 @@ import java.beans.*;
public class FontEditor extends Panel implements java.beans.PropertyEditor {
private static final long serialVersionUID = 6732704486002715933L;
@SuppressWarnings("deprecation")
public FontEditor() {
setLayout(null);
@ -62,6 +63,7 @@ public class FontEditor extends Panel implements java.beans.PropertyEditor {
}
@SuppressWarnings("deprecation")
public Dimension preferredSize() {
return new Dimension(300, 40);
}
@ -93,6 +95,7 @@ public class FontEditor extends Panel implements java.beans.PropertyEditor {
}
}
@SuppressWarnings("deprecation")
private void changeFont(Font f) {
font = f;
if (sample != null) {
@ -124,6 +127,7 @@ public class FontEditor extends Panel implements java.beans.PropertyEditor {
font.getStyle() + ", " + font.getSize() + ")";
}
@SuppressWarnings("deprecation")
public boolean action(Event e, Object arg) {
String family = familyChoser.getSelectedItem();
int style = styles[styleChoser.getSelectedIndex()];

@ -143,6 +143,7 @@ class GTKFileChooserUI extends SynthFileChooserUI {
return map;
}
@SuppressWarnings("deprecation")
public String getFileName() {
JFileChooser fc = getFileChooser();
String typedInName = fileNameTextField != null ?
@ -419,6 +420,7 @@ class GTKFileChooserUI extends SynthFileChooserUI {
@SuppressWarnings("deprecation")
protected class SelectionListener implements ListSelectionListener {
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {

@ -245,6 +245,7 @@ public class MotifDesktopIconUI extends BasicDesktopIconUI
e.isPopupTrigger(), MouseEvent.NOBUTTON));
}
@SuppressWarnings("deprecation")
public boolean isFocusTraversable() {
return false;
}
@ -336,6 +337,7 @@ public class MotifDesktopIconUI extends BasicDesktopIconUI
e.getClickCount(), e.isPopupTrigger(), MouseEvent.NOBUTTON ));
}
@SuppressWarnings("deprecation")
public boolean isFocusTraversable() {
return false;
}

@ -242,6 +242,7 @@ public class MotifInternalFrameTitlePane
setBorderPainted(false);
}
@SuppressWarnings("deprecation")
public boolean isFocusTraversable() {
return false;
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -60,6 +60,7 @@ public class WindowsDesktopPaneUI extends BasicDesktopPaneUI
super.installDefaults();
}
@SuppressWarnings("deprecation")
protected void installKeyboardActions() {
super.installKeyboardActions();

@ -2487,6 +2487,7 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
/**
* Calculates the dialog unit mapping.
*/
@SuppressWarnings("deprecation")
private void calculateBaseUnits() {
// This calculation comes from:
// http://support.microsoft.com/default.aspx?scid=kb;EN-US;125681

@ -78,6 +78,7 @@ class WindowsPopupWindow extends JWindow {
paint(g);
}
@SuppressWarnings("deprecation")
public void hide() {
super.hide();
/** We need to call removeNotify() here because hide() does
@ -89,6 +90,7 @@ class WindowsPopupWindow extends JWindow {
removeNotify();
}
@SuppressWarnings("deprecation")
public void show() {
super.show();
this.pack();

@ -700,6 +700,7 @@ class XPStyle {
setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
}
@SuppressWarnings("deprecation")
public boolean isFocusTraversable() {
return false;
}

@ -167,9 +167,9 @@ public final class WaveExtensibleFileReader extends AudioFileReader {
for (int i = 0; i < allchannelnames.length; i++) {
if ((channelmask & m) != 0L) {
if (i < channelnames.length) {
sb.append(channelnames[i] + " ");
sb.append(channelnames[i]).append(' ');
} else {
sb.append(allchannelnames[i] + " ");
sb.append(allchannelnames[i]).append(' ');
}
}
m *= 2L;

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -70,6 +70,7 @@ public class Canvas extends Component implements Accessible {
}
@Override
@SuppressWarnings("deprecation")
void setGraphicsConfiguration(GraphicsConfiguration gc) {
synchronized(getTreeLock()) {
CanvasPeer peer = (CanvasPeer)getPeer();

@ -805,6 +805,7 @@ public class Container extends Component {
* to new heavyweight parent.
* @since 1.5
*/
@SuppressWarnings("deprecation")
private void reparentTraverse(ContainerPeer parentPeer, Container child) {
checkTreeLock();
@ -828,6 +829,7 @@ public class Container extends Component {
* Container must be heavyweight.
* @since 1.5
*/
@SuppressWarnings("deprecation")
private void reparentChild(Component comp) {
checkTreeLock();
if (comp == null) {
@ -4189,6 +4191,7 @@ public class Container extends Component {
}
}
@SuppressWarnings("deprecation")
private void recursiveShowHeavyweightChildren() {
if (!hasHeavyweightDescendants() || !isVisible()) {
return;
@ -4210,6 +4213,7 @@ public class Container extends Component {
}
}
@SuppressWarnings("deprecation")
private void recursiveHideHeavyweightChildren() {
if (!hasHeavyweightDescendants()) {
return;
@ -4231,6 +4235,7 @@ public class Container extends Component {
}
}
@SuppressWarnings("deprecation")
private void recursiveRelocateHeavyweightChildren(Point origin) {
for (int index = 0; index < getComponentCount(); index++) {
Component comp = getComponent(index);

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -93,6 +93,7 @@ public class DefaultFocusTraversalPolicy
* @return <code>true</code> if aComponent meets the above requirements;
* <code>false</code> otherwise
*/
@SuppressWarnings("deprecation")
protected boolean accept(Component aComponent) {
if (!(aComponent.isVisible() && aComponent.isDisplayable() &&
aComponent.isEnabled()))

@ -796,6 +796,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
* @return <code>true</code>
* @see Component#dispatchEvent
*/
@SuppressWarnings("deprecation")
public boolean dispatchKeyEvent(KeyEvent e) {
Component focusOwner = (((AWTEvent)e).isPosted) ? getFocusOwner() : e.getComponent();
@ -1021,6 +1022,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
}
}
@SuppressWarnings("deprecation")
private boolean preDispatchKeyEvent(KeyEvent ke) {
if (((AWTEvent) ke).isPosted) {
Component focusOwner = getFocusOwner();

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -749,6 +749,7 @@ public class Dialog extends Window {
* @see Component#isDisplayable
* @see #removeNotify
*/
@SuppressWarnings("deprecation")
public void addNotify() {
synchronized (getTreeLock()) {
if (parent != null && parent.getPeer() == null) {
@ -897,6 +898,7 @@ public class Dialog extends Window {
/**
* @return true if we actually showed, false if we just called toFront()
*/
@SuppressWarnings("deprecation")
private boolean conditionalShow(Component toFocus, AtomicLong time) {
boolean retval;

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -314,6 +314,7 @@ public class FileDialog extends Dialog {
* Creates the file dialog's peer. The peer allows us to change the look
* of the file dialog without changing its functionality.
*/
@SuppressWarnings("deprecation")
public void addNotify() {
synchronized(getTreeLock()) {
if (parent != null && parent.getPeer() == null) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -409,6 +409,7 @@ public abstract class FontMetrics implements java.io.Serializable {
* @see #charsWidth(char[], int, int)
* @see #stringWidth(String)
*/
@SuppressWarnings("deprecation")
public int bytesWidth(byte data[], int off, int len) {
return stringWidth(new String(data, 0, off, len));
}

@ -843,6 +843,7 @@ public abstract class Graphics {
* @see java.awt.Graphics#drawChars
* @see java.awt.Graphics#drawString
*/
@SuppressWarnings("deprecation")
public void drawBytes(byte data[], int offset, int length, int x, int y) {
drawString(new String(data, 0, offset, length), x, y);
}

@ -28,6 +28,7 @@ package java.awt;
import java.awt.image.BufferedImage;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Locale;
import sun.font.FontManager;
@ -161,43 +162,38 @@ public abstract class GraphicsEnvironment {
*/
private static boolean getHeadlessProperty() {
if (headless == null) {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Object>() {
public Object run() {
String nm = System.getProperty("java.awt.headless");
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
String nm = System.getProperty("java.awt.headless");
if (nm == null) {
/* No need to ask for DISPLAY when run in a browser */
if (System.getProperty("javaplugin.version") != null) {
headless = defaultHeadless = Boolean.FALSE;
} else {
String osName = System.getProperty("os.name");
if (osName.contains("OS X") && "sun.awt.HToolkit".equals(
System.getProperty("awt.toolkit")))
{
headless = defaultHeadless = Boolean.TRUE;
} else {
headless = defaultHeadless =
Boolean.valueOf(("Linux".equals(osName) ||
"SunOS".equals(osName) ||
"FreeBSD".equals(osName) ||
"NetBSD".equals(osName) ||
"OpenBSD".equals(osName) ||
"AIX".equals(osName)) &&
(System.getenv("DISPLAY") == null));
}
}
} else if (nm.equals("true")) {
headless = Boolean.TRUE;
if (nm == null) {
/* No need to ask for DISPLAY when run in a browser */
if (System.getProperty("javaplugin.version") != null) {
headless = defaultHeadless = Boolean.FALSE;
} else {
headless = Boolean.FALSE;
String osName = System.getProperty("os.name");
if (osName.contains("OS X") && "sun.awt.HToolkit".equals(
System.getProperty("awt.toolkit")))
{
headless = defaultHeadless = Boolean.TRUE;
} else {
final String display = System.getenv("DISPLAY");
headless = defaultHeadless =
("Linux".equals(osName) ||
"SunOS".equals(osName) ||
"FreeBSD".equals(osName) ||
"NetBSD".equals(osName) ||
"OpenBSD".equals(osName) ||
"AIX".equals(osName)) &&
(display == null || display.trim().isEmpty());
}
}
return null;
} else {
headless = Boolean.valueOf(nm);
}
}
);
return null;
});
}
return headless.booleanValue();
return headless;
}
/**

@ -3054,6 +3054,7 @@ public abstract class KeyboardFocusManager
return (wto != wfrom);
}
@SuppressWarnings("deprecation")
static Component getHeavyweight(Component comp) {
if (comp == null || comp.getPeer() == null) {
return null;

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -153,6 +153,7 @@ public class PopupMenu extends Menu {
* parent's hierarchy
* @exception RuntimeException if the parent is not showing on screen
*/
@SuppressWarnings("deprecation")
public void show(Component origin, int x, int y) {
// Use localParent for thread safety.
MenuContainer localParent = parent;

@ -732,6 +732,7 @@ public class ScrollPane extends Container implements Accessible {
/**
* Invoked when the value of the adjustable has changed.
*/
@SuppressWarnings("deprecation")
public void adjustmentValueChanged(AdjustmentEvent e) {
Adjustable adj = e.getAdjustable();
int value = e.getValue();
@ -831,6 +832,7 @@ class PeerFixer implements AdjustmentListener, java.io.Serializable {
/**
* Invoked when the value of the adjustable has changed.
*/
@SuppressWarnings("deprecation")
public void adjustmentValueChanged(AdjustmentEvent e) {
Adjustable adj = e.getAdjustable();
int value = e.getValue();

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -203,6 +203,7 @@ public final class SplashScreen {
* @return URL for the current splash screen image file
* @throws IllegalStateException if the splash screen has already been closed
*/
@SuppressWarnings("deprecation")
public URL getImageURL() throws IllegalStateException {
synchronized (SplashScreen.class) {
checkVisible();

@ -755,6 +755,7 @@ public class Window extends Container implements Accessible {
* @see Container#removeNotify
* @since 1.0
*/
@SuppressWarnings("deprecation")
public void addNotify() {
synchronized (getTreeLock()) {
Container parent = this.parent;
@ -798,6 +799,7 @@ public class Window extends Container implements Accessible {
* @see Component#isDisplayable
* @see #setMinimumSize
*/
@SuppressWarnings("deprecation")
public void pack() {
Container parent = this.parent;
if (parent != null && parent.getPeer() == null) {
@ -1070,6 +1072,7 @@ public class Window extends Container implements Accessible {
}
}
@SuppressWarnings("deprecation")
static void updateChildFocusableWindowState(Window w) {
if (w.getPeer() != null && w.isShowing()) {
((WindowPeer)w.getPeer()).updateFocusableWindowState();
@ -1157,6 +1160,7 @@ public class Window extends Container implements Accessible {
* as reported in javadoc. So we need to implement this functionality even if a
* child overrides dispose() in a wrong way without calling super.dispose().
*/
@SuppressWarnings("deprecation")
void disposeImpl() {
dispose();
if (getPeer() != null) {
@ -3623,6 +3627,7 @@ public class Window extends Container implements Accessible {
*
* @since 1.7
*/
@SuppressWarnings("deprecation")
public void setOpacity(float opacity) {
synchronized (getTreeLock()) {
if (opacity < 0.0f || opacity > 1.0f) {
@ -3721,6 +3726,7 @@ public class Window extends Container implements Accessible {
*
* @since 1.7
*/
@SuppressWarnings("deprecation")
public void setShape(Shape shape) {
synchronized (getTreeLock()) {
if (shape != null) {
@ -3838,6 +3844,7 @@ public class Window extends Container implements Accessible {
* @see GraphicsConfiguration#isTranslucencyCapable()
*/
@Override
@SuppressWarnings("deprecation")
public void setBackground(Color bgColor) {
Color oldBg = getBackground();
super.setBackground(bgColor);
@ -3890,6 +3897,7 @@ public class Window extends Container implements Accessible {
return bg != null ? bg.getAlpha() == 255 : true;
}
@SuppressWarnings("deprecation")
private void updateWindow() {
synchronized (getTreeLock()) {
WindowPeer peer = (WindowPeer)getPeer();
@ -4080,6 +4088,7 @@ public class Window extends Container implements Accessible {
window.securityWarningHeight = height;
}
@SuppressWarnings("deprecation")
public void setSecurityWarningPosition(Window window,
Point2D point, float alignmentX, float alignmentY)
{

@ -47,6 +47,7 @@ public class StringSelection implements Transferable, ClipboardOwner {
private static final int STRING = 0;
private static final int PLAIN_TEXT = 1;
@SuppressWarnings("deprecation")
private static final DataFlavor[] flavors = {
DataFlavor.stringFlavor,
DataFlavor.plainTextFlavor // deprecated

@ -624,6 +624,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
return new ArrayList<>(returnValue);
}
@SuppressWarnings("deprecation")
private static Set<DataFlavor> convertMimeTypeToDataFlavors(
final String baseType) {

@ -499,6 +499,7 @@ public class DropTarget implements DropTargetListener, Serializable {
*
*/
@SuppressWarnings("deprecation")
public void addNotify(ComponentPeer peer) {
if (peer == componentPeer) return;
@ -690,6 +691,7 @@ public class DropTarget implements DropTargetListener, Serializable {
* update the geometry of the autoscroll region
*/
@SuppressWarnings("deprecation")
private void updateRegion() {
Insets i = autoScroll.getAutoscrollInsets();
Dimension size = component.getSize();

@ -149,6 +149,7 @@ public class ServiceUI {
* or attributes is null, or the initial PrintService is not in the
* list of browsable services.
*/
@SuppressWarnings("deprecation")
public static PrintService printDialog(GraphicsConfiguration gc,
int x, int y,
PrintService[] services,

@ -1453,6 +1453,7 @@ public class DebugGraphics extends Graphics {
/** Returns a DebugGraphics for use in buffering window.
*/
@SuppressWarnings("deprecation")
private Graphics debugGraphics() {
DebugGraphics debugGraphics;
DebugGraphicsInfo info = info();

@ -1213,15 +1213,15 @@ public class GroupLayout implements LayoutManager2 {
registerComponents(horizontalGroup, HORIZONTAL);
registerComponents(verticalGroup, VERTICAL);
}
StringBuffer buffer = new StringBuffer();
buffer.append("HORIZONTAL\n");
createSpringDescription(buffer, horizontalGroup, " ", HORIZONTAL);
buffer.append("\nVERTICAL\n");
createSpringDescription(buffer, verticalGroup, " ", VERTICAL);
return buffer.toString();
StringBuilder sb = new StringBuilder();
sb.append("HORIZONTAL\n");
createSpringDescription(sb, horizontalGroup, " ", HORIZONTAL);
sb.append("\nVERTICAL\n");
createSpringDescription(sb, verticalGroup, " ", VERTICAL);
return sb.toString();
}
private void createSpringDescription(StringBuffer buffer, Spring spring,
private void createSpringDescription(StringBuilder sb, Spring spring,
String indent, int axis) {
String origin = "";
String padding = "";
@ -1239,20 +1239,19 @@ public class GroupLayout implements LayoutManager2 {
padding = ", userCreated=" + paddingSpring.getUserCreated() +
", matches=" + paddingSpring.getMatchDescription();
}
buffer.append(indent + spring.getClass().getName() + " " +
Integer.toHexString(spring.hashCode()) + " " +
origin +
", size=" + spring.getSize() +
", alignment=" + spring.getAlignment() +
" prefs=[" + spring.getMinimumSize(axis) +
" " + spring.getPreferredSize(axis) +
" " + spring.getMaximumSize(axis) +
padding + "]\n");
sb.append(indent).append(spring.getClass().getName()).append(' ')
.append(Integer.toHexString(spring.hashCode())).append(' ')
.append(origin).append(", size=").append(spring.getSize())
.append(", alignment=").append(spring.getAlignment())
.append(" prefs=[").append(spring.getMinimumSize(axis))
.append(' ').append(spring.getPreferredSize(axis)).append(' ')
.append(spring.getMaximumSize(axis)).append(padding)
.append("]\n");
if (spring instanceof Group) {
List<Spring> springs = ((Group)spring).springs;
indent += " ";
for (int counter = 0; counter < springs.size(); counter++) {
createSpringDescription(buffer, springs.get(counter), indent,
createSpringDescription(sb, springs.get(counter), indent,
axis);
}
}

@ -243,6 +243,7 @@ public class JApplet extends Applet implements Accessible,
* hidden: true
* description: The menubar for accessing pulldown menus from this applet.
*/
@SuppressWarnings("deprecation")
public void setJMenuBar(JMenuBar menuBar) {
getRootPane().setMenuBar(menuBar);
}
@ -253,6 +254,7 @@ public class JApplet extends Applet implements Accessible,
* @return the menubar set on this applet
* @see #setJMenuBar
*/
@SuppressWarnings("deprecation")
public JMenuBar getJMenuBar() {
return getRootPane().getMenuBar();
}

@ -133,6 +133,7 @@ public class JColorChooser extends JComponent implements Accessible {
* returns true.
* @see java.awt.GraphicsEnvironment#isHeadless
*/
@SuppressWarnings("deprecation")
public static Color showDialog(Component component,
String title, Color initialColor) throws HeadlessException {
@ -543,17 +544,17 @@ public class JColorChooser extends JComponent implements Accessible {
* @return a string representation of this <code>JColorChooser</code>
*/
protected String paramString() {
StringBuilder chooserPanelsString = new StringBuilder("");
for (int i=0; i<chooserPanels.length; i++) {
chooserPanelsString.append("[" + chooserPanels[i].toString()
+ "]");
StringBuilder chooserPanelsString = new StringBuilder();
for (AbstractColorChooserPanel panel : chooserPanels) {
chooserPanelsString.append('[').append(panel)
.append(']');
}
String previewPanelString = (previewPanel != null ?
previewPanel.toString() : "");
String previewPanelString = (previewPanel != null ? previewPanel
.toString() : "");
return super.paramString() +
",chooserPanels=" + chooserPanelsString.toString() +
",previewPanel=" + previewPanelString;
return super.paramString() + ",chooserPanels="
+ chooserPanelsString.toString() + ",previewPanel="
+ previewPanelString;
}
/////////////////
@ -654,6 +655,7 @@ class ColorChooserDialog extends JDialog {
okButton.getAccessibleContext().setAccessibleDescription(okString);
okButton.setActionCommand("OK");
okButton.addActionListener(new ActionListener() {
@SuppressWarnings("deprecation")
public void actionPerformed(ActionEvent e) {
hide();
}
@ -685,6 +687,7 @@ class ColorChooserDialog extends JDialog {
cancelButton.setActionCommand("cancel");
cancelButton.addActionListener(new ActionListener() {
@SuppressWarnings("deprecation")
public void actionPerformed(ActionEvent e) {
hide();
}
@ -723,6 +726,7 @@ class ColorChooserDialog extends JDialog {
this.addWindowListener(new Closer());
}
@SuppressWarnings("deprecation")
public void show() {
initialColor = chooserPane.getColor();
super.show();
@ -734,6 +738,7 @@ class ColorChooserDialog extends JDialog {
@SuppressWarnings("serial") // JDK-implementation class
class Closer extends WindowAdapter implements Serializable{
@SuppressWarnings("deprecation")
public void windowClosing(WindowEvent e) {
cancelButton.doClick(0);
Window w = e.getWindow();

@ -5049,6 +5049,7 @@ public abstract class JComponent extends Container implements Serializable,
this.paintingChild = paintingChild;
}
@SuppressWarnings("deprecation")
void _paintImmediately(int x, int y, int w, int h) {
Graphics g;
Container c;

@ -849,6 +849,7 @@ public class JDialog extends Dialog implements WindowConstants,
* hidden: true
* description: The menubar for accessing pulldown menus from this dialog.
*/
@SuppressWarnings("deprecation")
public void setJMenuBar(JMenuBar menu) {
getRootPane().setMenuBar(menu);
}
@ -859,6 +860,7 @@ public class JDialog extends Dialog implements WindowConstants,
* @return the menubar set on this dialog
* @see #setJMenuBar
*/
@SuppressWarnings("deprecation")
public JMenuBar getJMenuBar() {
return getRootPane().getMenuBar();
}

@ -757,6 +757,7 @@ public class JFileChooser extends JComponent implements Accessible {
* returns true.
* @see java.awt.GraphicsEnvironment#isHeadless
*/
@SuppressWarnings("deprecation")
public int showDialog(Component parent, String approveButtonText)
throws HeadlessException {
if (dialog != null) {

@ -494,6 +494,7 @@ public class JFrame extends Frame implements WindowConstants,
* hidden: true
* description: The menubar for accessing pulldown menus from this frame.
*/
@SuppressWarnings("deprecation")
public void setJMenuBar(JMenuBar menubar) {
getRootPane().setMenuBar(menubar);
}
@ -504,6 +505,7 @@ public class JFrame extends Frame implements WindowConstants,
*
* @see #setJMenuBar
*/
@SuppressWarnings("deprecation")
public JMenuBar getJMenuBar() {
return getRootPane().getMenuBar();
}

@ -1494,6 +1494,7 @@ public class JInternalFrame extends JComponent implements
* @param width an integer giving the component's new width in pixels
* @param height an integer giving the component's new height in pixels
*/
@SuppressWarnings("deprecation")
public void reshape(int x, int y, int width, int height) {
super.reshape(x, y, width, height);
validate();
@ -1735,6 +1736,7 @@ public class JInternalFrame extends JComponent implements
* @see InternalFrameEvent#INTERNAL_FRAME_OPENED
* @see #setVisible
*/
@SuppressWarnings("deprecation")
public void show() {
// bug 4312922
if (isVisible()) {
@ -1766,6 +1768,7 @@ public class JInternalFrame extends JComponent implements
}
}
@SuppressWarnings("deprecation")
public void hide() {
if (isIcon()) {
getDesktopIcon().setVisible(false);

@ -3663,6 +3663,7 @@ public class JList<E> extends JComponent implements Scrollable, Accessible
}
}
@SuppressWarnings("deprecation")
public boolean isFocusTraversable() {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {

@ -566,6 +566,7 @@ public class JOptionPane extends JComponent implements Accessible
* <code>true</code>
* @see java.awt.GraphicsEnvironment#isHeadless
*/
@SuppressWarnings("deprecation")
public static Object showInputDialog(Component parentComponent,
Object message, String title, int messageType, Icon icon,
Object[] selectionValues, Object initialSelectionValue)
@ -855,6 +856,7 @@ public class JOptionPane extends JComponent implements Accessible
* <code>true</code>
* @see java.awt.GraphicsEnvironment#isHeadless
*/
@SuppressWarnings("deprecation")
public static int showOptionDialog(Component parentComponent,
Object message, String title, int optionType, int messageType,
Icon icon, Object[] options, Object initialValue)

@ -333,6 +333,7 @@ public class JTabbedPane extends JComponent
* @see #addChangeListener
* @see EventListenerList
*/
@SuppressWarnings("deprecation")
protected void fireStateChanged() {
/* --- Begin code to deal with visibility --- */
@ -949,6 +950,7 @@ public class JTabbedPane extends JComponent
* @see #addTab
* @see #insertTab
*/
@SuppressWarnings("deprecation")
public void removeTabAt(int index) {
checkIndex(index);
@ -1557,6 +1559,7 @@ public class JTabbedPane extends JComponent
* attribute: visualUpdate true
* description: The component at the specified tab index.
*/
@SuppressWarnings("deprecation")
public void setComponentAt(int index, Component component) {
Page page = pages.get(index);
if (component != page.component) {

@ -5810,6 +5810,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* where 0 is the first column
* @return the <code>Component</code> being edited
*/
@SuppressWarnings("deprecation")
public Component prepareEditor(TableCellEditor editor, int row, int column) {
Object value = getValueAt(row, column);
boolean isSelected = isCellSelected(row, column);
@ -8788,6 +8789,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
}
}
@SuppressWarnings("deprecation")
public boolean isFocusTraversable() {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
@ -9640,6 +9642,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* @see AccessibleState#FOCUSED
* @see AccessibleStateSet
*/
@SuppressWarnings("deprecation")
public boolean isFocusTraversable() {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {

@ -829,6 +829,7 @@ public class JViewport extends JComponent implements Accessible
*
* @see JComponent#reshape(int, int, int, int)
*/
@SuppressWarnings("deprecation")
public void reshape(int x, int y, int w, int h) {
boolean sizeChanged = (getWidth() != w) || (getHeight() != h);
if (sizeChanged) {
@ -1447,6 +1448,7 @@ public class JViewport extends JComponent implements Accessible
* Returns true if the component needs to be completely repainted after
* a blit and a paint is received.
*/
@SuppressWarnings("deprecation")
private boolean needsRepaintAfterBlit() {
// Find the first heavy weight ancestor. isObscured and
// canDetermineObscurity are only appropriate for heavy weights.

@ -253,6 +253,7 @@ public class Popup {
paint(g);
}
@SuppressWarnings("deprecation")
public void show() {
this.pack();
if (getWidth() > 0 && getHeight() > 0) {

@ -260,6 +260,7 @@ public class ProgressMonitor implements Accessible
* @see #setMaximum
* @see #close
*/
@SuppressWarnings("deprecation")
public void setProgress(int nv) {
if (nv >= max) {
close();

@ -401,6 +401,7 @@ public class RepaintManager
*
* @see JComponent#repaint
*/
@SuppressWarnings("deprecation")
private void addDirtyRegion0(Container c, int x, int y, int w, int h) {
/* Special cases we don't have to bother with.
*/

@ -195,6 +195,7 @@ public class SortingFocusTraversalPolicy
return true;
}
@SuppressWarnings("deprecation")
private void enumerateCycle(Container container, List<Component> cycle) {
if (!(container.isVisible() && container.isDisplayable())) {
return;

@ -1929,6 +1929,7 @@ public class SwingUtilities implements SwingConstants
public void windowDeactivated(WindowEvent e) {
}
@SuppressWarnings("deprecation")
public void show() {
// This frame can never be shown
}

@ -1436,6 +1436,7 @@ public class UIManager implements Serializable
/*
* Sets default swing focus traversal policy.
*/
@SuppressWarnings("deprecation")
private static void maybeInitializeFocusPolicy(JComponent comp) {
// Check for JRootPane which indicates that a swing toplevel
// is coming, in which case a swing default focus policy

@ -3,7 +3,7 @@
<HEAD>
<!--
Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
@ -68,6 +68,8 @@ invokeLater} method schedules a {@code Runnable} to be processed on
the event dispatching thread. The following two examples work equally
well for transferring control and starting up a Swing application:
<pre>
import javax.swing.SwingUtilities;
public class MyApp implements Runnable {
public void run() {
// Invoked on the event dispatching thread.
@ -75,16 +77,18 @@ public class MyApp implements Runnable {
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new MyApp(args));
SwingUtilities.invokeLater(new MyApp());
}
}
</pre>
Or:
<pre>
import javax.swing.SwingUtilities;
public class MyApp {
MyApp(String[] args) {
// Invoked on the event dispatching thread. Do any initialization
// here.
// Invoked on the event dispatching thread.
// Do any initialization here.
}
public void show() {

@ -216,6 +216,7 @@ public class BasicArrowButton extends JButton implements SwingConstants
*
* @return {@code false}
*/
@SuppressWarnings("deprecation")
public boolean isFocusTraversable() {
return false;
}

@ -223,6 +223,7 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup {
/**
* Implementation of ComboPopup.show().
*/
@SuppressWarnings("deprecation")
public void show() {
comboBox.firePopupMenuWillBecomeVisible();
setListSelection(comboBox.getSelectedIndex());
@ -234,6 +235,7 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup {
/**
* Implementation of ComboPopup.hide().
*/
@SuppressWarnings("deprecation")
public void hide() {
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
MenuElement [] selection = manager.getSelectedPath();
@ -1032,6 +1034,7 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup {
/**
* Overridden to unconditionally return false.
*/
@SuppressWarnings("deprecation")
public boolean isFocusTraversable() {
return false;
}

@ -502,6 +502,7 @@ public class BasicFileChooserUI extends FileChooserUI {
public void mouseReleased(MouseEvent evt) {
}
@SuppressWarnings("deprecation")
public void valueChanged(ListSelectionEvent evt) {
if(!evt.getValueIsAdjusting()) {
JFileChooser chooser = getFileChooser();
@ -1305,6 +1306,7 @@ public class BasicFileChooserUI extends FileChooserUI {
* @return The representation of the data to be transfered.
*
*/
@SuppressWarnings("deprecation")
protected Transferable createTransferable(JComponent c) {
Object[] values = null;
if (c instanceof JList) {
@ -1330,8 +1332,8 @@ public class BasicFileChooserUI extends FileChooserUI {
for (Object obj : values) {
String val = ((obj == null) ? "" : obj.toString());
plainBuf.append(val + "\n");
htmlBuf.append(" <li>" + val + "\n");
plainBuf.append(val).append('\n');
htmlBuf.append(" <li>").append(val).append('\n');
}
// remove the last newline

@ -926,6 +926,7 @@ public class BasicInternalFrameTitlePane extends JComponent
* This class should be treated as a &quot;protected&quot; inner class.
* Instantiate it only within subclasses of <code>Foo</code>.
*/
@SuppressWarnings("deprecation")
public class SystemMenuBar extends JMenuBar {
public boolean isFocusTraversable() { return false; }
public void requestFocus() {}
@ -963,6 +964,7 @@ public class BasicInternalFrameTitlePane extends JComponent
setOpaque(((Boolean)opacity).booleanValue());
}
}
@SuppressWarnings("deprecation")
public boolean isFocusTraversable() { return false; }
public void requestFocus() {}
public AccessibleContext getAccessibleContext() {

@ -2931,6 +2931,7 @@ public class BasicListUI extends ListUI
* @return The representation of the data to be transfered.
*
*/
@SuppressWarnings("deprecation")
protected Transferable createTransferable(JComponent c) {
if (c instanceof JList) {
JList<?> list = (JList) c;
@ -2948,8 +2949,8 @@ public class BasicListUI extends ListUI
for (int i = 0; i < values.length; i++) {
Object obj = values[i];
String val = ((obj == null) ? "" : obj.toString());
plainStr.append(val + "\n");
htmlStr.append(" <li>" + val + "\n");
plainStr.append(val).append('\n');
htmlStr.append(" <li>").append(val).append('\n');
}
// remove the last newline

@ -441,6 +441,7 @@ public class BasicSplitPaneDivider extends Container
}
}
// Don't want the button to participate in focus traversable.
@SuppressWarnings("deprecation")
public boolean isFocusTraversable() {
return false;
}
@ -497,6 +498,7 @@ public class BasicSplitPaneDivider extends Container
}
}
// Don't want the button to participate in focus traversable.
@SuppressWarnings("deprecation")
public boolean isFocusTraversable() {
return false;
}

@ -1191,6 +1191,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
* Should be messaged before the dragging session starts, resets
* lastDragLocation and dividerSize.
*/
@SuppressWarnings("deprecation")
protected void startDragging() {
Component leftC = splitPane.getLeftComponent();
Component rightC = splitPane.getRightComponent();

@ -2395,6 +2395,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
return total;
}
@SuppressWarnings("deprecation")
public void layoutContainer(Container parent) {
/* Some of the code in this method deals with changing the
* visibility of components to hide and show the contents for the
@ -2903,6 +2904,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
return calculateMaxTabWidth(tabPlacement);
}
@SuppressWarnings("deprecation")
public void layoutContainer(Container parent) {
/* Some of the code in this method deals with changing the
* visibility of components to hide and show the contents for the

Some files were not shown because too many files have changed in this diff Show More