You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ml...@apache.org on 2006/04/26 09:54:24 UTC
svn commit: r397136 [2/3] - in
/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security:
./ cert/
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Policy.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Policy.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Policy.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Policy.java Wed Apr 26 00:54:18 2006
@@ -28,9 +28,9 @@
/**
- * @com.intel.drl.spec_ref
+ * Abstract superclass of classes which represent the system security policy.
+ *
*/
-
public abstract class Policy {
// Key to security properties, defining default policy provider.
@@ -47,20 +47,40 @@
// The policy currently in effect.
private static Policy activePolicy;
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers a PermissionCollection describing what permissions are available
+ * to the given CodeSource based on the current security policy.
+ * <p>
+ * Note that this method is <em>not</em> called for classes which are in
+ * the system domain (i.e. system classes). System classes are
+ * <em>always</em> given full permissions (i.e. AllPermission). This can
+ * not be changed by installing a new Policy.
+ *
+ *
+ * @param cs
+ * CodeSource the code source to compute the permissions for.
+ * @return PermissionCollection the permissions the code source should have.
+ */
public abstract PermissionCollection getPermissions(CodeSource cs);
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Reloads the policy configuration, depending on how the type of source
+ * location for the policy information.
+ *
+ *
+ */
public abstract void refresh();
- /**
- * @com.intel.drl.spec_ref
- * The returned collection does not include static permissions of the domain.
- */
+ /**
+ * Answers a PermissionCollection describing what permissions are available
+ * to the given ProtectionDomain (more specifically, its CodeSource) based
+ * on the current security policy.
+ *
+ * @param domain
+ * ProtectionDomain the protection domain to compute the
+ * permissions for.
+ * @return PermissionCollection the permissions the code source should have.
+ */
public PermissionCollection getPermissions(ProtectionDomain domain) {
if (domain != null) {
return getPermissions(domain.getCodeSource());
@@ -68,9 +88,16 @@
return new Permissions();
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers whether the Permission is implied by the PermissionCollection of
+ * the Protection Domain
+ *
+ * @param domain
+ * ProtectionDomain for which Permission to be checked
+ * @param permission
+ * Permission for which authorization is to be verified
+ * @return boolean Permission implied by ProtectionDomain
+ */
public boolean implies(ProtectionDomain domain, Permission permission) {
if (domain != null) {
PermissionCollection total = getPermissions(domain);
@@ -89,11 +116,13 @@
return false;
}
- /**
- * @com.intel.drl.spec_ref
- * If policy was set to <code>null</code>, loads default provider,
- * so this method never returns <code>null</code>.
- */
+ /**
+ * Answers the current system security policy. If no policy has been
+ * instantiated then this is done using the security property <EM>policy.provider</EM>
+ *
+ *
+ * @return Policy the current system security policy.
+ */
public static Policy getPolicy() {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
@@ -166,11 +195,13 @@
return current;
}
- /**
- * @com.intel.drl.spec_ref
- * Policy assigment is synchronized with default provider loading, to avoid
- * non-deterministic behavior.
- */
+ /**
+ * Sets the system-wide policy object if it is permitted by the security
+ * manager.
+ *
+ * @param policy
+ * Policy the policy object that needs to be set.
+ */
public static void setPolicy(Policy policy) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Principal.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Principal.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Principal.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Principal.java Wed Apr 26 00:54:18 2006
@@ -21,10 +21,12 @@
package java.security;
-/**
- * @com.intel.drl.spec_ref
- */
+/**
+ * Principals are objects which have identities. These can be individuals,
+ * groups, corporations, unique program executions, etc.
+ *
+ */
public interface Principal {
/**
* @com.intel.drl.spec_ref
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/PrivilegedActionException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/PrivilegedActionException.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/PrivilegedActionException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/PrivilegedActionException.java Wed Apr 26 00:54:18 2006
@@ -22,7 +22,9 @@
package java.security;
/**
- * @com.intel.drl.spec_ref
+ * Instances of this class are used to wrap exceptions which occur within
+ * privileged operations.
+ *
*/
public class PrivilegedActionException extends Exception {
@@ -36,35 +38,44 @@
*/
private Exception exception;
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its exception filled in.
+ * @param ex
+ */
public PrivilegedActionException(Exception ex) {
super(ex);
this.exception = ex;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers the exception which caused the receiver to be thrown.
+ * @return exception
+ */
public Exception getException() {
return exception; // return ( getCause() instanceof Exception ) ?
// getCause() : null;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers the cause of this Throwable, or null if there is no cause.
+ *
+ *
+ * @return Throwable The receiver's cause.
+ */
public Throwable getCause() {
return exception;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers a string containing a concise, human-readable description of the
+ * receiver.
+ *
+ *
+ * @return String a printable representation for the receiver.
+ */
public String toString() {
String s = getClass().getName();
return exception == null ? s : s + ": " + exception;
}
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/ProtectionDomain.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/ProtectionDomain.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/ProtectionDomain.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/ProtectionDomain.java Wed Apr 26 00:54:18 2006
@@ -22,7 +22,11 @@
package java.security;
/**
- * @com.intel.drl.spec_ref
+ * This class represents a domain in which classes from the same source (URL)
+ * and signed by the same keys are stored. All the classes inside are given the
+ * same permissions.
+ * <p>
+ * Note: a class can only belong to one and only one protection domain.
*/
public class ProtectionDomain {
@@ -42,9 +46,13 @@
// permissions, true otherwise.
private boolean dynamicPerms;
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Contructs a protection domain from the given code source and the
+ * permissions that that should be granted to the classes which are
+ * encapsulated in it.
+ * @param cs
+ * @param permissions
+ */
public ProtectionDomain(CodeSource cs, PermissionCollection permissions) {
this.codeSource = cs;
if (permissions != null) {
@@ -56,9 +64,23 @@
//dynamicPerms = false;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Contructs a protection domain from the given code source and the
+ * permissions that that should be granted to the classes which are
+ * encapsulated in it.
+ *
+ * This constructor also allows the association of a ClassLoader and group
+ * of Principals.
+ *
+ * @param cs
+ * the CodeSource associated with this domain
+ * @param permissions
+ * the Permissions associated with this domain
+ * @param cl
+ * the ClassLoader associated with this domain
+ * @param principals
+ * the Principals associated with this domain
+ */
public ProtectionDomain(CodeSource cs, PermissionCollection permissions,
ClassLoader cl, Principal[] principals) {
this.codeSource = cs;
@@ -75,30 +97,41 @@
dynamicPerms = true;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Returns the ClassLoader associated with the ProtectionDomain
+ *
+ * @return ClassLoader associated ClassLoader
+ */
public final ClassLoader getClassLoader() {
return classLoader;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers the code source of this domain.
+ *
+ * @return java.security.CodeSource the code source of this domain
+ */
public final CodeSource getCodeSource() {
return codeSource;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers the permissions that should be granted to the classes which are
+ * encapsulated in this domain.
+ *
+ * @return java.security.PermissionCollection collection of permissions
+ * associated with this domain.
+ */
public final PermissionCollection getPermissions() {
return permissions;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Returns the Principals associated with this ProtectionDomain. A change to
+ * the returned array will not impact the ProtectionDomain.
+ *
+ * @return Principals[] Principals associated with the ProtectionDomain.
+ */
public final Principal[] getPrincipals() {
if( principals == null ) {
return new Principal[0];
@@ -108,9 +141,16 @@
return tmp;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Determines whether the permission collection of this domain implies the
+ * argument permission.
+ *
+ *
+ * @return boolean true if this permission collection implies the argument
+ * and false otherwise.
+ * @param permission
+ * java.security.Permission the permission to check.
+ */
public boolean implies(Permission permission) {
// First, test with the Policy, as the default Policy.implies()
// checks for both dynamic and static collections of the
@@ -127,9 +167,12 @@
return permissions == null ? false : permissions.implies(permission);
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers a string containing a concise, human-readable description of the
+ * receiver.
+ *
+ * @return String a printable representation for the receiver.
+ */
public String toString() {
//FIXME: 1.5 use StreamBuilder here
StringBuffer buf = new StringBuffer(200);
@@ -177,4 +220,4 @@
}
return buf.toString();
}
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Provider.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Provider.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Provider.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Provider.java Wed Apr 26 00:54:18 2006
@@ -119,34 +119,46 @@
putProviderInfo();
}
- /**
- * @com.intel.drl.spec_ref
- *
- */
+ /**
+ * Returns the name of this provider.
+ *
+ *
+ *
+ * @return String name of the provider
+ */
public String getName() {
return name;
}
- /**
- * @com.intel.drl.spec_ref
- *
- */
+ /**
+ * Returns the version number for the services being provided
+ *
+ *
+ *
+ * @return double version number for the services being provided
+ */
public double getVersion() {
return version;
}
- /**
- * @com.intel.drl.spec_ref
- *
- */
+ /**
+ * Returns the generic information about the services being provided.
+ *
+ *
+ *
+ * @return String generic description of the services being provided
+ */
public String getInfo() {
return info;
}
- /**
- * @com.intel.drl.spec_ref
- *
- */
+ /**
+ * Answers a string containing a concise, human-readable description of the
+ * receiver.
+ *
+ *
+ * @return a printable representation for the receiver.
+ */
public String toString() {
return name + " provider, Ver. " + version + " " + info;
}
@@ -980,10 +992,13 @@
return true;
}
- /**
- * @com.intel.drl.spec_ref
- *
- */
+ /**
+ * Answers a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ *
+ * @return a printable representation for the receiver.
+ */
public String toString() {
String result = "Provider " + provider.getName() + " Service "
+ type + "." + algorithm + " " + className;
@@ -996,4 +1011,4 @@
return result;
}
}
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/PublicKey.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/PublicKey.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/PublicKey.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/PublicKey.java Wed Apr 26 00:54:18 2006
@@ -22,12 +22,15 @@
package java.security;
/**
- * @com.intel.drl.spec_ref
+ * Superinterface for all specific public key interfaces
*
+ *
+ * @see PublicKey
+ * @see PrivateKey
*/
public interface PublicKey extends Key {
/**
* @com.intel.drl.spec_ref
*/
public static final long serialVersionUID = 7187392471159151072L;
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SecureClassLoader.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SecureClassLoader.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SecureClassLoader.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SecureClassLoader.java Wed Apr 26 00:54:18 2006
@@ -25,7 +25,11 @@
import java.util.HashMap;
/**
- * @com.intel.drl.spec_ref
+ * SecureClassLoaders are used to dynamically load, link and install classes
+ * into a running image. Additionally, they (optionally) associate the classes
+ * they create with a code source and provide mechanisms to allow the relevant
+ * permissions to be retrieved.
+ *
*/
public class SecureClassLoader extends ClassLoader {
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SecureRandom.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SecureRandom.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SecureRandom.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SecureRandom.java Wed Apr 26 00:54:18 2006
@@ -1,349 +1,383 @@
-/*
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
-* @author Boris V. Kuznetsov
-* @version $Revision$
-*/
-
-package java.security;
-
-import java.util.Iterator;
-import java.util.Random;
-import java.util.Set;
-
-import org.apache.harmony.security.fortress.Engine;
-import org.apache.harmony.security.fortress.Services;
-
-
-/**
- * @com.intel.drl.spec_ref
- *
- */
-
-public class SecureRandom extends Random {
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- private static final long serialVersionUID = 4940670005562187L;
-
- // The service name.
- private static final transient String SERVICE = "SecureRandom";
-
- // Used to access common engine functionality
- private static transient Engine engine = new Engine(SERVICE);
-
- /**
- * @com.intel.drl.spec_ref
- */
- private Provider provider;
-
- /**
- * @com.intel.drl.spec_ref
- */
- private SecureRandomSpi secureRandomSpi;
-
- /**
- * @com.intel.drl.spec_ref
- */
- private String algorithm;
-
- /**
- * @com.intel.drl.spec_ref
- */
- private byte[] state;
-
- /**
- * @com.intel.drl.spec_ref
- */
- private byte[] randomBytes;
-
- /**
- * @com.intel.drl.spec_ref
- */
- private int randomBytesUsed;
-
- /**
- * @com.intel.drl.spec_ref
- */
- private long counter;
-
- // Internal SecureRandom used for getSeed(int)
- private static transient SecureRandom internalSecureRandom;
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public SecureRandom() {
- super(0);
- Provider.Service service = findService();
- if (service == null) {
- this.provider = null;
- this.secureRandomSpi = new DummySecureRandom();
- this.algorithm = "java.util.Random";
- } else {
- try {
- this.provider = service.getProvider();
- this.secureRandomSpi = (SecureRandomSpi)service.newInstance(null);
- this.algorithm = service.getAlgorithm();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public SecureRandom(byte[] seed) {
- this();
- setSeed(seed);
- }
-
- //Find SecureRandom service.
- private Provider.Service findService() {
- Set s;
- Provider.Service service;
- for (Iterator it1 = Services.getProvidersList().iterator(); it1.hasNext();) {
- service = ((Provider)it1.next()).getService("SecureRandom");
- if (service != null) {
- return service;
- }
- }
- return null;
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- protected SecureRandom(SecureRandomSpi secureRandomSpi,
- Provider provider) {
- this(secureRandomSpi, provider, null);
- }
-
- // Constructor
- private SecureRandom(SecureRandomSpi secureRandomSpi,
- Provider provider,
- String algorithm) {
- super(0);
- this.provider = provider;
- this. algorithm = algorithm;
- this.secureRandomSpi = secureRandomSpi;
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public static SecureRandom getInstance(String algorithm)
- throws NoSuchAlgorithmException {
- if (algorithm == null) {
- throw new NullPointerException("Algorithm is null");
- }
- synchronized (engine) {
- engine.getInstance(algorithm, null);
- return new SecureRandom((SecureRandomSpi)engine.spi, engine.provider, algorithm);
- }
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public static SecureRandom getInstance(String algorithm, String provider)
- throws NoSuchAlgorithmException, NoSuchProviderException {
- if ((provider == null) || (provider.length() == 0)) {
- throw new IllegalArgumentException(
- "Provider is null or empty string");
- }
- Provider p = Security.getProvider(provider);
- if (p == null) {
- throw new NoSuchProviderException("Provider "+ provider + " is not available");
- }
- return getInstance(algorithm, p);
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public static SecureRandom getInstance(String algorithm, Provider provider)
- throws NoSuchAlgorithmException {
- if (provider == null) {
- throw new IllegalArgumentException("Provider is null");
- }
- if (algorithm == null) {
- throw new NullPointerException("Algorithm is null");
- }
- synchronized (engine) {
- engine.getInstance(algorithm, provider, null);
- return new SecureRandom((SecureRandomSpi)engine.spi, provider, algorithm);
- }
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public final Provider getProvider() {
- return provider;
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public String getAlgorithm() {
- return algorithm;
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public synchronized void setSeed(byte[] seed) {
- secureRandomSpi.engineSetSeed(seed);
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public void setSeed(long seed) {
- if (seed == 0) { // skip call from Random
- return;
- }
- byte[] byteSeed = {
- (byte)((seed >> 56) & 0xFF),
- (byte)((seed >> 48) & 0xFF),
- (byte)((seed >> 40) & 0xFF),
- (byte)((seed >> 32) & 0xFF),
- (byte)((seed >> 24) & 0xFF),
- (byte)((seed >> 16) & 0xFF),
- (byte)((seed >> 8) & 0xFF),
- (byte)((seed) & 0xFF)
- };
- setSeed(byteSeed);
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public synchronized void nextBytes(byte[] bytes) {
- secureRandomSpi.engineNextBytes(bytes);
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- protected final int next(int numBits) {
- if (numBits < 0) {
- numBits = 0;
- } else {
- if (numBits > 32) {
- numBits = 32;
- }
- }
- int bytes = (numBits+7)/8;
- byte[] next = new byte[bytes];
- int ret = 0;
-
- nextBytes(next);
- for (int i = 0; i < bytes; i++) {
- ret = (next[i] & 0xFF) | (ret << 8);
- }
- ret = ret >> (bytes*8 - numBits);
- return ret;
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public static byte[] getSeed(int numBytes) {
- if (internalSecureRandom == null) {
- internalSecureRandom = new SecureRandom();
- }
- return internalSecureRandom.generateSeed(numBytes);
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public byte[] generateSeed(int numBytes) {
- return secureRandomSpi.engineGenerateSeed(numBytes);
- }
-
- /**
- *
- * Dummy SecureRandom based on Random
- *
- */
- private class DummySecureRandom extends SecureRandomSpi {
-
- Random rand;
-
- // Creates SecureRandomSpi object
- public DummySecureRandom() {
- rand = new Random();
- }
-
- // Creates SecureRandomSpi object
- public DummySecureRandom(long seed) {
- rand = new Random(seed);
- }
-
- // Sets the seed of this random number generator
- public void engineSetSeed(byte[] seed) {
- long l = 0;
- int length = 8;
-
- if (seed.length < 8) {
- length = seed.length;
- }
- for (int i = 0; i < length; i++) {
- l = (l << 8) | (seed[i] & 0xFF);
- }
- rand.setSeed(l);
- }
-
- // Generates random bytes and places them into a byte array
- public void engineNextBytes(byte[] bytes) {
- rand.nextBytes(bytes);
- }
-
- // Generates random bytes
- //
- // @param numBytes
- // @return An array of random bytes
- public byte[] engineGenerateSeed(int numBytes) {
- if (numBytes < 1) {
- return null;
- }
- byte[] next = new byte[numBytes];
- nextBytes(next);
- return next;
- }
- }
-}
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+* @author Boris V. Kuznetsov
+* @version $Revision$
+*/
+
+package java.security;
+
+import java.util.Iterator;
+import java.util.Random;
+import java.util.Set;
+
+import org.apache.harmony.security.fortress.Engine;
+import org.apache.harmony.security.fortress.Services;
+
+
+/**
+ * @com.intel.drl.spec_ref
+ *
+ */
+
+public class SecureRandom extends Random {
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ private static final long serialVersionUID = 4940670005562187L;
+
+ // The service name.
+ private static final transient String SERVICE = "SecureRandom";
+
+ // Used to access common engine functionality
+ private static transient Engine engine = new Engine(SERVICE);
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ private Provider provider;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ private SecureRandomSpi secureRandomSpi;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ private String algorithm;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ private byte[] state;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ private byte[] randomBytes;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ private int randomBytesUsed;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ private long counter;
+
+ // Internal SecureRandom used for getSeed(int)
+ private static transient SecureRandom internalSecureRandom;
+
+ /**
+ * Constructs a new instance of this class. Users are encouraged to use
+ * <code>getInstance()</code> instead.
+ *
+ * An implementation for the highest-priority provider is returned. The
+ * instance returned will not have been seeded.
+ */
+ public SecureRandom() {
+ super(0);
+ Provider.Service service = findService();
+ if (service == null) {
+ this.provider = null;
+ this.secureRandomSpi = new DummySecureRandom();
+ this.algorithm = "java.util.Random";
+ } else {
+ try {
+ this.provider = service.getProvider();
+ this.secureRandomSpi = (SecureRandomSpi)service.newInstance(null);
+ this.algorithm = service.getAlgorithm();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ /**
+ * Constructs a new instance of this class. Users are encouraged to use
+ * <code>getInstance()</code> instead.
+ *
+ * An implementation for the highest-priority provider is returned. The
+ * instance returned will be seeded with the parameter.
+ *
+ * @param seed
+ * bytes forming the seed for this generator.
+ */
+ public SecureRandom(byte[] seed) {
+ this();
+ setSeed(seed);
+ }
+
+ //Find SecureRandom service.
+ private Provider.Service findService() {
+ Set s;
+ Provider.Service service;
+ for (Iterator it1 = Services.getProvidersList().iterator(); it1.hasNext();) {
+ service = ((Provider)it1.next()).getService("SecureRandom");
+ if (service != null) {
+ return service;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ protected SecureRandom(SecureRandomSpi secureRandomSpi,
+ Provider provider) {
+ this(secureRandomSpi, provider, null);
+ }
+
+ // Constructor
+ private SecureRandom(SecureRandomSpi secureRandomSpi,
+ Provider provider,
+ String algorithm) {
+ super(0);
+ this.provider = provider;
+ this. algorithm = algorithm;
+ this.secureRandomSpi = secureRandomSpi;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ public static SecureRandom getInstance(String algorithm)
+ throws NoSuchAlgorithmException {
+ if (algorithm == null) {
+ throw new NullPointerException("Algorithm is null");
+ }
+ synchronized (engine) {
+ engine.getInstance(algorithm, null);
+ return new SecureRandom((SecureRandomSpi)engine.spi, engine.provider, algorithm);
+ }
+ }
+
+ /**
+ * Answers a new SecureRandom which is capable of running the algorithm
+ * described by the argument. The result will be an instance of a subclass
+ * of SecureRandomSpi which implements that algorithm.
+ *
+ * @param algorithm
+ * java.lang.String Name of the algorithm desired
+ * @param provider
+ * java.security.Provider Provider which has to implement the
+ * algorithm
+ * @return SecureRandom a concrete implementation for the algorithm desired.
+ *
+ * @exception NoSuchAlgorithmException
+ * If the algorithm cannot be found
+ */
+ public static SecureRandom getInstance(String algorithm, String provider)
+ throws NoSuchAlgorithmException, NoSuchProviderException {
+ if ((provider == null) || (provider.length() == 0)) {
+ throw new IllegalArgumentException(
+ "Provider is null or empty string");
+ }
+ Provider p = Security.getProvider(provider);
+ if (p == null) {
+ throw new NoSuchProviderException("Provider "+ provider + " is not available");
+ }
+ return getInstance(algorithm, p);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ public static SecureRandom getInstance(String algorithm, Provider provider)
+ throws NoSuchAlgorithmException {
+ if (provider == null) {
+ throw new IllegalArgumentException("Provider is null");
+ }
+ if (algorithm == null) {
+ throw new NullPointerException("Algorithm is null");
+ }
+ synchronized (engine) {
+ engine.getInstance(algorithm, provider, null);
+ return new SecureRandom((SecureRandomSpi)engine.spi, provider, algorithm);
+ }
+ }
+
+ /**
+ * Returns the Provider of the secure random represented by the receiver.
+ *
+ * @return Provider an instance of a subclass of java.security.Provider
+ */
+ public final Provider getProvider() {
+ return provider;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ public String getAlgorithm() {
+ return algorithm;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ public synchronized void setSeed(byte[] seed) {
+ secureRandomSpi.engineSetSeed(seed);
+ }
+
+ /**
+ * Reseeds this random object with the eight bytes described by the
+ * representation of the long provided.
+ *
+ *
+ * @param seed
+ * long Number whose representation to use to reseed the
+ * receiver.
+ */
+ public void setSeed(long seed) {
+ if (seed == 0) { // skip call from Random
+ return;
+ }
+ byte[] byteSeed = {
+ (byte)((seed >> 56) & 0xFF),
+ (byte)((seed >> 48) & 0xFF),
+ (byte)((seed >> 40) & 0xFF),
+ (byte)((seed >> 32) & 0xFF),
+ (byte)((seed >> 24) & 0xFF),
+ (byte)((seed >> 16) & 0xFF),
+ (byte)((seed >> 8) & 0xFF),
+ (byte)((seed) & 0xFF)
+ };
+ setSeed(byteSeed);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ public synchronized void nextBytes(byte[] bytes) {
+ secureRandomSpi.engineNextBytes(bytes);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ protected final int next(int numBits) {
+ if (numBits < 0) {
+ numBits = 0;
+ } else {
+ if (numBits > 32) {
+ numBits = 32;
+ }
+ }
+ int bytes = (numBits+7)/8;
+ byte[] next = new byte[bytes];
+ int ret = 0;
+
+ nextBytes(next);
+ for (int i = 0; i < bytes; i++) {
+ ret = (next[i] & 0xFF) | (ret << 8);
+ }
+ ret = ret >> (bytes*8 - numBits);
+ return ret;
+ }
+
+ /**
+ * Returns the given number of seed bytes, computed using the seed
+ * generation algorithm used by this class.
+ *
+ * @param numBytes
+ * int the given number of seed bytes
+ * @return byte[] The seed bytes generated
+ */
+ public static byte[] getSeed(int numBytes) {
+ if (internalSecureRandom == null) {
+ internalSecureRandom = new SecureRandom();
+ }
+ return internalSecureRandom.generateSeed(numBytes);
+ }
+
+ /**
+ * Generates a certain number of seed bytes
+ *
+ *
+ * @param numBytes
+ * int Number of seed bytes to generate
+ * @return byte[] The seed bytes generated
+ */
+ public byte[] generateSeed(int numBytes) {
+ return secureRandomSpi.engineGenerateSeed(numBytes);
+ }
+
+ /**
+ *
+ * Dummy SecureRandom based on Random
+ *
+ */
+ private class DummySecureRandom extends SecureRandomSpi {
+
+ Random rand;
+
+ // Creates SecureRandomSpi object
+ public DummySecureRandom() {
+ rand = new Random();
+ }
+
+ // Creates SecureRandomSpi object
+ public DummySecureRandom(long seed) {
+ rand = new Random(seed);
+ }
+
+ // Sets the seed of this random number generator
+ public void engineSetSeed(byte[] seed) {
+ long l = 0;
+ int length = 8;
+
+ if (seed.length < 8) {
+ length = seed.length;
+ }
+ for (int i = 0; i < length; i++) {
+ l = (l << 8) | (seed[i] & 0xFF);
+ }
+ rand.setSeed(l);
+ }
+
+ // Generates random bytes and places them into a byte array
+ public void engineNextBytes(byte[] bytes) {
+ rand.nextBytes(bytes);
+ }
+
+ // Generates random bytes
+ //
+ // @param numBytes
+ // @return An array of random bytes
+ public byte[] engineGenerateSeed(int numBytes) {
+ if (numBytes < 1) {
+ return null;
+ }
+ byte[] next = new byte[numBytes];
+ nextBytes(next);
+ return next;
+ }
+ }
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SecureRandomSpi.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SecureRandomSpi.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SecureRandomSpi.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SecureRandomSpi.java Wed Apr 26 00:54:18 2006
@@ -24,10 +24,10 @@
import java.io.Serializable;
/**
- * @com.intel.drl.spec_ref
+ * This class is a Service Provider Interface (therefore the Spi suffix) for
+ * secure random number generation algorithms to be supplied by providers.
*
*/
-
public abstract class SecureRandomSpi implements Serializable {
/**
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Security.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Security.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Security.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Security.java Wed Apr 26 00:54:18 2006
@@ -42,12 +42,9 @@
import org.apache.harmony.security.fortress.SecurityAccess;
import org.apache.harmony.security.fortress.Services;
-
/**
- * @com.intel.drl.spec_ref
- *
+ * For access to security providers and properties.
*/
-
public final class Security {
// Security properties
@@ -133,11 +130,13 @@
// + "No providers registered.");
}
- /**
- * @com.intel.drl.spec_ref
- *
- * @deprecated Use {@link KeyFactory} and {@link AlgorithmParameters} to get
- * algorithm property information.
+ /**
+ * Deprecated method which returns null.
+ * @param algName
+ * @param propName
+ * @return <code>null</code>
+ *
+ * @deprecated Use AlgorithmParameters and KeyFactory instead
*/
public static String getAlgorithmProperty(String algName, String propName) {
if (algName == null || propName == null) {
@@ -179,10 +178,15 @@
return result;
}
- /**
- * @com.intel.drl.spec_ref
- *
- */
+ /**
+ * Adds the extra provider to the collection of providers.
+ * @param provider
+ *
+ * @return int The priority/position of the provider added.
+ * @exception SecurityException
+ * If there is a SecurityManager installed and it denies
+ * adding a new provider.
+ */
public static int addProvider(Provider provider) {
return insertProviderAt(provider, 0);
}
@@ -231,10 +235,19 @@
return Services.getProvider(name);
}
- /**
- * @com.intel.drl.spec_ref
- *
- */
+ /**
+ * Returns the collection of providers which meet the user supplied string
+ * filter.
+ *
+ * @param filter
+ * case-insensitive filter
+ * @return the providers which meet the user supplied string filter
+ * <code>filter</code>. A <code>null</code> value signifies
+ * that none of the installed providers meets the filter
+ * specification
+ * @exception InvalidParameterException
+ * if an unusable filter is supplied
+ */
public static Provider[] getProviders(String filter) {
if (filter == null) {
throw new NullPointerException("The filter is null");
@@ -317,10 +330,19 @@
}
}
- /**
- * @com.intel.drl.spec_ref
- *
- */
+ /**
+ * Answers the value of the security property named by the argument.
+ *
+ *
+ * @param key
+ * String The property name
+ * @return String The property value
+ *
+ * @exception SecurityException
+ * If there is a SecurityManager installed and it will not
+ * allow the property to be fetched from the current access
+ * control context.
+ */
public static String getProperty(String key) {
if (key == null) {
throw new NullPointerException("The key is null");
@@ -332,10 +354,19 @@
return secprops.getProperty(key);
}
- /**
- * @com.intel.drl.spec_ref
- *
- */
+ /**
+ * Sets a given security property.
+ *
+ *
+ * @param key
+ * String The property name.
+ * @param datnum
+ * String The property value.
+ * @exception SecurityException
+ * If there is a SecurityManager installed and it will not
+ * allow the property to be set from the current access
+ * control context.
+ */
public static void setProperty(String key, String datnum) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SecurityPermission.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SecurityPermission.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SecurityPermission.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SecurityPermission.java Wed Apr 26 00:54:18 2006
@@ -22,7 +22,8 @@
package java.security;
/**
- * @com.intel.drl.spec_ref
+ * SecurityPermission objects guard access to the mechanisms which implement
+ * security. Security permissions have names, but not actions.
*
*/
public final class SecurityPermission extends BasicPermission {
@@ -32,17 +33,26 @@
*/
private static final long serialVersionUID = 5236109936224050470L;
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Creates an instance of this class with the given name.
+ *
+ * @param name
+ * String the name of the new permission.
+ */
public SecurityPermission(String name) {
super(name);
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Creates an instance of this class with the given name and action list.
+ * The action list is ignored.
+ *
+ * @param name
+ * String the name of the new permission.
+ * @param action
+ * String ignored.
+ */
public SecurityPermission(String name, String action) {
super(name, action);
}
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SignatureException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SignatureException.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SignatureException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SignatureException.java Wed Apr 26 00:54:18 2006
@@ -22,7 +22,7 @@
package java.security;
/**
- * @com.intel.drl.spec_ref
+ * This class represents generic security exceptions.
*
*/
public class SignatureException extends GeneralSecurityException {
@@ -31,16 +31,22 @@
*/
private static final long serialVersionUID = 7509989324975124438L;
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback and message
+ * filled in.
+ *
+ *
+ * @param msg
+ * String The detail message for the exception.
+ */
public SignatureException(String msg) {
super(msg);
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback filled in.
+ *
+ */
public SignatureException() {
}
@@ -57,4 +63,4 @@
public SignatureException(Throwable cause) {
super(cause);
}
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/UnrecoverableKeyException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/UnrecoverableKeyException.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/UnrecoverableKeyException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/UnrecoverableKeyException.java Wed Apr 26 00:54:18 2006
@@ -22,7 +22,7 @@
package java.security;
/**
- * @com.intel.drl.spec_ref
+ * This class represents exceptions if a key cannot be found in the keystore.
*
*/
public class UnrecoverableKeyException extends GeneralSecurityException {
@@ -32,16 +32,22 @@
*/
private static final long serialVersionUID = 7275063078190151277L;
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback and message
+ * filled in.
+ *
+ *
+ * @param msg
+ * String The detail message for the exception.
+ */
public UnrecoverableKeyException(String msg) {
super(msg);
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback filled in.
+ *
+ */
public UnrecoverableKeyException() {
}
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/UnresolvedPermission.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/UnresolvedPermission.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/UnresolvedPermission.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/UnresolvedPermission.java Wed Apr 26 00:54:18 2006
@@ -38,14 +38,13 @@
import org.apache.harmony.security.fortress.PolicyUtils;
-
/**
- * @com.intel.drl.spec_ref
- * Technically, the resolution of UnresolvedPermissions
- * and substitution by actual permissions takes place in
- * <code>implies()</code> method of a
- * <code>Permissions</code> collection, right before
- * actual checking.
+ * Holds permissions which are of an unknown type when a policy file is read.
+ *
+ * Technically, the resolution of UnresolvedPermissions and
+ * substitution by actual permissions takes place in the
+ * <code>implies()</code> method of a <code>Permissions</code>
+ * collection, right before actual checking.
*
*/
public final class UnresolvedPermission extends Permission
@@ -73,9 +72,17 @@
// Cached hash value
private transient int hash;
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its type, name, and
+ * certificates set to the arguments by definition, actions are ignored
+ *
+ * @param type
+ * class of permission object
+ * @param name
+ * identifies the permission that could not be resolved
+ * @param actions
+ * @param certs
+ */
public UnresolvedPermission(String type, String name, String actions,
Certificate[] certs) {
super(type);
@@ -108,9 +115,19 @@
}
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Compares the argument to the receiver, and answers true if they represent
+ * the <em>same</em> object using a class specific comparison. In this
+ * case, the receiver and the object must have the same class, permission
+ * name, actions, and certificates
+ *
+ * @param obj
+ * the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object,
+ * <code>false</code> otherwise.
+ *
+ * @see #hashCode
+ */
public boolean equals(Object obj) {
if (obj == this) {
return true;
@@ -130,9 +147,15 @@
return false;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers an integer hash code for the receiver. Any two objects which
+ * answer <code>true</code> when passed to <code>equals</code> must
+ * answer the same value for this method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
public int hashCode() {
if (hash == 0) {
hash = getName().hashCode();
@@ -146,9 +169,12 @@
return hash;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers the actions associated with the receiver. Since
+ * UnresolvedPermission objects have no actions, answer the empty string.
+ *
+ * @return the actions associated with the receiver.
+ */
public String getActions() {
return "";
}
@@ -186,30 +212,43 @@
return null;
}
- /**
- * @com.intel.drl.spec_ref
- * The enclosed target permission would be resolved
- * and consulted for implication if this
- * UnresolvedPermission is an element of a
- * <code>Permissions</code> collection and the
- * collection's <code>implies()</code> method is
- * called.
- */
+ /**
+ * Indicates whether the argument permission is implied by the
+ * receiver. UnresolvedPermission objects imply nothing
+ * because nothing is known about them yet.
+ *
+ * Before actual implication checking, this method tries to
+ * resolve UnresolvedPermissions (if any) against the passed
+ * instance. Successfully resolved permissions (if any) are
+ * taken into account during further processing.
+ *
+ * @param permission
+ * the permission to check
+ * @return always replies false
+ */
public boolean implies(Permission permission) {
return false;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers a string containing a concise, human-readable description of the
+ * receiver.
+ *
+ * @return a printable representation for the receiver.
+ */
public String toString() {
return "(unresolved " + getName() + " " + targetName + " "
+ targetActions + ")";
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers a new PermissionCollection for holding permissions of this class.
+ * Answer null if any permission collection can be used.
+ *
+ * @return a new PermissionCollection or null
+ *
+ * @see java.security.BasicPermissionCollection
+ */
public PermissionCollection newPermissionCollection() {
return new UnresolvedPermissionCollection();
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CRL.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CRL.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CRL.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CRL.java Wed Apr 26 00:54:18 2006
@@ -22,8 +22,10 @@
package java.security.cert;
/**
- * @com.intel.drl.spec_ref
+ * This class represents Certificate Revocation Lists (CRLs). They are used to
+ * indicate that a given Certificate has expired already.
*
+ * @see CertificateFactory
*/
public abstract class CRL {
// The CRL type
@@ -36,20 +38,31 @@
this.type = type;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers the type of this CRL.
+ *
+ * @return String the type of this CRL.
+ */
public final String getType() {
return type;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers if a given Certificate has been revoked or not.
+ *
+ * @param cert
+ * Certificate The Certificate to test
+ *
+ * @return true if the certificate has been revoked false if the certificate
+ * has not been revoked yet
+ */
public abstract boolean isRevoked(Certificate cert);
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers a string containing a concise, human-readable description of the
+ * receiver.
+ *
+ * @return a printable representation for the receiver.
+ */
public abstract String toString();
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CRLException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CRLException.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CRLException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CRLException.java Wed Apr 26 00:54:18 2006
@@ -34,16 +34,20 @@
*/
private static final long serialVersionUID = -6694728944094197147L;
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback and message
+ * filled in.
+ *
+ * @param msg
+ * String The detail message for the exception.
+ */
public CRLException(String msg) {
super(msg);
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback filled in.
+ */
public CRLException() {
}
@@ -60,4 +64,4 @@
public CRLException(Throwable cause) {
super(cause);
}
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertPath.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertPath.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertPath.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertPath.java Wed Apr 26 00:54:18 2006
@@ -30,8 +30,17 @@
import java.util.List;
/**
- * @com.intel.drl.spec_ref
+ * An immutable certificate path that can be validated. All certificates in the
+ * path are of the same type (i.e., X509).
*
+ * A <code>CertPath</code> can be represented as a byte array in at least one
+ * supported encoding when serialized.
+ *
+ * When a <code>List</code> of the certificates is obtained it must be
+ * immutable.
+ *
+ * A <code>CertPath</code> must be thread-safe without requiring coordinated
+ * access.
*/
public abstract class CertPath implements Serializable {
/**
@@ -48,16 +57,24 @@
this.type = type;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Returns the type of <code>Certificate</code> in the
+ * <code>CertPath</code>
+ *
+ * @return <code>Certificate</code> type
+ */
public String getType() {
return type;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Returns true if <code>Certificate</code>s in the list are the same
+ * type and the lists are equal (and by implication the certificates
+ * contained within are the same).
+ *
+ * @param other
+ * <code>CertPath</code> to be compared for equality
+ */
public boolean equals(Object other) {
if (this == other) {
return true;
@@ -73,18 +90,27 @@
return false;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Overrides Object.hashCode() Defined as: hashCode = 31 *
+ * path.getType().hashCode() + path.getCertificates().hashCode();
+ *
+ * @return hash code for CertPath object
+ */
public int hashCode() {
int hash = getType().hashCode();
hash = hash*31 + getCertificates().hashCode();
return hash;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Returns a <code>String</code> representation of the
+ * <code>CertPath</code>
+ * <code>Certificate</code>s. It is the result of
+ * calling <code>toString</code> on all <code>Certificate</code>s in
+ * the <code>List</code>. <code>Certificate</code>s
+ *
+ * @return string representation of <code>CertPath</code>
+ */
public String toString() {
StringBuffer sb = new StringBuffer(getType());
sb.append(" Cert Path, len=");
@@ -103,24 +129,41 @@
}
/**
- * @com.intel.drl.spec_ref
+ * Returns an immutable List of the <code>Certificate</code>s contained
+ * in the <code>CertPath</code>.
+ *
+ * @return list of <code>Certificate</code>s in the <code>CertPath</code>
*/
public abstract List<? extends Certificate> getCertificates();
/**
- * @com.intel.drl.spec_ref
+ * Returns an encoding of the <code>CertPath</code> using the default
+ * encoding
+ *
+ * @return default encoding of the <code>CertPath</code>
+ * @throws CertificateEncodingException
*/
public abstract byte[] getEncoded()
throws CertificateEncodingException;
/**
- * @com.intel.drl.spec_ref
+ * Returns an encoding of the <code>CertPath</code> using the specified
+ * encoding
+ *
+ * @param encoding
+ * encoding that should be generated
+ * @return default encoding of the <code>CertPath</code>
+ * @throws CertificateEncodingException
*/
public abstract byte[] getEncoded(String encoding)
throws CertificateEncodingException;
/**
- * @com.intel.drl.spec_ref
+ * Return an <code>Iterator</code> over the supported encodings for a
+ * representation of the certificate path.
+ *
+ * @return <code>Iterator</code> over supported encodings (as
+ * <code>String</code>s)
*/
public abstract Iterator<String> getEncodings();
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/Certificate.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/Certificate.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/Certificate.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/Certificate.java Wed Apr 26 00:54:18 2006
@@ -34,8 +34,9 @@
import java.util.Arrays;
/**
- * @com.intel.drl.spec_ref
- *
+ * Abstract class to represent identity certificates. It represents a way to
+ * verify the binding of a Principal and its public key. Examples are X.509,
+ * PGP, and SDSI.
*/
public abstract class Certificate implements Serializable {
/**
@@ -53,16 +54,27 @@
this.type = type;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers the certificate type represented by the receiver.
+ *
+ * @return the certificate type represented by the receiver.
+ */
public final String getType() {
return type;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Compares the argument to the receiver, and answers true if they represent
+ * the <em>same</em> object using a class specific comparison. The
+ * implementation in Object answers true only if the argument is the exact
+ * same object as the receiver (==).
+ *
+ * @param other
+ * the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object
+ * <code>false</code> if it is different from this object
+ * @see #hashCode
+ */
public boolean equals(Object other) {
// obj equal to itself
if (this == other) {
@@ -80,9 +92,15 @@
return false;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers an integer hash code for the receiver. Any two objects which
+ * answer <code>true</code> when passed to <code>equals</code> must
+ * answer the same value for this method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
public int hashCode() {
try {
byte[] encoded = getEncoded();
@@ -96,14 +114,31 @@
}
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers the encoded representation for this certificate.
+ *
+ * @return the encoded representation for this certificate.
+ */
public abstract byte[] getEncoded() throws CertificateEncodingException;
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Verifies that this certificate was signed with the given public key.
+ *
+ * @param key
+ * PublicKey public key for which verification should be
+ * performed.
+ *
+ * @exception CertificateException
+ * if encoding errors are detected
+ * @exception NoSuchAlgorithmException
+ * if an unsupported algorithm is detected
+ * @exception InvalidKeyException
+ * if an invalid key is detected
+ * @exception NoSuchProviderException
+ * if there is no default provider
+ * @exception SignatureException
+ * if signature errors are detected
+ */
public abstract void verify(PublicKey key)
throws CertificateException,
NoSuchAlgorithmException,
@@ -111,9 +146,27 @@
NoSuchProviderException,
SignatureException;
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Verifies that this certificate was signed with the given public key. Uses
+ * the signature algorithm given by the provider.
+ *
+ * @param key
+ * PublicKey public key for which verification should be
+ * performed.
+ * @param sigProvider
+ * String the name of the signature provider.
+ *
+ * @exception CertificateException
+ * if encoding errors are detected
+ * @exception NoSuchAlgorithmException
+ * if an unsupported algorithm is detected
+ * @exception InvalidKeyException
+ * if an invalid key is detected
+ * @exception NoSuchProviderException
+ * if there is no default provider
+ * @exception SignatureException
+ * if signature errors are detected
+ */
public abstract void verify(PublicKey key, String sigProvider)
throws CertificateException,
NoSuchAlgorithmException,
@@ -121,14 +174,19 @@
NoSuchProviderException,
SignatureException;
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers a string containing a concise, human-readable description of the
+ * receiver.
+ *
+ * @return a printable representation for the receiver.
+ */
public abstract String toString();
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers the public key corresponding to this certificate.
+ *
+ * @return the public key corresponding to this certificate.
+ */
public abstract PublicKey getPublicKey();
/**
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateEncodingException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateEncodingException.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateEncodingException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateEncodingException.java Wed Apr 26 00:54:18 2006
@@ -22,8 +22,7 @@
package java.security.cert;
/**
- * @com.intel.drl.spec_ref
- *
+ * This class represents an encoding exception for a certificate.
*/
public class CertificateEncodingException extends CertificateException {
/**
@@ -31,18 +30,20 @@
*/
private static final long serialVersionUID = 6219492851589449162L;
- /**
- * @com.intel.drl.spec_ref
- *
- */
+ /**
+ * Constructs a new instance of this class with its walkback and message
+ * filled in.
+ *
+ * @param msg
+ * String The detail message for the exception.
+ */
public CertificateEncodingException(String msg) {
super(msg);
}
- /**
- * @com.intel.drl.spec_ref
- *
- */
+ /**
+ * Constructs a new instance of this class with its walkback filled in.
+ */
public CertificateEncodingException() {
}
@@ -61,4 +62,4 @@
public CertificateEncodingException(Throwable cause) {
super(cause);
}
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateException.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateException.java Wed Apr 26 00:54:18 2006
@@ -24,8 +24,7 @@
import java.security.GeneralSecurityException;
/**
- * @com.intel.drl.spec_ref
- *
+ * This class represents a general certificate exception.
*/
public class CertificateException extends GeneralSecurityException {
@@ -35,18 +34,20 @@
*/
private static final long serialVersionUID = 3192535253797119798L;
- /**
- * @com.intel.drl.spec_ref
- *
- */
+ /**
+ * Constructs a new instance of this class with its walkback and message
+ * filled in.
+ *
+ * @param msg
+ * String The detail message for the exception.
+ */
public CertificateException(String msg) {
super(msg);
}
- /**
- * @com.intel.drl.spec_ref
- *
- */
+ /**
+ * Constructs a new instance of this class with its walkback filled in.
+ */
public CertificateException() {
}
@@ -65,4 +66,4 @@
public CertificateException(Throwable cause) {
super(cause);
}
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateExpiredException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateExpiredException.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateExpiredException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateExpiredException.java Wed Apr 26 00:54:18 2006
@@ -22,8 +22,7 @@
package java.security.cert;
/**
- * @com.intel.drl.spec_ref
- *
+ * This class indicates that a given certificate has expired.
*/
public class CertificateExpiredException extends CertificateException {
@@ -33,18 +32,20 @@
*/
private static final long serialVersionUID = 9071001339691533771L;
- /**
- * @com.intel.drl.spec_ref
- *
- */
+ /**
+ * Constructs a new instance of this class with its walkback and message
+ * filled in.
+ *
+ * @param msg
+ * String The detail message for the exception.
+ */
public CertificateExpiredException(String msg) {
super(msg);
}
- /**
- * @com.intel.drl.spec_ref
- *
- */
+ /**
+ * Constructs a new instance of this class with its walkback filled in.
+ */
public CertificateExpiredException() {
}
-}
\ No newline at end of file
+}