summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/security/AccessControlContext.java8
-rw-r--r--java/security/AllPermission.java11
-rw-r--r--java/security/BasicPermission.java16
-rw-r--r--java/security/CodeSource.java17
-rw-r--r--java/security/DummySignature.java11
-rw-r--r--java/security/Identity.java8
-rw-r--r--java/security/IntersectingDomainCombiner.java7
-rw-r--r--java/security/KeyPairGenerator.java4
-rw-r--r--java/security/Permissions.java53
-rw-r--r--java/security/Policy.java17
-rw-r--r--java/security/SecureRandom.java12
-rw-r--r--java/security/Security.java97
-rw-r--r--java/security/SignatureSpi.java3
-rw-r--r--java/security/UnresolvedPermission.java46
-rw-r--r--java/security/cert/CertPath.java4
-rw-r--r--java/security/cert/CertPathValidator.java18
-rw-r--r--java/security/cert/CertStore.java16
-rw-r--r--java/security/cert/CollectionCertStoreParameters.java7
-rw-r--r--java/security/cert/PKIXParameters.java38
-rw-r--r--java/security/cert/X509CRLSelector.java23
-rw-r--r--java/security/cert/X509CertSelector.java22
-rw-r--r--java/util/Properties.java44
22 files changed, 266 insertions, 216 deletions
diff --git a/java/security/AccessControlContext.java b/java/security/AccessControlContext.java
index fd964751c..726a6f6e6 100644
--- a/java/security/AccessControlContext.java
+++ b/java/security/AccessControlContext.java
@@ -1,5 +1,5 @@
/* AccessControlContext.java --- Access Control Context Class
- Copyright (C) 1999, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2004, 2014 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -67,11 +67,11 @@ public final class AccessControlContext
*/
public AccessControlContext(ProtectionDomain[] context)
{
- HashSet domains = new HashSet (context.length);
+ HashSet<ProtectionDomain> domains =
+ new HashSet<ProtectionDomain>(context.length);
for (int i = 0; i < context.length; i++)
domains.add (context[i]);
- protectionDomains = (ProtectionDomain[])
- domains.toArray (new ProtectionDomain[domains.size()]);
+ protectionDomains = domains.toArray (new ProtectionDomain[domains.size()]);
combiner = null;
}
diff --git a/java/security/AllPermission.java b/java/security/AllPermission.java
index 6adcd8c9c..0a0a5f2ce 100644
--- a/java/security/AllPermission.java
+++ b/java/security/AllPermission.java
@@ -1,5 +1,5 @@
/* AllPermission.java -- Permission to do anything
- Copyright (C) 1998, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2001, 2002, 2004, 2005, 2014 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -163,6 +163,7 @@ public final class AllPermission extends Permission
* @throws IllegalArgumentException if perm is not an AllPermission
* @throws SecurityException if the collection is read-only
*/
+ @Override
public void add(Permission perm)
{
if (isReadOnly())
@@ -178,6 +179,7 @@ public final class AllPermission extends Permission
* @param perm the permission to check
* @return true if this collection contains an AllPermission
*/
+ @Override
public boolean implies(Permission perm)
{
return all_allowed;
@@ -188,11 +190,12 @@ public final class AllPermission extends Permission
*
* @return the elements in the collection
*/
- public Enumeration elements()
+ @Override
+ public Enumeration<Permission> elements()
{
return all_allowed
- ? Collections.enumeration(Collections.singleton(new AllPermission()))
- : EmptyEnumeration.getInstance();
+ ? Collections.enumeration(Collections.singleton((Permission) new AllPermission()))
+ : new EmptyEnumeration<Permission>();
}
} // class AllPermissionCollection
} // class AllPermission
diff --git a/java/security/BasicPermission.java b/java/security/BasicPermission.java
index 6296cffea..3bd0bd8f3 100644
--- a/java/security/BasicPermission.java
+++ b/java/security/BasicPermission.java
@@ -1,5 +1,5 @@
/* BasicPermission.java -- implements a simple named permission
- Copyright (C) 1998, 1999, 2002, 2003, 2004, 2005, 2006
+ Copyright (C) 1998, 1999, 2002, 2003, 2004, 2005, 2006, 2014
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -128,6 +128,7 @@ public abstract class BasicPermission extends Permission
* @param perm the <code>Permission</code> object to test against
* @return true if the specified permission is implied
*/
+ @Override
public boolean implies(Permission perm)
{
if (! getClass().isInstance(perm))
@@ -155,6 +156,7 @@ public abstract class BasicPermission extends Permission
* @param obj the <code>Object</code> to test for equality
* @return true if obj is semantically equal to this
*/
+ @Override
public boolean equals(Object obj)
{
return getClass().isInstance(obj)
@@ -168,6 +170,7 @@ public abstract class BasicPermission extends Permission
*
* @return a hash value for this object
*/
+ @Override
public int hashCode()
{
return getName().hashCode();
@@ -217,7 +220,7 @@ public abstract class BasicPermission extends Permission
*
* @serial a hash mapping name to permissions, all of type permClass
*/
- private final Hashtable permissions = new Hashtable();
+ private final Hashtable<String,Permission> permissions = new Hashtable<String,Permission>();
/**
* If "*" is in the collection.
@@ -231,14 +234,14 @@ public abstract class BasicPermission extends Permission
*
* @serial the limiting subclass of this collection
*/
- private final Class permClass;
+ private final Class<? extends BasicPermission> permClass;
/**
* Construct a collection over the given runtime class.
*
* @param c the class
*/
- BasicPermissionCollection(Class c)
+ BasicPermissionCollection(Class<? extends BasicPermission> c)
{
permClass = c;
}
@@ -251,6 +254,7 @@ public abstract class BasicPermission extends Permission
* @throws IllegalArgumentException if perm is not the correct type
* @throws SecurityException if the collection is read-only
*/
+ @Override
public void add(Permission perm)
{
if (isReadOnly())
@@ -270,6 +274,7 @@ public abstract class BasicPermission extends Permission
* @param permission the permission to check
* @return true if it is implied by this
*/
+ @Override
public boolean implies(Permission permission)
{
if (! permClass.isInstance(permission))
@@ -300,7 +305,8 @@ public abstract class BasicPermission extends Permission
*
* @return an enumeration of the collection contents
*/
- public Enumeration elements()
+ @Override
+ public Enumeration<Permission> elements()
{
return permissions.elements();
}
diff --git a/java/security/CodeSource.java b/java/security/CodeSource.java
index dd353eda0..6f98a00cd 100644
--- a/java/security/CodeSource.java
+++ b/java/security/CodeSource.java
@@ -1,5 +1,5 @@
/* CodeSource.java -- Code location and certifcates
- Copyright (C) 1998, 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2002, 2004, 2014 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -82,7 +82,7 @@ public class CodeSource implements Serializable
private final URL location;
/** The set of certificates for this code base. */
- private transient HashSet certs;
+ private transient HashSet<Certificate> certs;
/**
* This creates a new instance of <code>CodeSource</code> that loads code
@@ -96,7 +96,7 @@ public class CodeSource implements Serializable
{
this.location = location;
if (certs != null)
- this.certs = new HashSet(Arrays.asList(certs));
+ this.certs = new HashSet<Certificate>(Arrays.asList(certs));
}
/**
@@ -104,6 +104,7 @@ public class CodeSource implements Serializable
*
* @return a hash value for this object
*/
+ @Override
public int hashCode()
{
return (location == null ? 0 : location.hashCode())
@@ -118,6 +119,7 @@ public class CodeSource implements Serializable
* @param obj the <code>Object</code> to test against
* @return true if the specified object is equal to this one
*/
+ @Override
public boolean equals(Object obj)
{
if (! (obj instanceof CodeSource))
@@ -259,6 +261,7 @@ public class CodeSource implements Serializable
*
* @return a <code>String</code> for this object
*/
+ @Override
public String toString()
{
CPStringBuilder sb = new CPStringBuilder("(").append(location);
@@ -266,7 +269,7 @@ public class CodeSource implements Serializable
sb.append(" <no certificates>");
else
{
- Iterator iter = certs.iterator();
+ Iterator<Certificate> iter = certs.iterator();
for (int i = certs.size(); --i >= 0; )
sb.append(' ').append(iter.next());
}
@@ -288,7 +291,7 @@ public class CodeSource implements Serializable
{
s.defaultReadObject();
int count = s.readInt();
- certs = new HashSet();
+ certs = new HashSet<Certificate>();
while (--count >= 0)
{
String type = (String) s.readObject();
@@ -327,10 +330,10 @@ public class CodeSource implements Serializable
{
int count = certs.size();
s.writeInt(count);
- Iterator iter = certs.iterator();
+ Iterator<Certificate> iter = certs.iterator();
while (--count >= 0)
{
- Certificate c = (Certificate) iter.next();
+ Certificate c = iter.next();
s.writeObject(c.getType());
byte[] encoded;
try
diff --git a/java/security/DummySignature.java b/java/security/DummySignature.java
index b74885c99..2720dd47a 100644
--- a/java/security/DummySignature.java
+++ b/java/security/DummySignature.java
@@ -1,5 +1,5 @@
/* DummySignature.java - Signature wrapper for SignatureSpi.
- Copyright (C) 1999, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2014 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -47,6 +47,7 @@ final class DummySignature extends Signature
this.sigSpi = sigSpi;
}
+ @Override
public Object clone() throws CloneNotSupportedException
{
Signature result = new DummySignature
@@ -55,45 +56,53 @@ final class DummySignature extends Signature
return result;
}
+ @Override
protected void engineInitVerify(PublicKey publicKey)
throws InvalidKeyException
{
sigSpi.engineInitVerify(publicKey);
}
+ @Override
protected void engineInitSign(PrivateKey privateKey)
throws InvalidKeyException
{
sigSpi.engineInitSign(privateKey);
}
+ @Override
protected void engineUpdate(byte b) throws SignatureException
{
sigSpi.engineUpdate(b);
}
+ @Override
protected void engineUpdate(byte[]b, int off, int len)
throws SignatureException
{
sigSpi.engineUpdate(b, off, len);
}
+ @Override
protected byte[] engineSign() throws SignatureException
{
return sigSpi.engineSign();
}
+ @Override
protected boolean engineVerify(byte[]sigBytes) throws SignatureException
{
return sigSpi.engineVerify(sigBytes);
}
+ @Override
protected void engineSetParameter(String param, Object value)
throws InvalidParameterException
{
sigSpi.engineSetParameter(param, value);
}
+ @Override
protected Object engineGetParameter(String param)
throws InvalidParameterException
{
diff --git a/java/security/Identity.java b/java/security/Identity.java
index 83ec4c8e1..d3f48e887 100644
--- a/java/security/Identity.java
+++ b/java/security/Identity.java
@@ -1,5 +1,5 @@
/* Identity.java --- Identity Class
- Copyright (C) 1999, 2003, Free Software Foundation, Inc.
+ Copyright (C) 1999, 2003, 2014, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -71,7 +71,7 @@ public abstract class Identity implements Principal, Serializable
private IdentityScope scope;
private PublicKey publicKey;
private String info;
- private Vector certificates;
+ private Vector<Certificate> certificates;
/** Constructor for serialization only. */
protected Identity()
@@ -202,7 +202,7 @@ public abstract class Identity implements Principal, Serializable
// Check public key of this certificate against the first one in the vector
if (certificates.size() > 0)
{
- if (((Certificate) certificates.firstElement()).getPublicKey() != publicKey)
+ if (certificates.firstElement().getPublicKey() != publicKey)
throw new KeyManagementException("Public key does not match");
}
certificates.addElement(certificate);
@@ -238,7 +238,7 @@ public abstract class Identity implements Principal, Serializable
Certificate[] certs = new Certificate[certificates.size()];
int max = certificates.size();
for (int i = 0; i < max; i++)
- certs[i] = (Certificate) certificates.elementAt(i);
+ certs[i] = certificates.elementAt(i);
return certs;
}
diff --git a/java/security/IntersectingDomainCombiner.java b/java/security/IntersectingDomainCombiner.java
index 2bfcfb442..9a40ce75e 100644
--- a/java/security/IntersectingDomainCombiner.java
+++ b/java/security/IntersectingDomainCombiner.java
@@ -1,5 +1,5 @@
/* IntersectingDomainCombiner.java --
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2014 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -65,7 +65,7 @@ final class IntersectingDomainCombiner implements DomainCombiner
public ProtectionDomain[] combine (ProtectionDomain[] currentDomains,
ProtectionDomain[] assignedDomains)
{
- HashSet newDomains = new HashSet ();
+ HashSet<ProtectionDomain> newDomains = new HashSet<ProtectionDomain>();
for (int i = 0; i < currentDomains.length; i++)
{
if (currentDomains[i] == null)
@@ -76,7 +76,6 @@ final class IntersectingDomainCombiner implements DomainCombiner
newDomains.add (currentDomains[i]);
}
}
- return (ProtectionDomain[])
- newDomains.toArray(new ProtectionDomain[newDomains.size()]);
+ return newDomains.toArray(new ProtectionDomain[newDomains.size()]);
}
}
diff --git a/java/security/KeyPairGenerator.java b/java/security/KeyPairGenerator.java
index 5e6bb1a3c..19724da6f 100644
--- a/java/security/KeyPairGenerator.java
+++ b/java/security/KeyPairGenerator.java
@@ -1,5 +1,5 @@
/* KeyPairGenerator.java --- Key Pair Generator Class
- Copyright (C) 1999, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2003, 2004, 2005, 2014 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -236,6 +236,7 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi
* the {@link SecureRandom} to use.
* @since 1.2
*/
+ @Override
public void initialize(int keysize, SecureRandom random)
{
}
@@ -269,6 +270,7 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi
* if the designated specifications are invalid.
* @since 1.2
*/
+ @Override
public void initialize(AlgorithmParameterSpec params, SecureRandom random)
throws InvalidAlgorithmParameterException
{
diff --git a/java/security/Permissions.java b/java/security/Permissions.java
index d814064e0..40087ba02 100644
--- a/java/security/Permissions.java
+++ b/java/security/Permissions.java
@@ -1,5 +1,5 @@
/* Permissions.java -- a collection of permission collections
- Copyright (C) 1998, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2001, 2002, 2004, 2005, 2014 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -78,7 +78,8 @@ public final class Permissions extends PermissionCollection
*
* @serial maps Class to PermissionCollection
*/
- final Hashtable perms = new Hashtable();
+ final Hashtable<Class<?>,PermissionCollection> perms =
+ new Hashtable<Class<?>,PermissionCollection>();
/**
* This method initializes a new instance of <code>Permissions</code>.
@@ -99,6 +100,7 @@ public final class Permissions extends PermissionCollection
* @param perm the <code>Permission</code> to add
* @throws SecurityException if this collection is marked as read only
*/
+ @Override
public void add(Permission perm)
{
if (isReadOnly())
@@ -114,8 +116,7 @@ public final class Permissions extends PermissionCollection
}
else
{
- PermissionCollection pc
- = (PermissionCollection) perms.get(perm.getClass());
+ PermissionCollection pc = perms.get(perm.getClass());
if (pc == null)
{
pc = perm.newPermissionCollection();
@@ -134,12 +135,12 @@ public final class Permissions extends PermissionCollection
* @param perm the <code>Permission</code> to test
* @return true if the specified permission is implied by this
*/
+ @Override
public boolean implies(Permission perm)
{
if (allPermission != null)
return true;
- PermissionCollection pc
- = (PermissionCollection) perms.get(perm.getClass());
+ PermissionCollection pc = perms.get(perm.getClass());
return pc == null ? false : pc.implies(perm);
}
@@ -150,41 +151,41 @@ public final class Permissions extends PermissionCollection
*
* @return an <code>Enumeration</code> of this collection's elements
*/
+ @Override
public Enumeration<Permission> elements()
{
- return new Enumeration()
+ return new Enumeration<Permission>()
{
- Enumeration main_enum = perms.elements();
- Enumeration sub_enum;
+ Enumeration<PermissionCollection> mainEnum = perms.elements();
+ Enumeration<Permission> subEnum;
public boolean hasMoreElements()
{
- if (sub_enum == null)
+ if (subEnum == null)
{
- if (main_enum == null)
+ if (mainEnum == null)
return false;
- if (! main_enum.hasMoreElements())
+ if (! mainEnum.hasMoreElements())
{
- main_enum = null;
+ mainEnum = null;
return false;
}
- PermissionCollection pc =
- (PermissionCollection) main_enum.nextElement();
- sub_enum = pc.elements();
+ PermissionCollection pc = mainEnum.nextElement();
+ subEnum = pc.elements();
}
- if (! sub_enum.hasMoreElements())
+ if (! subEnum.hasMoreElements())
{
- sub_enum = null;
+ subEnum = null;
return hasMoreElements();
}
return true;
}
- public Object nextElement()
+ public Permission nextElement()
{
if (! hasMoreElements())
throw new NoSuchElementException();
- return sub_enum.nextElement();
+ return subEnum.nextElement();
}
};
}
@@ -207,7 +208,8 @@ public final class Permissions extends PermissionCollection
*
* @serial the stored permissions, both as key and value
*/
- private final Hashtable perms = new Hashtable();
+ private final Hashtable<Permission,Permission> perms =
+ new Hashtable<Permission,Permission>();
/**
* Add a permission. We don't need to check for read-only, as this
@@ -216,6 +218,7 @@ public final class Permissions extends PermissionCollection
*
* @param perm the permission to add
*/
+ @Override
public void add(Permission perm)
{
perms.put(perm, perm);
@@ -228,13 +231,14 @@ public final class Permissions extends PermissionCollection
* @return true if it is implied
*/
// FIXME: Should this method be synchronized?
+ @Override
public boolean implies(Permission perm)
{
- Enumeration elements = elements();
+ Enumeration<Permission> elements = elements();
while (elements.hasMoreElements())
{
- Permission p = (Permission)elements.nextElement();
+ Permission p = elements.nextElement();
if (p.implies(perm))
return true;
}
@@ -246,7 +250,8 @@ public final class Permissions extends PermissionCollection
*
* @return the elements
*/
- public Enumeration elements()
+ @Override
+ public Enumeration<Permission> elements()
{
return perms.elements();
}
diff --git a/java/security/Policy.java b/java/security/Policy.java
index 118626ea1..930315bfd 100644
--- a/java/security/Policy.java
+++ b/java/security/Policy.java
@@ -1,5 +1,5 @@
/* Policy.java --- Policy Manager Class
- Copyright (C) 1999, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2003, 2004, 2014 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -92,7 +92,7 @@ public abstract class Policy
private static Policy currentPolicy;
/** Map of ProtectionDomains to PermissionCollections for this instance. */
- private Map pd2pc = null;
+ private Map<ProtectionDomain,PermissionCollection> pd2pc = null;
/** Constructs a new <code>Policy</code> object. */
public Policy()
@@ -140,7 +140,8 @@ public abstract class Policy
private static void setup(final Policy policy)
{
if (policy.pd2pc == null)
- policy.pd2pc = Collections.synchronizedMap(new LinkedHashMap());
+ policy.pd2pc =
+ Collections.synchronizedMap(new LinkedHashMap<ProtectionDomain,PermissionCollection>());
ProtectionDomain pd = policy.getClass().getProtectionDomain();
if (pd.getCodeSource() != null)
@@ -232,12 +233,12 @@ public abstract class Policy
if (pd2pc == null)
setup(this);
- PermissionCollection result = (PermissionCollection) pd2pc.get(domain);
+ PermissionCollection result = pd2pc.get(domain);
if (result != null)
{
Permissions realResult = new Permissions();
- for (Enumeration e = result.elements(); e.hasMoreElements(); )
- realResult.add((Permission) e.nextElement());
+ for (Enumeration<Permission> e = result.elements(); e.hasMoreElements(); )
+ realResult.add(e.nextElement());
return realResult;
}
@@ -248,8 +249,8 @@ public abstract class Policy
PermissionCollection pc = domain.getPermissions();
if (pc != null)
- for (Enumeration e = pc.elements(); e.hasMoreElements(); )
- result.add((Permission) e.nextElement());
+ for (Enumeration<Permission> e = pc.elements(); e.hasMoreElements(); )
+ result.add(e.nextElement());
return result;
}
diff --git a/java/security/SecureRandom.java b/java/security/SecureRandom.java
index abf4ff308..649966fee 100644
--- a/java/security/SecureRandom.java
+++ b/java/security/SecureRandom.java
@@ -1,5 +1,5 @@
/* SecureRandom.java --- Secure Random class implementation
- Copyright (C) 1999, 2001, 2002, 2003, 2005, 2006
+ Copyright (C) 1999, 2001, 2002, 2003, 2005, 2006, 2014
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,22 +38,14 @@ exception statement from your version. */
package java.security;
-import gnu.classpath.SystemProperties;
import gnu.java.lang.CPStringBuilder;
import gnu.java.security.Engine;
-import gnu.java.security.action.GetSecurityPropertyAction;
import gnu.java.security.jce.prng.SecureRandomAdapter;
import gnu.java.security.jce.prng.Sha160RandomSpi;
-import java.io.IOException;
-import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
-import java.net.URL;
import java.util.Enumeration;
import java.util.Random;
-import java.util.logging.Level;
-import java.util.logging.Logger;
/**
* An interface to a cryptographically secure pseudo-random number
@@ -110,7 +102,7 @@ public class SecureRandom extends Random
String classname = null;
int i;
- Enumeration e;
+ Enumeration<?> e;
for (i = 0; i < p.length; i++)
{
e = p[i].propertyNames();
diff --git a/java/security/Security.java b/java/security/Security.java
index 6cd98b0fb..6b20a7cb6 100644
--- a/java/security/Security.java
+++ b/java/security/Security.java
@@ -1,5 +1,5 @@
/* Security.java --- Java base security class implementation
- Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006
+ Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2014
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -48,10 +48,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Collections;
-import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Properties;
@@ -68,7 +66,7 @@ public final class Security
{
private static final String ALG_ALIAS = "Alg.Alias.";
- private static Vector providers = new Vector();
+ private static Vector<Provider> providers = new Vector<Provider>();
private static Properties secprops = new Properties();
static
@@ -139,7 +137,7 @@ public final class Security
try
{
ClassLoader sys = ClassLoader.getSystemClassLoader();
- providers.addElement(Class.forName(name, true, sys).newInstance());
+ providers.addElement((Provider) Class.forName(name, true, sys).newInstance());
}
catch (ClassNotFoundException x)
{
@@ -191,13 +189,10 @@ public final class Security
return null;
String property = String.valueOf(propName) + "." + String.valueOf(algName);
- Provider p;
- for (Iterator i = providers.iterator(); i.hasNext(); )
+ for (Provider p : providers)
{
- p = (Provider) i.next();
- for (Iterator j = p.keySet().iterator(); j.hasNext(); )
+ for (String key : p.stringPropertyNames())
{
- String key = (String) j.next();
if (key.equalsIgnoreCase(property))
return p.getProperty(key);
}
@@ -235,7 +230,7 @@ public final class Security
int max = providers.size ();
for (int i = 0; i < max; i++)
{
- if (((Provider) providers.elementAt(i)).getName().equals(provider.getName()))
+ if (providers.elementAt(i).getName().equals(provider.getName()))
return -1;
}
@@ -291,7 +286,7 @@ public final class Security
int max = providers.size ();
for (int i = 0; i < max; i++)
{
- if (((Provider) providers.elementAt(i)).getName().equals(name))
+ if (providers.elementAt(i).getName().equals(name))
{
providers.remove(i);
break;
@@ -337,7 +332,7 @@ public final class Security
int max = providers.size ();
for (int i = 0; i < max; i++)
{
- p = (Provider) providers.elementAt(i);
+ p = providers.elementAt(i);
if (p.getName().equals(name))
return p;
}
@@ -422,9 +417,9 @@ public final class Security
Provider[] providers = getProviders();
int ndx;
for (int i = 0; i < providers.length; i++)
- for (Enumeration e = providers[i].propertyNames(); e.hasMoreElements(); )
+ for (String s : providers[i].stringPropertyNames())
{
- String service = ((String) e.nextElement()).trim();
+ String service = s.trim();
if (service.toUpperCase().startsWith(serviceName))
{
service = service.substring(serviceName.length()).trim();
@@ -490,7 +485,7 @@ public final class Security
if (filter == null || filter.length() == 0)
return getProviders();
- HashMap map = new HashMap(1);
+ HashMap<String,String> map = new HashMap<String,String>(1);
int i = filter.indexOf(':');
if (i == -1) // <service>.<algorithm>
map.put(filter, "");
@@ -505,7 +500,7 @@ public final class Security
* set of <i>selection</i> criteria.
*
* <p>The <i>selection</i> criteria are defined in a {@link Map} where each
- * element specifies a <i>selection</i> querry. The <i>Keys</i> in this
+ * element specifies a <i>selection</i> query. The <i>Keys</i> in this
* {@link Map} must be in one of the two following forms:</p>
*
* <ul>
@@ -531,7 +526,7 @@ public final class Security
* </ul>
*
* @param filter
- * a {@link Map} of <i>selection querries</i>.
+ * a {@link Map} of <i>selection queries</i>.
* @return all currently installed {@link Provider}s which satisfy ALL the
* <i>selection</i> criteria defined in <code>filter</code>.
* Returns ALL installed {@link Provider}s if <code>filter</code>
@@ -549,68 +544,67 @@ public final class Security
if (filter == null)
return getProviders();
- Set<String> querries = filter.keySet();
- if (querries == null || querries.isEmpty())
+ Set<String> queries = filter.keySet();
+ if (queries == null || queries.isEmpty())
return getProviders();
- LinkedHashSet result = new LinkedHashSet(providers); // assume all
+ LinkedHashSet<Provider> result = new LinkedHashSet<Provider>(providers); // assume all
int dot, ws;
- String querry, service, algorithm, attribute, value;
- LinkedHashSet serviceProviders = new LinkedHashSet(); // preserve insertion order
- for (Iterator i = querries.iterator(); i.hasNext(); )
+ String service, algorithm, attribute, value;
+ LinkedHashSet<Provider> serviceProviders = new LinkedHashSet<Provider>(); // preserve insertion order
+ for (String query : queries)
{
- querry = (String) i.next();
- if (querry == null) // all providers
+ if (query == null) // all providers
continue;
- querry = querry.trim();
- if (querry.length() == 0) // all providers
+ query = query.trim();
+ if (query.length() == 0) // all providers
continue;
- dot = querry.indexOf('.');
+ dot = query.indexOf('.');
if (dot == -1) // syntax error
throw new InvalidParameterException(
- "missing dot in '" + String.valueOf(querry)+"'");
+ "missing dot in '" + String.valueOf(query)+"'");
- value = filter.get(querry);
- // deconstruct querry into [service, algorithm, attribute]
+ value = filter.get(query);
+ // deconstruct query into [service, algorithm, attribute]
if (value == null || value.trim().length() == 0) // <service>.<algorithm>
{
value = null;
attribute = null;
- service = querry.substring(0, dot).trim();
- algorithm = querry.substring(dot+1).trim();
+ service = query.substring(0, dot).trim();
+ algorithm = query.substring(dot+1).trim();
}
else // <service>.<algorithm> <attribute>
{
- ws = querry.indexOf(' ');
+ ws = query.indexOf(' ');
if (ws == -1)
throw new InvalidParameterException(
"value (" + String.valueOf(value) +
- ") is not empty, but querry (" + String.valueOf(querry) +
+ ") is not empty, but query (" + String.valueOf(query) +
") is missing at least one space character");
value = value.trim();
- attribute = querry.substring(ws+1).trim();
+ attribute = query.substring(ws+1).trim();
// was the dot in the attribute?
if (attribute.indexOf('.') != -1)
throw new InvalidParameterException(
"attribute_name (" + String.valueOf(attribute) +
- ") in querry (" + String.valueOf(querry) + ") contains a dot");
+ ") in query (" + String.valueOf(query) + ") contains a dot");
- querry = querry.substring(0, ws).trim();
- service = querry.substring(0, dot).trim();
- algorithm = querry.substring(dot+1).trim();
+ query = query.substring(0, ws).trim();
+ service = query.substring(0, dot).trim();
+ algorithm = query.substring(dot+1).trim();
}
// service and algorithm must not be empty
if (service.length() == 0)
throw new InvalidParameterException(
- "<crypto_service> in querry (" + String.valueOf(querry) +
+ "<crypto_service> in query (" + String.valueOf(query) +
") is empty");
if (algorithm.length() == 0)
throw new InvalidParameterException(
- "<algorithm_or_type> in querry (" + String.valueOf(querry) +
+ "<algorithm_or_type> in query (" + String.valueOf(query) +
") is empty");
selectProviders(service, algorithm, attribute, value, result, serviceProviders);
@@ -622,17 +616,16 @@ public final class Security
if (result.isEmpty())
return null;
- return (Provider[]) result.toArray(new Provider[result.size()]);
+ return result.toArray(new Provider[result.size()]);
}
private static void selectProviders(String svc, String algo, String attr,
- String val, LinkedHashSet providerSet,
- LinkedHashSet result)
+ String val, LinkedHashSet<Provider> providerSet,
+ LinkedHashSet<Provider> result)
{
result.clear(); // ensure we start with an empty result set
- for (Iterator i = providerSet.iterator(); i.hasNext(); )
+ for (Provider p : providerSet)
{
- Provider p = (Provider) i.next();
if (provides(p, svc, algo, attr, val))
result.add(p);
}
@@ -641,9 +634,7 @@ public final class Security
private static boolean provides(Provider p, String svc, String algo,
String attr, String val)
{
- Iterator it;
String serviceDotAlgorithm = null;
- String key = null;
String realVal;
boolean found = false;
// if <svc>.<algo> <attr> is in the set then so is <svc>.<algo>
@@ -651,9 +642,8 @@ public final class Security
outer: for (int r = 0; r < 3; r++) // guard against circularity
{
serviceDotAlgorithm = (svc+"."+String.valueOf(algo)).trim();
- for (it = p.keySet().iterator(); it.hasNext(); )
+ for (String key : p.stringPropertyNames())
{
- key = (String) it.next();
if (key.equalsIgnoreCase(serviceDotAlgorithm)) // eureka
{
found = true;
@@ -679,9 +669,8 @@ public final class Security
// <service>.<algorithm> <attribute>; find the key entry that match
String realAttr;
int limit = serviceDotAlgorithm.length() + 1;
- for (it = p.keySet().iterator(); it.hasNext(); )
+ for (String key : p.stringPropertyNames())
{
- key = (String) it.next();
if (key.length() <= limit)
continue;
diff --git a/java/security/SignatureSpi.java b/java/security/SignatureSpi.java
index 1ed078c0b..11ce551a0 100644
--- a/java/security/SignatureSpi.java
+++ b/java/security/SignatureSpi.java
@@ -1,5 +1,5 @@
/* SignatureSpi.java --- Signature Service Provider Interface
- Copyright (C) 1999, 2003, Free Software Foundation, Inc.
+ Copyright (C) 1999, 2003, 2014 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -309,6 +309,7 @@ public abstract class SignatureSpi
* @throws CloneNotSupportedException
* if the implementation does not support cloning.
*/
+ @Override
public Object clone() throws CloneNotSupportedException
{
return super.clone();
diff --git a/java/security/UnresolvedPermission.java b/java/security/UnresolvedPermission.java
index 449454aaf..d7af92211 100644
--- a/java/security/UnresolvedPermission.java
+++ b/java/security/UnresolvedPermission.java
@@ -1,5 +1,5 @@
/* UnresolvedPermission.java -- Placeholder for unresolved permissions
- Copyright (C) 1998, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2001, 2002, 2004, 2005, 2014 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -128,6 +128,7 @@ public final class UnresolvedPermission extends Permission
* @param perm the <code>Permission</code> object to test
* @return false; until a permission is resolved, it implies nothing
*/
+ @Override
public boolean implies(Permission perm)
{
return false;
@@ -149,6 +150,7 @@ public final class UnresolvedPermission extends Permission
* @param obj the <code>Object</code> to test for equality
* @return true if the specified object is equal to this one
*/
+ @Override
public boolean equals(Object obj)
{
if (! (obj instanceof UnresolvedPermission))
@@ -164,6 +166,7 @@ public final class UnresolvedPermission extends Permission
*
* @return A hash value
*/
+ @Override
public int hashCode()
{
return name.hashCode();
@@ -175,6 +178,7 @@ public final class UnresolvedPermission extends Permission
*
* @return the action list
*/
+ @Override
public String getActions()
{
return actions;
@@ -186,6 +190,7 @@ public final class UnresolvedPermission extends Permission
*
* @return <code>String</code> representation of this object
*/
+ @Override
public String toString()
{
return "(unresolved " + type + ' ' + name + ' ' + actions + ')';
@@ -197,6 +202,7 @@ public final class UnresolvedPermission extends Permission
*
* @return a new <code>PermissionCollection</code>
*/
+ @Override
public PermissionCollection newPermissionCollection()
{
return new UnresolvedPermissionCollection();
@@ -264,7 +270,8 @@ class UnresolvedPermissionCollection extends PermissionCollection
* @serial map of typename to a Vector of permissions (you'd think Sun
* would document this better!)
*/
- final Hashtable permissions = new Hashtable();
+ final Hashtable<String,Vector<Permission>> permissions =
+ new Hashtable<String,Vector<Permission>>();
/**
* Add a permission.
@@ -273,6 +280,7 @@ class UnresolvedPermissionCollection extends PermissionCollection
* @throws IllegalArgumentException if perm is not an UnresolvedPermission
* @throws SecurityException if the collection is read-only
*/
+ @Override
public void add(Permission perm)
{
if (isReadOnly())
@@ -280,10 +288,10 @@ class UnresolvedPermissionCollection extends PermissionCollection
if (! (perm instanceof UnresolvedPermission))
throw new IllegalArgumentException();
UnresolvedPermission up = (UnresolvedPermission) perm;
- Vector v = (Vector) permissions.get(up.type);
+ Vector<Permission> v = permissions.get(up.type);
if (v == null)
{
- v = new Vector();
+ v = new Vector<Permission>();
permissions.put(up.type, v);
}
v.add(up);
@@ -295,6 +303,7 @@ class UnresolvedPermissionCollection extends PermissionCollection
* @param perm the permission to check
* @return false; unresolved permissions imply nothing
*/
+ @Override
public boolean implies(Permission perm)
{
return false;
@@ -305,40 +314,41 @@ class UnresolvedPermissionCollection extends PermissionCollection
*
* @return the elements
*/
- public Enumeration elements()
+ @Override
+ public Enumeration<Permission> elements()
{
- return new Enumeration()
+ return new Enumeration<Permission>()
{
- Enumeration main_enum = permissions.elements();
- Enumeration sub_enum;
+ Enumeration<Vector<Permission>> mainEnum = permissions.elements();
+ Enumeration<Permission> subEnum;
public boolean hasMoreElements()
{
- if (sub_enum == null)
+ if (subEnum == null)
{
- if (main_enum == null)
+ if (mainEnum == null)
return false;
- if (! main_enum.hasMoreElements())
+ if (! mainEnum.hasMoreElements())
{
- main_enum = null;
+ mainEnum = null;
return false;
}
- Vector v = (Vector) main_enum.nextElement();
- sub_enum = v.elements();
+ Vector<Permission> v = mainEnum.nextElement();
+ subEnum = v.elements();
}
- if (! sub_enum.hasMoreElements())
+ if (! subEnum.hasMoreElements())
{
- sub_enum = null;
+ subEnum = null;
return hasMoreElements();
}
return true;
}
- public Object nextElement()
+ public Permission nextElement()
{
if (! hasMoreElements())
throw new NoSuchElementException();
- return sub_enum.nextElement();
+ return subEnum.nextElement();
}
};
}
diff --git a/java/security/cert/CertPath.java b/java/security/cert/CertPath.java
index 7211647a4..5c9a12ab9 100644
--- a/java/security/cert/CertPath.java
+++ b/java/security/cert/CertPath.java
@@ -1,5 +1,5 @@
/* CertPath.java -- a sequence of certificates
- Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005, 2014 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -195,7 +195,7 @@ public abstract class CertPath implements Serializable
public String toString()
{
- List l = getCertificates();
+ List<? extends Certificate> l = getCertificates();
int size = l.size();
int i = 0;
CPStringBuilder result = new CPStringBuilder(type);
diff --git a/java/security/cert/CertPathValidator.java b/java/security/cert/CertPathValidator.java
index 8bd7b58e8..ec02a7585 100644
--- a/java/security/cert/CertPathValidator.java
+++ b/java/security/cert/CertPathValidator.java
@@ -1,5 +1,5 @@
/* CertPathValidator -- validates certificate paths.
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2014 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,15 +39,14 @@ exception statement from your version. */
package java.security.cert;
import gnu.java.lang.CPStringBuilder;
-
import gnu.java.security.Engine;
+import gnu.java.security.action.GetSecurityPropertyAction;
import java.lang.reflect.InvocationTargetException;
import java.security.AccessController;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
-import java.security.PrivilegedAction;
import java.security.Provider;
import java.security.Security;
@@ -112,18 +111,9 @@ public class CertPathValidator {
* @return The default validator type.
*/
public static synchronized String getDefaultType() {
- String type = (String) AccessController.doPrivileged(
- new PrivilegedAction()
- {
- public Object run()
- {
- return Security.getProperty("certpathvalidator.type");
- }
- }
+ return AccessController.doPrivileged(
+ new GetSecurityPropertyAction("certpathvalidator.type", "PKIX")
);
- if (type == null)
- type = "PKIX";
- return type;
}
/**
diff --git a/java/security/cert/CertStore.java b/java/security/cert/CertStore.java
index 630e96762..d4435c1a0 100644
--- a/java/security/cert/CertStore.java
+++ b/java/security/cert/CertStore.java
@@ -1,5 +1,5 @@
/* CertStore -- stores and retrieves certificates.
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2014 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,12 +41,12 @@ package java.security.cert;
import gnu.java.lang.CPStringBuilder;
import gnu.java.security.Engine;
+import gnu.java.security.action.GetSecurityPropertyAction;
import java.lang.reflect.InvocationTargetException;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
-import java.security.PrivilegedAction;
import java.security.Provider;
import java.security.Security;
import java.util.Collection;
@@ -112,17 +112,9 @@ public class CertStore
*/
public static final synchronized String getDefaultType()
{
- String type = null;
- type = (String) java.security.AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
- return Security.getProperty("certstore.type");
- }
- }
+ return java.security.AccessController.doPrivileged(
+ new GetSecurityPropertyAction("certstore.type", "LDAP")
);
- if (type == null)
- type = "LDAP";
- return type;
}
/**
diff --git a/java/security/cert/CollectionCertStoreParameters.java b/java/security/cert/CollectionCertStoreParameters.java
index 389874854..6edaf7677 100644
--- a/java/security/cert/CollectionCertStoreParameters.java
+++ b/java/security/cert/CollectionCertStoreParameters.java
@@ -1,5 +1,5 @@
/* CollectionCertStoreParameters -- collection-based cert store parameters
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2014 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -60,7 +60,7 @@ public class CollectionCertStoreParameters implements CertStoreParameters
// ------------------------------------------------------------------------
/** The underlying collection. */
- private final Collection collection;
+ private final Collection<?> collection;
// Constructors.
// ------------------------------------------------------------------------
@@ -92,9 +92,10 @@ public class CollectionCertStoreParameters implements CertStoreParameters
// Instance methods.
// ------------------------------------------------------------------------
+ @Override
public Object clone()
{
- return new CollectionCertStoreParameters(new ArrayList(collection));
+ return new CollectionCertStoreParameters(new ArrayList<Object>(collection));
}
/**
diff --git a/java/security/cert/PKIXParameters.java b/java/security/cert/PKIXParameters.java
index bbb75571f..1778d6127 100644
--- a/java/security/cert/PKIXParameters.java
+++ b/java/security/cert/PKIXParameters.java
@@ -1,5 +1,5 @@
/* PKIXParameters.java -- parameters for the PKIX cert path algorithm
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2014 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -65,16 +65,16 @@ public class PKIXParameters implements CertPathParameters
// ------------------------------------------------------------------------
/** The trusted certificates. */
- private final Set trustAnchors;
+ private final Set<TrustAnchor> trustAnchors;
/** The set of initial policy identifiers. */
- private final Set initPolicies;
+ private final Set<String> initPolicies;
/** The list of certificate stores. */
- private final List certStores;
+ private final List<CertStore> certStores;
/** The list of path checkers. */
- private final List pathCheckers;
+ private final List<PKIXCertPathChecker> pathCheckers;
/** The revocation enabled flag. */
private boolean revocationEnabled;
@@ -120,9 +120,9 @@ public class PKIXParameters implements CertPathParameters
throws KeyStoreException, InvalidAlgorithmParameterException
{
this();
- for (Enumeration e = keystore.aliases(); e.hasMoreElements(); )
+ for (Enumeration<String> e = keystore.aliases(); e.hasMoreElements(); )
{
- String alias = (String) e.nextElement();
+ String alias = e.nextElement();
if (!keystore.isCertificateEntry(alias))
continue;
Certificate cert = keystore.getCertificate(alias);
@@ -157,10 +157,10 @@ public class PKIXParameters implements CertPathParameters
*/
private PKIXParameters()
{
- trustAnchors = new HashSet();
- initPolicies = new HashSet();
- certStores = new LinkedList();
- pathCheckers = new LinkedList();
+ trustAnchors = new HashSet<TrustAnchor>();
+ initPolicies = new HashSet<String>();
+ certStores = new LinkedList<CertStore>();
+ pathCheckers = new LinkedList<PKIXCertPathChecker>();
revocationEnabled = true;
exPolicyRequired = false;
policyMappingInhibited = false;
@@ -223,9 +223,9 @@ public class PKIXParameters implements CertPathParameters
if (trustAnchors.isEmpty())
throw new InvalidAlgorithmParameterException("no trust anchors");
this.trustAnchors.clear();
- for (Iterator i = trustAnchors.iterator(); i.hasNext(); )
+ for (Iterator<TrustAnchor> i = trustAnchors.iterator(); i.hasNext(); )
{
- this.trustAnchors.add((TrustAnchor) i.next());
+ this.trustAnchors.add(i.next());
}
}
@@ -255,9 +255,9 @@ public class PKIXParameters implements CertPathParameters
this.initPolicies.clear();
if (initPolicies == null)
return;
- for (Iterator i = initPolicies.iterator(); i.hasNext(); )
+ for (String ip : initPolicies)
{
- this.initPolicies.add((String) i.next());
+ this.initPolicies.add(ip);
}
}
@@ -294,9 +294,9 @@ public class PKIXParameters implements CertPathParameters
this.certStores.clear();
if (certStores == null)
return;
- for (Iterator i = certStores.iterator(); i.hasNext(); )
+ for (Iterator<CertStore> i = certStores.iterator(); i.hasNext(); )
{
- this.certStores.add((CertStore) i.next());
+ this.certStores.add(i.next());
}
}
@@ -465,9 +465,9 @@ public class PKIXParameters implements CertPathParameters
this.pathCheckers.clear();
if (pathCheckers == null)
return;
- for (Iterator i = pathCheckers.iterator(); i.hasNext(); )
+ for (Iterator<PKIXCertPathChecker> i = pathCheckers.iterator(); i.hasNext(); )
{
- this.pathCheckers.add((PKIXCertPathChecker) i.next());
+ this.pathCheckers.add(i.next());
}
}
diff --git a/java/security/cert/X509CRLSelector.java b/java/security/cert/X509CRLSelector.java
index d412a1ae3..1ac5c640b 100644
--- a/java/security/cert/X509CRLSelector.java
+++ b/java/security/cert/X509CRLSelector.java
@@ -1,5 +1,5 @@
/* X509CRLSelector.java -- selects X.509 CRLs by criteria.
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2014 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -80,7 +80,7 @@ public class X509CRLSelector implements CRLSelector, Cloneable
private static final String CRL_NUMBER_ID = "2.5.29.20";
- private List issuerNames;
+ private List<X500Principal> issuerNames;
private BigInteger maxCrlNumber;
private BigInteger minCrlNumber;
private Date date;
@@ -121,7 +121,7 @@ public class X509CRLSelector implements CRLSelector, Cloneable
throw ioe;
}
if (issuerNames == null)
- issuerNames = new LinkedList();
+ issuerNames = new LinkedList<X500Principal>();
issuerNames.add(p);
}
@@ -146,7 +146,7 @@ public class X509CRLSelector implements CRLSelector, Cloneable
throw ioe;
}
if (issuerNames == null)
- issuerNames = new LinkedList();
+ issuerNames = new LinkedList<X500Principal>();
issuerNames.add(p);
}
@@ -166,12 +166,12 @@ public class X509CRLSelector implements CRLSelector, Cloneable
issuerNames = null;
return;
}
- List l = new ArrayList(names.size());
- for (Iterator it = names.iterator(); it.hasNext(); )
+ List<X500Principal> l = new ArrayList<X500Principal>(names.size());
+ for (Iterator<?> it = names.iterator(); it.hasNext(); )
{
Object o = it.next();
if (o instanceof X500Principal)
- l.add(o);
+ l.add((X500Principal) o);
else if (o instanceof String)
{
try
@@ -222,14 +222,19 @@ public class X509CRLSelector implements CRLSelector, Cloneable
/**
* Returns the set of issuer names that are matched by this selector,
* or <code>null</code> if this criteria is not set. The returned
- * collection is not modifiable.
+ * collection is not modifiable and is a deep copy of the original.
*
* @return The set of issuer names.
*/
public Collection<Object> getIssuerNames()
{
if (issuerNames != null)
- return Collections.unmodifiableList(issuerNames);
+ {
+ List<Object> iNames = new ArrayList<Object>();
+ for (X500Principal principal : issuerNames)
+ iNames.add(principal.getName());
+ return Collections.unmodifiableList(iNames);
+ }
else
return null;
}
diff --git a/java/security/cert/X509CertSelector.java b/java/security/cert/X509CertSelector.java
index 8c1230afb..ef8123bf7 100644
--- a/java/security/cert/X509CertSelector.java
+++ b/java/security/cert/X509CertSelector.java
@@ -1,5 +1,5 @@
/* X509CertSelector.java -- selects X.509 certificates by criteria.
- Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005, 2006, 2014 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -646,7 +646,7 @@ public class X509CertSelector implements CertSelector, Cloneable
}
if (keyPurposeSet != null)
{
- List kp = null;
+ List<String> kp = null;
try
{
kp = cert.getExtendedKeyUsage();
@@ -657,7 +657,7 @@ public class X509CertSelector implements CertSelector, Cloneable
}
if (kp == null)
return false;
- for (Iterator it = keyPurposeSet.iterator(); it.hasNext(); )
+ for (Iterator<String> it = keyPurposeSet.iterator(); it.hasNext(); )
{
if (!kp.contains(it.next()))
return false;
@@ -846,14 +846,20 @@ public class X509CertSelector implements CertSelector, Cloneable
return;
}
Set<String> s = new HashSet<String>();
- for (Iterator it = keyPurposeSet.iterator(); it.hasNext(); )
+ for (Iterator<String> it = keyPurposeSet.iterator(); it.hasNext(); )
{
- Object o = it.next();
- if (!(o instanceof String))
- throw new IOException("not a string: " + o);
+ String o = null;
+ try
+ {
+ o = it.next();
+ }
+ catch (ClassCastException ce)
+ {
+ throw new IOException("not a string: " + o, ce);
+ }
try
{
- OID oid = new OID((String) o);
+ OID oid = new OID(o);
int[] comp = oid.getIDs();
if (!checkOid(comp))
throw new IOException("malformed OID: " + o);
diff --git a/java/util/Properties.java b/java/util/Properties.java
index b0f436f42..9ca60a831 100644
--- a/java/util/Properties.java
+++ b/java/util/Properties.java
@@ -1,5 +1,5 @@
/* Properties.java -- a set of persistent properties
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2014 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -439,12 +439,12 @@ label = Name:\\u0020</pre>
writer.println("#" + header);
writer.println ("#" + Calendar.getInstance ().getTime ());
- Iterator iter = entrySet ().iterator ();
+ Iterator<Map.Entry<Object,Object>> iter = entrySet().iterator();
int i = size ();
CPStringBuilder s = new CPStringBuilder (); // Reuse the same buffer.
while (--i >= 0)
{
- Map.Entry entry = (Map.Entry) iter.next ();
+ Map.Entry<Object,Object> entry = iter.next ();
formatForOutput ((String) entry.getKey (), s, true);
s.append ('=');
formatForOutput ((String) entry.getValue (), s, false);
@@ -516,7 +516,7 @@ label = Name:\\u0020</pre>
// for that. This prevents modifications from ruining the enumeration,
// as well as ignoring duplicates.
Properties prop = this;
- Set s = new HashSet();
+ Set<Object> s = new HashSet<Object>();
// Eliminate tail recursion.
do
{
@@ -528,6 +528,42 @@ label = Name:\\u0020</pre>
}
/**
+ * <p>
+ * Returns the set of keys in this property list, including keys
+ * from the default properties which are distinct from those in the
+ * main property list. Only entries where both the key and its value
+ * are {@code String} objects are returned; any other entries are
+ * omitted.
+ * </p>
+ * <p>
+ * The returned set is not backed by this object, so any modifications
+ * to it will <emph>not</emph> be reflected in this object.
+ * </p>
+ *
+ * @return all keys from the main and default property lists which are
+ * {@code} String objects.
+ * @since 1.6
+ */
+ public Set<String> stringPropertyNames()
+ {
+ Properties prop = this;
+ Set<String> s = new HashSet<String>();
+ do
+ {
+ for (Map.Entry<Object,Object> entry : entrySet())
+ {
+ Object key = entry.getKey();
+ if (key instanceof String &&
+ entry.getValue() instanceof String)
+ s.add((String) key);
+ }
+ prop = prop.defaults;
+ }
+ while (prop != null);
+ return s;
+ }
+
+ /**
* Prints the key/value pairs to the given print stream. This is
* mainly useful for debugging purposes.
*