7008713: diamond conversion of kerberos5 and security tools
Reviewed-by: weijun
This commit is contained in:
parent
677a39996a
commit
07549260db
@ -528,7 +528,7 @@ public class Config {
|
|||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
String Line;
|
String Line;
|
||||||
Vector<String> v = new Vector<String> ();
|
Vector<String> v = new Vector<>();
|
||||||
String previous = null;
|
String previous = null;
|
||||||
while ((Line = br.readLine()) != null) {
|
while ((Line = br.readLine()) != null) {
|
||||||
// ignore comments and blank line in the configuration file.
|
// ignore comments and blank line in the configuration file.
|
||||||
@ -589,7 +589,7 @@ public class Config {
|
|||||||
throw new KrbException("I/O error while reading" +
|
throw new KrbException("I/O error while reading" +
|
||||||
" configuration file.");
|
" configuration file.");
|
||||||
}
|
}
|
||||||
Hashtable<String,Object> table = new Hashtable<String,Object> ();
|
Hashtable<String,Object> table = new Hashtable<>();
|
||||||
for (int i = 0; i < v.size(); i++) {
|
for (int i = 0; i < v.size(); i++) {
|
||||||
String line = v.elementAt(i).trim();
|
String line = v.elementAt(i).trim();
|
||||||
if (line.equalsIgnoreCase("[realms]")) {
|
if (line.equalsIgnoreCase("[realms]")) {
|
||||||
@ -598,7 +598,7 @@ public class Config {
|
|||||||
if ((count == v.size()) ||
|
if ((count == v.size()) ||
|
||||||
(v.elementAt(count).startsWith("["))) {
|
(v.elementAt(count).startsWith("["))) {
|
||||||
Hashtable<String,Hashtable<String,Vector<String>>> temp =
|
Hashtable<String,Hashtable<String,Vector<String>>> temp =
|
||||||
new Hashtable<String,Hashtable<String,Vector<String>>>();
|
new Hashtable<>();
|
||||||
temp = parseRealmField(v, i + 1, count);
|
temp = parseRealmField(v, i + 1, count);
|
||||||
table.put("realms", temp);
|
table.put("realms", temp);
|
||||||
i = count - 1;
|
i = count - 1;
|
||||||
@ -611,7 +611,7 @@ public class Config {
|
|||||||
if ((count == v.size()) ||
|
if ((count == v.size()) ||
|
||||||
(v.elementAt(count).startsWith("["))) {
|
(v.elementAt(count).startsWith("["))) {
|
||||||
Hashtable<String,Hashtable<String,Vector<String>>> temp =
|
Hashtable<String,Hashtable<String,Vector<String>>> temp =
|
||||||
new Hashtable<String,Hashtable<String,Vector<String>>>();
|
new Hashtable<>();
|
||||||
temp = parseRealmField(v, i + 1, count);
|
temp = parseRealmField(v, i + 1, count);
|
||||||
table.put("capaths", temp);
|
table.put("capaths", temp);
|
||||||
i = count - 1;
|
i = count - 1;
|
||||||
@ -729,7 +729,7 @@ public class Config {
|
|||||||
* Parses key-value pairs under a stanza name.
|
* Parses key-value pairs under a stanza name.
|
||||||
*/
|
*/
|
||||||
private Hashtable<String,String> parseField(Vector<String> v, int start, int end) {
|
private Hashtable<String,String> parseField(Vector<String> v, int start, int end) {
|
||||||
Hashtable<String,String> table = new Hashtable<String,String> ();
|
Hashtable<String,String> table = new Hashtable<>();
|
||||||
String line;
|
String line;
|
||||||
for (int i = start; i < end; i++) {
|
for (int i = start; i < end; i++) {
|
||||||
line = v.elementAt(i);
|
line = v.elementAt(i);
|
||||||
@ -751,7 +751,7 @@ public class Config {
|
|||||||
* information for the realm given within a pair of braces.
|
* information for the realm given within a pair of braces.
|
||||||
*/
|
*/
|
||||||
private Hashtable<String,Hashtable<String,Vector<String>>> parseRealmField(Vector<String> v, int start, int end) {
|
private Hashtable<String,Hashtable<String,Vector<String>>> parseRealmField(Vector<String> v, int start, int end) {
|
||||||
Hashtable<String,Hashtable<String,Vector<String>>> table = new Hashtable<String,Hashtable<String,Vector<String>>> ();
|
Hashtable<String,Hashtable<String,Vector<String>>> table = new Hashtable<>();
|
||||||
String line;
|
String line;
|
||||||
for (int i = start; i < end; i++) {
|
for (int i = start; i < end; i++) {
|
||||||
line = v.elementAt(i).trim();
|
line = v.elementAt(i).trim();
|
||||||
@ -791,10 +791,9 @@ public class Config {
|
|||||||
* Parses key-value pairs within each braces under [realms].
|
* Parses key-value pairs within each braces under [realms].
|
||||||
*/
|
*/
|
||||||
private Hashtable<String,Vector<String>> parseRealmFieldEx(Vector<String> v, int start, int end) {
|
private Hashtable<String,Vector<String>> parseRealmFieldEx(Vector<String> v, int start, int end) {
|
||||||
Hashtable<String,Vector<String>> table =
|
Hashtable<String,Vector<String>> table = new Hashtable<>();
|
||||||
new Hashtable<String,Vector<String>> ();
|
Vector<String> keyVector = new Vector<>();
|
||||||
Vector<String> keyVector = new Vector<String> ();
|
Vector<String> nameVector = new Vector<>();
|
||||||
Vector<String> nameVector = new Vector<String> ();
|
|
||||||
String line = "";
|
String line = "";
|
||||||
String key;
|
String key;
|
||||||
for (int i = start; i < end; i++) {
|
for (int i = start; i < end; i++) {
|
||||||
@ -899,7 +898,7 @@ public class Config {
|
|||||||
}
|
}
|
||||||
st = new StringTokenizer(default_enctypes, delim);
|
st = new StringTokenizer(default_enctypes, delim);
|
||||||
int len = st.countTokens();
|
int len = st.countTokens();
|
||||||
ArrayList<Integer> ls = new ArrayList<Integer> (len);
|
ArrayList<Integer> ls = new ArrayList<>(len);
|
||||||
int type;
|
int type;
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
type = getType(st.nextToken());
|
type = getType(st.nextToken());
|
||||||
|
@ -462,7 +462,7 @@ public final class KdcComm {
|
|||||||
*/
|
*/
|
||||||
static class KdcAccessibility {
|
static class KdcAccessibility {
|
||||||
// Known bad KDCs
|
// Known bad KDCs
|
||||||
private static Set<String> bads = new HashSet<String>();
|
private static Set<String> bads = new HashSet<>();
|
||||||
|
|
||||||
private static synchronized void addBad(String kdc) {
|
private static synchronized void addBad(String kdc) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
@ -492,9 +492,9 @@ public final class KdcComm {
|
|||||||
// Returns a preferred KDC list by putting the bad ones at the end
|
// Returns a preferred KDC list by putting the bad ones at the end
|
||||||
private static synchronized String[] list(String kdcList) {
|
private static synchronized String[] list(String kdcList) {
|
||||||
StringTokenizer st = new StringTokenizer(kdcList);
|
StringTokenizer st = new StringTokenizer(kdcList);
|
||||||
List<String> list = new ArrayList<String>();
|
List<String> list = new ArrayList<>();
|
||||||
if (badPolicy == BpType.TRY_LAST) {
|
if (badPolicy == BpType.TRY_LAST) {
|
||||||
List<String> badkdcs = new ArrayList<String>();
|
List<String> badkdcs = new ArrayList<>();
|
||||||
while (st.hasMoreTokens()) {
|
while (st.hasMoreTokens()) {
|
||||||
String t = st.nextToken();
|
String t = st.nextToken();
|
||||||
if (bads.contains(t)) badkdcs.add(t);
|
if (bads.contains(t)) badkdcs.add(t);
|
||||||
|
@ -244,7 +244,7 @@ public class PrincipalName
|
|||||||
if (subDer.getTag() != DerValue.tag_SequenceOf) {
|
if (subDer.getTag() != DerValue.tag_SequenceOf) {
|
||||||
throw new Asn1Exception(Krb5.ASN1_BAD_ID);
|
throw new Asn1Exception(Krb5.ASN1_BAD_ID);
|
||||||
}
|
}
|
||||||
Vector<String> v = new Vector<String> ();
|
Vector<String> v = new Vector<>();
|
||||||
DerValue subSubDer;
|
DerValue subSubDer;
|
||||||
while(subDer.getData().available() > 0) {
|
while(subDer.getData().available() > 0) {
|
||||||
subSubDer = subDer.getData().getDerValue();
|
subSubDer = subDer.getData().getDerValue();
|
||||||
@ -299,7 +299,7 @@ public class PrincipalName
|
|||||||
// Code repetition, realm parsed again by class Realm
|
// Code repetition, realm parsed again by class Realm
|
||||||
protected static String[] parseName(String name) {
|
protected static String[] parseName(String name) {
|
||||||
|
|
||||||
Vector<String> tempStrings = new Vector<String> ();
|
Vector<String> tempStrings = new Vector<>();
|
||||||
String temp = name;
|
String temp = name;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int componentStart = 0;
|
int componentStart = 0;
|
||||||
|
@ -359,12 +359,12 @@ public class Realm implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String tempTarget = null, tempRealm = null;
|
String tempTarget = null, tempRealm = null;
|
||||||
Stack<String> iStack = new Stack<String> ();
|
Stack<String> iStack = new Stack<>();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* I don't expect any more than a handful of intermediaries.
|
* I don't expect any more than a handful of intermediaries.
|
||||||
*/
|
*/
|
||||||
Vector<String> tempList = new Vector<String> (8, 8);
|
Vector<String> tempList = new Vector<>(8, 8);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The initiator at first location.
|
* The initiator at first location.
|
||||||
|
@ -176,7 +176,7 @@ public class Authenticator {
|
|||||||
* @exception IOException if an I/O error occurs while reading encoded data.
|
* @exception IOException if an I/O error occurs while reading encoded data.
|
||||||
*/
|
*/
|
||||||
public byte[] asn1Encode() throws Asn1Exception, IOException {
|
public byte[] asn1Encode() throws Asn1Exception, IOException {
|
||||||
Vector<DerValue> v = new Vector<DerValue>();
|
Vector<DerValue> v = new Vector<>();
|
||||||
DerOutputStream temp = new DerOutputStream();
|
DerOutputStream temp = new DerOutputStream();
|
||||||
temp.putInteger(BigInteger.valueOf(authenticator_vno));
|
temp.putInteger(BigInteger.valueOf(authenticator_vno));
|
||||||
v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x00), temp.toByteArray()));
|
v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x00), temp.toByteArray()));
|
||||||
|
@ -99,8 +99,7 @@ public class AuthorizationData implements Cloneable {
|
|||||||
* @exception IOException if an I/O error occurs while reading encoded data.
|
* @exception IOException if an I/O error occurs while reading encoded data.
|
||||||
*/
|
*/
|
||||||
public AuthorizationData(DerValue der) throws Asn1Exception, IOException {
|
public AuthorizationData(DerValue der) throws Asn1Exception, IOException {
|
||||||
Vector<AuthorizationDataEntry> v =
|
Vector<AuthorizationDataEntry> v = new Vector<>();
|
||||||
new Vector<AuthorizationDataEntry>();
|
|
||||||
if (der.getTag() != DerValue.tag_Sequence) {
|
if (der.getTag() != DerValue.tag_Sequence) {
|
||||||
throw new Asn1Exception(Krb5.ASN1_BAD_ID);
|
throw new Asn1Exception(Krb5.ASN1_BAD_ID);
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ public class EncAPRepPart {
|
|||||||
* @exception IOException if an I/O error occurs while reading encoded data.
|
* @exception IOException if an I/O error occurs while reading encoded data.
|
||||||
*/
|
*/
|
||||||
public byte[] asn1Encode() throws Asn1Exception, IOException {
|
public byte[] asn1Encode() throws Asn1Exception, IOException {
|
||||||
Vector<DerValue> v = new Vector<DerValue>();
|
Vector<DerValue> v = new Vector<>();
|
||||||
DerOutputStream temp = new DerOutputStream();
|
DerOutputStream temp = new DerOutputStream();
|
||||||
v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT,
|
v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT,
|
||||||
true, (byte) 0x00), ctime.asn1Encode()));
|
true, (byte) 0x00), ctime.asn1Encode()));
|
||||||
|
@ -179,7 +179,7 @@ public class HostAddresses implements Cloneable {
|
|||||||
*/
|
*/
|
||||||
public HostAddresses(DerValue encoding)
|
public HostAddresses(DerValue encoding)
|
||||||
throws Asn1Exception, IOException {
|
throws Asn1Exception, IOException {
|
||||||
Vector<HostAddress> tempAddresses = new Vector<HostAddress> ();
|
Vector<HostAddress> tempAddresses = new Vector<>();
|
||||||
DerValue der = null;
|
DerValue der = null;
|
||||||
while (encoding.getData().available() > 0) {
|
while (encoding.getData().available() > 0) {
|
||||||
der = encoding.getData().getDerValue();
|
der = encoding.getData().getDerValue();
|
||||||
@ -265,8 +265,7 @@ public class HostAddresses implements Cloneable {
|
|||||||
if (addresses == null || addresses.length == 0)
|
if (addresses == null || addresses.length == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
ArrayList<InetAddress> ipAddrs =
|
ArrayList<InetAddress> ipAddrs = new ArrayList<>(addresses.length);
|
||||||
new ArrayList<InetAddress> (addresses.length);
|
|
||||||
|
|
||||||
for (int i = 0; i < addresses.length; i++) {
|
for (int i = 0; i < addresses.length; i++) {
|
||||||
try {
|
try {
|
||||||
|
@ -150,7 +150,7 @@ public class KDCReq {
|
|||||||
if (subsubDer.getTag() != DerValue.tag_SequenceOf) {
|
if (subsubDer.getTag() != DerValue.tag_SequenceOf) {
|
||||||
throw new Asn1Exception(Krb5.ASN1_BAD_ID);
|
throw new Asn1Exception(Krb5.ASN1_BAD_ID);
|
||||||
}
|
}
|
||||||
Vector<PAData> v = new Vector<PAData>();
|
Vector<PAData> v = new Vector<>();
|
||||||
while (subsubDer.getData().available() > 0) {
|
while (subsubDer.getData().available() > 0) {
|
||||||
v.addElement(new PAData(subsubDer.getData().getDerValue()));
|
v.addElement(new PAData(subsubDer.getData().getDerValue()));
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ public class KDCReqBody {
|
|||||||
throw new Asn1Exception(Krb5.ASN1_BAD_ID);
|
throw new Asn1Exception(Krb5.ASN1_BAD_ID);
|
||||||
}
|
}
|
||||||
der = encoding.getData().getDerValue();
|
der = encoding.getData().getDerValue();
|
||||||
Vector<Integer> v = new Vector<Integer> ();
|
Vector<Integer> v = new Vector<>();
|
||||||
if ((der.getTag() & (byte)0x1F) == (byte)0x08) {
|
if ((der.getTag() & (byte)0x1F) == (byte)0x08) {
|
||||||
subDer = der.getData().getDerValue();
|
subDer = der.getData().getDerValue();
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ public class KDCReqBody {
|
|||||||
encAuthorizationData = EncryptedData.parse(encoding.getData(), (byte)0x0A, true);
|
encAuthorizationData = EncryptedData.parse(encoding.getData(), (byte)0x0A, true);
|
||||||
}
|
}
|
||||||
if (encoding.getData().available() > 0) {
|
if (encoding.getData().available() > 0) {
|
||||||
Vector<Ticket> tempTickets = new Vector<Ticket> ();
|
Vector<Ticket> tempTickets = new Vector<>();
|
||||||
der = encoding.getData().getDerValue();
|
der = encoding.getData().getDerValue();
|
||||||
if ((der.getTag() & (byte)0x1F) == (byte)0x0B) {
|
if ((der.getTag() & (byte)0x1F) == (byte)0x0B) {
|
||||||
subDer = der.getData().getDerValue();
|
subDer = der.getData().getDerValue();
|
||||||
@ -216,7 +216,7 @@ public class KDCReqBody {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public byte[] asn1Encode(int msgType) throws Asn1Exception, IOException {
|
public byte[] asn1Encode(int msgType) throws Asn1Exception, IOException {
|
||||||
Vector<DerValue> v = new Vector<DerValue> ();
|
Vector<DerValue> v = new Vector<>();
|
||||||
v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), kdcOptions.asn1Encode()));
|
v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), kdcOptions.asn1Encode()));
|
||||||
if (msgType == Krb5.KRB_AS_REQ) {
|
if (msgType == Krb5.KRB_AS_REQ) {
|
||||||
if (cname != null) {
|
if (cname != null) {
|
||||||
|
@ -134,7 +134,7 @@ public class KRBCred {
|
|||||||
if (subsubDer.getTag() != DerValue.tag_SequenceOf) {
|
if (subsubDer.getTag() != DerValue.tag_SequenceOf) {
|
||||||
throw new Asn1Exception(Krb5.ASN1_BAD_ID);
|
throw new Asn1Exception(Krb5.ASN1_BAD_ID);
|
||||||
}
|
}
|
||||||
Vector<Ticket> v = new Vector<Ticket>();
|
Vector<Ticket> v = new Vector<>();
|
||||||
while (subsubDer.getData().available() > 0) {
|
while (subsubDer.getData().available() > 0) {
|
||||||
v.addElement(new Ticket(subsubDer.getData().getDerValue()));
|
v.addElement(new Ticket(subsubDer.getData().getDerValue()));
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ public class KRBError implements java.io.Serializable {
|
|||||||
private void parsePAData(byte[] data)
|
private void parsePAData(byte[] data)
|
||||||
throws IOException, Asn1Exception {
|
throws IOException, Asn1Exception {
|
||||||
DerValue derPA = new DerValue(data);
|
DerValue derPA = new DerValue(data);
|
||||||
List<PAData> paList = new ArrayList<PAData>();
|
List<PAData> paList = new ArrayList<>();
|
||||||
while (derPA.data.available() > 0) {
|
while (derPA.data.available() > 0) {
|
||||||
// read the PA-DATA
|
// read the PA-DATA
|
||||||
DerValue tmp = derPA.data.getDerValue();
|
DerValue tmp = derPA.data.getDerValue();
|
||||||
|
@ -157,7 +157,7 @@ public class KrbCredInfo {
|
|||||||
* @exception IOException if an I/O error occurs while reading encoded data.
|
* @exception IOException if an I/O error occurs while reading encoded data.
|
||||||
*/
|
*/
|
||||||
public byte[] asn1Encode() throws Asn1Exception, IOException {
|
public byte[] asn1Encode() throws Asn1Exception, IOException {
|
||||||
Vector<DerValue> v = new Vector<DerValue> ();
|
Vector<DerValue> v = new Vector<>();
|
||||||
v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), key.asn1Encode()));
|
v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), key.asn1Encode()));
|
||||||
if (prealm != null)
|
if (prealm != null)
|
||||||
v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), prealm.asn1Encode()));
|
v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), prealm.asn1Encode()));
|
||||||
|
@ -77,7 +77,7 @@ public class LastReq {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public LastReq(DerValue encoding) throws Asn1Exception, IOException {
|
public LastReq(DerValue encoding) throws Asn1Exception, IOException {
|
||||||
Vector<LastReqEntry> v= new Vector<LastReqEntry> ();
|
Vector<LastReqEntry> v= new Vector<>();
|
||||||
if (encoding.getTag() != DerValue.tag_Sequence) {
|
if (encoding.getTag() != DerValue.tag_Sequence) {
|
||||||
throw new Asn1Exception(Krb5.ASN1_BAD_ID);
|
throw new Asn1Exception(Krb5.ASN1_BAD_ID);
|
||||||
}
|
}
|
||||||
|
@ -490,7 +490,7 @@ public class FileCredentialsCache extends CredentialsCache
|
|||||||
|
|
||||||
private static String exec(String c) {
|
private static String exec(String c) {
|
||||||
StringTokenizer st = new StringTokenizer(c);
|
StringTokenizer st = new StringTokenizer(c);
|
||||||
Vector<String> v = new Vector<String> ();
|
Vector<String> v = new Vector<>();
|
||||||
while (st.hasMoreTokens()) {
|
while (st.hasMoreTokens()) {
|
||||||
v.addElement(st.nextToken());
|
v.addElement(st.nextToken());
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ public abstract class EType {
|
|||||||
+ configName);
|
+ configName);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Integer> list = new ArrayList<Integer> (answer.length);
|
List<Integer> list = new ArrayList<>(answer.length);
|
||||||
for (int i = 0; i < answer.length; i++) {
|
for (int i = 0; i < answer.length; i++) {
|
||||||
if (EncryptionKey.findKey(answer[i], keys) != null) {
|
if (EncryptionKey.findKey(answer[i], keys) != null) {
|
||||||
list.add(answer[i]);
|
list.add(answer[i]);
|
||||||
|
@ -57,7 +57,7 @@ public class KeyTab implements KeyTabConstants {
|
|||||||
private static KeyTab singleton = null;
|
private static KeyTab singleton = null;
|
||||||
private static final boolean DEBUG = Krb5.DEBUG;
|
private static final boolean DEBUG = Krb5.DEBUG;
|
||||||
private static String name;
|
private static String name;
|
||||||
private Vector<KeyTabEntry> entries = new Vector<KeyTabEntry> ();
|
private Vector<KeyTabEntry> entries = new Vector<>();
|
||||||
|
|
||||||
private KeyTab(String filename) throws IOException, RealmException {
|
private KeyTab(String filename) throws IOException, RealmException {
|
||||||
init(filename);
|
init(filename);
|
||||||
@ -240,7 +240,7 @@ public class KeyTab implements KeyTabConstants {
|
|||||||
KeyTabEntry entry;
|
KeyTabEntry entry;
|
||||||
EncryptionKey key;
|
EncryptionKey key;
|
||||||
int size = entries.size();
|
int size = entries.size();
|
||||||
ArrayList<EncryptionKey> keys = new ArrayList<EncryptionKey> (size);
|
ArrayList<EncryptionKey> keys = new ArrayList<>(size);
|
||||||
|
|
||||||
for (int i = size-1; i >= 0; i--) {
|
for (int i = size-1; i >= 0; i--) {
|
||||||
entry = entries.elementAt(i);
|
entry = entries.elementAt(i);
|
||||||
|
@ -123,19 +123,19 @@ public class JarSigner {
|
|||||||
// or the default keystore, never null
|
// or the default keystore, never null
|
||||||
|
|
||||||
String keystore; // key store file
|
String keystore; // key store file
|
||||||
List<String> crlfiles = new ArrayList<String>(); // CRL files to add
|
List<String> crlfiles = new ArrayList<>(); // CRL files to add
|
||||||
boolean nullStream = false; // null keystore input stream (NONE)
|
boolean nullStream = false; // null keystore input stream (NONE)
|
||||||
boolean token = false; // token-based keystore
|
boolean token = false; // token-based keystore
|
||||||
String jarfile; // jar files to sign or verify
|
String jarfile; // jar files to sign or verify
|
||||||
String alias; // alias to sign jar with
|
String alias; // alias to sign jar with
|
||||||
List<String> ckaliases = new ArrayList<String>(); // aliases in -verify
|
List<String> ckaliases = new ArrayList<>(); // aliases in -verify
|
||||||
char[] storepass; // keystore password
|
char[] storepass; // keystore password
|
||||||
boolean protectedPath; // protected authentication path
|
boolean protectedPath; // protected authentication path
|
||||||
String storetype; // keystore type
|
String storetype; // keystore type
|
||||||
String providerName; // provider name
|
String providerName; // provider name
|
||||||
Vector<String> providers = null; // list of providers
|
Vector<String> providers = null; // list of providers
|
||||||
// arguments for provider constructors
|
// arguments for provider constructors
|
||||||
HashMap<String,String> providerArgs = new HashMap<String, String>();
|
HashMap<String,String> providerArgs = new HashMap<>();
|
||||||
char[] keypass; // private key password
|
char[] keypass; // private key password
|
||||||
String sigfile; // name of .SF file
|
String sigfile; // name of .SF file
|
||||||
String sigalg; // name of signature algorithm
|
String sigalg; // name of signature algorithm
|
||||||
@ -236,7 +236,7 @@ public class JarSigner {
|
|||||||
if (crlfiles.size() > 0 || autoCRL) {
|
if (crlfiles.size() > 0 || autoCRL) {
|
||||||
CertificateFactory fac =
|
CertificateFactory fac =
|
||||||
CertificateFactory.getInstance("X509");
|
CertificateFactory.getInstance("X509");
|
||||||
List<CRL> list = new ArrayList<CRL>();
|
List<CRL> list = new ArrayList<>();
|
||||||
for (String file: crlfiles) {
|
for (String file: crlfiles) {
|
||||||
Collection<? extends CRL> tmp = KeyTool.loadCRLs(file);
|
Collection<? extends CRL> tmp = KeyTool.loadCRLs(file);
|
||||||
for (CRL crl: tmp) {
|
for (CRL crl: tmp) {
|
||||||
@ -606,7 +606,7 @@ public class JarSigner {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
jf = new JarFile(jarName, true);
|
jf = new JarFile(jarName, true);
|
||||||
Vector<JarEntry> entriesVec = new Vector<JarEntry>();
|
Vector<JarEntry> entriesVec = new Vector<>();
|
||||||
byte[] buffer = new byte[8192];
|
byte[] buffer = new byte[8192];
|
||||||
|
|
||||||
Enumeration<JarEntry> entries = jf.entries();
|
Enumeration<JarEntry> entries = jf.entries();
|
||||||
@ -633,8 +633,7 @@ public class JarSigner {
|
|||||||
// The map to record display info, only used when -verbose provided
|
// The map to record display info, only used when -verbose provided
|
||||||
// key: signer info string
|
// key: signer info string
|
||||||
// value: the list of files with common key
|
// value: the list of files with common key
|
||||||
Map<String,List<String>> output =
|
Map<String,List<String>> output = new LinkedHashMap<>();
|
||||||
new LinkedHashMap<String,List<String>>();
|
|
||||||
|
|
||||||
if (man != null) {
|
if (man != null) {
|
||||||
if (verbose != null) System.out.println();
|
if (verbose != null) System.out.println();
|
||||||
@ -1000,8 +999,7 @@ public class JarSigner {
|
|||||||
.append(signTimeForm.format(source)).append("]").toString();
|
.append(signTimeForm.format(source)).append("]").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<CodeSigner,Integer> cacheForInKS =
|
private Map<CodeSigner,Integer> cacheForInKS = new IdentityHashMap<>();
|
||||||
new IdentityHashMap<CodeSigner,Integer>();
|
|
||||||
|
|
||||||
private int inKeyStoreForOneSigner(CodeSigner signer) {
|
private int inKeyStoreForOneSigner(CodeSigner signer) {
|
||||||
if (cacheForInKS.containsKey(signer)) {
|
if (cacheForInKS.containsKey(signer)) {
|
||||||
@ -1044,8 +1042,7 @@ public class JarSigner {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Hashtable<Certificate, String> storeHash =
|
Hashtable<Certificate, String> storeHash = new Hashtable<>();
|
||||||
new Hashtable<Certificate, String>();
|
|
||||||
|
|
||||||
int inKeyStore(CodeSigner[] signers) {
|
int inKeyStore(CodeSigner[] signers) {
|
||||||
|
|
||||||
@ -1175,7 +1172,7 @@ public class JarSigner {
|
|||||||
* generated one. (This may invalidate existing signatures!)
|
* generated one. (This may invalidate existing signatures!)
|
||||||
*/
|
*/
|
||||||
BASE64Encoder encoder = new JarBASE64Encoder();
|
BASE64Encoder encoder = new JarBASE64Encoder();
|
||||||
Vector<ZipEntry> mfFiles = new Vector<ZipEntry>();
|
Vector<ZipEntry> mfFiles = new Vector<>();
|
||||||
|
|
||||||
boolean wasSigned = false;
|
boolean wasSigned = false;
|
||||||
|
|
||||||
@ -1531,7 +1528,7 @@ public class JarSigner {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<CodeSigner,String> cacheForSignerInfo = new IdentityHashMap<CodeSigner,String>();
|
Map<CodeSigner,String> cacheForSignerInfo = new IdentityHashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a string of singer info, with a newline at the end
|
* Returns a string of singer info, with a newline at the end
|
||||||
@ -1655,7 +1652,7 @@ public class JarSigner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Set<TrustAnchor> tas = new HashSet<TrustAnchor>();
|
Set<TrustAnchor> tas = new HashSet<>();
|
||||||
try {
|
try {
|
||||||
KeyStore caks = KeyTool.getCacertsKeyStore();
|
KeyStore caks = KeyTool.getCacertsKeyStore();
|
||||||
if (caks != null) {
|
if (caks != null) {
|
||||||
|
@ -153,11 +153,11 @@ public final class KeyTool {
|
|||||||
private KeyStore caks = null; // "cacerts" keystore
|
private KeyStore caks = null; // "cacerts" keystore
|
||||||
private char[] srcstorePass = null;
|
private char[] srcstorePass = null;
|
||||||
private String srcstoretype = null;
|
private String srcstoretype = null;
|
||||||
private Set<char[]> passwords = new HashSet<char[]> ();
|
private Set<char[]> passwords = new HashSet<>();
|
||||||
private String startDate = null;
|
private String startDate = null;
|
||||||
|
|
||||||
private List <String> ids = new ArrayList <String> (); // used in GENCRL
|
private List<String> ids = new ArrayList<>(); // used in GENCRL
|
||||||
private List <String> v3ext = new ArrayList <String> ();
|
private List<String> v3ext = new ArrayList<>();
|
||||||
|
|
||||||
enum Command {
|
enum Command {
|
||||||
CERTREQ("Generates.a.certificate.request",
|
CERTREQ("Generates.a.certificate.request",
|
||||||
@ -2091,7 +2091,7 @@ public final class KeyTool {
|
|||||||
*/
|
*/
|
||||||
public static List<CRL> readCRLsFromCert(X509Certificate cert)
|
public static List<CRL> readCRLsFromCert(X509Certificate cert)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
List<CRL> crls = new ArrayList<CRL>();
|
List<CRL> crls = new ArrayList<>();
|
||||||
CRLDistributionPointsExtension ext =
|
CRLDistributionPointsExtension ext =
|
||||||
X509CertImpl.toImpl(cert).getCRLDistributionPointsExtension();
|
X509CertImpl.toImpl(cert).getCRLDistributionPointsExtension();
|
||||||
if (ext == null) return crls;
|
if (ext == null) return crls;
|
||||||
@ -2258,7 +2258,7 @@ public final class KeyTool {
|
|||||||
if (jarfile != null) {
|
if (jarfile != null) {
|
||||||
JarFile jf = new JarFile(jarfile, true);
|
JarFile jf = new JarFile(jarfile, true);
|
||||||
Enumeration<JarEntry> entries = jf.entries();
|
Enumeration<JarEntry> entries = jf.entries();
|
||||||
Set<CodeSigner> ss = new HashSet<CodeSigner>();
|
Set<CodeSigner> ss = new HashSet<>();
|
||||||
byte[] buffer = new byte[8192];
|
byte[] buffer = new byte[8192];
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
while (entries.hasMoreElements()) {
|
while (entries.hasMoreElements()) {
|
||||||
@ -3347,7 +3347,7 @@ public final class KeyTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// start building chain
|
// start building chain
|
||||||
Vector<Certificate> chain = new Vector<Certificate>(2);
|
Vector<Certificate> chain = new Vector<>(2);
|
||||||
if (buildChain((X509Certificate)certToVerify, chain, certs)) {
|
if (buildChain((X509Certificate)certToVerify, chain, certs)) {
|
||||||
Certificate[] newChain = new Certificate[chain.size()];
|
Certificate[] newChain = new Certificate[chain.size()];
|
||||||
// buildChain() returns chain with self-signed root-cert first and
|
// buildChain() returns chain with self-signed root-cert first and
|
||||||
@ -3873,8 +3873,7 @@ public final class KeyTool {
|
|||||||
break;
|
break;
|
||||||
case 2: // EKU
|
case 2: // EKU
|
||||||
if(value != null) {
|
if(value != null) {
|
||||||
Vector <ObjectIdentifier> v =
|
Vector<ObjectIdentifier> v = new Vector<>();
|
||||||
new Vector <ObjectIdentifier>();
|
|
||||||
for (String s: value.split(",")) {
|
for (String s: value.split(",")) {
|
||||||
int p = oneOf(s,
|
int p = oneOf(s,
|
||||||
"anyExtendedKeyUsage",
|
"anyExtendedKeyUsage",
|
||||||
@ -3944,7 +3943,7 @@ public final class KeyTool {
|
|||||||
}
|
}
|
||||||
if(value != null) {
|
if(value != null) {
|
||||||
List<AccessDescription> accessDescriptions =
|
List<AccessDescription> accessDescriptions =
|
||||||
new ArrayList<AccessDescription>();
|
new ArrayList<>();
|
||||||
String[] ps = value.split(",");
|
String[] ps = value.split(",");
|
||||||
for(String item: ps) {
|
for(String item: ps) {
|
||||||
colonpos = item.indexOf(':');
|
colonpos = item.indexOf(':');
|
||||||
@ -4228,7 +4227,7 @@ class Pair<A, B> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static <A,B> Pair<A,B> of(A a, B b) {
|
public static <A,B> Pair<A,B> of(A a, B b) {
|
||||||
return new Pair<A,B>(a,b);
|
return new Pair<>(a,b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -643,7 +643,7 @@ public class PolicyTool {
|
|||||||
Class<?> pc = Class.forName(type, true,
|
Class<?> pc = Class.forName(type, true,
|
||||||
Thread.currentThread().getContextClassLoader());
|
Thread.currentThread().getContextClassLoader());
|
||||||
Constructor<?> c = null;
|
Constructor<?> c = null;
|
||||||
Vector<String> objects = new Vector<String>(2);
|
Vector<String> objects = new Vector<>(2);
|
||||||
if (name != null) objects.add(name);
|
if (name != null) objects.add(name);
|
||||||
if (actions != null) objects.add(actions);
|
if (actions != null) objects.add(actions);
|
||||||
switch (objects.size()) {
|
switch (objects.size()) {
|
||||||
@ -1722,8 +1722,7 @@ class ToolDialog extends Dialog {
|
|||||||
new PolicyParser.GrantEntry(signedby, codebase);
|
new PolicyParser.GrantEntry(signedby, codebase);
|
||||||
|
|
||||||
// get the new Principals
|
// get the new Principals
|
||||||
LinkedList<PolicyParser.PrincipalEntry> prins =
|
LinkedList<PolicyParser.PrincipalEntry> prins = new LinkedList<>();
|
||||||
new LinkedList<PolicyParser.PrincipalEntry>();
|
|
||||||
TaggedList prinList = (TaggedList)getComponent(PE_PRIN_LIST);
|
TaggedList prinList = (TaggedList)getComponent(PE_PRIN_LIST);
|
||||||
for (int i = 0; i < prinList.getItemCount(); i++) {
|
for (int i = 0; i < prinList.getItemCount(); i++) {
|
||||||
prins.add((PolicyParser.PrincipalEntry)prinList.getObject(i));
|
prins.add((PolicyParser.PrincipalEntry)prinList.getObject(i));
|
||||||
@ -1731,8 +1730,7 @@ class ToolDialog extends Dialog {
|
|||||||
ge.principals = prins;
|
ge.principals = prins;
|
||||||
|
|
||||||
// get the new Permissions
|
// get the new Permissions
|
||||||
Vector<PolicyParser.PermissionEntry> perms =
|
Vector<PolicyParser.PermissionEntry> perms = new Vector<>();
|
||||||
new Vector<PolicyParser.PermissionEntry>();
|
|
||||||
TaggedList permList = (TaggedList)getComponent(PE_PERM_LIST);
|
TaggedList permList = (TaggedList)getComponent(PE_PERM_LIST);
|
||||||
for (int i = 0; i < permList.getItemCount(); i++) {
|
for (int i = 0; i < permList.getItemCount(); i++) {
|
||||||
perms.addElement((PolicyParser.PermissionEntry)permList.getObject(i));
|
perms.addElement((PolicyParser.PermissionEntry)permList.getObject(i));
|
||||||
@ -3649,7 +3647,7 @@ class NoDisplayException extends RuntimeException {
|
|||||||
* This is a java.awt.List that bind an Object to each String it holds.
|
* This is a java.awt.List that bind an Object to each String it holds.
|
||||||
*/
|
*/
|
||||||
class TaggedList extends List {
|
class TaggedList extends List {
|
||||||
private java.util.List<Object> data = new LinkedList<Object>();
|
private java.util.List<Object> data = new LinkedList<>();
|
||||||
public TaggedList(int i, boolean b) {
|
public TaggedList(int i, boolean b) {
|
||||||
super(i, b);
|
super(i, b);
|
||||||
}
|
}
|
||||||
|
@ -78,8 +78,8 @@ public class IPv6 {
|
|||||||
try {
|
try {
|
||||||
Subject subject = new Subject();
|
Subject subject = new Subject();
|
||||||
Krb5LoginModule krb5 = new Krb5LoginModule();
|
Krb5LoginModule krb5 = new Krb5LoginModule();
|
||||||
Map<String, String> map = new HashMap<String, String>();
|
Map<String, String> map = new HashMap<>();
|
||||||
Map<String, Object> shared = new HashMap<String, Object>();
|
Map<String, Object> shared = new HashMap<>();
|
||||||
|
|
||||||
map.put("debug", "true");
|
map.put("debug", "true");
|
||||||
map.put("doNotPrompt", "true");
|
map.put("doNotPrompt", "true");
|
||||||
|
@ -49,11 +49,11 @@ public class CleanState {
|
|||||||
final char[] password = OneKDC.PASS;
|
final char[] password = OneKDC.PASS;
|
||||||
char[] badpassword = "hellokitty".toCharArray();
|
char[] badpassword = "hellokitty".toCharArray();
|
||||||
|
|
||||||
Map<String,String> map = new HashMap<String,String>();
|
Map<String,String> map = new HashMap<>();
|
||||||
map.put("useTicketCache", "false");
|
map.put("useTicketCache", "false");
|
||||||
map.put("doNotPrompt", "false");
|
map.put("doNotPrompt", "false");
|
||||||
map.put("tryFirstPass", "true");
|
map.put("tryFirstPass", "true");
|
||||||
Map<String,Object> shared = new HashMap<String,Object>();
|
Map<String,Object> shared = new HashMap<>();
|
||||||
shared.put("javax.security.auth.login.name", name);
|
shared.put("javax.security.auth.login.name", name);
|
||||||
shared.put("javax.security.auth.login.password", badpassword);
|
shared.put("javax.security.auth.login.password", badpassword);
|
||||||
|
|
||||||
|
@ -117,8 +117,8 @@ public class Context {
|
|||||||
out.name = user;
|
out.name = user;
|
||||||
out.s = new Subject();
|
out.s = new Subject();
|
||||||
Krb5LoginModule krb5 = new Krb5LoginModule();
|
Krb5LoginModule krb5 = new Krb5LoginModule();
|
||||||
Map<String, String> map = new HashMap<String, String>();
|
Map<String, String> map = new HashMap<>();
|
||||||
Map<String, Object> shared = new HashMap<String, Object>();
|
Map<String, Object> shared = new HashMap<>();
|
||||||
|
|
||||||
if (pass != null) {
|
if (pass != null) {
|
||||||
map.put("useFirstPass", "true");
|
map.put("useFirstPass", "true");
|
||||||
@ -151,7 +151,7 @@ public class Context {
|
|||||||
out.name = user;
|
out.name = user;
|
||||||
out.s = new Subject();
|
out.s = new Subject();
|
||||||
Krb5LoginModule krb5 = new Krb5LoginModule();
|
Krb5LoginModule krb5 = new Krb5LoginModule();
|
||||||
Map<String, String> map = new HashMap<String, String>();
|
Map<String, String> map = new HashMap<>();
|
||||||
|
|
||||||
map.put("doNotPrompt", "true");
|
map.put("doNotPrompt", "true");
|
||||||
map.put("useTicketCache", "false");
|
map.put("useTicketCache", "false");
|
||||||
|
@ -297,8 +297,8 @@ public class HttpNegotiateServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Krb5LoginModule krb5 = new Krb5LoginModule();
|
Krb5LoginModule krb5 = new Krb5LoginModule();
|
||||||
Map<String, String> map = new HashMap<String, String>();
|
Map<String, String> map = new HashMap<>();
|
||||||
Map<String, Object> shared = new HashMap<String, Object>();
|
Map<String, Object> shared = new HashMap<>();
|
||||||
|
|
||||||
map.put("storeKey", "true");
|
map.put("storeKey", "true");
|
||||||
map.put("isInitiator", "false");
|
map.put("isInitiator", "false");
|
||||||
|
@ -132,7 +132,7 @@ public class KDC {
|
|||||||
// Principal db. principal -> pass. A case-insensitive TreeMap is used
|
// Principal db. principal -> pass. A case-insensitive TreeMap is used
|
||||||
// so that even if the client provides a name with different case, the KDC
|
// so that even if the client provides a name with different case, the KDC
|
||||||
// can still locate the principal and give back correct salt.
|
// can still locate the principal and give back correct salt.
|
||||||
private TreeMap<String,char[]> passwords = new TreeMap<String,char[]>
|
private TreeMap<String,char[]> passwords = new TreeMap<>
|
||||||
(String.CASE_INSENSITIVE_ORDER);
|
(String.CASE_INSENSITIVE_ORDER);
|
||||||
|
|
||||||
// Realm name
|
// Realm name
|
||||||
@ -142,9 +142,9 @@ public class KDC {
|
|||||||
// Service port number
|
// Service port number
|
||||||
private int port;
|
private int port;
|
||||||
// The request/response job queue
|
// The request/response job queue
|
||||||
private BlockingQueue<Job> q = new ArrayBlockingQueue<Job>(100);
|
private BlockingQueue<Job> q = new ArrayBlockingQueue<>(100);
|
||||||
// Options
|
// Options
|
||||||
private Map<Option,Object> options = new HashMap<Option,Object>();
|
private Map<Option,Object> options = new HashMap<>();
|
||||||
|
|
||||||
private Thread thread1, thread2, thread3;
|
private Thread thread1, thread2, thread3;
|
||||||
DatagramSocket u1 = null;
|
DatagramSocket u1 = null;
|
||||||
@ -537,7 +537,7 @@ public class KDC {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String,String> policies = new HashMap<String,String>();
|
private Map<String,String> policies = new HashMap<>();
|
||||||
|
|
||||||
public void setPolicy(String rule, String value) {
|
public void setPolicy(String rule, String value) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
@ -760,7 +760,7 @@ public class KDC {
|
|||||||
private byte[] processAsReq(byte[] in) throws Exception {
|
private byte[] processAsReq(byte[] in) throws Exception {
|
||||||
ASReq asReq = new ASReq(in);
|
ASReq asReq = new ASReq(in);
|
||||||
int[] eTypes = null;
|
int[] eTypes = null;
|
||||||
List<PAData> outPAs = new ArrayList<PAData>();
|
List<PAData> outPAs = new ArrayList<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
System.out.println(realm + "> " + asReq.reqBody.cname +
|
System.out.println(realm + "> " + asReq.reqBody.cname +
|
||||||
|
@ -135,8 +135,8 @@ public class LoginModuleOptions {
|
|||||||
throws Exception {
|
throws Exception {
|
||||||
Krb5LoginModule krb5 = new Krb5LoginModule();
|
Krb5LoginModule krb5 = new Krb5LoginModule();
|
||||||
Subject subject = new Subject();
|
Subject subject = new Subject();
|
||||||
Map<String, String> map = new HashMap<String, String>();
|
Map<String, String> map = new HashMap<>();
|
||||||
Map<String, Object> shared = new HashMap<String, Object>();
|
Map<String, Object> shared = new HashMap<>();
|
||||||
|
|
||||||
int count = options.length / 2;
|
int count = options.length / 2;
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
|
@ -39,7 +39,7 @@ public class KtabCheck {
|
|||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
System.out.println("Checking " + Arrays.toString(args));
|
System.out.println("Checking " + Arrays.toString(args));
|
||||||
KeyTab ktab = KeyTab.getInstance(args[0]);
|
KeyTab ktab = KeyTab.getInstance(args[0]);
|
||||||
Set<String> expected = new HashSet<String>();
|
Set<String> expected = new HashSet<>();
|
||||||
for (int i=1; i<args.length; i += 2) {
|
for (int i=1; i<args.length; i += 2) {
|
||||||
expected.add(args[i]+":"+args[i+1]);
|
expected.add(args[i]+":"+args[i+1]);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user