--- a/jdk/src/share/classes/javax/crypto/JceSecurityManager.java Mon Aug 15 12:56:01 2011 -0700
+++ b/jdk/src/share/classes/javax/crypto/JceSecurityManager.java Mon Aug 15 11:48:20 2011 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -28,7 +28,6 @@
import java.security.*;
import java.net.*;
import java.util.*;
-import java.util.jar.*;
/**
* The JCE security manager.
@@ -50,8 +49,10 @@
private static final CryptoPermissions defaultPolicy;
private static final CryptoPermissions exemptPolicy;
private static final CryptoAllPermission allPerm;
- private static final Vector TrustedCallersCache = new Vector(2);
- private static final Map exemptCache = new HashMap();
+ private static final Vector<Class<?>> TrustedCallersCache =
+ new Vector<>(2);
+ private static final Map<URL, CryptoPermissions> exemptCache =
+ new HashMap<>();
// singleton instance
static final JceSecurityManager INSTANCE;
@@ -60,12 +61,12 @@
defaultPolicy = JceSecurity.getDefaultPolicy();
exemptPolicy = JceSecurity.getExemptPolicy();
allPerm = CryptoAllPermission.INSTANCE;
- INSTANCE = (JceSecurityManager)
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return new JceSecurityManager();
- }
- });
+ INSTANCE = AccessController.doPrivileged(
+ new PrivilegedAction<JceSecurityManager>() {
+ public JceSecurityManager run() {
+ return new JceSecurityManager();
+ }
+ });
}
private JceSecurityManager() {
@@ -94,11 +95,11 @@
// javax.crypto.* packages.
// NOTE: javax.crypto.* package maybe subject to package
// insertion, so need to check its classloader as well.
- Class[] context = getClassContext();
+ Class<?>[] context = getClassContext();
URL callerCodeBase = null;
int i;
for (i=0; i<context.length; i++) {
- Class cls = context[i];
+ Class<?> cls = context[i];
callerCodeBase = JceSecurity.getCodeBase(cls);
if (callerCodeBase != null) {
break;
@@ -119,7 +120,7 @@
CryptoPermissions appPerms;
synchronized (this.getClass()) {
if (exemptCache.containsKey(callerCodeBase)) {
- appPerms = (CryptoPermissions)exemptCache.get(callerCodeBase);
+ appPerms = exemptCache.get(callerCodeBase);
} else {
appPerms = getAppPermissions(callerCodeBase);
exemptCache.put(callerCodeBase, appPerms);
@@ -143,7 +144,7 @@
if (appPc == null) {
return defaultPerm;
}
- Enumeration enum_ = appPc.elements();
+ Enumeration<Permission> enum_ = appPc.elements();
while (enum_.hasMoreElements()) {
CryptoPermission cp = (CryptoPermission)enum_.nextElement();
if (cp.getExemptionMechanism() == null) {
@@ -215,7 +216,7 @@
* Returns the default permission for the given algorithm.
*/
private CryptoPermission getDefaultPermission(String alg) {
- Enumeration enum_ =
+ Enumeration<Permission> enum_ =
defaultPolicy.getPermissionCollection(alg).elements();
return (CryptoPermission)enum_.nextElement();
}