From dd828f42a5c83b4270d4fbf6fce2da1878f1e84a Mon Sep 17 00:00:00 2001
From: The Android Open Source Project
+ * If a {@code SecurityManager} is installed, code calling this method needs
+ * the {@code SecurityPermission} {@code authProvider.NAME} (where NAME is
+ * the provider name) to be granted, otherwise a {@code SecurityException}
+ * will be thrown.
*
+ * @param subject
+ * the subject that is used to login.
+ * @param handler
+ * the handler to obtain authentication information from the
+ * caller.
+ * @throws LoginException
+ * if the login fails.
+ * @throws SecurityException
+ * if a {@code SecurityManager} is installed and the caller does
+ * not have permission to invoke this method.
+ * @since Android 1.0
*/
public abstract void login(Subject subject, CallbackHandler handler) throws LoginException;
/**
- * @com.intel.drl.spec_ref
+ * Performs a logout from this {@code AuthProvider}.
+ *
+ * If a {@code SecurityManager} is installed, code calling this method needs
+ * the {@code SecurityPermission} {@code authProvider.NAME} (where NAME is
+ * the provider name) to be granted, otherwise a {@code SecurityException}
+ * will be thrown.
+ *
+ * If no handler is set, this {@code AuthProvider} uses the {@code
+ * CallbackHandler} specified by the {@code
+ * auth.login.defaultCallbackHandler} security property.
+ *
+ * If a {@code SecurityManager} is installed, code calling this method needs
+ * the {@code SecurityPermission} {@code authProvider.NAME} (where NAME is
+ * the provider name) to be granted, otherwise a {@code SecurityException}
+ * will be thrown.
+ *
+ * Names of a BasicPermission follow the dot separated, hierarchical property
+ * naming convention. Asterisk '*' can be used as wildcards. Either by itself,
+ * matching anything, or at the end of the name, immediately preceded by a '.'.
+ * For example:
*
+ * Policy
so that it has a consistent call
- * pattern across all Permissions. The name and action list are both
+ * Constructs a new instance of {@code AllPermission}. The two argument
+ * version is provided for class {@code Policy} so that it has a consistent
+ * call pattern across all permissions. The name and action list are both
* ignored.
*
* @param name
- * java.lang.String ignored.
+ * ignored.
* @param actions
- * java.lang.String ignored.
+ * ignored.
+ * @since Android 1.0
*/
public AllPermission(String name, String actions) {
super(ALL_PERMISSIONS);
}
/**
- * Constructs a new instance of this class.
+ * Constructs a new instance of {@code AllPermission}.
+ *
+ * @since Android 1.0
*/
public AllPermission() {
super(ALL_PERMISSIONS);
}
/**
- * Compares the argument to the receiver, and returns true if they represent
- * the same object using a class specific comparison. All
- * AllPermissions are equal to each other.
+ * Compares the specified object with this {@code AllPermission} for
+ * equality and returns {@code true} if the specified object is equal,
+ * {@code false} otherwise. To be equal, the given object needs to be an
+ * instance of {@code AllPermission}.
*
* @param obj
- * the object to compare with this object
- * @return true
if the object is the same as this object
- * false
if it is different from this object
+ * object to be compared for equality with this {@code
+ * AllPermission}.
+ * @return {@code true} if the specified object is equal to this {@code
+ * AllPermission}, otherwise {@code false}.
+ * @since Android 1.0
* @see #hashCode
*/
public boolean equals(Object obj) {
@@ -74,48 +79,50 @@ public final class AllPermission extends Permission {
}
/**
- * Returns an integer hash code for the receiver. Any two objects which
- * answer true
when passed to equals
must
- * answer the same value for this method.
+ * Returns the hash code value for this {@code AllPermission}. Returns the
+ * same hash code for {@code AllPermission}s that are equal to each other as
+ * required by the general contract of {@link Object#hashCode}.
*
- * @return the receiver's hash
- *
- * @see #equals
+ * @return the hash code value for this {@code AllPermission}.
+ * @see Object#equals(Object)
+ * @see AllPermission#equals(Object)
+ * @since Android 1.0
*/
public int hashCode() {
return 1;
}
/**
- * Returns the actions associated with the receiver. Since AllPermission
- * objects allow all actions, answer with the string "true
if the argument permission is implied
- * by the receiver, and false
if it is not.
+ * @return always {@code true}.
* @param permission
- * java.security.Permission the permission to check
+ * the permission to check.
+ * @since Android 1.0
*/
public boolean implies(Permission permission) {
return true;
}
/**
- * Returns a new PermissionCollection for holding permissions of this class.
- * Answer null if any permission collection can be used.
- *
- * @return a new PermissionCollection or null
+ * Returns a new {@code PermissionCollection} for holding permissions of
+ * this class.
*
- * @see java.security.BasicPermissionCollection
+ * @return a new {@code PermissionCollection}.
+ * @since Android 1.0
*/
public PermissionCollection newPermissionCollection() {
return new AllPermissionCollection();
diff --git a/security/src/main/java/java/security/AllPermissionCollection.java b/security/src/main/java/java/security/AllPermissionCollection.java
index 08b0b1e..000365d 100644
--- a/security/src/main/java/java/security/AllPermissionCollection.java
+++ b/security/src/main/java/java/security/AllPermissionCollection.java
@@ -27,10 +27,12 @@ import java.util.NoSuchElementException;
import org.apache.harmony.security.internal.nls.Messages;
/**
- * Specific PermissionCollection for storing AllPermissions. All instances of
- * AllPermission are equivalent, so it is enough to store a single added
- * instance.
+ * Specific {@code PermissionCollection} for storing {@code AllPermission}s. All
+ * instances of {@code AllPermission} are equivalent, so it is enough to store a
+ * single added instance.
*
+ * @see AllPermission
+ * @since Android 1.0
*/
final class AllPermissionCollection extends PermissionCollection {
@@ -46,7 +48,7 @@ final class AllPermissionCollection extends PermissionCollection {
private transient Permission all;
/**
- * Adds an AllPermission to the collection.
+ * Adds an {@code AllPermission} to the collection.
*/
public void add(Permission permission) {
if (isReadOnly()) {
@@ -60,7 +62,7 @@ final class AllPermissionCollection extends PermissionCollection {
}
/**
- * Returns enumeration of the collection.
+ * Returns the enumeration of the collection.
*/
public Enumerationtrue
if the argument permission is implied
- * by the receiver, and false
if it is not.
+ * @return boolean {@code true} if the argument permission is implied by the
+ * receiver, and {@code false} if it is not.
* @param permission
- * java.security.Permission the permission to check
+ * the permission to check.
*/
public boolean implies(Permission permission) {
return all != null;
}
/**
- * Writes accordingly to expected format:
- *
- *
+ * Writes the fields according to expected format, adding the boolean field
+ * {@code all_allowed} which is {@code true} if this collection is not
+ * empty.
*/
private void writeObject(java.io.ObjectOutputStream out) throws IOException {
ObjectOutputStream.PutField fields = out.putFields();
diff --git a/security/src/main/java/java/security/AuthProvider.java b/security/src/main/java/java/security/AuthProvider.java
index ae8b159..5a3be77 100644
--- a/security/src/main/java/java/security/AuthProvider.java
+++ b/security/src/main/java/java/security/AuthProvider.java
@@ -27,40 +27,94 @@ import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.login.LoginException;
/**
- * @com.intel.drl.spec_ref
+ * {@code AuthProvider} is an abstract superclass for Java Security {@code
+ * Provider} which provide login and logout.
*
+ * @since Android 1.0
*/
-
public abstract class AuthProvider extends Provider {
- /**
- * @serial
- */
private static final long serialVersionUID = 4197859053084546461L;
/**
- * @com.intel.drl.spec_ref
+ * Constructs a new instance of {@code AuthProvider} with its name, version
+ * and description.
*
+ * @param name
+ * the name of the provider.
+ * @param version
+ * the version of the provider.
+ * @param info
+ * a description of the provider.
+ * @since Android 1.0
*/
protected AuthProvider(String name, double version, String info) {
super(name, version, info);
}
/**
- * @com.intel.drl.spec_ref
+ * Performs a login into this {@code AuthProvider}. The specified {@code
+ * CallbackHandler} is used to obtain information from the caller.
+ *
+ * com.google.android.* grants all permissions under the com.google.android permission hierarchy
+ * * grants all permissions
+ *
+ *
+ * While this class ignores the action list in the + * {@link #BasicPermission(String, String)} constructor, subclasses may + * implement actions on top of this class. + *
*/ - public abstract class BasicPermission extends Permission implements Serializable { private static final long serialVersionUID = 6279438298436773498L; /** - * Creates an instance of this class with the given name and action list. + * Constructs a new instance of {@code BasicPermission} with the specified + * name. * * @param name - * String the name of the new permission. + * the name of the permission. + * @throws NullPointerException if {@code name} is {@code null}. + * @throws IllegalArgumentException if {@code name.length() == 0}. + * @since Android 1.0 */ public BasicPermission(String name) { super(name); @@ -49,13 +68,18 @@ public abstract class BasicPermission extends Permission implements } /** - * Creates an instance of this class with the given name and action list. - * The action list is ignored. + * Constructs a new instance of {@code BasicPermission} with the specified + * name. The {@code action} parameter is ignored. * * @param name - * String the name of the new permission. + * the name of the permission. * @param action - * String ignored. + * is ignored. + * @throws NullPointerException + * if {@code name} is {@code null}. + * @throws IllegalArgumentException + * if {@code name.length() == 0}. + * @since Android 1.0 */ public BasicPermission(String name, String action) { super(name); @@ -75,15 +99,20 @@ public abstract class BasicPermission extends Permission implements } /** - * Compares the argument to the receiver, and returns true if they represent - * the same object using a class specific comparison. In this - * case, the receiver and the object must have the same class and name. + * Compares the specified object with this {@code BasicPermission} for + * equality. Returns {@code true} if the specified object has the same class + * and the two {@code Permissions}s have the same name. + *+ * The {@link #implies(Permission)} method should be used for making access + * control checks. + *
* * @param obj - * the object to compare with this object - * @returntrue
if the object is the same as this object
- * false
if it is different from this object
- * @see #hashCode
+ * object to be compared for equality with this {@code
+ * BasicPermission}.
+ * @return {@code true} if the specified object is equal to this {@code
+ * BasicPermission}, otherwise {@code false}.
+ * @since Android 1.0
*/
public boolean equals(Object obj) {
if (obj == this) {
@@ -97,35 +126,38 @@ public abstract class BasicPermission extends Permission implements
}
/**
- * Returns an integer hash code for the receiver. Any two objects which
- * answer true
when passed to equals
must
- * answer the same value for this method.
+ * Returns the hash code value for this {@code BasicPermission}. Returns the
+ * same hash code for {@code BasicPermission}s that are equal to each other
+ * as required by the general contract of {@link Object#hashCode}.
*
- * @return int the receiver's hash
- *
- * @see #equals
+ * @return the hash code value for this {@code BasicPermission}.
+ * @see Object#equals(Object)
+ * @see BasicPermission#equals(Object)
+ * @since Android 1.0
*/
public int hashCode() {
return getName().hashCode();
}
/**
- * Returns the actions associated with the receiver. BasicPermission objects
- * have no actions, so answer the empty string.
+ * Returns the actions associated with this permission. Since {@code
+ * BasicPermission} instances have no actions, an empty string is returned.
*
- * @return String the actions associated with the receiver.
+ * @return an empty string.
+ * @since Android 1.0
*/
public String getActions() {
return ""; //$NON-NLS-1$
}
/**
- * Indicates whether the argument permission is implied by the receiver.
+ * Indicates whether the specified permission is implied by this permission.
*
- * @return boolean true
if the argument permission is implied
- * by the receiver, and false
if it is not.
* @param permission
- * java.security.Permission the permission to check
+ * the permission to check against this permission.
+ * @return {@code true} if the specified permission is implied by this
+ * permission, {@code false} otherwise.
+ * @since Android 1.0
*/
public boolean implies(Permission permission) {
if (permission != null && permission.getClass() == this.getClass()) {
@@ -135,9 +167,9 @@ public abstract class BasicPermission extends Permission implements
}
/**
- * Checks if thisName
implies thatName
,
+ * Checks if {@code thisName} implies {@code thatName},
* accordingly to hierarchical property naming convention.
- * It is assumed that names cannot be null or empty.
+ * It is assumed that names cannot be {@code null} or empty.
*/
static boolean nameImplies(String thisName, String thatName) {
if (thisName == thatName) {
@@ -164,19 +196,19 @@ public abstract class BasicPermission extends Permission implements
}
/**
- * Returns a new PermissionCollection for holding permissions of this class.
- * Answer null if any permission collection can be used.
+ * Returns an empty {@link PermissionCollection} for holding permissions.
* - * Note: For BasicPermission (and subclasses which do not override this - * method), the collection which is returned does not invoke the - * .implies method of the permissions which are stored in it when checking - * if the collection implies a permission. Instead, it assumes that if the - * type of the permission is correct, and the name of the permission is - * correct, there is a match. - * - * @return a new PermissionCollection or null + * For {@code PermissionCollection} (and subclasses which do not override + * this method), the collection which is returned does not invoke + * the {@link #implies(Permission)} method of the permissions which are + * stored in it when checking if the collection implies a permission. + * Instead, it assumes that if the type of the permission is correct, and + * the name of the permission is correct, there is a match. + *
* - * @see java.security.BasicPermissionCollection + * @return an empty {@link PermissionCollection} for holding permissions. + * @see BasicPermissionCollection + * @since Android 1.0 */ public PermissionCollection newPermissionCollection() { return new BasicPermissionCollection(); diff --git a/security/src/main/java/java/security/BasicPermissionCollection.java b/security/src/main/java/java/security/BasicPermissionCollection.java index 46dad02..c345865 100644 --- a/security/src/main/java/java/security/BasicPermissionCollection.java +++ b/security/src/main/java/java/security/BasicPermissionCollection.java @@ -32,10 +32,13 @@ import java.util.Map; import org.apache.harmony.security.internal.nls.Messages; /** - * Specific PermissionCollection for storing BasicPermissions of arbitrary type. + * Specific {@code PermissionCollection} for storing {@code BasicPermissions} of + * arbitrary type. * + * @see BasicPermission + * @see PermissionCollection + * @since Android 1.0 */ - final class BasicPermissionCollection extends PermissionCollection { private static final long serialVersionUID = 739301742472979399L; @@ -103,10 +106,11 @@ final class BasicPermissionCollection extends PermissionCollection { /** * Indicates whether the argument permission is implied by the receiver. * - * @return booleantrue
if the argument permission is implied
- * by the receiver, and false
if it is not.
+ * @return boolean {@code true} if the argument permission is implied by the
+ * receiver, and {@code false} if it is not.
* @param permission
- * java.security.Permission the permission to check
+ * the permission to check.
+ * @see Permission
*/
public boolean implies(Permission permission) {
if (permission == null || permission.getClass() != permClass) {
@@ -150,15 +154,21 @@ final class BasicPermissionCollection extends PermissionCollection {
* + * BasicPermission + *+ * + * s in this {@code BasicPermissionCollection}. All {@code BasicPermission}s + * in the collection must belong to the same class. The Hashtable is indexed + * by the {@code BasicPermission} name; the value of the Hashtable entry is + * the permission. *
true
if the object is the same as this object
- * false
if it is different from this object
- * @see #hashCode
+ * object to be compared for equality with this {@code
+ * CodeSource}.
+ * @return {@code true} if the specified object is equal to this {@code
+ * CodeSource}, otherwise {@code false}.
+ * @since Android 1.0
*/
public boolean equals(Object obj) {
if (obj == this) {
@@ -138,10 +163,17 @@ public class CodeSource implements Serializable {
}
/**
- * Returns the certificates held onto by the receiver.
- *
+ * Returns the certificates of this {@code CodeSource}. If the
+ * {@link #CodeSource(URL, CodeSigner[])} constructor was used to create
+ * this instance, the certificates are obtained from the supplied signers.
+ * + * External modifications of the returned {@code Certificate[]} has no + * impact on this {@code CodeSource}. + *
* - * @return Certificate[] the receiver's certificates + * @return the certificates of this {@code CodeSource} or {@code null} if + * there is none. + * @since Android 1.0 */ public final Certificate[] getCertificates() { getCertificatesNoClone(); @@ -176,6 +208,16 @@ public class CodeSource implements Serializable { return certs; } + /** + * Returns the {@code CodeSigner}s of this {@code CodeSource}. If the + * {@link #CodeSource(URL, Certificate[])} constructor was used to create + * this instance, the signers are obtained from the supplied certificates. + * Only X.509 certificates are analyzed. + * + * @return the signers of this {@code CodeSource}, or {@code null} if there + * is none. + * @since Android 1.0 + */ public final CodeSigner[] getCodeSigners() { if (signers != null) { CodeSigner[] tmp = new CodeSigner[signers.length]; @@ -265,24 +307,25 @@ public class CodeSource implements Serializable { } /** - * Returns the receiver's location. - * + * Returns the location of this {@code CodeSource}. * - * @return URL the receiver's URL + * @return the location of this {@code CodeSource}, maybe {@code null}. + * @since Android 1.0 */ public final URL getLocation() { return location; } /** - * Returns an integer hash code for the receiver. Any two objects which - * answertrue
when passed to .equals
must
- * answer the same value for this method.
+ * Returns the hash code value for this {@code CodeSource}.
+ * Returns the same hash code for {@code CodeSource}s that are
+ * equal to each other as required by the general contract of
+ * {@link Object#hashCode}.
*
- *
- * @return int the receiver's hash.
- *
- * @see #equals
+ * @return the hash code value for this {@code CodeSource}.
+ * @see Object#equals(Object)
+ * @see CodeSource#equals(Object)
+ * @since Android 1.0
*/
public int hashCode() {
//
@@ -293,13 +336,70 @@ public class CodeSource implements Serializable {
}
/**
- * Indicates whether the argument code source is implied by the receiver.
+ * Indicates whether the specified code source is implied by this {@code
+ * CodeSource}. Returns {@code true} if all of the following conditions are
+ * {@code true}, otherwise {@code false}:
+ * + *
+ * Note: If this {@code CodeSource} has a {@code null} location and not any + * certificates, this method returns {@code true}. + *
+ * Matching rules for the {@code CodeSource}'s location file: + *
+ * http: + * http://*/android/* + * http://*.google.com/android/* + * http://code.google.com/android/- + * http://code.google.com/android/security.apk + ** - * @return boolean
true
if the argument code source is
- * implied by the receiver, and false
if it is not.
* @param cs
- * CodeSource the code source to check
+ * the code source to check.
+ * @return {@code true} if the argument code source is implied by this
+ * {@code CodeSource}, otherwise {@code false}.
+ * @since Android 1.0
*/
public boolean implies(CodeSource cs) {
//
@@ -449,10 +549,11 @@ public class CodeSource implements Serializable {
/**
* Returns a string containing a concise, human-readable description of the
- * receiver.
- *
+ * this {@code CodeSource} including its location, its certificates and its
+ * signers.
*
- * @return a printable representation for the receiver.
+ * @return a printable representation for this {@code CodeSource}.
+ * @since Android 1.0
*/
public String toString() {
StringBuilder buf = new StringBuilder();
diff --git a/security/src/main/java/java/security/DigestException.java b/security/src/main/java/java/security/DigestException.java
index b63edda..d579885 100644
--- a/security/src/main/java/java/security/DigestException.java
+++ b/security/src/main/java/java/security/DigestException.java
@@ -23,44 +23,55 @@
package java.security;
/**
- * This class represents exceptions for message digest computation.
- *
+ *{@code DigestException} is a general message digest exception.
+ *
+ *@since Android 1.0
*/
public class DigestException extends GeneralSecurityException {
- /**
- * @com.intel.drl.spec_ref
- */
private static final long serialVersionUID = 5821450303093652515L;
/**
- * Constructs a new instance of this class with its walkback and message
- * filled in.
- *
+ * Constructs a new instance of {@code DigestException} with the
+ * given message.
*
* @param msg
- * String The detail message for the exception.
+ * the detail message for this exception.
+ * @since Android 1.0
*/
public DigestException(String msg) {
super(msg);
}
/**
- * Constructs a new instance of this class with its walkback filled in.
+ * Constructs a new instance of {@code DigestException}.
*
+ * @since Android 1.0
*/
public DigestException() {
}
/**
- * @com.intel.drl.spec_ref
+ * Constructs a new instance of {@code DigestException} with the
+ * given message and the cause.
+ *
+ * @param message
+ * the detail message for this exception.
+ * @param cause
+ * the exception which is the cause for this exception.
+ * @since Android 1.0
*/
public DigestException(String message, Throwable cause) {
super(message, cause);
}
/**
- * @com.intel.drl.spec_ref
+ * Constructs a new instance of {@code DigestException} with the
+ * cause.
+ *
+ * @param cause
+ * the exception which is the cause for this exception.
+ * @since Android 1.0
*/
public DigestException(Throwable cause) {
super(cause);
diff --git a/security/src/main/java/java/security/DigestInputStream.java b/security/src/main/java/java/security/DigestInputStream.java
index 84ce3ad..0db7613 100644
--- a/security/src/main/java/java/security/DigestInputStream.java
+++ b/security/src/main/java/java/security/DigestInputStream.java
@@ -27,13 +27,17 @@ import java.io.IOException;
import java.io.InputStream;
/**
- * @com.intel.drl.spec_ref
+ * {@code DigestInputStream} is a {@code FilterInputStream} which maintains an
+ * associated message digest.
*
+ * @since Android 1.0
*/
public class DigestInputStream extends FilterInputStream {
/**
- * @com.intel.drl.spec_ref
+ * The message digest for this stream.
+ *
+ * @since Android 1.0
*/
protected MessageDigest digest;
@@ -41,7 +45,14 @@ public class DigestInputStream extends FilterInputStream {
private boolean isOn = true;
/**
- * @com.intel.drl.spec_ref
+ * Constructs a new instance of this {@code DigestInputStream}, using the
+ * given {@code stream} and the {@code digest}.
+ *
+ * @param stream
+ * the input stream.
+ * @param digest
+ * the message digest.
+ * @since Android 1.0
*/
public DigestInputStream(InputStream stream, MessageDigest digest) {
super(stream);
@@ -49,42 +60,37 @@ public class DigestInputStream extends FilterInputStream {
}
/**
- * Returns the MessageDigest which the receiver uses when computing the
- * hash.
- *
- *
- * @return MessageDigest the digest the receiver uses when computing the
- * hash.
+ * Returns the message digest for this stream.
*
+ * @return the message digest for this stream.
+ * @since Android 1.0
*/
public MessageDigest getMessageDigest() {
return digest;
}
/**
- * Sets the MessageDigest which the receiver will use when computing the
- * hash.
- *
+ * Sets the message digest which this stream will use.
*
* @param digest
- * MessageDigest the digest to use when computing the hash.
- *
- * @see MessageDigest
- * @see #on
+ * the message digest which this stream will use.
+ * @since Android 1.0
*/
public void setMessageDigest(MessageDigest digest) {
this.digest = digest;
}
/**
- * Reads the next byte and returns it as an int. Updates the digest for the
- * byte if this function is enabled.
+ * Reads the next byte and returns it as an {@code int}. Updates the digest
+ * for the byte if this function is {@link #on(boolean)}.
+ * + * This operation is blocking. + *
* - * - * @return int the byte which was read or -1 at end of stream. - * - * @exception java.io.IOException - * If reading the source stream causes an IOException. + * @return the byte which was read or -1 at end of stream. + * @throws IOException + * if reading the source stream causes an {@code IOException}. + * @since Android 1.0 */ public int read() throws IOException { // read the next byte @@ -100,7 +106,25 @@ public class DigestInputStream extends FilterInputStream { } /** - * @com.intel.drl.spec_ref + * Reads {@code len} bytes into the specified {@code byte[]}, starting from + * the specified offset. Updates the digest if this function is + * {@link #on(boolean)}. + *+ * This operation is blocking. + *
+ * + * @param b + * the byte array in which to store the bytes + * @param off + * the initial position in {@code b} to store the bytes read from + * this stream + * @param len + * the maximum number of bytes to store in {@code b} + * @return the number of bytes actually read or -1 if the end of the + * filtered stream has been reached while reading + * @throws IOException + * if reading the source stream causes an {@code IOException} + * @since Android 1.0 */ public int read(byte[] b, int off, int len) throws IOException { // read next up to len bytes @@ -118,23 +142,21 @@ public class DigestInputStream extends FilterInputStream { /** * Enables or disables the digest function (default is on). * - * * @param on - * boolean true if the digest should be computed, and false + * {@code true} if the digest should be computed, {@code false} * otherwise. - * - * @see MessageDigest + * @since Android 1.0 */ public void on(boolean on) { isOn = on; } /** - * Returns a string containing a concise, human-readable description of the - * receiver. - * + * Returns a string containing a concise, human-readable description of this + * {@code DigestInputStream} including the digest. * - * @return String a printable representation for the receiver. + * @return a printable representation for this {@code DigestInputStream}. + * @since Android 1.0 */ public String toString() { return super.toString() + ", " + digest.toString() + //$NON-NLS-1$ diff --git a/security/src/main/java/java/security/DigestOutputStream.java b/security/src/main/java/java/security/DigestOutputStream.java index 9bbc593..858f8dd 100644 --- a/security/src/main/java/java/security/DigestOutputStream.java +++ b/security/src/main/java/java/security/DigestOutputStream.java @@ -27,13 +27,15 @@ import java.io.IOException; import java.io.OutputStream; /** - * @com.intel.drl.spec_ref - * + * {@code DigestOutputStream} is a {@code FilterOutputStream} which maintains an + * associated message digest. */ public class DigestOutputStream extends FilterOutputStream { /** - * @com.intel.drl.spec_ref + * The message digest for this stream. + * + * @since Android 1.0 */ protected MessageDigest digest; @@ -41,7 +43,14 @@ public class DigestOutputStream extends FilterOutputStream { private boolean isOn = true; /** - * @com.intel.drl.spec_ref + * Constructs a new instance of this {@code DigestOutputStream}, using the + * given {@code stream} and the {@code digest}. + * + * @param stream + * the output stream. + * @param digest + * the message digest. + * @since Android 1.0 */ public DigestOutputStream(OutputStream stream, MessageDigest digest) { super(stream); @@ -49,35 +58,35 @@ public class DigestOutputStream extends FilterOutputStream { } /** - * Returns the MessageDigest which the receiver uses when computing the - * hash. + * Returns the message digest for this stream. * - * - * @return MessageDigest the digest the receiver uses when computing the - * hash. + * @return the message digest for this stream. + * @since Android 1.0 */ - public MessageDigest getMessageDigest() { return digest; } /** - * Sets the MessageDigest which the receiver will use when computing the - * hash. - * + * Sets the message digest which this stream will use. * * @param digest - * MessageDigest the digest to use when computing the hash. - * - * @see MessageDigest - * @see #on + * the message digest which this stream will use. + * @since Android 1.0 */ public void setMessageDigest(MessageDigest digest) { this.digest = digest; } /** - * @com.intel.drl.spec_ref + * Writes the specified {@code int} to the stream. Updates the digest if + * this function is {@link #on(boolean)}. + * + * @param b + * the byte to be written. + * @throws IOException + * if writing to the stream causes a {@code IOException} + * @since Android 1.0 */ public void write(int b) throws IOException { // update digest only if digest functionality is on @@ -89,7 +98,18 @@ public class DigestOutputStream extends FilterOutputStream { } /** - * @com.intel.drl.spec_ref + * Writes {@code len} bytes into the stream, starting from the specified + * offset. Updates the digest if this function is {@link #on(boolean)}. + * + * @param b + * the buffer to write to. + * @param off + * the index of the first byte in {@code b} to write. + * @param len + * the number of bytes in {@code b} to write. + * @throws IOException + * if writing to the stream causes an {@code IOException}. + * @since Android 1.0 */ public void write(byte[] b, int off, int len) throws IOException { // update digest only if digest functionality is on @@ -103,23 +123,21 @@ public class DigestOutputStream extends FilterOutputStream { /** * Enables or disables the digest function (default is on). * - * * @param on - * boolean true if the digest should be computed, and false + * {@code true} if the digest should be computed, {@code false} * otherwise. - * - * @see MessageDigest + * @since Android 1.0 */ public void on(boolean on) { isOn = on; } /** - * Returns a string containing a concise, human-readable description of the - * receiver. - * + * Returns a string containing a concise, human-readable description of this + * {@code DigestOutputStream} including the digest. * - * @return String a printable representation for the receiver. + * @return a printable representation for this {@code DigestOutputStream}. + * @since Android 1.0 */ public String toString() { return super.toString() + ", " + digest.toString() + //$NON-NLS-1$ diff --git a/security/src/main/java/java/security/DomainCombiner.java b/security/src/main/java/java/security/DomainCombiner.java index db072b6..501c419 100644 --- a/security/src/main/java/java/security/DomainCombiner.java +++ b/security/src/main/java/java/security/DomainCombiner.java @@ -23,13 +23,31 @@ package java.security; /** - * A DomainCombiner is a way to update the protection domains from an - * AccessControlContext + * {@code DomainCombiner} is used to update and optimize {@code + * ProtectionDomain}s from an {@code AccessControlContext}. * + * @see AccessControlContext + * @see AccessControlContext#AccessControlContext(AccessControlContext, + * DomainCombiner) + * @since Android 1.0 */ public interface DomainCombiner { + /** - * @com.intel.drl.spec_ref + * Returns a combination of the two provided {@code ProtectionDomain} + * arrays. Implementers can simply merge the two arrays into one, remove + * duplicates and perform other optimizations. + * + * @param current + * the protection domains of the current execution thread (since + * the most recent call to {@link AccessController#doPrivileged} + * ). + * @param assigned + * the protection domains of the parent thread, maybe {@code + * null}. + * @return a single {@code ProtectionDomain} array computed from the two + * provided arrays. + * @since Android 1.0 */ ProtectionDomain[] combine(ProtectionDomain[] current, ProtectionDomain[] assigned); diff --git a/security/src/main/java/java/security/GeneralSecurityException.java b/security/src/main/java/java/security/GeneralSecurityException.java index fb8d72e..2a1cacb 100644 --- a/security/src/main/java/java/security/GeneralSecurityException.java +++ b/security/src/main/java/java/security/GeneralSecurityException.java @@ -23,44 +23,56 @@ package java.security; /** - * This class represents the general security exception. Subclasses will - * represents specific security problems. + * {@code GeneralSecurityException} is a general security exception and the + * superclass for all security specific exceptions. * + * @since Android 1.0 */ public class GeneralSecurityException extends Exception { - /** - * @com.intel.drl.spec_ref - */ + private static final long serialVersionUID = 894798122053539237L; /** - * Constructs a new instance of this class with its walkback and message - * filled in. - * + * Constructs a new instance of {@code GeneralSecurityException} with the + * given message. * * @param msg - * String The detail message for the exception. + * the detail message for this exception. + * @since Android 1.0 */ public GeneralSecurityException(String msg) { super(msg); } /** - * Constructs a new instance of this class with its walkback filled in. + * Constructs a new instance of {@code GeneralSecurityException}. * + * @since Android 1.0 */ public GeneralSecurityException() { } /** - * @com.intel.drl.spec_ref + * Constructs a new instance of {@code GeneralSecurityException} with the + * given message and the cause. + * + * @param message + * the detail message for this exception. + * @param cause + * the exception which is the cause for this exception. + * @since Android 1.0 */ public GeneralSecurityException(String message, Throwable cause) { super(message, cause); } /** - * @com.intel.drl.spec_ref + * Constructs a new instance of {@code GeneralSecurityException} with the + * cause. + * + * @param cause + * the exception which is the cause for this exception. + * @since Android 1.0 */ public GeneralSecurityException(Throwable cause) { super(cause); diff --git a/security/src/main/java/java/security/Guard.java b/security/src/main/java/java/security/Guard.java index 8042e34..1e4d270 100644 --- a/security/src/main/java/java/security/Guard.java +++ b/security/src/main/java/java/security/Guard.java @@ -23,14 +23,22 @@ package java.security; /** - * This interface is implemented by objects which wish to control access to - * other objects. + * {@code Guard} implementors protect access to other objects. * + * @since Android 1.0 */ public interface Guard { - /** - * @com.intel.drl.spec_ref + /** + * Checks whether access to the specified {@code Object} should be granted. + * This method returns silently if access is granted, otherwise a {@code + * SecurityException} is thrown. + * + * @param object + * the object to be protected by this {@code Guard}. + * @throws SecurityException + * if access is not granted. + * @since Android 1.0 */ public void checkGuard(Object object) throws SecurityException; } diff --git a/security/src/main/java/java/security/GuardedObject.java b/security/src/main/java/java/security/GuardedObject.java index b284026..a64d634 100644 --- a/security/src/main/java/java/security/GuardedObject.java +++ b/security/src/main/java/java/security/GuardedObject.java @@ -26,35 +26,29 @@ import java.io.IOException; import java.io.Serializable; /** - * GuardedObject controls access to an object, by checking all requests for the - * object with a Guard. + * {@code GuardedObject} controls access to an object, by checking all requests + * for the object with a {@code Guard}. * + * @since Android 1.0 */ public class GuardedObject implements Serializable { - /** - * @com.intel.drl.spec_ref - */ private static final long serialVersionUID = -5240450096227834308L; - /** - * @com.intel.drl.spec_ref - */ private final Object object; - /** - * @com.intel.drl.spec_ref - */ private final Guard guard; /** - * Constructs a GuardedObject to protect access to the specified Object - * using the specified Guard. + * Constructs a new instance of {@code GuardedObject} which protects access + * to the specified {@code Object} using the specified {@code Guard}. * * @param object - * the Object to guard + * the {@code Object} to protect. * @param guard - * the Guard + * the {@code Guard} which protects the specified {@code Object}, + * maybe {@code null}. + * @since Android 1.0 */ public GuardedObject(Object object, Guard guard) { this.object = object; @@ -62,15 +56,14 @@ public class GuardedObject implements Serializable { } /** - * Checks whether access should be granted to the object. If access is - * granted, this method returns the object. If it is not granted, then a - *SecurityException
is thrown.
- *
+ * Returns the guarded {@code Object} if the associated {@code Guard}
+ * permits access. If access is not granted, then a {@code
+ * SecurityException} is thrown.
*
- * @return the guarded object
- *
- * @exception java.lang.SecurityException
- * If access is not granted to the object
+ * @return the guarded object.
+ * @exception SecurityException
+ * if access is not granted to the guarded object.
+ * @since Android 1.0
*/
public Object getObject() throws SecurityException {
if (guard != null) {
@@ -79,8 +72,9 @@ public class GuardedObject implements Serializable {
return object;
}
- /**
- * Checks guard (if there is one) before performing a default serialization.
+ /**
+ * Checks the guard (if there is one) before performing a default
+ * serialization.
*/
private void writeObject(java.io.ObjectOutputStream out) throws IOException {
if (guard != null) {
diff --git a/security/src/main/java/java/security/Identity.java b/security/src/main/java/java/security/Identity.java
index 7c3469d..7111029 100644
--- a/security/src/main/java/java/security/Identity.java
+++ b/security/src/main/java/java/security/Identity.java
@@ -20,6 +20,10 @@
* @version $Revision$
*/
+// BEGIN android-note
+// Added Deprecated annotation.
+// END android-note
+
package java.security;
import java.io.Serializable;
@@ -29,9 +33,14 @@ import java.util.Arrays;
import org.apache.harmony.security.internal.nls.Messages;
/**
+ * {@code Identity} represents an identity like a person or a company.
*
- * @deprecated
+ * @deprecated The functionality of this class has been replace by
+ * {@link Principal}, {@link KeyStore} and the {@code
+ * java.security.cert} package.
+ * @since Android 1.0
*/
+@Deprecated
public abstract class Identity implements Principal, Serializable {
private static final long serialVersionUID = 3609922007826600659L;
@@ -45,13 +54,38 @@ public abstract class Identity implements Principal, Serializable {
private Vector+ * If a {@code SecurityManager} is installed, code calling this method needs + * the {@code SecurityPermission} {@code addIdentityCertificate} to be + * granted, otherwise a {@code SecurityException} will be thrown. + *
+ * + * @param certificate + * the {@code Certificate} to be added to this {@code Identity}. + * @throws KeyManagementException + * if the certificate is not valid. + * @throws SecurityException + * if a {@code SecurityManager} is installed and the caller does + * not have permission to invoke this method. + * @since Android 1.0 + */ public void addCertificate(Certificate certificate) throws KeyManagementException { SecurityManager sm = System.getSecurityManager(); @@ -105,6 +156,23 @@ public abstract class Identity implements Principal, Serializable { + /** + * Removes the specified {@code Certificate} from this {@code Identity}. + *+ * If a {@code SecurityManager} is installed, code calling this method needs + * the {@code SecurityPermission} {@code "removeIdentityCertificate"} to be + * granted, otherwise a {@code SecurityException} will be thrown. + *
+ * + * @param certificate + * the {@code Certificate} to be removed. + * @throws KeyManagementException + * if the certificate is not found. + * @throws SecurityException + * if a {@code SecurityManager} is installed and the caller does + * not have permission to invoke this method. + * @since Android 1.0 + */ public void removeCertificate(Certificate certificate) throws KeyManagementException { SecurityManager sm = System.getSecurityManager(); @@ -112,6 +180,11 @@ public abstract class Identity implements Principal, Serializable { sm.checkSecurityAccess("removeIdentityCertificate"); //$NON-NLS-1$ } if (certificates != null) { + // BEGIN android-added + if (!certificates.contains(certificate)) { + throw new KeyManagementException("Certificate not found"); + } + // END android-added certificates.removeElement(certificate); } } @@ -119,6 +192,14 @@ public abstract class Identity implements Principal, Serializable { + /** + * Returns the certificates for this {@code Identity}. External + * modifications of the returned array has no impact on this {@code + * Identity}. + * + * @return the {@code Certificates} for this {@code Identity} + * @since Android 1.0 + */ public Certificate[] certificates() { if (certificates == null) { return new Certificate[0]; @@ -131,6 +212,21 @@ public abstract class Identity implements Principal, Serializable { + /** + * Compares the specified {@code Identity} with this {@code Identity} for + * equality and returns {@code true} if the specified object is equal, + * {@code false} otherwise. + *
+ * To be equal, two {@code Identity} objects need to have the same name and + * the same public keys. + *
+ * + * @param identity + * the identity to check for equality. + * @return {@code true} if the {@code Identity} objects are equal, {@code + * false} otherwise. + * @since Android 1.0 + */ protected boolean identityEquals(Identity identity) { if (!name.equals(identity.name)) { return false; @@ -146,6 +242,15 @@ public abstract class Identity implements Principal, Serializable { + /** + * Returns a string containing a concise, human-readable description of the + * this {@code Identity}. + * + * @param detailed + * whether or not this method should return detailed information. + * @return a printable representation for this {@code Permission}. + * @since Android 1.0 + */ public String toString(boolean detailed) { String s = toString(); if (detailed) { @@ -157,6 +262,12 @@ public abstract class Identity implements Principal, Serializable { + /** + * Returns the {@code IdentityScope} of this {@code Identity}. + * + * @return the {@code IdentityScope} of this {@code Identity}. + * @since Android 1.0 + */ public final IdentityScope getScope() { return scope; } @@ -164,6 +275,24 @@ public abstract class Identity implements Principal, Serializable { + /** + * Sets the specified {@code PublicKey} to this {@code Identity}. + *+ * If a {@code SecurityManager} is installed, code calling this method needs + * the {@code SecurityPermission} {@code setIdentityPublicKey} to be + * granted, otherwise a {@code SecurityException} will be thrown. + *
+ * + * @param key + * the {@code PublicKey} to be set. + * @throws KeyManagementException + * if another {@code Identity} in the same scope as this {@code + * Identity} already has the same {@code PublicKey}. + * @throws SecurityException + * if a {@code SecurityManager} is installed and the caller does + * not have permission to invoke this method. + * @since Android 1.0 + */ public void setPublicKey(PublicKey key) throws KeyManagementException { SecurityManager sm = System.getSecurityManager(); if (sm != null) { @@ -184,6 +313,12 @@ public abstract class Identity implements Principal, Serializable { + /** + * Returns the {@code PublicKey} associated with this {@code Identity}. + * + * @return the {@code PublicKey} associated with this {@code Identity}. + * @since Android 1.0 + */ public PublicKey getPublicKey() { return publicKey; } @@ -191,6 +326,20 @@ public abstract class Identity implements Principal, Serializable { + /** + * Sets an information string for this {@code Identity}. + *+ * If a {@code SecurityManager} is installed, code calling this method needs + * the {@code SecurityPermission} {@code setIdentityInfo} to be granted, + * otherwise a {@code SecurityException} will be thrown. + * + * @param info + * the information to be set. + * @throws SecurityException + * if a {@code SecurityManager} is installed and the caller does + * not have permission to invoke this method. + * @since Android 1.0 + */ public void setInfo(String info) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { @@ -202,6 +351,12 @@ public abstract class Identity implements Principal, Serializable { + /** + * Returns the information string of this {@code Identity}. + * + * @return the information string of this {@code Identity}. + * @since Android 1.0 + */ public String getInfo() { return info; } @@ -209,6 +364,19 @@ public abstract class Identity implements Principal, Serializable { + /** + * Compares the specified object with this {@code Identity} for equality and + * returns {@code true} if the specified object is equal, {@code false} + * otherwise. {@code Identity} objects are considered equal, if they have + * the same name and are in the same scope. + * + * @param obj + * object to be compared for equality with this {@code + * Identity}. + * @return {@code true} if the specified object is equal to this {@code + * Identity}, otherwise {@code false}. + * @since Android 1.0 + */ public final boolean equals(Object obj) { if (this == obj) { return true; @@ -227,6 +395,12 @@ public abstract class Identity implements Principal, Serializable { + /** + * Returns the name of this {@code Identity}. + * + * @return the name of this {@code Identity}. + * @since Android 1.0 + */ public final String getName() { return name; } @@ -234,6 +408,16 @@ public abstract class Identity implements Principal, Serializable { + /** + * Returns the hash code value for this {@code Identity}. Returns the same + * hash code for {@code Identity}s that are equal to each other as required + * by the general contract of {@link Object#hashCode}. + * + * @return the hash code value for this {@code Identity}. + * @see Object#equals(Object) + * @see Identity#equals(Object) + * @since Android 1.0 + */ public int hashCode() { int hash = 0; if (name != null) { @@ -248,6 +432,21 @@ public abstract class Identity implements Principal, Serializable { + /** + * Returns a string containing a concise, human-readable description of the + * this {@code Identity} including its name and its scope. + *
+ * If a {@code SecurityManager} is installed, code calling this method + * needs the {@code SecurityPermission} {@code printIdentity} to be granted, + * otherwise a {@code SecurityException} will be thrown. + *
+ * + * @return a printable representation for this {@code Identity}. + * @throws SecurityException + * if a {@code SecurityManager} is installed and the caller does + * not have permission to invoke this method. + * @since Android 1.0 + */ public String toString() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { @@ -259,4 +458,4 @@ public abstract class Identity implements Principal, Serializable { } return s; } -} \ No newline at end of file +} diff --git a/security/src/main/java/java/security/IdentityScope.java b/security/src/main/java/java/security/IdentityScope.java index daa8925..93729dc 100644 --- a/security/src/main/java/java/security/IdentityScope.java +++ b/security/src/main/java/java/security/IdentityScope.java @@ -20,6 +20,10 @@ * @version $Revision$ */ +// BEGIN android-note +// Added Deprecated annotation. +// END android-note + package java.security; import java.util.Enumeration; @@ -28,35 +32,53 @@ import org.apache.harmony.security.SystemScope; /** - * @com.intel.drl.spec_ref - * @deprecated + * {@code IdentityScope} represents a scope for {@link Identity} objects. + * + * @deprecated The functionality of this class has been replace by + * {@link Principal}, {@link KeyStore} and the {@code + * java.security.cert} package. + * @since Android 1.0 */ +@Deprecated public abstract class IdentityScope extends Identity { - /** - * @com.intel.drl.spec_ref - */ private static final long serialVersionUID = -2337346281189773310L; // systemScope holds reference to the current system scope private static IdentityScope systemScope; /** - * @com.intel.drl.spec_ref + * Constructs a new instance of {@code IdentityScope}. + * + * @since Android 1.0 */ protected IdentityScope() { super(); } /** - * @com.intel.drl.spec_ref + * Constructs a new instance of {@code IdentityScope} with the specified + * name. + * + * @param name + * the name of this {@code IdentityScope}. + * @since Android 1.0 */ public IdentityScope(String name) { super(name); } /** - * @com.intel.drl.spec_ref + * Constructs a new instance of {@code IdentityScope} with the specified + * name and the specified scope. + * + * @param name + * the name of this {@code IdentityScope}. + * @param scope + * the scope of this {@code IdentityScope}. + * @throws KeyManagementException + * if an identity with the same key already exists. + * @since Android 1.0 */ public IdentityScope(String name, IdentityScope scope) throws KeyManagementException { @@ -64,7 +86,10 @@ public abstract class IdentityScope extends Identity { } /** - * @com.intel.drl.spec_ref + * Returns the system's scope. + * + * @return the system's scope. + * @since Android 1.0 */ public static IdentityScope getSystemScope() { /* @@ -90,7 +115,11 @@ public abstract class IdentityScope extends Identity { } /** - * @com.intel.drl.spec_ref + * Sets the system's scope. + * + * @param scope + * the scope to set. + * @since Android 1.0 */ protected static void setSystemScope(IdentityScope scope) { SecurityManager sm = System.getSecurityManager(); @@ -101,49 +130,98 @@ public abstract class IdentityScope extends Identity { } /** - * @com.intel.drl.spec_ref + * Returns the number of {@code Identity} objects in this scope. + * + * @return the number of {@code Identity} objects in this scope. + * @since Android 1.0 */ public abstract int size(); /** - * @com.intel.drl.spec_ref + * Returns the {@code Identity} with the specified name or {@code null} if + * no {@code Identity} with the specified name is present in this scope. + * + * @param name + * the name of the {@code Identity} to be returned. + * @return the {@code Identity} with the specified name or {@code null} if + * not present. + * @since Android 1.0 */ public abstract Identity getIdentity(String name); /** - * @com.intel.drl.spec_ref + * Returns the {@code Identity} with the name of the specified principal or + * {@code null} if no {@code Identity} with the name of the specified + * principal is present in this scope. + * + * @param principal + * the {@code Principal} whose name is used to lookup the {@code + * Identity} to be returned. + * @return the {@code Identity} with the specified name or {@code null} if + * not present. + * @since Android 1.0 */ public Identity getIdentity(Principal principal) { return getIdentity(principal.getName()); } /** - * @com.intel.drl.spec_ref + * Returns the {@code Identity} which is associated with the specified key + * or {@code null} if no {@code Identity} associated with the specified key + * is present in this scope. + * + * @param key + * the {@code PublicKey} of the {@code Identity} to be returned. + * @return the {@code Identity} associated with the specified key or {@code + * null} if not present. + * @since Android 1.0 */ public abstract Identity getIdentity(PublicKey key); /** - * @com.intel.drl.spec_ref + * Adds an {@code Identity} to this {@code IdentityScope}. + * + * @param identity + * the {@code Identity} to be added. + * @throws KeyManagementException + * if the specified {@code Identity} is invalid or an identity + * with the same key already exists. + * @since Android 1.0 */ public abstract void addIdentity(Identity identity) throws KeyManagementException; /** - * @com.intel.drl.spec_ref + * Removes an {@code Identity} from this {@code IdentityScope}. + * + * @param identity + * the {@code Identity} to be removed. + * @throws KeyManagementException + * if the {@code Identity} is not present in this scope. + * @since Android 1.0 */ public abstract void removeIdentity(Identity identity) throws KeyManagementException; /** - * @com.intel.drl.spec_ref + * Returns an {@code Enumeration} over the {@code Identity} objects in this + * {@code IdentityScope}. + * + * @return an {@code Enumeration} over the {@code Identity} objects in this + * {@code IdentityScope}. + * @since Android 1.0 */ public abstract Enumeration+ * This does exactly the same as {@link #generateKeyPair()}. + * + * @return a new unique {@code KeyPair} each time this method is called + * @since Android 1.0 */ public final KeyPair genKeyPair() { return generateKeyPair(); } + /** + * Computes and returns a new unique {@code KeyPair} each time this method + * is called. + *
+ * This does exactly the same as {@link #genKeyPair()}. + * + * @return a new unique {@code KeyPair} each time this method is called + * @since Android 1.0 + */ public KeyPair generateKeyPair() { return null; } /** - * @com.intel.drl.spec_ref - * + * Initializes this {@code KeyPairGenerator} with the given key size and the + * given {@code SecureRandom}. The default parameter set will be used. + * + * @param keysize + * the key size + * @param random + * the source of randomness + * @since Android 1.0 */ public void initialize(int keysize, SecureRandom random) { } /** - * @com.intel.drl.spec_ref - * + * Initializes this {@code KeyPairGenerator} with the given {@code + * AlgorithmParameterSpec} and the given {@code SecureRandom}. + * + * @param param + * the parameters to use + * @param random + * the source of randomness + * @throws InvalidAlgorithmParameterException + * if the specified parameters are not supported + * @since Android 1.0 */ public void initialize(AlgorithmParameterSpec param, SecureRandom random) throws InvalidAlgorithmParameterException { diff --git a/security/src/main/java/java/security/KeyPairGeneratorSpi.java b/security/src/main/java/java/security/KeyPairGeneratorSpi.java index 8e51367..272c305 100644 --- a/security/src/main/java/java/security/KeyPairGeneratorSpi.java +++ b/security/src/main/java/java/security/KeyPairGeneratorSpi.java @@ -27,33 +27,54 @@ import java.security.spec.AlgorithmParameterSpec; import org.apache.harmony.security.internal.nls.Messages; /** - * @com.intel.drl.spec_ref + * {@code KeyPairGeneratorSpi} is the Service Provider Interface (SPI) + * definition for {@link KeyPairGenerator}. * + * @see KeyPairGenerator + * @since Android 1.0 */ - public abstract class KeyPairGeneratorSpi { + /** - * @com.intel.drl.spec_ref - * + * Constructs a new instance of {@code KeyPairGeneratorSpi}. + * + * @since Android 1.0 */ public KeyPairGeneratorSpi() { } /** - * @com.intel.drl.spec_ref - * + * Computes and returns a new unique {@code KeyPair} each time this method + * is called. + * + * @return a new unique {@code KeyPair} each time this method is called. + * @since Android 1.0 */ public abstract KeyPair generateKeyPair(); /** - * @com.intel.drl.spec_ref - * + * Initializes this {@code KeyPairGeneratorSpi} with the given key size and + * the given {@code SecureRandom}. The default parameter set will be used. + * + * @param keysize + * the key size (number of bits). + * @param random + * the source of randomness. + * @since Android 1.0 */ public abstract void initialize(int keysize, SecureRandom random); /** - * @com.intel.drl.spec_ref - * + * Initializes this {@code KeyPairGeneratorSpi} with the given {@code + * AlgorithmParameterSpec} and the given {@code SecureRandom}. + * + * @param params + * the parameters to use. + * @param random + * the source of randomness. + * @throws InvalidAlgorithmParameterException + * if the specified parameters are not supported. + * @since Android 1.0 */ public void initialize(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException { diff --git a/security/src/main/java/java/security/KeyRep.java b/security/src/main/java/java/security/KeyRep.java index 957fdac..ec1d364 100644 --- a/security/src/main/java/java/security/KeyRep.java +++ b/security/src/main/java/java/security/KeyRep.java @@ -36,13 +36,13 @@ import javax.crypto.spec.SecretKeySpec; import org.apache.harmony.security.internal.nls.Messages; /** - * @com.intel.drl.spec_ref + * {@code KeyRep} is a standardized representation for serialized {@link Key} + * objects. * + * @since Android 1.0 */ public class KeyRep implements Serializable { - /** - * @com.intel.drl.spec_ref - */ + private static final long serialVersionUID = -4757683898830641853L; // Key type private final Type type; @@ -54,7 +54,23 @@ public class KeyRep implements Serializable { private byte[] encoded; /** - * @com.intel.drl.spec_ref + * Constructs a new instance of {@code KeyRep} with the specified arguments. + * The arguments should be obtained from the {@code Key} object that has to + * be serialized. + * + * @param type + * the type of the key. + * @param algorithm + * the algorithm (obtained by {@link Key#getAlgorithm()}). + * @param format + * the format of the key (obtained by {@link Key#getFormat()}). + * @param encoded + * the encoded {@code byte[]} (obtained by + * {@link Key#getEncoded()}). + * @throws NullPointerException + * if {@code type, algorithm, format or encoded} is {@code null} + * . + * @since Android 1.0 */ public KeyRep(Type type, String algorithm, String format, byte[] encoded) { @@ -77,7 +93,26 @@ public class KeyRep implements Serializable { } /** - * @com.intel.drl.spec_ref + * Resolves and returns the {@code Key} object. Three {@link Type}|format + * combinations are supported: + *
+ * The type of the system key store can be changed by setting the {@code + * 'keystore.type'} property in the file named {@code + * JAVA_HOME/lib/security/java.security}. + *
+ * + * @see Certificate + * @see PrivateKey + * @since Android 1.0 + */ public class KeyStore { // Store KeyStore SERVICE name @@ -73,6 +86,17 @@ public class KeyStore { // Store used type private final String type; + /** + * Constructs a new instance of {@code KeyStore} with the given arguments. + * + * @param keyStoreSpi + * the concrete key store. + * @param provider + * the provider. + * @param type + * the type of the {@code KeyStore} to be constructed. + * @since Android 1.0 + */ protected KeyStore(KeyStoreSpi keyStoreSpi, Provider provider, String type) { this.type = type; this.provider = provider; @@ -91,9 +115,20 @@ public class KeyStore { throw new KeyStoreException(NOTINITKEYSTORE); } // END android-added - + /** - * @throws NullPointerException if type is null + * Returns a new instance of {@code KeyStore} with the specified type. + * + * @param type + * the type of the returned {@code KeyStore}. + * @return a new instance of {@code KeyStore} with the specified type. + * @throws KeyStoreException + * if an error occurred during the creation of the new {@code + * KeyStore}. + * @throws NullPointerException + * if {@code type} is {@code null}. + * @see #getDefaultType + * @since Android 1.0 */ public static KeyStore getInstance(String type) throws KeyStoreException { if (type == null) { @@ -110,10 +145,24 @@ public class KeyStore { } /** + * Returns a new instance of {@code KeyStore} from the specified provider + * with the given type. * - * - * @throws NullPointerException if type is null (instead of - * NoSuchAlgorithmException) as in 1.4 release + * @param type + * the type of the returned {@code KeyStore}. + * @param provider + * name of the provider of the {@code KeyStore}. + * @return a new instance of {@code KeyStore} from the specified provider + * with the given type. + * @throws KeyStoreException + * if an error occurred during the creation of the new {@code + * KeyStore}. + * @throws NoSuchProviderException + * if the specified provider is not available. + * @throws IllegalArgumentException + * if {@code provider} is {@code null} or the empty string. + * @see #getDefaultType + * @since Android 1.0 */ public static KeyStore getInstance(String type, String provider) throws KeyStoreException, NoSuchProviderException { @@ -132,10 +181,22 @@ public class KeyStore { } /** + * Returns a new instance of {@code KeyStore} from the specified provider + * with the given type. * - * - * throws NullPointerException if type is null (instead of - * NoSuchAlgorithmException) as in 1.4 release + * @param type + * the type of the returned {@code KeyStore}. + * @param provider + * the provider of the {@code KeyStore}. + * @return a new instance of {@code KeyStore} from the specified provider + * with the given type. + * @throws KeyStoreException + * if an error occurred during the creation of the new {@code + * KeyStore}. + * @throws IllegalArgumentException + * if {@code provider} is {@code null} or the empty string. + * @see #getDefaultType + * @since Android 1.0 */ public static KeyStore getInstance(String type, Provider provider) throws KeyStoreException { @@ -159,8 +220,15 @@ public class KeyStore { } /** + * Returns the default type for {@code KeyStore} instances. + *+ * The default is specified in the {@code 'keystore.type'} property in the + * file named {@code JAVA_HOME/lib/security/java.security}. If this property + * is not set, {@code "jks"} will be used. + *
* - * + * @return the default type for {@code KeyStore} instances + * @since Android 1.0 */ public static final String getDefaultType() { String dt = AccessController.doPrivileged( @@ -174,24 +242,42 @@ public class KeyStore { } /** + * Returns the provider associated with this {@code KeyStore}. * - * + * @return the provider associated with this {@code KeyStore}. + * @since Android 1.0 */ public final Provider getProvider() { return provider; } /** + * Returns the type of this {@code KeyStore}. * - * + * @return the type of this {@code KeyStore}. + * @since Android 1.0 */ public final String getType() { return type; } /** + * Returns the key with the given alias, using the password to recover the + * key from the store. * - * + * @param alias + * the alias for the entry. + * @param password + * the password used to recover the key. + * @return the key with the specified alias, or {@code null} if the + * specified alias is not bound to an entry. + * @throws KeyStoreException + * if this {@code KeyStore} is not initialized. + * @throws NoSuchAlgorithmException + * if the algorithm for recovering the key is not available. + * @throws UnrecoverableKeyException + * if the key can not be recovered. + * @since Android 1.0 */ public final Key getKey(String alias, char[] password) throws KeyStoreException, NoSuchAlgorithmException, @@ -205,8 +291,15 @@ public class KeyStore { } /** + * Returns the certificate chain for the entry with the given alias. * - * + * @param alias + * the alias for the entry. + * @return the certificate chain for the entry with the given alias, or + * {@code null} if the specified alias is not bound to an entry. + * @throws KeyStoreException + * if this {@code KeyStore} is not initialized. + * @since Android 1.0 */ public final Certificate[] getCertificateChain(String alias) throws KeyStoreException { @@ -219,8 +312,15 @@ public class KeyStore { } /** + * Returns the trusted certificate for the entry with the given alias. * - * + * @param alias + * the alias for the entry. + * @return the trusted certificate for the entry with the given alias, or + * {@code null} if the specified alias is not bound to an entry. + * @throws KeyStoreException + * if this {@code KeyStore} is not initialized. + * @since Android 1.0 */ public final Certificate getCertificate(String alias) throws KeyStoreException { @@ -233,8 +333,15 @@ public class KeyStore { } /** + * Returns the creation date of the entry with the given alias. * - * + * @param alias + * the alias for the entry. + * @return the creation date, or {@code null} if the specified alias is not + * bound to an entry. + * @throws KeyStoreException + * if this {@code KeyStore} is not initialized. + * @since Android 1.0 */ public final Date getCreationDate(String alias) throws KeyStoreException { if (!isInit) { @@ -246,12 +353,25 @@ public class KeyStore { } /** + * Associates the given alias with the key, password and certificate chain. + *+ * If the specified alias already exists, it will be reassigned. + *
* - * - * 1.4.2 and 1.5 releases throw unspecified NullPointerException - - * when alias is null IllegalArgumentException - when password is null - * IllegalArgumentException - when key is instance of PrivateKey and chain - * is null or empty + * @param alias + * the alias for the key. + * @param key + * the key. + * @param password + * the password. + * @param chain + * the certificate chain. + * @throws KeyStoreException + * if this {@code KeyStore} is not initialized. + * @throws IllegalArgumentException + * if {@code key} is a {@code PrivateKey} and {@code chain} does + * not contain any certificates. + * @since Android 1.0 */ public final void setKeyEntry(String alias, Key key, char[] password, Certificate[] chain) throws KeyStoreException { @@ -271,8 +391,28 @@ public class KeyStore { } /** + * Associates the given alias with a key and a certificate chain. + *+ * If the specified alias already exists, it will be reassigned. + *
+ *+ * If this {@code KeyStore} is of type {@code "jks"}, {@code key} must be + * encoded conform to the PKS#8 standard as an + * {@link javax.crypto.EncryptedPrivateKeyInfo}. + *
* - * + * @param alias + * the alias for the key. + * @param key + * the key in an encoded format. + * @param chain + * the certificate chain. + * @throws KeyStoreException + * if this {@code KeyStore} is not initialized. + * @throws IllegalArgumentException + * if {@code key} is a {@code PrivateKey} and {@code chain} + * does. + * @since Android 1.0 */ public final void setKeyEntry(String alias, byte[] key, Certificate[] chain) throws KeyStoreException { @@ -285,10 +425,20 @@ public class KeyStore { } /** + * Associates the given alias with a certificate. + *+ * If the specified alias already exists, it will be reassigned. + *
* - * - * 1.4.2 and 1.5 releases throw unspecified NullPointerException - * when alias is null + * @param alias + * the alias for the certificate. + * @param cert + * the certificate. + * @throws KeyStoreException + * if this {@code KeyStore} is not initialized, or an existing + * alias is not associated to an entry containing a trusted + * certificate, or this method fails for any other reason. + * @since Android 1.0 */ public final void setCertificateEntry(String alias, Certificate cert) throws KeyStoreException { @@ -301,24 +451,34 @@ public class KeyStore { } /** + * Deletes the entry identified with the given alias from this {@code + * KeyStore}. * - * - * 1.4.2 and 1.5 releases throw NullPointerException when alias is null + * @param alias + * the alias for the entry. + * @throws KeyStoreException + * if this {@code KeyStore} is not initialized, or if the entry + * can not be deleted. + * @since Android 1.0 */ public final void deleteEntry(String alias) throws KeyStoreException { + // BEGIN android-changed if (!isInit) { - // BEGIN android-changed throwNotInitialized(); - // END android-changed - } - if (alias == null) { - throw new NullPointerException(Messages.getString("security.3F")); //$NON-NLS-1$ } + // END android-changed implSpi.engineDeleteEntry(alias); } /** + * Returns an {@code Enumeration} over all alias names stored in this + * {@code KeyStore}. * + * @return an {@code Enumeration} over all alias names stored in this + * {@code KeyStore}. + * @throws KeyStoreException + * if this {@code KeyStore} is not initialized. + * @since Android 1.0 */ public final Enumeration+ * If the specified alias already exists, it will be reassigned. + *
* - * - * 1.5 release throws unspecified NullPointerException when alias or - * entry is null + * @param alias + * the alias for the entry. + * @param entry + * the entry to store. + * @param param + * the {@code ProtectionParameter} to protect the entry. + * @throws KeyStoreException + * if this {@code KeyStore} is not initialized. + * @since Android 1.0 */ public final void setEntry(String alias, Entry entry, ProtectionParameter param) throws KeyStoreException { @@ -508,7 +772,18 @@ public class KeyStore { } /** + * Indicates whether the entry for the given alias is assignable to the + * provided {@code Class}. * + * @param alias + * the alias for the entry. + * @param entryClass + * the type of the entry. + * @return {@code true} if the {@code Entry} for the alias is assignable to + * the specified {@code entryClass}. + * @throws KeyStoreException + * if this {@code KeyStore} is not initialized. + * @since Android 1.0 */ public final boolean entryInstanceOf(String alias, Class extends KeyStore.Entry> entryClass) @@ -529,34 +804,71 @@ public class KeyStore { } /** + * {@code Builder} is used to construct new instances of {@code KeyStore}. * - * - * + * @since Android 1.0 */ public abstract static class Builder { /** + * Constructs a new instance of {@code Builder}. * - * + * @since Android 1.0 */ protected Builder() { } /** + * Returns the {@code KeyStore} created by this {@code Builder}. * - * + * @return the {@code KeyStore} created by this {@code Builder}. + * @throws KeyStoreException + * if an error occurred during construction. + * @since Android 1.0 */ public abstract KeyStore getKeyStore() throws KeyStoreException; /** + * Returns the {@code ProtectionParameter} to be used when a {@code + * Entry} with the specified alias is requested. Before this method is + * invoked, {@link #getKeyStore()} must be called. * - * + * @param alias + * the alias for the entry. + * @return the {@code ProtectionParameter} to be used when a {@code + * Entry} with the specified alias is requested. + * @throws KeyStoreException + * if an error occurred during the lookup for the protection + * parameter. + * @throws IllegalStateException + * if {@link #getKeyStore()} is not called prior the + * invocation of this method. + * @throws NullPointerException + * if {@code alias} is {@code null}. + * @since Android 1.0 */ - public abstract ProtectionParameter getProtectionParameter(String alise) + public abstract ProtectionParameter getProtectionParameter(String alias) throws KeyStoreException; + // BEGIN android-note + // renamed parameter + // END android-note /** + * Returns a new {@code Builder} that holds the given {@code KeyStore} + * and the given {@code ProtectionParameter}. * - * + * @param keyStore + * the {@code KeyStore} to be held. + * @param protectionParameter + * the {@code ProtectionParameter} to be held. + * @return a new instance of {@code Builder} that holds the specified + * {@code KeyStore} and the specified {@code + * ProtectionParameter}. + * @throws NullPointerException + * if {@code keyStore} or {@code protectionParameter} is + * {@code null}. + * @throws IllegalArgumentException + * if the given {@code KeyStore} is not initialized. + * @since Android 1.0 */ public static Builder newInstance(KeyStore keyStore, ProtectionParameter protectionParameter) { @@ -575,8 +887,36 @@ public class KeyStore { } /** + * Returns a new {@code Builder} that creates a new {@code KeyStore} + * based on the provided arguments. + *+ * If {@code provider} is {@code null}, all installed providers are + * searched, otherwise the key store from the specified provider is + * used. + *
* - * + * @param type + * the type of the {@code KeyStore} to be constructed. + * @param provider + * the provider of the {@code KeyStore} to be constructed, + * maybe {@code null}. + * @param file + * the {@code File} that contains the data for the {@code + * KeyStore}. + * @param protectionParameter + * the {@code ProtectionParameter} used to protect the stored + * keys. + * @return a new {@code Builder} that creates a new {@code KeyStore} + * based on the provided arguments. + * @throws NullPointerException + * if {@code type, protectionParameter} or {@code file} is + * {@code null}. + * @throws IllegalArgumentException + * {@code protectionParameter} not an instance of either + * {@code PasswordProtection} or {@code + * CallbackHandlerProtection}, {@code file} is not a file or + * does not exist at all. + * @since Android 1.0 */ public static Builder newInstance(String type, Provider provider, File file, ProtectionParameter protectionParameter) { @@ -609,8 +949,33 @@ public class KeyStore { } /** + * Returns a new {@code Builder} that creates a new {@code KeyStore} + * based on the provided arguments. + *+ * If {@code provider} is {@code null}, all installed providers are + * searched, otherwise the key store from the specified provider is + * used. + *
* - * + * @param type + * the type of the {@code KeyStore} to be constructed. + * @param provider + * the provider of the {@code KeyStore} to be constructed, + * maybe {@code null}. + * @param protectionParameter + * the {@code ProtectionParameter} used to protect the stored + * keys. + * @return a new {@code Builder} that creates a new {@code KeyStore} + * based on the provided arguments. + * @throws NullPointerException + * if {@code type} or {@code protectionParameter} is {@code + * null}. + * @throws IllegalArgumentException + * {@code protectionParameter} not an instance of either + * {@code PasswordProtection} or {@code + * CallbackHandlerProtection}, {@code file} is not a file or + * does not exist at all. + * @since Android 1.0 */ public static Builder newInstance(String type, Provider provider, ProtectionParameter protectionParameter) { @@ -806,9 +1171,10 @@ public class KeyStore { } /** + * {@code CallbackHandlerProtection} is a {@code ProtectionParameter} that + * encapsulates a {@link CallbackHandler}. * - * - * + * @since Android 1.0 */ public static class CallbackHandlerProtection implements ProtectionParameter { @@ -816,8 +1182,14 @@ public class KeyStore { private final CallbackHandler callbackHandler; /** + * Constructs a new instance of {@code CallbackHandlerProtection} with + * the {@code CallbackHandler}. * - * + * @param handler + * the {@code CallbackHandler}. + * @throws NullPointerException + * if {@code handler} is {@code null}. + * @since Android 1.0 */ public CallbackHandlerProtection(CallbackHandler handler) { if (handler == null) { @@ -827,8 +1199,10 @@ public class KeyStore { } /** + * Returns the {@code CallbackHandler}. * - * + * @return the {@code CallbackHandler}. + * @since Android 1.0 */ public CallbackHandler getCallbackHandler() { return callbackHandler; @@ -836,30 +1210,39 @@ public class KeyStore { } /** + * {@code Entry} is the common marker interface for a {@code KeyStore} + * entry. * - * - * + * @since Android 1.0 */ public static interface Entry { } /** + * {@code LoadStoreParameter} represents a parameter that specifies how a + * {@code KeyStore} can be loaded and stored. * - * - * + * @see KeyStore#load(LoadStoreParameter) + * @see KeyStore#store(LoadStoreParameter) + * @since Android 1.0 */ public static interface LoadStoreParameter { /** + * Returns the {@code ProtectionParameter} which is used to protect data + * in the {@code KeyStore}. * - * + * @return the {@code ProtectionParameter} which is used to protect data + * in the {@code KeyStore}, maybe {@code null}. + * @since Android 1.0 */ public ProtectionParameter getProtectionParameter(); } /** + * {@code PasswordProtection} is a {@code ProtectionParameter} that protects + * a {@code KeyStore} using a password. * - * - * + * @since Android 1.0 */ public static class PasswordProtection implements ProtectionParameter, Destroyable { @@ -870,16 +1253,27 @@ public class KeyStore { private boolean isDestroyed = false; /** + * Constructs a new instance of {@code PasswordProtection} with a + * password. A copy of the password is stored in the new {@code + * PasswordProtection} object. * - * + * @param password + * the password, maybe {@code null}. + * @since Android 1.0 */ public PasswordProtection(char[] password) { - this.password = password; + // BEGIN android-changed + this.password = (password != null) ? password.clone() : null; + // END android-changed } /** + * Returns the password. * - * + * @return the password. + * @throws IllegalStateException + * if the password has been destroyed. + * @since Android 1.0 */ public synchronized char[] getPassword() { if (isDestroyed) { @@ -889,8 +1283,11 @@ public class KeyStore { } /** + * Destroys / invalidates the password. * - * + * @throws DestroyFailedException + * if the password could not be invalidated. + * @since Android 1.0 */ public synchronized void destroy() throws DestroyFailedException { isDestroyed = true; @@ -901,8 +1298,11 @@ public class KeyStore { } /** + * Indicates whether the password is invalidated. * - * + * @return {@code true} if the password is invalidated, {@code false} + * otherwise. + * @since Android 1.0 */ public synchronized boolean isDestroyed() { return isDestroyed; @@ -910,17 +1310,20 @@ public class KeyStore { } /** + * {@code ProtectionParameter} is a marker interface for protection + * parameters. A protection parameter is used to protect the content of a + * {@code KeyStore}. * - * - * + * @since Android 1.0 */ public static interface ProtectionParameter { } /** + * {@code PrivateKeyEntry} represents a {@code KeyStore} entry that + * holds a private key. * - * - * + * @since Android 1.0 */ public static final class PrivateKeyEntry implements Entry { // Store Certificate chain @@ -930,8 +1333,22 @@ public class KeyStore { private PrivateKey privateKey; /** + * Constructs a new instance of {@code PrivateKeyEntry} with the given + * {@code PrivateKey} and the provided certificate chain. * - * + * @param privateKey + * the private key. + * @param chain + * the ordered certificate chain with the certificate + * corresponding to the private key at index 0. + * @throws NullPointerException + * if {@code privateKey} or {@code chain} is {@code null}. + * @throws IllegalArgumentException + * if {@code chain.length == 0}, the algorithm of the + * private key does not match the algorithm of the public + * key of the first certificate or the certificates are not + * all of the same type. + * @since Android 1.0 */ public PrivateKeyEntry(PrivateKey privateKey, Certificate[] chain) { if (privateKey == null) { @@ -959,38 +1376,51 @@ public class KeyStore { } } // clone chain - this.chain = (Certificate[])chain.clone(); + // BEGIN android-changed this.chain = new Certificate[chain.length]; + // END android-changed System.arraycopy(chain, 0, this.chain, 0, chain.length); this.privateKey = privateKey; } /** + * Returns the private key. * - * + * @return the private key. + * @since Android 1.0 */ public PrivateKey getPrivateKey() { return privateKey; } /** + * Returns the certificate chain. * - * + * @return the certificate chain. + * @since Android 1.0 */ public Certificate[] getCertificateChain() { + // BEGIN android-changed return chain; + // END android-changed } /** + * Returns the certificate corresponding to the private key. * - * + * @return the certificate corresponding to the private key. + * @since Android 1.0 */ public Certificate getCertificate() { return chain[0]; } /** + * Returns a string containing a concise, human-readable description of + * this {@code PrivateKeyEntry}. * - * + * @return a printable representation for this {@code PrivateKeyEntry}. + * @since Android 1.0 */ public String toString() { StringBuffer sb = new StringBuffer( @@ -1006,9 +1436,10 @@ public class KeyStore { } /** + * {@code SecretKeyEntry} represents a {@code KeyStore} entry that + * holds a secret key. * - * - * + * @since Android 1.0 */ public static final class SecretKeyEntry implements Entry { @@ -1016,8 +1447,14 @@ public class KeyStore { private final SecretKey secretKey; /** + * Constructs a new instance of {@code SecretKeyEntry} with the given + * {@code SecretKey}. * - * + * @param secretKey + * the secret key. + * @throws NullPointerException + * if {@code secretKey} is {@code null}. + * @since Android 1.0 */ public SecretKeyEntry(SecretKey secretKey) { if (secretKey == null) { @@ -1027,16 +1464,22 @@ public class KeyStore { } /** + * Returns the secret key. * - * + * @return the secret key. + * @since Android 1.0 */ public SecretKey getSecretKey() { return secretKey; } /** + * Returns a string containing a concise, human-readable description of + * this {@code SecretKeyEntry}. * - * + * @return a printable representation for this {@code + * SecretKeyEntry}. + * @since Android 1.0 */ public String toString() { StringBuffer sb = new StringBuffer("SecretKeyEntry: algorithm - "); //$NON-NLS-1$ @@ -1046,9 +1489,10 @@ public class KeyStore { } /** + * {@code TrustedCertificateEntry} represents a {@code KeyStore} entry that + * holds a trusted certificate. * - * - * + * @since Android 1.0 */ public static final class TrustedCertificateEntry implements Entry { @@ -1056,8 +1500,14 @@ public class KeyStore { private final Certificate trustCertificate; /** + * Constructs a new instance of {@code TrustedCertificateEntry} with the + * given {@code Certificate}. * - * + * @param trustCertificate + * the trusted certificate. + * @throws NullPointerException + * if {@code trustCertificate} is {@code null}. + * @since Android 1.0 */ public TrustedCertificateEntry(Certificate trustCertificate) { if (trustCertificate == null) { @@ -1067,16 +1517,22 @@ public class KeyStore { } /** + * Returns the trusted certificate. * - * + * @return the trusted certificate. + * @since Android 1.0 */ public Certificate getTrustedCertificate() { return trustCertificate; } /** + * Returns a string containing a concise, human-readable description of + * this {@code TrustedCertificateEntry}. * - * + * @return a printable representation for this {@code + * TrustedCertificateEntry}. + * @since Android 1.0 */ public String toString() { return "Trusted certificate entry:\n" + trustCertificate; //$NON-NLS-1$ diff --git a/security/src/main/java/java/security/KeyStoreException.java b/security/src/main/java/java/security/KeyStoreException.java index 0e77e47..7c697f7 100644 --- a/security/src/main/java/java/security/KeyStoreException.java +++ b/security/src/main/java/java/security/KeyStoreException.java @@ -23,40 +23,58 @@ package java.security; /** - * @com.intel.drl.spec_ref + * {@code KeyStoreException} is a general {@code KeyStore} exception. * + * @see KeyStore + * @since Android 1.0 */ public class KeyStoreException extends GeneralSecurityException { - /** - * @com.intel.drl.spec_ref - */ private static final long serialVersionUID = -1119353179322377262L; /** - * @com.intel.drl.spec_ref + * Constructs a new instance of {@code KeyStoreException} with the + * given message. + * + * @param msg + * the detail message for this exception. + * @since Android 1.0 */ public KeyStoreException(String msg) { super(msg); } /** - * @com.intel.drl.spec_ref + * Constructs a new instance of {@code KeyStoreException}. + * + * @since Android 1.0 */ public KeyStoreException() { } /** - * @com.intel.drl.spec_ref + * Constructs a new instance of {@code KeyStoreException} with the + * given message and the cause. + * + * @param message + * the detail message for this exception. + * @param cause + * the exception which is the cause for this exception. + * @since Android 1.0 */ public KeyStoreException(String message, Throwable cause) { super(message, cause); } /** - * @com.intel.drl.spec_ref + * Constructs a new instance of {@code KeyStoreException} with the + * cause. + * + * @param cause + * the exception which is the cause for this exception. + * @since Android 1.0 */ public KeyStoreException(Throwable cause) { super(cause); } -} \ No newline at end of file +} diff --git a/security/src/main/java/java/security/KeyStoreSpi.java b/security/src/main/java/java/security/KeyStoreSpi.java index 0ed01dd..b02f264 100644 --- a/security/src/main/java/java/security/KeyStoreSpi.java +++ b/security/src/main/java/java/security/KeyStoreSpi.java @@ -30,52 +30,294 @@ import javax.security.auth.callback.PasswordCallback; import org.apache.harmony.security.internal.nls.Messages; +/** + * {@code KeyStoreSpi} is the Service Provider Interface (SPI) definition for + * {@link KeyStore}. + * + * @see KeyStore + * @since Android 1.0 + */ public abstract class KeyStoreSpi { + /** + * Returns the key with the given alias, using the password to recover the + * key from the store. + * + * @param alias + * the alias for the entry. + * @param password + * the password used to recover the key. + * @return the key with the specified alias, or {@code null} if the + * specified alias is not bound to an entry. + * @throws NoSuchAlgorithmException + * if the algorithm for recovering the key is not available. + * @throws UnrecoverableKeyException + * if the key can not be recovered. + * @since Android 1.0 + */ public abstract Key engineGetKey(String alias, char[] password) throws NoSuchAlgorithmException, UnrecoverableKeyException; + /** + * Returns the certificate chain for the entry with the given alias. + * + * @param alias + * the alias for the entry + * @return the certificate chain for the entry with the given alias, or + * {@code null} if the specified alias is not bound to an entry. + * @since Android 1.0 + */ public abstract Certificate[] engineGetCertificateChain(String alias); + /** + * Returns the trusted certificate for the entry with the given alias. + * + * @param alias + * the alias for the entry. + * @return the trusted certificate for the entry with the given alias, or + * {@code null} if the specified alias is not bound to an entry. + * @since Android 1.0 + */ public abstract Certificate engineGetCertificate(String alias); + /** + * Returns the creation date of the entry with the given alias. + * + * @param alias + * the alias for the entry. + * @return the creation date, or {@code null} if the specified alias is not + * bound to an entry. + * @since Android 1.0 + */ public abstract Date engineGetCreationDate(String alias); + /** + * Associates the given alias with the key, password and certificate chain. + *+ * If the specified alias already exists, it will be reassigned. + *
+ * + * @param alias + * the alias for the key. + * @param key + * the key. + * @param password + * the password. + * @param chain + * the certificate chain. + * @throws KeyStoreException + * if the specified key can not be protected, or if this + * operation fails for another reason. + * @throws IllegalArgumentException + * if {@code key} is a {@code PrivateKey} and {@code chain} does + * not contain any certificates. + * @since Android 1.0 + */ public abstract void engineSetKeyEntry(String alias, Key key, char[] password, Certificate[] chain) throws KeyStoreException; + /** + * Associates the given alias with a key and a certificate chain. + *+ * If the specified alias already exists, it will be reassigned. + *
+ * + * @param alias + * the alias for the key. + * @param key + * the key in an encoded format. + * @param chain + * the certificate chain. + * @throws KeyStoreException + * if this operation fails. + * @throws IllegalArgumentException + * if {@code key} is a {@code PrivateKey} and {@code chain} + * does. + * @since Android 1.0 + */ public abstract void engineSetKeyEntry(String alias, byte[] key, Certificate[] chain) throws KeyStoreException; + /** + * Associates the given alias with a certificate. + *+ * If the specified alias already exists, it will be reassigned. + *
+ * + * @param alias + * the alias for the certificate. + * @param cert + * the certificate. + * @throws KeyStoreException + * if an existing alias is not associated to an entry containing + * a trusted certificate, or this method fails for any other + * reason. + * @since Android 1.0 + */ public abstract void engineSetCertificateEntry(String alias, Certificate cert) throws KeyStoreException; + /** + * Deletes the entry identified with the given alias from this {@code + * KeyStoreSpi}. + * + * @param alias + * the alias for the entry. + * @throws KeyStoreException + * if the entry can not be deleted. + * @since Android 1.0 + */ public abstract void engineDeleteEntry(String alias) throws KeyStoreException; + /** + * Returns an {@code Enumeration} over all alias names stored in this + * {@code KeyStoreSpi}. + * + * @return an {@code Enumeration} over all alias names stored in this + * {@code KeyStoreSpi}. + * @since Android 1.0 + */ public abstract Enumeration+ * If the specified alias already exists, it will be reassigned. + *
+ * + * @param alias + * the alias for the entry. + * @param entry + * the entry to store. + * @param protParam + * the {@code ProtectionParameter} to protect the entry. + * @throws KeyStoreException + * if this operation fails. + * @since Android 1.0 + */ public void engineSetEntry(String alias, KeyStore.Entry entry, KeyStore.ProtectionParameter protParam) throws KeyStoreException { if (entry == null) { @@ -204,6 +483,18 @@ public abstract class KeyStoreSpi { Messages.getString("security.3B", entry.toString())); //$NON-NLS-1$ } + /** + * Indicates whether the entry for the given alias is assignable to the + * provided {@code Class}. + * + * @param alias + * the alias for the entry. + * @param entryClass + * the type of the entry. + * @return {@code true} if the {@code Entry} for the alias is assignable to + * the specified {@code entryClass}. + * @since Android 1.0 + */ public boolean engineEntryInstanceOf(String alias, Class extends KeyStore.Entry> entryClass) { if (!engineContainsAlias(alias)) { diff --git a/security/src/main/java/java/security/MessageDigest.java b/security/src/main/java/java/security/MessageDigest.java index c665c45..97cbdcc 100644 --- a/security/src/main/java/java/security/MessageDigest.java +++ b/security/src/main/java/java/security/MessageDigest.java @@ -27,12 +27,14 @@ import java.nio.ByteBuffer; import org.apache.harmony.security.fortress.Engine; import org.apache.harmony.security.internal.nls.Messages; - /** - * @com.intel.drl.spec_ref + * {@code MessageDigest} is an engine class which is capable of generating one + * way hash values for arbitrary input, utilizing the algorithm it was + * initialized with. * + * @see MessageDigestSpi + * @since Android 1.0 */ - public abstract class MessageDigest extends MessageDigestSpi { // The service name @@ -48,16 +50,30 @@ public abstract class MessageDigest extends MessageDigestSpi { private String algorithm; /** - * @com.intel.drl.spec_ref - * + * Constructs a new instance of {@code MessageDigest} with the name of + * the algorithm to use. + * + * @param algorithm + * the name of algorithm to use + * @since Android 1.0 */ protected MessageDigest(String algorithm) { this.algorithm = algorithm; } /** - * @com.intel.drl.spec_ref - * + * Returns a new instance of {@code MessageDigest} that utilizes the + * specified algorithm. + * + * @param algorithm + * the name of the algorithm to use + * @return a new instance of {@code MessageDigest} that utilizes the + * specified algorithm + * @throws NoSuchAlgorithmException + * if the specified algorithm is not available + * @throws NullPointerException + * if {@code algorithm} is {@code null} + * @since Android 1.0 */ public static MessageDigest getInstance(String algorithm) throws NoSuchAlgorithmException { @@ -81,8 +97,22 @@ public abstract class MessageDigest extends MessageDigestSpi { } /** - * @com.intel.drl.spec_ref - * + * Returns a new instance of {@code MessageDigest} that utilizes the + * specified algorithm from the specified provider. + * + * @param algorithm + * the name of the algorithm to use + * @param provider + * the name of the provider + * @return a new instance of {@code MessageDigest} that utilizes the + * specified algorithm from the specified provider + * @throws NoSuchAlgorithmException + * if the specified algorithm is not available + * @throws NoSuchProviderException + * if the specified provider is not available + * @throws NullPointerException + * if {@code algorithm} is {@code null} + * @since Android 1.0 */ public static MessageDigest getInstance(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException { @@ -97,20 +127,20 @@ public abstract class MessageDigest extends MessageDigestSpi { } /** - * Returns a new MessageDigest which is capable of running the algorithm - * described by the argument. The result will be an instance of a subclass - * of MessageDigest which implements that algorithm. - * + * Returns a new instance of {@code MessageDigest} that utilizes the + * specified algorithm from the specified provider. * * @param algorithm - * java.lang.String Name of the algorithm desired + * the name of the algorithm to use * @param provider - * Provider Provider which has to implement the algorithm - * @return MessageDigest a concrete implementation for the algorithm - * desired. - * - * @exception NoSuchAlgorithmException - * If the algorithm cannot be found + * the provider + * @return a new instance of {@code MessageDigest} that utilizes the + * specified algorithm from the specified provider + * @throws NoSuchAlgorithmException + * if the specified algorithm is not available + * @throws NullPointerException + * if {@code algorithm} is {@code null} + * @since Android 1.0 */ public static MessageDigest getInstance(String algorithm, Provider provider) throws NoSuchAlgorithmException { @@ -136,34 +166,41 @@ public abstract class MessageDigest extends MessageDigestSpi { } } - // BEGIN android-note - // Removed @see tag that didn't seem to actually refer to anything. - // END android-note - /** - * Puts the receiver back in an initial state, such that it is ready to - * compute a new hash. + * Puts this {@code MessageDigest} back in an initial state, such that it is + * ready to compute a one way hash value. + * + * @since Android 1.0 */ public void reset() { engineReset(); } /** - * Includes the argument in the hash value computed - * by the receiver. - * - * @param arg0 byte - * the byte to feed to the hash algorithm - * + * Updates this {@code MessageDigest} using the given {@code byte}. + * + * @param arg0 + * the {@code byte} to update this {@code MessageDigest} with * @see #reset() + * @since Android 1.0 */ public void update(byte arg0) { engineUpdate(arg0); } /** - * @com.intel.drl.spec_ref - * + * Updates this {@code MessageDigest} using the given {@code byte[]}. + * + * @param input + * the {@code byte} array + * @param offset + * the index of the first byte in {@code input} to update from + * @param len + * the number of bytes in {@code input} to update from + * @throws IllegalArgumentException + * if {@code offset} or {@code len} are not valid in respect to + * {@code input} + * @since Android 1.0 */ public void update(byte[] input, int offset, int len) { if (input == null || @@ -178,8 +215,13 @@ public abstract class MessageDigest extends MessageDigestSpi { } /** - * @com.intel.drl.spec_ref - * + * Updates this {@code MessageDigest} using the given {@code byte[]}. + * + * @param input + * the {@code byte} array + * @throws NullPointerException + * if {@code input} is {@code null} + * @since Android 1.0 */ public void update(byte[] input) { if (input == null) { @@ -189,20 +231,35 @@ public abstract class MessageDigest extends MessageDigestSpi { } /** - * Computes and returns the final hash value that the receiver represents. + * Computes and returns the final hash value for this {@link MessageDigest}. * After the digest is computed the receiver is reset. * - * @return the hash the receiver computed - * + * @return the computed one way hash value * @see #reset + * @since Android 1.0 */ public byte[] digest() { return engineDigest(); } /** - * @com.intel.drl.spec_ref - * + * Computes and stores the final hash value for this {@link MessageDigest}. + * After the digest is computed the receiver is reset. + * + * @param buf + * the buffer to store the result + * @param offset + * the index of the first byte in {@code buf} to store + * @param len + * the number of bytes allocated for the digest + * @return the number of bytes written to {@code buf} + * @throws DigestException + * if an error occures + * @throws IllegalArgumentException + * if {@code offset} or {@code len} are not valid in respect to + * {@code buf} + * @see #reset() + * @since Android 1.0 */ public int digest(byte[] buf, int offset, int len) throws DigestException { if (buf == null || @@ -217,8 +274,15 @@ public abstract class MessageDigest extends MessageDigestSpi { } /** - * @com.intel.drl.spec_ref - * + * Performs the final update and then computes and returns the final hash + * value for this {@link MessageDigest}. After the digest is computed the + * receiver is reset. + * + * @param input + * the {@code byte} array + * @return the computed one way hash value + * @see #reset() + * @since Android 1.0 */ public byte[] digest(byte[] input) { update(input); @@ -226,25 +290,26 @@ public abstract class MessageDigest extends MessageDigestSpi { } /** - * Returns a string containing a concise, human-readable description of the - * receiver. + * Returns a string containing a concise, human-readable description of this + * {@code MessageDigest} including the name of its algorithm. * - * @return a printable representation for the receiver. + * @return a printable representation for this {@code MessageDigest} + * @since Android 1.0 */ public String toString() { return "MESSAGE DIGEST " + algorithm; //$NON-NLS-1$ } /** - * Does a simply byte-per-byte compare of the two digests. + * Indicates whether to digest are equal by performing a simply + * byte-per-byte compare of the two digests. * * @param digesta - * One of the digests to compare + * the first digest to be compared * @param digestb - * The digest to compare to - * - * @returntrue
if the two hashes are equal
- * false
if the two hashes are not equal
+ * the second digest to be compared
+ * @return {@code true} if the two hashes are equal, {@code false} otherwise
+ * @since Android 1.0
*/
public static boolean isEqual(byte[] digesta, byte[] digestb) {
if (digesta.length != digestb.length) {
@@ -259,29 +324,32 @@ public abstract class MessageDigest extends MessageDigestSpi {
}
/**
- * Returns the standard Java Security name for the algorithm being used by
- * the receiver.
+ * Returns the name of the algorithm of this {@code MessageDigest}.
*
- * @return String the name of the algorithm
+ * @return the name of the algorithm of this {@code MessageDigest}
+ * @since Android 1.0
*/
public final String getAlgorithm() {
return algorithm;
}
/**
- * Returns the Provider of the digest represented by the receiver.
+ * Returns the provider associated with this {@code MessageDigest}.
*
- * @return Provider an instance of a subclass of java.security.Provider
+ * @return the provider associated with this {@code MessageDigest}
+ * @since Android 1.0
*/
public final Provider getProvider() {
return provider;
}
/**
- * Return the engine digest length in bytes. Default is 0.
- *
- * @return int the engine digest length in bytes
+ * Returns the engine digest length in bytes. If the implementation does not
+ * implement this function or is not an instance of {@code Cloneable},
+ * {@code 0} is returned.
*
+ * @return the digest length in bytes, or {@code 0}
+ * @since Android 1.0
*/
public final int getDigestLength() {
int l = engineGetDigestLength();
@@ -299,10 +367,6 @@ public abstract class MessageDigest extends MessageDigestSpi {
}
}
- /**
- * @com.intel.drl.spec_ref
- *
- */
public Object clone() throws CloneNotSupportedException {
if (this instanceof Cloneable) {
return super.clone();
@@ -312,8 +376,11 @@ public abstract class MessageDigest extends MessageDigestSpi {
}
/**
- * @com.intel.drl.spec_ref
- *
+ * Updates this {@code MessageDigest} using the given {@code input}.
+ *
+ * @param input
+ * the {@code ByteBuffer}
+ * @since Android 1.0
*/
public final void update(ByteBuffer input) {
engineUpdate(input);
diff --git a/security/src/main/java/java/security/MessageDigestSpi.java b/security/src/main/java/java/security/MessageDigestSpi.java
index 3d44fb1..ae5ed32 100644
--- a/security/src/main/java/java/security/MessageDigestSpi.java
+++ b/security/src/main/java/java/security/MessageDigestSpi.java
@@ -26,41 +26,60 @@ import java.nio.ByteBuffer;
import org.apache.harmony.security.internal.nls.Messages;
-
/**
- * This class is a Service Provider Interface (therefore the Spi suffix) for
- * digest algorithms to be supplied by providers. Examples of digest algorithms
- * are MD5 and SHA.
- *
- * A digest is a secure hash function for a stream of bytes, like a fingerprint
- * for the stream of bytes.
+ * {@code MessageDigestSpi} is the Service Provider Interface (SPI) definition
+ * for {@link MessageDigest}. Examples of digest algorithms are MD5 and SHA. A
+ * digest is a secure one way hash function for a stream of bytes. It acts like
+ * a fingerprint for a stream of bytes.
*
+ * @see MessageDigest
+ * @since Android 1.0
*/
public abstract class MessageDigestSpi {
/**
- * @com.intel.drl.spec_ref
+ * Returns the engine digest length in bytes. If the implementation does not
+ * implement this function {@code 0} is returned.
*
+ * @return the digest length in bytes, or {@code 0}.
+ * @since Android 1.0
*/
protected int engineGetDigestLength() {
return 0;
}
/**
- * @com.intel.drl.spec_ref
+ * Updates this {@code MessageDigestSpi} using the given {@code byte}.
*
+ * @param input
+ * the {@code byte} to update this {@code MessageDigestSpi} with.
+ * @see #engineReset()
+ * @since Android 1.0
*/
protected abstract void engineUpdate(byte input);
-
+
/**
- * @com.intel.drl.spec_ref
+ * Updates this {@code MessageDigestSpi} using the given {@code byte[]}.
*
+ * @param input
+ * the {@code byte} array.
+ * @param offset
+ * the index of the first byte in {@code input} to update from.
+ * @param len
+ * the number of bytes in {@code input} to update from.
+ * @throws IllegalArgumentException
+ * if {@code offset} or {@code len} are not valid in respect to
+ * {@code input}.
+ * @since Android 1.0
*/
protected abstract void engineUpdate(byte[] input, int offset, int len);
/**
- * @com.intel.drl.spec_ref
+ * Updates this {@code MessageDigestSpi} using the given {@code input}.
*
+ * @param input
+ * the {@code ByteBuffer}.
+ * @since Android 1.0
*/
protected void engineUpdate(ByteBuffer input) {
if (!input.hasRemaining()) {
@@ -82,14 +101,35 @@ public abstract class MessageDigestSpi {
}
/**
- * @com.intel.drl.spec_ref
+ * Computes and returns the final hash value for this
+ * {@link MessageDigestSpi}. After the digest is computed the receiver is
+ * reset.
*
+ * @return the computed one way hash value.
+ * @see #engineReset()
+ * @since Android 1.0
*/
protected abstract byte[] engineDigest();
/**
- * @com.intel.drl.spec_ref
+ * Computes and stores the final hash value for this
+ * {@link MessageDigestSpi}. After the digest is computed the receiver is
+ * reset.
*
+ * @param buf
+ * the buffer to store the result in.
+ * @param offset
+ * the index of the first byte in {@code buf} to store in.
+ * @param len
+ * the number of bytes allocated for the digest.
+ * @return the number of bytes written to {@code buf}.
+ * @throws DigestException
+ * if an error occures.
+ * @throws IllegalArgumentException
+ * if {@code offset} or {@code len} are not valid in respect to
+ * {@code buf}.
+ * @see #engineReset()
+ * @since Android 1.0
*/
protected int engineDigest(byte[] buf, int offset, int len)
throws DigestException {
@@ -114,15 +154,13 @@ public abstract class MessageDigestSpi {
}
/**
- * @com.intel.drl.spec_ref
+ * Puts this {@code MessageDigestSpi} back in an initial state, such that it
+ * is ready to compute a one way hash value.
*
+ * @since Android 1.0
*/
protected abstract void engineReset();
- /**
- * @com.intel.drl.spec_ref
- *
- */
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
diff --git a/security/src/main/java/java/security/NoSuchAlgorithmException.java b/security/src/main/java/java/security/NoSuchAlgorithmException.java
index 98650c2..3324076 100644
--- a/security/src/main/java/java/security/NoSuchAlgorithmException.java
+++ b/security/src/main/java/java/security/NoSuchAlgorithmException.java
@@ -23,46 +23,56 @@
package java.security;
/**
- * Instances of this class are thrown when an attempt is made to access an
- * algorithm which is not provided by the library.
+ * {@code NoSuchAlgorithmException} indicates that a requested algorithm could
+ * not be found.
*
- * @see Throwable
+ * @since Android 1.0
*/
public class NoSuchAlgorithmException extends GeneralSecurityException {
- /**
- * @com.intel.drl.spec_ref
- */
private static final long serialVersionUID = -7443947487218346562L;
/**
- * Constructs a new instance of this class with its walkback and message
- * filled in.
- *
+ * Constructs a new instance of {@code NoSuchAlgorithmException} with the
+ * given message.
*
* @param msg
- * String The detail message for the exception.
+ * the detail message for this exception.
+ * @since Android 1.0
*/
public NoSuchAlgorithmException(String msg) {
super(msg);
}
/**
- * Constructs a new instance of this class with its walkback filled in.
+ * Constructs a new instance of {@code NoSuchAlgorithmException}.
*
+ * @since Android 1.0
*/
public NoSuchAlgorithmException() {
}
/**
- * @com.intel.drl.spec_ref
+ * Constructs a new instance of {@code NoSuchAlgorithmException} with the
+ * given message and the cause.
+ *
+ * @param message
+ * the detail message for this exception.
+ * @param cause
+ * the exception which is the cause for this exception.
+ * @since Android 1.0
*/
public NoSuchAlgorithmException(String message, Throwable cause) {
super(message, cause);
}
/**
- * @com.intel.drl.spec_ref
+ * Constructs a new instance of {@code NoSuchAlgorithmException} with the
+ * cause.
+ *
+ * @param cause
+ * the exception which is the cause for this exception.
+ * @since Android 1.0
*/
public NoSuchAlgorithmException(Throwable cause) {
super(cause);
diff --git a/security/src/main/java/java/security/NoSuchProviderException.java b/security/src/main/java/java/security/NoSuchProviderException.java
index 5710916..f016ce6 100644
--- a/security/src/main/java/java/security/NoSuchProviderException.java
+++ b/security/src/main/java/java/security/NoSuchProviderException.java
@@ -23,32 +23,31 @@
package java.security;
/**
- * Instances of this class are thrown when an attempt is made to access a
- * provider by name which is not currently available.
+ * {@code NoSuchProviderException} indicates that a requested security provider
+ * could not be found.
*
- *
- * @see Throwable
+ * @since Android 1.0
*/
public class NoSuchProviderException extends GeneralSecurityException {
- /**
- * @com.intel.drl.spec_ref
- */
+
private static final long serialVersionUID = 8488111756688534474L;
/**
- * Constructs a new instance of this class with its walkback and message
- * filled in.
+ * Constructs a new instance of {@code NoSuchProviderException} with the
+ * given message.
*
* @param msg
- * String The detail message for the exception.
+ * the detail message for this exception.
+ * @since Android 1.0
*/
public NoSuchProviderException(String msg) {
super(msg);
}
/**
- * Constructs a new instance of this class with its walkback filled in.
+ * Constructs a new instance of {@code NoSuchProviderException}.
*
+ * @since Android 1.0
*/
public NoSuchProviderException() {
}
diff --git a/security/src/main/java/java/security/Permission.java b/security/src/main/java/java/security/Permission.java
index de91fc4..93e769c 100644
--- a/security/src/main/java/java/security/Permission.java
+++ b/security/src/main/java/java/security/Permission.java
@@ -25,81 +25,116 @@ package java.security;
import java.io.Serializable;
/**
- * Abstract superclass of all classes which represent permission to access
- * system resources.
+ * {@code Permission} is the common base class of all permissions that
+ * participate in the access control security framework around
+ * {@link AccessController} and {@link AccessControlContext}. A permission
+ * constitutes of a name and associated actions.
*
+ * @since Android 1.0
*/
public abstract class Permission implements Guard, Serializable {
- /**
- * @com.intel.drl.spec_ref
- */
private static final long serialVersionUID = -5636570222231596674L;
private final String name;
- /**
- * @com.intel.drl.spec_ref
+ /**
+ * Compares the specified object with this {@code Permission} for equality
+ * and returns {@code true} if the specified object is equal, {@code false}
+ * otherwise.
+ * + * The {@link #implies(Permission)} method should be used for making access + * control checks. + *
+ * + * @param obj + * object to be compared for equality with this {@code + * Permission}. + * @return {@code true} if the specified object is equal to this {@code + * Permission}, otherwise {@code false}. + * @since Android 1.0 */ public abstract boolean equals(Object obj); /** - * Returns an integer hash code for the receiver. Any two objects which - * answertrue
when passed to .equals
must
- * answer the same value for this method.
- *
+ * Returns the hash code value for this {@code Permission}. Returns the same
+ * hash code for {@code Permission}s that are equal to each other as
+ * required by the general contract of {@link Object#hashCode}.
*
- * @return int the receiver's hash.
- *
- * @see #equals
+ * @return the hash code value for this {@code Permission}.
+ * @see Object#equals(Object)
+ * @see Permission#equals(Object)
+ * @since Android 1.0
*/
public abstract int hashCode();
/**
- * Returns the actions associated with the receiver. Subclasses should
- * return their actions in canonical form. If no actions are associated with
- * the receiver, the empty string should be returned.
+ * Returns a comma separated string identifying the actions associated with
+ * this permission. The returned actions are in canonical form. For example:
+ *
+ * + * sp0 = new SocketPermission("www.google.com", "connect,resolve") + * sp1 = new SocketPermission("www.google.com", "resolve,connect") + * sp0.getActions().equals(sp1.getActions()) //yields true + ** + * Both permissions return "connect,resolve" (in that order) if {@code + * #getActions()} is invoked. Returns an empty String, if no actions are + * associated with this permission. * - * @return String the receiver's actions. + * @return the actions associated with this permission or an empty string if + * no actions are associated with this permission. + * @since Android 1.0 */ public abstract String getActions(); /** - * Indicates whether the argument permission is implied by the receiver. - * + * Indicates whether the specified permission is implied by this permission. + * The {@link AccessController} uses this method to check whether permission + * protected access is allowed with the present policy. * - * @return boolean
true
if the argument permission is implied
- * by the receiver, and false
if it is not.
* @param permission
- * Permission the permission to check.
+ * the permission to check against this permission.
+ * @return {@code true} if the specified permission is implied by this
+ * permission, {@code false} otherwise.
+ * @since Android 1.0
*/
public abstract boolean implies(Permission permission);
/**
- * Constructs a new instance of this class with its name set to the
- * argument.
- *
+ * Constructs a new instance of {@code Permission} with its name.
*
* @param name
- * String the name of the permission.
+ * the name of the permission.
+ * @since Android 1.0
*/
public Permission(String name) {
this.name = name;
}
/**
- * Returns the name of the receiver.
- *
+ * Returns the name of this permission.
*
- * @return String the receiver's name.
+ * @return the name of this permission.
+ * @since Android 1.0
*/
public final String getName() {
return name;
}
- /**
- * @com.intel.drl.spec_ref
+ /**
+ * Invokes {@link SecurityManager#checkPermission(Permission)} with this
+ * permission as its argument. This method implements the {@link Guard}
+ * interface.
+ *
+ * @param obj
+ * as specified in {@link Guard#checkGuard(Object)} but ignored
+ * in this implementation.
+ * @throws SecurityException
+ * if this permission is not granted.
+ * @see Guard
+ * @see SecurityManager#checkPermission(Permission)
+ * @since Android 1.0
*/
public void checkGuard(Object obj) throws SecurityException {
SecurityManager sm = System.getSecurityManager();
@@ -109,12 +144,17 @@ public abstract class Permission implements Guard, Serializable {
}
/**
- * Returns a new PermissionCollection for holding permissions of this class.
- * Answer null if any permission collection can be used.
- *
+ * Returns a specific {@link PermissionCollection} container for permissions
+ * of this type. Returns {@code null} if any permission collection can be
+ * used.
+ * + * Subclasses may override this method to return an appropriate collection + * for the specific permissions they implement. + *
* - * @return PermissionCollection or null a suitable permission collection for - * instances of the class of the receiver. + * @return an empty {@link PermissionCollection} or {@code null} if any + * permission collection can be used. + * @since Android 1.0 */ public PermissionCollection newPermissionCollection() { return null; @@ -122,10 +162,10 @@ public abstract class Permission implements Guard, Serializable { /** * Returns a string containing a concise, human-readable description of the - * receiver. - * + * this {@code Permission} including its name and its actions. * - * @return String a printable representation for the receiver. + * @return a printable representation for this {@code Permission}. + * @since Android 1.0 */ public String toString() { String actions = getActions(); diff --git a/security/src/main/java/java/security/PermissionCollection.java b/security/src/main/java/java/security/PermissionCollection.java index a0cda25..2502123 100644 --- a/security/src/main/java/java/security/PermissionCollection.java +++ b/security/src/main/java/java/security/PermissionCollection.java @@ -28,81 +28,88 @@ import java.util.Enumeration; import java.util.List; /** - * Abstract superclass of classes which are collections of Permission objects. + * {@code PermissionCollection} is the common base class for all collections + * that provide a convenient method for determining whether or not a given + * permission is implied by any of the permissions present in this collection. + *+ * A {@code PermissionCollection} is typically created by using the + * {@link Permission#newPermissionCollection()} factory method. If the mentioned + * method returns {@code null}, then a {@code PermissionCollection} of any type + * can be used. If a collection is returned, it must be used for holding several + * permissions of the particular type. + *
+ *+ * Subclasses must be implemented thread save. + *
* + * @since Android 1.0 */ public abstract class PermissionCollection implements Serializable { - /** - * @com.intel.drl.spec_ref - */ private static final long serialVersionUID = -6727011328946861783L; - /** - * @com.intel.drl.spec_ref - */ private boolean readOnly; // = false; /** - * Adds the argument to the collection. - * + * Adds the specified {@code Permission} to this collection. * * @param permission - * java.security.Permission the permission to add to the - * collection. - * @exception IllegalStateException - * if the collection is read only. + * the {@code Permission} to add. + * @throws IllegalStateException + * if the collection is read only. + * @since Android 1.0 */ public abstract void add(Permission permission); /** - * Returns an enumeration of the permissions in the receiver. + * Returns an enumeration over all {@link Permission}s encapsulated by this + * {@code PermissionCollection}. * - * - * @return Enumeration the permissions in the receiver. + * @return an enumeration over all {@link Permission}s. + * @since Android 1.0 */ public abstract Enumerationtrue
if the argument permission is implied
- * by the permissions in the receiver, and false
if
- * it is not.
* @param permission
- * java.security.Permission the permission to check
+ * the permission to check.
+ * @return {@code true} if the given permission is implied by the
+ * permissions in this collection, {@code false} otherwise.
+ * @since Android 1.0
*/
public abstract boolean implies(Permission permission);
/**
- * Indicates whether new permissions can be added to the receiver.
+ * Indicates whether new permissions can be added to this {@code
+ * PermissionCollection}.
*
- *
- * @return boolean true
if the receiver is read only
- * false
if new elements can still be added to the
- * receiver.
+ * @return {@code true} if the receiver is read only, {@code false} if new
+ * elements can still be added to this {@code PermissionCollection}.
+ * @since Android 1.0
*/
public boolean isReadOnly() {
return readOnly;
}
/**
- * Marks the receiver as read only, so that no new permissions can be added
- * to it.
+ * Marks this {@code PermissionCollection} as read only, so that no new
+ * permissions can be added to it.
*
+ * @since Android 1.0
*/
public void setReadOnly() {
readOnly = true;
}
/**
- * Returns a string containing a concise, human-readable description of the
- * receiver.
- *
+ * Returns a string containing a concise, human-readable description of this
+ * {@code PermissionCollection}.
*
- * @return a printable representation for the receiver.
+ * @return a printable representation for this {@code PermissionCollection}.
+ * @since Android 1.0
*/
public String toString() {
List elist = new ArrayList(100);
diff --git a/security/src/main/java/java/security/Permissions.java b/security/src/main/java/java/security/Permissions.java
index 93faf33..b9b13c6 100644
--- a/security/src/main/java/java/security/Permissions.java
+++ b/security/src/main/java/java/security/Permissions.java
@@ -38,15 +38,18 @@ import java.util.NoSuchElementException;
import org.apache.harmony.security.internal.nls.Messages;
/**
- * A heterogeneous collection of permissions.
+ * {@code Permissions} represents a {@code PermissionCollection} where the
+ * contained permissions can be of different types. The permissions are
+ * organized in their appropriate {@code PermissionCollection} obtained by
+ * {@link Permission#newPermissionCollection()}. For permissions which do not
+ * provide a dedicated {@code PermissionCollection}, a default permission
+ * collection, based on a hash table, will be used.
*
+ * @since Android 1.0
*/
public final class Permissions extends PermissionCollection implements
Serializable {
- /**
- * @com.intel.drl.spec_ref
- */
private static final long serialVersionUID = 4858622370623524688L;
private static final ObjectStreamField[] serialPersistentFields = {
@@ -56,18 +59,21 @@ public final class Permissions extends PermissionCollection implements
// Hash to store PermissionCollection's
private transient Map klasses = new HashMap();
- /**
- * @com.intel.drl.spec_ref
- */
private boolean allEnabled; // = false;
/**
- * Adds the argument to the collection.
- *
+ * Adds the given {@code Permission} to this heterogeneous {@code
+ * PermissionCollection}. The {@code permission} is stored in its
+ * appropriate {@code PermissionCollection}.
*
* @param permission
- * java.security.Permission the permission to add to the
- * collection
+ * the {@code Permission} to be added.
+ * @throws SecurityException
+ * if this collection's {@link #isReadOnly()} method returns
+ * {@code true}.
+ * @throws NullPointerException
+ * if {@code permission} is {@code null}.
+ * @since Android 1.0
*/
public void add(Permission permission) {
if (isReadOnly()) {
@@ -102,12 +108,6 @@ public final class Permissions extends PermissionCollection implements
}
}
- /**
- * Returns an enumeration of the permissions in the receiver.
- *
- *
- * @return Enumeration the permissions in the receiver.
- */
public Enumerationtrue
if the argument permission is implied
- * by the permissions in the receiver, and false
if
- * it is not.
- * @param permission
- * java.security.Permission the permission to check
- */
public boolean implies(Permission permission) {
if (permission == null) {
// RI compatible
diff --git a/security/src/main/java/java/security/PermissionsHash.java b/security/src/main/java/java/security/PermissionsHash.java
index 875abe4..69d2b07 100644
--- a/security/src/main/java/java/security/PermissionsHash.java
+++ b/security/src/main/java/java/security/PermissionsHash.java
@@ -28,12 +28,13 @@ import java.util.Hashtable;
import org.apache.harmony.security.internal.nls.Messages;
/**
- * A default PermissionCollection implementation that uses a hashtable. Each
- * hashtable entry stores a Permission object as both the key and the value.
- * + * The system policy can be changed by setting the {@code 'policy.provider'} + * property in the file named {@code JAVA_HOME/lib/security/java.security} to + * the fully qualified class name of the desired {@code Policy}. + *
+ *+ * Only one instance of a {@code Policy} is active at any time. + *
* + * @since Android 1.0 */ public abstract class Policy { @@ -49,38 +60,47 @@ public abstract class Policy { private static Policy activePolicy; /** - * Returns a PermissionCollection describing what permissions are available - * to the given CodeSource based on the current security policy. + * Returns a {@code PermissionCollection} describing what permissions are + * allowed for the specified {@code CodeSource} based on the current + * security policy. *- * Note that this method is not called for classes which are in - * the system domain (i.e. system classes). System classes are - * always given full permissions (i.e. AllPermission). This can - * not be changed by installing a new Policy. - * + * Note that this method is not called for classes which are in the system + * domain (i.e. system classes). System classes are always 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. + * the {@code CodeSource} to compute the permissions for. + * @return the permissions that are granted to the specified {@code + * CodeSource}. + * @since Android 1.0 */ public abstract PermissionCollection getPermissions(CodeSource cs); /** - * Reloads the policy configuration, depending on how the type of source - * location for the policy information. - * + * Reloads the policy configuration for this {@code Policy} instance. * + * @since Android 1.0 */ public abstract void refresh(); /** - * Returns a PermissionCollection describing what permissions are available - * to the given ProtectionDomain (more specifically, its CodeSource) based - * on the current security policy. + * Returns a {@code PermissionCollection} describing what permissions are + * allowed for the specified {@code ProtectionDomain} (more specifically, + * its {@code CodeSource}) based on the current security policy. + *+ * Note that this method is not< called for classes which are in the + * system domain (i.e. system classes). System classes are always + * given full permissions (i.e. AllPermission). This can not be changed by + * installing a new policy. + *
* * @param domain - * ProtectionDomain the protection domain to compute the - * permissions for. - * @return PermissionCollection the permissions the code source should have. + * the {@code ProtectionDomain} to compute the permissions for. + * @return the permissions that are granted to the specified {@code + * CodeSource}. + * @since Android 1.0 */ public PermissionCollection getPermissions(ProtectionDomain domain) { if (domain != null) { @@ -90,14 +110,18 @@ public abstract class Policy { } /** - * Returns whether the Permission is implied by the PermissionCollection of - * the Protection Domain + * Indicates whether the specified {@code Permission} is implied by the + * {@code PermissionCollection} of the specified {@code ProtectionDomain}. * * @param domain - * ProtectionDomain for which Permission to be checked + * the {@code ProtectionDomain} for which the permission should + * be granted. * @param permission - * Permission for which authorization is to be verified - * @return boolean Permission implied by ProtectionDomain + * the {@code Permission} for which authorization is to be + * verified. + * @return {@code true} if the {@code Permission} is implied by the {@code + * ProtectionDomain}, {@code false} otherwise. + * @since Android 1.0 */ public boolean implies(ProtectionDomain domain, Permission permission) { if (domain != null) { @@ -119,10 +143,19 @@ public abstract class Policy { /** * Returns the current system security policy. If no policy has been - * instantiated then this is done using the security property policy.provider - * + * instantiated then this is done using the security property {@code + * "policy.provider"}. + *+ * If a {@code SecurityManager} is installed, code calling this method needs + * the {@code SecurityPermission} {@code getPolicy} to be granted, otherwise + * a {@code SecurityException} will be thrown. + *
* - * @return Policy the current system security policy. + * @return the current system security policy. + * @throws SecurityException + * if a {@code SecurityManager} is installed and the caller does + * not have permission to invoke this method. + * @since Android 1.0 */ public static Policy getPolicy() { SecurityManager sm = System.getSecurityManager(); @@ -169,7 +202,7 @@ public abstract class Policy { } /** - * Returns true if system policy provider is instantiated. + * Returns {@code true} if system policy provider is instantiated. */ static boolean isSet() { return activePolicy != null; @@ -197,11 +230,19 @@ public abstract class Policy { } /** - * Sets the system-wide policy object if it is permitted by the security - * manager. + * Sets the system wide policy. + *+ * If a {@code SecurityManager} is installed, code calling this method needs + * the {@code SecurityPermission} {@code setPolicy} to be granted, otherwise + * a {@code SecurityException} will be thrown. + *
* * @param policy - * Policy the policy object that needs to be set. + * the {@code Policy} to set. + * @throws SecurityException + * if a {@code SecurityManager} is installed and the caller does + * not have permission to invoke this method. + * @since Android 1.0 */ public static void setPolicy(Policy policy) { SecurityManager sm = System.getSecurityManager(); diff --git a/security/src/main/java/java/security/Principal.java b/security/src/main/java/java/security/Principal.java index 2fac7af..0716681 100644 --- a/security/src/main/java/java/security/Principal.java +++ b/security/src/main/java/java/security/Principal.java @@ -24,25 +24,52 @@ package java.security; /** - * Principals are objects which have identities. These can be individuals, - * groups, corporations, unique program executions, etc. + * {@code Principal}s are objects which have identities. These can be + * individuals, groups, corporations, unique program executions, etc. * + * @since Android 1.0 */ public interface Principal { - /** - * @com.intel.drl.spec_ref + /** + * Compares the specified object with this {@code Principal} for equality + * and returns {@code true} if the specified object is equal, {@code false} + * otherwise. + * + * @param obj + * object to be compared for equality with this {@code + * Principal}. + * @return {@code true} if the specified object is equal to this {@code + * Principal}, otherwise {@code false}. + * @since Android 1.0 */ public boolean equals( Object obj ); - /** - * @com.intel.drl.spec_ref + + /** + * Returns the name of this {@code Principal}. + * + * @return the name of this {@code Principal}. + * @since Android 1.0 */ public String getName(); - /** - * @com.intel.drl.spec_ref + + /** + * Returns the hash code value for this {@code Principal}. Returns the same + * hash code for {@code Principal}s that are equal to each other as + * required by the general contract of {@link Object#hashCode}. + * + * @return the hash code value for this {@code Principal}. + * @see Object#equals(Object) + * @see Principal#equals(Object) + * @since Android 1.0 */ public int hashCode(); + /** - * @com.intel.drl.spec_ref + * Returns a string containing a concise, human-readable description of + * this {@code Principal}. + * + * @return a printable representation for this {@code Principal}. + * @since Android 1.0 */ public String toString(); } diff --git a/security/src/main/java/java/security/PrivateKey.java b/security/src/main/java/java/security/PrivateKey.java index f09b4a8..8513b75 100644 --- a/security/src/main/java/java/security/PrivateKey.java +++ b/security/src/main/java/java/security/PrivateKey.java @@ -23,12 +23,17 @@ package java.security; /** - * @com.intel.drl.spec_ref + * {@code PrivateKey} is the common interface for private keys. * + * @see PublicKey + * @since Android 1.0 */ public interface PrivateKey extends Key { + /** - * @com.intel.drl.spec_ref + * The {@code serialVersionUID} to be compatible with JDK1.1. + * + * @since Android 1.0 */ public static final long serialVersionUID = 6034044314589513430L; } \ No newline at end of file diff --git a/security/src/main/java/java/security/PrivilegedAction.java b/security/src/main/java/java/security/PrivilegedAction.java index 4e16e3a..5912cdc 100644 --- a/security/src/main/java/java/security/PrivilegedAction.java +++ b/security/src/main/java/java/security/PrivilegedAction.java @@ -23,12 +23,23 @@ package java.security; /** - * @com.intel.drl.spec_ref + * {@code PrivilegedAction} represents an action that can be executed privileged + * regarding access control. Instances of {@code PrivilegedAction} can be + * executed on {@code AccessController.doPrivileged()}. + * + * @see AccessController + * @see AccessController#doPrivileged(PrivilegedAction) + * @see AccessController#doPrivileged(PrivilegedAction, AccessControlContext) + * @see PrivilegedExceptionAction + * @since Android 1.0 */ - public interface PrivilegedAction+ * Privileged actions which can throw exceptions are of type {@code + * PrivilegedExceptionAction} and are thrown by + *
- * Note: a class can only belong to one and only one protection domain. + * A class belongs to exactly one protection domain and the protection domain + * can not be changed during the lifetime of the class. + *
+ * + * @since Android 1.0 */ public class ProtectionDomain { @@ -48,11 +53,32 @@ public class ProtectionDomain { private boolean dynamicPerms; /** - * Constructs 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 + * Constructs a new instance of {@code ProtectionDomain} with the specified + * code source and the specified static permissions. + *+ * If {@code permissions} is not {@code null}, the {@code permissions} + * collection is made immutable by calling + * {@link PermissionCollection#setReadOnly()} and it is considered as + * granted statically to this {@code ProtectionDomain}. + *
+ *+ * The policy will not be consulted by access checks against this {@code + * ProtectionDomain}. + *
+ *+ * If {@code permissions} is {@code null}, the method + * {@link ProtectionDomain#implies(Permission)} always returns {@code false} + * . + *
+ * + * @param cs + * the code source associated with this domain, maybe {@code + * null}. + * @param permissions + * the {@code PermissionCollection} containing all permissions to + * be statically granted to this {@code ProtectionDomain}, maybe + * {@code null}. + * @since Android 1.0 */ public ProtectionDomain(CodeSource cs, PermissionCollection permissions) { this.codeSource = cs; @@ -65,22 +91,36 @@ public class ProtectionDomain { //dynamicPerms = false; } + /** - * Constructs 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. + * Constructs a new instance of {@code ProtectionDomain} with the specified + * code source, the permissions, the class loader and the principals. + *+ * If {@code permissions} is {@code null}, and access checks are performed + * against this protection domain, the permissions defined by the policy are + * consulted. If {@code permissions} is not {@code null}, the {@code + * permissions} collection is made immutable by calling + * {@link PermissionCollection#setReadOnly()}. If access checks are + * performed, the policy and the provided permission collection are checked. + *
+ *+ * External modifications of the provided {@code principals} array has no + * impact on this {@code ProtectionDomain}. + *
* * @param cs - * the CodeSource associated with this domain + * the code source associated with this domain, maybe {@code + * null}. * @param permissions - * the Permissions associated with this domain + * the permissions associated with this domain, maybe {@code + * null}. * @param cl - * the ClassLoader associated with this domain + * the class loader associated with this domain, maybe {@code + * null}. * @param principals - * the Principals associated with this domain + * the principals associated with this domain, maybe {@code null} + * . + * @since Android 1.0 */ public ProtectionDomain(CodeSource cs, PermissionCollection permissions, ClassLoader cl, Principal[] principals) { @@ -99,39 +139,47 @@ public class ProtectionDomain { } /** - * Returns the ClassLoader associated with the ProtectionDomain + * Returns the {@code ClassLoader} associated with this {@code + * ProtectionDomain}. * - * @return ClassLoader associated ClassLoader + * @return the {@code ClassLoader} associated with this {@code + * ProtectionDomain}, maybe {@code null}. + * @since Android 1.0 */ public final ClassLoader getClassLoader() { return classLoader; } /** - * Returns the code source of this domain. + * Returns the {@code CodeSource} of this {@code ProtectionDomain}. * - * @return java.security.CodeSource the code source of this domain + * @return the {@code CodeSource} of this {@code ProtectionDomain}, maybe + * {@code null}. + * @since Android 1.0 */ public final CodeSource getCodeSource() { return codeSource; } /** - * Returns the permissions that should be granted to the classes which are - * encapsulated in this domain. + * Returns the static permissions that are granted to this {@code + * ProtectionDomain}. * - * @return java.security.PermissionCollection collection of permissions - * associated with this domain. + * @return the static permissions that are granted to this {@code + * ProtectionDomain}, maybe {@code null}. + * @since Android 1.0 */ public final PermissionCollection getPermissions() { return permissions; } /** - * Returns the Principals associated with this ProtectionDomain. A change to - * the returned array will not impact the ProtectionDomain. + * Returns the principals associated with this {@code ProtectionDomain}. + * Modifications of the returned {@code Principal} array has no impact on + * this {@code ProtectionDomain}. * - * @return Principals[] Principals associated with the ProtectionDomain. + * @return the principals associated with this {@code ProtectionDomain}. + * @since Android 1.0 */ public final Principal[] getPrincipals() { if( principals == null ) { @@ -143,14 +191,27 @@ public class ProtectionDomain { } /** - * Determines whether the permission collection of this domain implies the - * argument permission. - * + * Indicates whether the specified permission is implied by this {@code + * ProtectionDomain}. + *+ * If this {@code ProtectionDomain} was constructed with + * {@link #ProtectionDomain(CodeSource, PermissionCollection)}, the + * specified permission is only checked against the permission collection + * provided in the constructor. If {@code null} was provided, {@code false} + * is returned. + *
+ *+ * If this {@code ProtectionDomain} was constructed with + * {@link #ProtectionDomain(CodeSource, PermissionCollection, ClassLoader, Principal[])} + * , the specified permission is checked against the policy and the + * permission collection provided in the constructor. + *
* - * @return boolean true if this permission collection implies the argument - * and false otherwise. * @param permission - * java.security.Permission the permission to check. + * the permission to check against the domain. + * @return {@code true} if the specified {@code permission} is implied by + * this {@code ProtectionDomain}, {@code false} otherwise. + * @since Android 1.0 */ public boolean implies(Permission permission) { // First, test with the Policy, as the default Policy.implies() @@ -170,9 +231,10 @@ public class ProtectionDomain { /** * Returns a string containing a concise, human-readable description of the - * receiver. + * this {@code ProtectionDomain}. * - * @return String a printable representation for the receiver. + * @return a printable representation for this {@code ProtectionDomain}. + * @since Android 1.0 */ public String toString() { //FIXME: 1.5 use StreamBuilder here diff --git a/security/src/main/java/java/security/Provider.java b/security/src/main/java/java/security/Provider.java index ae4acb9..491470f 100644 --- a/security/src/main/java/java/security/Provider.java +++ b/security/src/main/java/java/security/Provider.java @@ -40,6 +40,12 @@ import org.apache.harmony.luni.util.TwoKeyHashMap; import org.apache.harmony.security.fortress.Services; import org.apache.harmony.security.internal.nls.Messages; +/** + * {@code Provider} is the abstract superclass for all security providers in the + * Java security infrastructure. + * + * @since Android 1.0 + */ public abstract class Provider extends Properties { private static final long serialVersionUID = -4298000515446427739L; @@ -90,6 +96,18 @@ public abstract class Provider extends Properties { // last Service found by type private transient Provider.Service lastServicesByType; + /** + * Constructs a new instance of {@code Provider} with its name, version and + * description. + * + * @param name + * the name of the provider. + * @param version + * the version of the provider. + * @param info + * a description of the provider. + * @since Android 1.0 + */ protected Provider(String name, double version, String info) { this.name = name; this.version = version; @@ -101,47 +119,61 @@ public abstract class Provider extends Properties { /** * Returns the name of this provider. * - * - * - * @return String name of the provider + * @return the name of this provider. + * @since Android 1.0 */ public String getName() { return name; } /** - * Returns the version number for the services being provided - * + * Returns the version number for the services being provided. * - * - * @return double version number for the services being provided + * @return the version number for the services being provided. + * @since Android 1.0 */ public double getVersion() { return version; } /** - * Returns the generic information about the services being provided. - * + * Returns a description of the services being provided. * - * - * @return String generic description of the services being provided + * @return a description of the services being provided. + * @since Android 1.0 */ public String getInfo() { return info; } /** - * Returns a string containing a concise, human-readable description of the - * receiver. - * - * - * @return a printable representation for the receiver. + * Returns a string containing a concise, human-readable description of + * this {@code Provider} including its name and its version. + * + * @return a printable representation for this {@code Provider}. + * @since Android 1.0 */ public String toString() { + // BEGIN android-changed return name + " version " + version; //$NON-NLS-1$ + // END android-changed } + /** + * Clears all properties used to look up services implemented by this + * {@code Provider}. + *+ * If a {@code SecurityManager} is installed, code calling this method needs + * the {@code SecurityPermission} {@code clearProviderProperties.NAME} + * (where NAME is the provider name) to be granted, otherwise a {@code + * SecurityException} will be thrown. + *
+ * + * @throws SecurityException + * if a {@code SecurityManager} is installed and the caller does + * not have permission to invoke this method. + * @since Android 1.0 + */ public synchronized void clear() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { @@ -177,6 +209,22 @@ public abstract class Provider extends Properties { myPutAll(tmp); } + /** + * Copies all from the provided map to this {@code Provider}. + *+ * If a {@code SecurityManager} is installed, code calling this method needs + * the {@code SecurityPermission} {@code putProviderProperty.NAME} (where + * NAME is the provider name) to be granted, otherwise a {@code + * SecurityException} will be thrown. + *
+ * + * @param t + * the mappings to copy to this provider. + * @throws SecurityException + * if a {@code SecurityManager} is installed and the caller does + * not have permission to invoke this method. + * @since Android 1.0 + */ public synchronized void putAll(Map,?> t) { // Implementation note: @@ -229,6 +277,27 @@ public abstract class Provider extends Properties { return Collections.unmodifiableCollection(super.values()); } + /** + * Maps the specified {@code key} property name to the specified {@code + * value}. + *+ * If a {@code SecurityManager} is installed, code calling this method needs + * the {@code SecurityPermission} {@code putProviderProperty.NAME} (where + * NAME is the provider name) to be granted, otherwise a {@code + * SecurityException} will be thrown. + *
+ * + * @param key + * the name of the property. + * @param value + * the value of the property. + * @return the value that was previously mapped to the specified {@code key} + * ,or {@code null} if it did not have one. + * @throws SecurityException + * if a {@code SecurityManager} is installed and the caller does + * not have permission to invoke this method. + * @since Android 1.0 + */ public synchronized Object put(Object key, Object value) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { @@ -252,6 +321,25 @@ public abstract class Provider extends Properties { return super.put(key, value); } + /** + * Removes the specified {@code key} and its associated value from this + * {@code Provider}. + *+ * If a {@code SecurityManager} is installed, code calling this method needs + * the {@code SecurityPermission} {@code removeProviderProperty.NAME} (where + * NAME is the provider name) to be granted, otherwise a {@code + * SecurityException} will be thrown. + *
+ * + * @param key + * the name of the property + * @return the value that was mapped to the specified {@code key} ,or + * {@code null} if no mapping was present + * @throws SecurityException + * if a {@code SecurityManager} is installed and the caller does + * not have the permission to invoke this method. + * @since Android 1.0 + */ public synchronized Object remove(Object key) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { @@ -277,19 +365,18 @@ public abstract class Provider extends Properties { } /** - * - * returns true if the provider implements the specified algorithm. Caller must - * specify the cryptographic service and specify constraints via the + * returns true if the provider implements the specified algorithm. Caller + * must specify the cryptographic service and specify constraints via the * attribute name the attribute value * * @param serv - * Crypto service + * Crypto service. * @param alg - * Algorithm or type + * Algorithm or type. * @param attribute - * The attribute name or null + * The attribute name or {@code null}. * @param val - * The attribute value + * The attribute value. * @return */ boolean implementsAlg(String serv, String alg, String attribute, String val) { @@ -319,11 +406,11 @@ public abstract class Provider extends Properties { String attributeValue = getPropertyIgnoreCase(servAlg + ' ' + attribute); if (attributeValue != null) { if (attribute.equalsIgnoreCase("KeySize")) { //$NON-NLS-1$ -// BEGIN android-changed + // BEGIN android-changed if (Integer.parseInt(attributeValue) >= Integer.parseInt(val)) { -// END android-changed return true; } + // END android-changed } else { // other attributes if (attributeValue.equalsIgnoreCase(val)) { return true; @@ -374,6 +461,23 @@ public abstract class Provider extends Properties { return null; } + /** + * Returns the service with the specified {@code type} implementing the + * specified {@code algorithm}, or {@code null} if no such implementation + * exists. + *
+ * If two services match the requested type and algorithm, the one added
+ * with the {@link #putService(Service)} is returned (as opposed to the one
+ * added via {@link #put(Object, Object)}.
+ *
+ * @param type
+ * the type of the service (for example {@code KeyPairGenerator})
+ * @param algorithm
+ * the algorithm name (case insensitive)
+ * @return the requested service, or {@code null} if no such implementation
+ * exists
+ * @since Android 1.0
+ */
public synchronized Provider.Service getService(String type,
String algorithm) {
if (type == null || algorithm == null) {
@@ -412,6 +516,14 @@ public abstract class Provider extends Properties {
return null;
}
+ /**
+ * Returns an unmodifiable {@code Set} of all services registered by this
+ * provider.
+ *
+ * @return an unmodifiable {@code Set} of all services registered by this
+ * provider
+ * @since Android 1.0
+ */
public synchronized Set
+ * If a {@code SecurityManager} is installed, code calling this method needs
+ * the {@code SecurityPermission} {@code putProviderProperty.NAME} (where
+ * NAME is the provider name) to be granted, otherwise a {@code
+ * SecurityException} will be thrown.
+ *
+ * @param s
+ * the {@code Service} to register
+ * @throws SecurityException
+ * if a {@code SecurityManager} is installed and the caller does
+ * not have permission to invoke this method
+ * @since Android 1.0
+ */
protected synchronized void putService(Provider.Service s) {
if (s == null) {
throw new NullPointerException();
@@ -457,6 +585,24 @@ public abstract class Provider extends Properties {
serviceInfoToProperties(s);
}
+ /**
+ * Removes a previously registered {@code Service} from this {@code
+ * Provider}.
+ *
+ * If a {@code SecurityManager} is installed, code calling this method needs
+ * the {@code SecurityPermission} {@code removeProviderProperty.NAME} (where
+ * NAME is the provider name) to be granted, otherwise a {@code
+ * SecurityException} will be thrown.
+ *
+ * @param s
+ * the {@code Service} to remove
+ * @throws SecurityException
+ * if a {@code SecurityManager} is installed and the caller does
+ * not have permission to invoke this method
+ * @throws NullPointerException
+ * if {@code s} is {@code null}
+ * @since Android 1.0
+ */
protected synchronized void removeService(Provider.Service s) {
if (s == null) {
throw new NullPointerException();
@@ -755,6 +901,13 @@ public abstract class Provider extends Properties {
return null;
}
+ /**
+ * {@code Service} represents a service in the Java Security infrastructure.
+ * Each service describes its type, the algorithm it implements, to which
+ * provider it belongs and other properties.
+ *
+ * @since Android 1.0
+ */
public static class Service {
// The provider
private Provider provider;
@@ -780,6 +933,30 @@ public abstract class Provider extends Properties {
// For newInstance() optimization
private String lastClassName;
+ /**
+ * Constructs a new instance of {@code Service} with the given
+ * attributes.
+ *
+ * @param provider
+ * the provider to which this service belongs.
+ * @param type
+ * the type of this service (for example {@code
+ * KeyPairGenerator}).
+ * @param algorithm
+ * the algorithm this service implements.
+ * @param className
+ * the name of the class implementing this service.
+ * @param aliases
+ * {@code List} of aliases for the algorithm name, or {@code
+ * null} if the implemented algorithm has no aliases.
+ * @param attributes
+ * {@code Map} of additional attributes, or {@code null} if
+ * this {@code Service} has no attributed.
+ * @throws NullPointerException
+ * if {@code provider, type, algorithm} or {@code className}
+ * is {@code null}.
+ * @since Android 1.0
+ */
public Service(Provider provider, String type, String algorithm,
String className, List
+ * If a {@code SecurityManager} is installed, code calling this constructor
+ * needs the {@code SecurityPermission} {@code checkCreateClassLoader} to be
+ * granted, otherwise a {@code SecurityException} will be thrown.
+ *
+ * If a {@code SecurityManager} is installed, code calling this constructor
+ * needs the {@code SecurityPermission} {@code checkCreateClassLoader} to be
+ * granted, otherwise a {@code SecurityException} will be thrown.
+ *
+ * If a {@code SecurityManager} is installed, code calling this method needs
+ * the {@code SecurityPermission} {@code insertProvider.NAME} (where NAME is
+ * the provider name) to be granted, otherwise a {@code SecurityException}
+ * will be thrown.
+ *
+ * If a {@code SecurityManager} is installed, code calling this method needs
+ * the {@code SecurityPermission} {@code insertProvider.NAME} (where NAME is
+ * the provider name) to be granted, otherwise a {@code SecurityException}
+ * will be thrown.
+ *
+ * Returns silently if {@code name} is {@code null} or no provider with the
+ * specified name is installed.
+ *
+ * If a {@code SecurityManager} is installed, code calling this method needs
+ * the {@code SecurityPermission} {@code removeProvider.NAME} (where NAME is
+ * the provider name) to be granted, otherwise a {@code SecurityException}
+ * will be thrown.
+ *
+ * (for example: "MessageDigest.SHA")
+ *
+ * (for example: "Signature.MD2withRSA KeySize:512")
+ *
+ * for example: "MessageDigest.SHA" The value associated with the key must
+ * be an empty string.
+ * for example: "Signature.MD2withRSA KeySize:512" where "KeySize:512" is
+ * the value of the filter map entry.
+ *
+ * If a {@code SecurityManager} is installed, code calling this method needs
+ * the {@code SecurityPermission} {@code getProperty.KEY} (where KEY is the
+ * specified {@code key}) to be granted, otherwise a {@code
+ * SecurityException} will be thrown.
+ *
+ * If a {@code SecurityManager} is installed, code calling this method needs
+ * the {@code SecurityPermission} {@code setProperty.KEY} (where KEY is the
+ * specified {@code key}) to be granted, otherwise a {@code
+ * SecurityException} will be thrown.
+ *
+ * If the given certificate is an instance of {@link X509Certificate} and
+ * has a key usage parameter that indicates, that this certificate is not to
+ * be used for signing, an {@code InvalidKeyException} is thrown.
+ *
+ * This {@code Signature} instance is reset to the state of its last
+ * initialization for signing and thus can be used for another signature
+ * from the same identity.
+ *
+ * This {@code Signature} instance is reset to the state of its last
+ * initialization for signing and thus can be used for another signature
+ * from the same identity.
+ *
+ * This {@code Signature} instance is reset to the state of its last
+ * initialization for verifying and thus can be used to verify another
+ * signature of the same signer.
+ *
+ * This {@code Signature} instance is reset to the state of its last
+ * initialization for verifying and thus can be used to verify another
+ * signature of the same signer.
+ *
+ * This {@code SignatureSpi} instance is reset to the state of its last
+ * initialization for signing and thus can be used for another signature
+ * from the same identity.
+ *
+ * This {@code SignatureSpi} instance is reset to the state of its last
+ * initialization for signing and thus can be used for another signature
+ * from the same identity.
+ *
+ * This {@code SignatureSpi} instance is reset to the state of its last
+ * initialization for verifying and thus can be used to verify another
+ * signature of the same signer.
+ *
+ * This {@code SignatureSpi} instance is reset to the state of its last
+ * initialization for verifying and thus can be used to verify another
+ * signature of the same signer.
+ *
+ * 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.
+ *
+ * It is assumed that the class has a proper name (as returned by {@code
+ * getName()} of this unresolved permission), so no check is performed to
+ * verify this. However, the class must have all required certificates (as
+ * per {@code getUnresolvedCerts()}) among the passed collection of signers.
+ * If it does, a zero, one, and/or two-argument constructor is tried to
+ * instantiate a new permission, which is then returned.
+ *
+ * If an appropriate constructor is not available or the class is improperly
+ * signed, {@code null} is returned.
+ *
+ * An ACL is a set of {@link AclEntry} objects.
+ *
+ * An {@code AclEntry} is a list of {@link Permission}s that are granted
+ * (positive) or denied
+ * (negative) to a {@link Principal}.
+ *
+ * An {@code Acl} has a list of owners ({@link Owner}) which are principals as well {@code
+ * Principal}. Only those principals which are the {@code Acl}'s owners are allowed to modify the {@code
+ * Acl}.
+ *
+ * The ACL has to conform to the following rules:
+ *
+ * If the ACL already has an {@code AclEntry} of the same type (
+ * positive or negative) and principal, then the new entry is not added.
+ *
+ * If the specified principal has no entry in this ACL, an empty set is
+ * returned.
+ *
+ * The allowed permissions are collected according to the following rules:
+ * getInstance()
instead.
+ * Constructs a new instance of {@code SecureRandom}. An implementation for
+ * the highest-priority provider is returned. The constructed instance will
+ * not have been seeded.
*
- * An implementation for the highest-priority provider is returned. The
- * instance returned will not have been seeded.
+ * @since Android 1.0
*/
public SecureRandom() {
super(0);
@@ -115,14 +91,13 @@ public class SecureRandom extends Random {
}
/**
- * Constructs a new instance of this class. Users are encouraged to use
- * getInstance()
instead.
- *
- * An implementation for the highest-priority provider is returned. The
- * instance returned will be seeded with the parameter.
+ * Constructs a new instance of {@code SecureRandom}. An implementation for
+ * the highest-priority provider is returned. The constructed instance will
+ * be seeded with the parameter.
*
* @param seed
- * bytes forming the seed for this generator.
+ * the seed for this generator.
+ * @since Android 1.0
*/
public SecureRandom(byte[] seed) {
this();
@@ -143,8 +118,14 @@ public class SecureRandom extends Random {
}
/**
- * @com.intel.drl.spec_ref
+ * Constructs a new instance of {@code SecureRandom} using the given
+ * implementation from the specified provider.
*
+ * @param secureRandomSpi
+ * the implementation.
+ * @param provider
+ * the security provider.
+ * @since Android 1.0
*/
protected SecureRandom(SecureRandomSpi secureRandomSpi,
Provider provider) {
@@ -162,8 +143,18 @@ public class SecureRandom extends Random {
}
/**
- * @com.intel.drl.spec_ref
+ * Returns a new instance of {@code SecureRandom} that utilizes the
+ * specified algorithm.
*
+ * @param algorithm
+ * the name of the algorithm to use.
+ * @return a new instance of {@code SecureRandom} that utilizes the
+ * specified algorithm.
+ * @throws NoSuchAlgorithmException
+ * if the specified algorithm is not available.
+ * @throws NullPointerException
+ * if {@code algorithm} is {@code null}.
+ * @since Android 1.0
*/
public static SecureRandom getInstance(String algorithm)
throws NoSuchAlgorithmException {
@@ -177,19 +168,22 @@ public class SecureRandom extends Random {
}
/**
- * Returns 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.
+ * Returns a new instance of {@code SecureRandom} that utilizes the
+ * specified algorithm from the specified provider.
*
* @param algorithm
- * java.lang.String Name of the algorithm desired
+ * the name of the algorithm to use.
* @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
+ * the name of the provider.
+ * @return a new instance of {@code SecureRandom} that utilizes the
+ * specified algorithm from the specified provider.
+ * @throws NoSuchAlgorithmException
+ * if the specified algorithm is not available.
+ * @throws NoSuchProviderException
+ * if the specified provider is not available.
+ * @throws NullPointerException
+ * if {@code algorithm} is {@code null}.
+ * @since Android 1.0
*/
public static SecureRandom getInstance(String algorithm, String provider)
throws NoSuchAlgorithmException, NoSuchProviderException {
@@ -205,8 +199,20 @@ public class SecureRandom extends Random {
}
/**
- * @com.intel.drl.spec_ref
+ * Returns a new instance of {@code SecureRandom} that utilizes the
+ * specified algorithm from the specified provider.
*
+ * @param algorithm
+ * the name of the algorithm to use.
+ * @param provider
+ * the security provider.
+ * @return a new instance of {@code SecureRandom} that utilizes the
+ * specified algorithm from the specified provider.
+ * @throws NoSuchAlgorithmException
+ * if the specified algorithm is not available.
+ * @throws NullPointerException
+ * if {@code algorithm} is {@code null}.
+ * @since Android 1.0
*/
public static SecureRandom getInstance(String algorithm, Provider provider)
throws NoSuchAlgorithmException {
@@ -223,38 +229,46 @@ public class SecureRandom extends Random {
}
/**
- * Returns the Provider of the secure random represented by the receiver.
+ * Returns the provider associated with this {@code SecureRandom}.
*
- * @return Provider an instance of a subclass of java.security.Provider
+ * @return the provider associated with this {@code SecureRandom}.
+ * @since Android 1.0
*/
public final Provider getProvider() {
return provider;
}
/**
- * @com.intel.drl.spec_ref
+ * Returns the name of the algorithm of this {@code SecureRandom}.
*
+ * @return the name of the algorithm of this {@code SecureRandom}.
+ * @since Android 1.0
*/
public String getAlgorithm() {
return algorithm;
}
/**
- * @com.intel.drl.spec_ref
+ * Reseeds this {@code SecureRandom} instance with the specified {@code
+ * seed}. The seed of this {@code SecureRandom} instance is supplemented,
+ * not replaced.
*
+ * @param seed
+ * the new seed.
+ * @since Android 1.0
*/
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.
- *
+ * Reseeds this this {@code SecureRandom} instance with the eight bytes
+ * described by the representation of the given {@code long seed}. The seed
+ * of this {@code SecureRandom} instance is supplemented, not replaced.
*
* @param seed
- * long Number whose representation to use to reseed the
- * receiver.
+ * the new seed.
+ * @since Android 1.0
*/
public void setSeed(long seed) {
if (seed == 0) { // skip call from Random
@@ -274,16 +288,26 @@ public class SecureRandom extends Random {
}
/**
- * @com.intel.drl.spec_ref
+ * Generates and stores random bytes in the given {@code byte[]} for each
+ * array element.
*
+ * @param bytes
+ * the {@code byte[]} to be filled with random bytes.
+ * @since Android 1.0
*/
public synchronized void nextBytes(byte[] bytes) {
secureRandomSpi.engineNextBytes(bytes);
}
/**
- * @com.intel.drl.spec_ref
+ * Generates and returns an {@code int} containing the specified number of
+ * random bits (right justified, with leading zeros).
*
+ * @param numBits
+ * number of bits to be generated. An input value should be in
+ * the range [0, 32].
+ * @return an {@code int} containing the specified number of random bits.
+ * @since Android 1.0
*/
protected final int next(int numBits) {
if (numBits < 0) {
@@ -306,12 +330,13 @@ public class SecureRandom extends Random {
}
/**
- * Returns the given number of seed bytes, computed using the seed
- * generation algorithm used by this class.
+ * Generates and returns the specified number of seed bytes, computed using
+ * the seed generation algorithm used by this {@code SecureRandom}.
*
* @param numBytes
- * int the given number of seed bytes
- * @return byte[] The seed bytes generated
+ * the number of seed bytes.
+ * @return the seed bytes
+ * @since Android 1.0
*/
public static byte[] getSeed(int numBytes) {
if (internalSecureRandom == null) {
@@ -321,12 +346,13 @@ public class SecureRandom extends Random {
}
/**
- * Generates a certain number of seed bytes
- *
+ * Generates and returns the specified number of seed bytes, computed using
+ * the seed generation algorithm used by this {@code SecureRandom}.
*
* @param numBytes
- * int Number of seed bytes to generate
- * @return byte[] The seed bytes generated
+ * the number of seed bytes.
+ * @return the seed bytes.
+ * @since Android 1.0
*/
public byte[] generateSeed(int numBytes) {
return secureRandomSpi.engineGenerateSeed(numBytes);
diff --git a/security/src/main/java/java/security/SecureRandomSpi.java b/security/src/main/java/java/security/SecureRandomSpi.java
index 1eb9c1a..7ce880c 100644
--- a/security/src/main/java/java/security/SecureRandomSpi.java
+++ b/security/src/main/java/java/security/SecureRandomSpi.java
@@ -25,33 +25,45 @@ package java.security;
import java.io.Serializable;
/**
- * This class is a Service Provider Interface (therefore the Spi suffix) for
- * secure random number generation algorithms to be supplied by providers.
+ * {@code SecureRandomSpi} is the Service Provider Interface (SPI) definition
+ * for {@link SecureRandom}.
*
+ * @see SecureRandom
+ * @since Android 1.0
*/
public abstract class SecureRandomSpi implements Serializable {
- /**
- * @com.intel.drl.spec_ref
- *
- */
private static final long serialVersionUID = -2991854161009191830L;
/**
- * @com.intel.drl.spec_ref
+ * Reseeds this {@code SecureRandomSpi} instance with the specified {@code
+ * seed}. The seed of this {@code SecureRandomSpi} instance is supplemented,
+ * not replaced.
*
+ * @param seed
+ * the new seed.
+ * @since Android 1.0
*/
protected abstract void engineSetSeed(byte[] seed);
/**
- * @com.intel.drl.spec_ref
+ * Generates and stores random bytes in the given {@code byte[]} for each
+ * array element.
*
+ * @param bytes
+ * the {@code byte[]} to be filled with random bytes.
+ * @since Android 1.0
*/
protected abstract void engineNextBytes(byte[] bytes);
/**
- * @com.intel.drl.spec_ref
+ * Generates and returns the specified number of seed bytes, computed using
+ * the seed generation algorithm used by this {@code SecureRandomSpi}.
*
+ * @param numBytes
+ * the number of seed bytes.
+ * @return the seed bytes
+ * @since Android 1.0
*/
protected abstract byte[] engineGenerateSeed(int numBytes);
}
diff --git a/security/src/main/java/java/security/Security.java b/security/src/main/java/java/security/Security.java
index 28fd210..78abdb7 100644
--- a/security/src/main/java/java/security/Security.java
+++ b/security/src/main/java/java/security/Security.java
@@ -27,8 +27,10 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+// BEGIN android-added
import java.util.logging.Level;
import java.util.logging.Logger;
+// END android-added
import java.util.Enumeration;
import java.net.URL;
import java.util.HashMap;
@@ -45,7 +47,11 @@ import org.apache.harmony.security.fortress.Services;
import org.apache.harmony.security.internal.nls.Messages;
/**
- * For access to security providers and properties.
+ * {@code Security} is the central class in the Java Security API. It manages
+ * the list of security {@code Provider} that have been installed into this
+ * runtime environment.
+ *
+ * @since Android 1.0
*/
public final class Security {
@@ -81,55 +87,55 @@ public final class Security {
// END android-added
// BEGIN android-removed
-// File f = new File(System.getProperty("java.home") //$NON-NLS-1$
-// + File.separator + "lib" + File.separator //$NON-NLS-1$
-// + "security" + File.separator + "java.security"); //$NON-NLS-1$ //$NON-NLS-2$
-// if (f.exists()) {
-// try {
-// FileInputStream fis = new FileInputStream(f);
-// InputStream is = new BufferedInputStream(fis);
-// secprops.load(is);
-// loaded = true;
-// is.close();
-// } catch (IOException e) {
-//// System.err.println("Could not load Security properties file: "
-//// + e);
-// }
-// }
-//
-// if ("true".equalsIgnoreCase(secprops.getProperty("security.allowCustomPropertiesFile", "true"))) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-// String securityFile = System.getProperty("java.security.properties"); //$NON-NLS-1$
-// if (securityFile != null) {
-// if (securityFile.startsWith("=")) { // overwrite //$NON-NLS-1$
-// secprops = new Properties();
-// loaded = false;
-// securityFile = securityFile.substring(1);
-// }
-// try {
-// securityFile = PolicyUtils.expand(securityFile, System.getProperties());
-// } catch (PolicyUtils.ExpansionFailedException e) {
-//// System.err.println("Could not load custom Security properties file "
-//// + securityFile +": " + e);
-// }
-// f = new File(securityFile);
-// InputStream is;
-// try {
-// if (f.exists()) {
-// FileInputStream fis = new FileInputStream(f);
-// is = new BufferedInputStream(fis);
-// } else {
-// URL url = new URL(securityFile);
-// is = new BufferedInputStream(url.openStream());
-// }
-// secprops.load(is);
-// loaded = true;
-// is.close();
-// } catch (IOException e) {
-// // System.err.println("Could not load custom Security properties file "
-// // + securityFile +": " + e);
-// }
-// }
-// }
+ // File f = new File(System.getProperty("java.home") //$NON-NLS-1$
+ // + File.separator + "lib" + File.separator //$NON-NLS-1$
+ // + "security" + File.separator + "java.security"); //$NON-NLS-1$ //$NON-NLS-2$
+ // if (f.exists()) {
+ // try {
+ // FileInputStream fis = new FileInputStream(f);
+ // InputStream is = new BufferedInputStream(fis);
+ // secprops.load(is);
+ // loaded = true;
+ // is.close();
+ // } catch (IOException e) {
+ //// System.err.println("Could not load Security properties file: "
+ //// + e);
+ // }
+ // }
+ //
+ // if ("true".equalsIgnoreCase(secprops.getProperty("security.allowCustomPropertiesFile", "true"))) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ // String securityFile = System.getProperty("java.security.properties"); //$NON-NLS-1$
+ // if (securityFile != null) {
+ // if (securityFile.startsWith("=")) { // overwrite //$NON-NLS-1$
+ // secprops = new Properties();
+ // loaded = false;
+ // securityFile = securityFile.substring(1);
+ // }
+ // try {
+ // securityFile = PolicyUtils.expand(securityFile, System.getProperties());
+ // } catch (PolicyUtils.ExpansionFailedException e) {
+ //// System.err.println("Could not load custom Security properties file "
+ //// + securityFile +": " + e);
+ // }
+ // f = new File(securityFile);
+ // InputStream is;
+ // try {
+ // if (f.exists()) {
+ // FileInputStream fis = new FileInputStream(f);
+ // is = new BufferedInputStream(fis);
+ // } else {
+ // URL url = new URL(securityFile);
+ // is = new BufferedInputStream(url.openStream());
+ // }
+ // secprops.load(is);
+ // loaded = true;
+ // is.close();
+ // } catch (IOException e) {
+ // // System.err.println("Could not load custom Security properties file "
+ // // + securityFile +": " + e);
+ // }
+ // }
+ // }
// END android-removed
if (!loaded) {
@@ -155,14 +161,22 @@ public final class Security {
secprops.put("security.provider.4", "org.bouncycastle.jce.provider.BouncyCastleProvider"); //$NON-NLS-1$ //$NON-NLS-2$
}
+ // BEGIN android-note
+ // added Deprecated annotation
+ // END android-note
/**
- * Deprecated method which returns null.
- * @param algName
- * @param propName
- * @return null
- *
- * @deprecated Use AlgorithmParameters and KeyFactory instead
+ * Returns value for the specified algorithm with the specified name.
+ *
+ * @param algName
+ * the name of the algorithm.
+ * @param propName
+ * the name of the property.
+ * @return value of the property.
+ * @deprecated Use {@link AlgorithmParameters} and {@link KeyFactory}
+ * instead.
+ * @since Android 1.0
*/
+ @Deprecated
public static String getAlgorithmProperty(String algName, String propName) {
if (algName == null || propName == null) {
return null;
@@ -182,8 +196,27 @@ public final class Security {
}
/**
- * @com.intel.drl.spec_ref
- *
+ * Insert the given {@code Provider} at the specified {@code position}. The
+ * positions define the preference order in which providers are searched for
+ * requested algorithms.
+ * filter
. A null
value signifies
- * that none of the installed providers meets the filter
- * specification
- * @exception InvalidParameterException
- * if an unusable filter is supplied
+ * case-insensitive filter.
+ * @return the providers which meet the user supplied string filter {@code
+ * filter}. A {@code null} value signifies that none of the
+ * installed providers meets the filter specification.
+ * @throws InvalidParameterException
+ * if an unusable filter is supplied.
+ * @throws NullPointerException
+ * if {@code filter} is {@code null}.
+ * @since Android 1.0
*/
public static Provider[] getProviders(String filter) {
if (filter == null) {
@@ -296,8 +378,29 @@ public final class Security {
}
/**
- * @com.intel.drl.spec_ref
- *
+ * Returns the array of providers which meet the user supplied set of
+ * filters. The filter must be supplied in one of two formats:
+ * implies()
method of a Permissions
- * collection, right before actual checking.
+ * An {@code UnresolvedPermission} represents a {@code Permission} whose type
+ * should be resolved lazy and not during initialization time of the {@code
+ * Policy}. {@code UnresolvedPermission}s contain all information to be replaced
+ * by a concrete typed {@code Permission} right before the access checks are
+ * performed.
*
+ * @since Android 1.0
*/
public final class UnresolvedPermission extends Permission
implements Serializable {
- /**
- * @com.intel.drl.spec_ref
- */
private static final long serialVersionUID = -4821973115467008846L;
private static final ObjectStreamField serialPersistentFields[] = {
@@ -75,15 +72,25 @@ public final class UnresolvedPermission extends Permission
private transient int hash;
/**
- * Constructs a new instance of this class with its type, name, and
- * certificates set to the arguments by definition, actions are ignored
+ * Constructs a new instance of {@code UnresolvedPermission}. The supplied
+ * parameters are used when this instance is resolved to the concrete
+ * {@code Permission}.
*
* @param type
- * class of permission object
+ * the fully qualified class name of the permission this class is
+ * resolved to.
* @param name
- * identifies the permission that could not be resolved
+ * the name of the permission this class is resolved to, maybe
+ * {@code null}.
* @param actions
+ * the actions of the permission this class is resolved to, maybe
+ * {@code null}.
* @param certs
+ * the certificates of the permission this class is resolved to,
+ * maybe {@code null}.
+ * @throws NullPointerException
+ * if type is {@code null}.
+ * @since Android 1.0
*/
public UnresolvedPermission(String type, String name, String actions,
Certificate[] certs) {
@@ -123,17 +130,19 @@ public final class UnresolvedPermission extends Permission
}
/**
- * Compares the argument to the receiver, and returns true if they represent
- * the same object using a class specific comparison. In this
- * case, the receiver and the object must have the same class, permission
- * name, actions, and certificates
+ * Compares the specified object with this {@code UnresolvedPermission} for
+ * equality and returns {@code true} if the specified object is equal,
+ * {@code false} otherwise. To be equal, the specified object needs to be an
+ * instance of {@code UnresolvedPermission}, the two {@code
+ * UnresolvedPermission}s must refer to the same type and must have the same
+ * name, the same actions and certificates.
*
* @param obj
- * the object to compare with this object
- * @return true
if the object is the same as this object,
- * false
otherwise.
- *
- * @see #hashCode
+ * object to be compared for equality with this {@code
+ * UnresolvedPermission}.
+ * @return {@code true} if the specified object is equal to this {@code
+ * UnresolvedPermission}, otherwise {@code false}.
+ * @since Android 1.0
*/
public boolean equals(Object obj) {
if (obj == this) {
@@ -155,13 +164,15 @@ public final class UnresolvedPermission extends Permission
}
/**
- * Returns an integer hash code for the receiver. Any two objects which
- * answer true
when passed to equals
must
- * answer the same value for this method.
- *
- * @return the receiver's hash
+ * Returns the hash code value for this {@code UnresolvedPermission}.
+ * Returns the same hash code for {@code UnresolvedPermission}s that are
+ * equal to each other as required by the general contract of
+ * {@link Object#hashCode}.
*
- * @see #equals
+ * @return the hash code value for this {@code UnresolvedPermission}.
+ * @see Object#equals(Object)
+ * @see UnresolvedPermission#equals(Object)
+ * @since Android 1.0
*/
public int hashCode() {
if (hash == 0) {
@@ -177,38 +188,60 @@ public final class UnresolvedPermission extends Permission
}
/**
- * Returns the actions associated with the receiver. Since
- * UnresolvedPermission objects have no actions, answer the empty string.
+ * Returns an empty string since there are no actions allowed for {@code
+ * UnresolvedPermission}. The actions, specified in the constructor, are
+ * used when the concrete permission is resolved and created.
*
- * @return the actions associated with the receiver.
+ * @return an empty string, indicating that there are no actions.
+ * @since Android 1.0
*/
public String getActions() {
return ""; //$NON-NLS-1$
}
- /**
- * @com.intel.drl.spec_ref
+ /**
+ * Returns the name of the permission this {@code UnresolvedPermission} is
+ * resolved to.
+ *
+ * @return the name of the permission this {@code UnresolvedPermission} is
+ * resolved to.
+ * @since Android 1.0
*/
public String getUnresolvedName() {
return targetName;
}
- /**
- * @com.intel.drl.spec_ref
+ /**
+ * Returns the actions of the permission this {@code UnresolvedPermission}
+ * is resolved to.
+ *
+ * @return the actions of the permission this {@code UnresolvedPermission}
+ * is resolved to.
+ * @since Android 1.0
*/
public String getUnresolvedActions() {
return targetActions;
}
- /**
- * @com.intel.drl.spec_ref
+ /**
+ * Returns the fully qualified class name of the permission this {@code
+ * UnresolvedPermission} is resolved to.
+ *
+ * @return the fully qualified class name of the permission this {@code
+ * UnresolvedPermission} is resolved to.
+ * @since Android 1.0
*/
public String getUnresolvedType() {
return super.getName();
}
- /**
- * @com.intel.drl.spec_ref
+ /**
+ * Returns the certificates of the permission this {@code
+ * UnresolvedPermission} is resolved to.
+ *
+ * @return the certificates of the permission this {@code
+ * UnresolvedPermission} is resolved to.
+ * @since Android 1.0
*/
public Certificate[] getUnresolvedCerts() {
if (targetCerts != null) {
@@ -220,28 +253,32 @@ public final class UnresolvedPermission extends Permission
}
/**
- * Indicates whether the argument permission is implied by the
- * receiver. UnresolvedPermission objects imply nothing
- * because nothing is known about them yet.
+ * Indicates whether the specified permission is implied by this {@code
+ * UnresolvedPermission}. {@code UnresolvedPermission} objects imply nothing
+ * since nothing is known about them yet.
+ * getName()
- * of this unresolved permission), so no check is performed to verify this.
- * However, the class must have all required certificates (as per
- * getUnresolvedCerts()
) among the passed collection of
- * signers. If it does, a zero, one, and/or two-argument constructor is
- * tried to instantiate a new permission, which is then returned.
- * If an appropriate constructor is not available or the class is
- * improperly signed, null
is returned.
+ * Tries to resolve this permission into the specified class.
+ * null
- * @param signers - actual signers of the targetType
+ * @param targetType
+ * - a target class instance, must not be {@code null}
+ * @param signers
+ * - actual signers of the targetType
* @return resolved permission or null
*/
Permission resolve(Class targetType) {
@@ -293,7 +335,7 @@ public final class UnresolvedPermission extends Permission
/**
* @com.intel.drl.spec_ref
*
- * Outputs type
,name
,actions
+ * Outputs {@code type},{@code name},{@code actions}
* fields via default mechanism; next manually writes certificates in the
* following format:
*
diff --git a/security/src/main/java/java/security/UnresolvedPermissionCollection.java b/security/src/main/java/java/security/UnresolvedPermissionCollection.java
index 84c4467..a43a54f 100644
--- a/security/src/main/java/java/security/UnresolvedPermissionCollection.java
+++ b/security/src/main/java/java/security/UnresolvedPermissionCollection.java
@@ -41,15 +41,12 @@ import java.util.Vector;
import org.apache.harmony.security.internal.nls.Messages;
/**
- * Specific PermissionCollection for storing UnresolvedPermissions. Contained
- * elements are grouped by their target type.
- *
+ * {@code UnresolvedPermissionCollection} represents a specific {@code
+ * PermissionCollection} for storing {@link UnresolvedPermission} instances.
+ * Contained elements are grouped by their target type.
*/
final class UnresolvedPermissionCollection extends PermissionCollection {
- /**
- * @com.intel.drl.spec_ref
- */
private static final long serialVersionUID = -7176153071733132400L;
private static final ObjectStreamField[] serialPersistentFields = {
@@ -59,9 +56,17 @@ final class UnresolvedPermissionCollection extends PermissionCollection {
private transient Map klasses = new HashMap();
/**
- * Adds an unresolved permission to the collection.
+ * Adds an unresolved permission to this {@code
+ * UnresolvedPermissionCollection}.
*
- * @see java.security.PermissionCollection#add(java.security.Permission)
+ * @param permission
+ * the permission to be added.
+ * @throws SecurityException
+ * if this collection is read only.
+ * @throws IllegalArgumentException
+ * if {@code permission} is {@code null} or not an {@code
+ * UnresolvedPermission}.
+ * @since Android 1.0
*/
public void add(Permission permission) {
if (isReadOnly()) {
@@ -83,11 +88,6 @@ final class UnresolvedPermissionCollection extends PermissionCollection {
}
}
- /**
- * Returns enumeration over collection elements.
- *
- * @see java.security.PermissionCollection#elements()
- */
public Enumeration elements() {
Collection all = new ArrayList();
for (Iterator iter = klasses.values().iterator(); iter.hasNext();) {
@@ -97,9 +97,11 @@ final class UnresolvedPermissionCollection extends PermissionCollection {
}
/**
- * Always returns false.
+ * Always returns {@code false}.
*
- * @see java.security.UnresolvedPermission#implies(Permission)
+ * @return always {@code false}
+ * @see UnresolvedPermission#implies(Permission).
+ * @since Android 1.0
*/
public boolean implies(Permission permission) {
return false;
@@ -116,13 +118,15 @@ final class UnresolvedPermissionCollection extends PermissionCollection {
/**
* Resolves all permissions of the same class as the specified target
* permission and adds them to the specified collection. If passed
- * collection is null
and some unresolved permissions were
- * resolved, an appropriate new collection is instantiated and used. All
- * resolved permissions are removed from this unresolved collection, and
- * collection with resolved ones is returned.
+ * collection is {@code null} and some unresolved permissions were resolved,
+ * an appropriate new collection is instantiated and used. All resolved
+ * permissions are removed from this unresolved collection, and collection
+ * with resolved ones is returned.
*
- * @param target - a kind of permissions to be resolved
- * @param holder - an existing collection for storing resolved permissions
+ * @param target
+ * a kind of permissions to be resolved.
+ * @param holder
+ * an existing collection for storing resolved permissions.
* @return a collection containing resolved permissions (if any found)
*/
PermissionCollection resolveCollection(Permission target,
diff --git a/security/src/main/java/java/security/acl/Acl.java b/security/src/main/java/java/security/acl/Acl.java
index 8a87a5e..35c92fc 100644
--- a/security/src/main/java/java/security/acl/Acl.java
+++ b/security/src/main/java/java/security/acl/Acl.java
@@ -15,61 +15,169 @@
* limitations under the License.
*/
-/**
-* @author Aleksei Y. Semenov
-* @version $Revision$
-*/
-
package java.security.acl;
import java.security.Principal;
import java.util.Enumeration;
/**
- * @com.intel.drl.spec_ref
- *
+ * The Access Control List (ACL) interface definition.
+ *
+ *
+ *
+ *
+ *
+ * The list of granted permissions is determined according to the rules + * specified by {@code getPermissions}. + *
+ * + * @param principal + * the principal the check the permissions for. + * @param permission + * the permission to check for the principal. + * @return {@code true} if the principal is granted the permission, otherwise {@code false}. + * @see #getPermissions(Principal) + * @since Android 1.0 */ boolean checkPermission(Principal principal, Permission permission); /** - * @com.intel.drl.spec_ref + * Returns the string representation of this ACL. + * + * @return the string representation of this ACL. + * @since Android 1.0 */ String toString(); } diff --git a/security/src/main/java/java/security/acl/AclEntry.java b/security/src/main/java/java/security/acl/AclEntry.java index 5d0abcf..7a5b722 100644 --- a/security/src/main/java/java/security/acl/AclEntry.java +++ b/security/src/main/java/java/security/acl/AclEntry.java @@ -15,70 +15,120 @@ * limitations under the License. */ -/** -* @author Aleksei Y. Semenov -* @version $Revision$ -*/ - package java.security.acl; import java.security.Principal; import java.util.Enumeration; /** - * @com.intel.drl.spec_ref + * The Access Control List Entry interface definition. + *+ * An {@code AclEntry} is a list of the {@link Permission}s that are + * granted (positive) or denied (negative) to a {@link Principal}. + *
* + * @since Android 1.0 */ - public interface AclEntry extends Cloneable { /** - * @com.intel.drl.spec_ref + * Set the principal for this ACL entry. + *+ * The principal for an ACL entry can only be set once. + *
+ * + * @param user + * the principal for this ACL entry. + * @return {@code true} on success, {@code false} if there is a principal already set for + * this entry. + * @since Android 1.0 */ boolean setPrincipal(Principal user); /** - * @com.intel.drl.spec_ref + * Returns the principal of this ACL entry. + * + * @return the principal of this ACL entry, or null if none is set. + * @since Android 1.0 */ Principal getPrincipal(); /** - * @com.intel.drl.spec_ref + * Sets this ACL entry to be negative. + *+ * The permissions in this ACL entry will be denied to the principal + * associated with this entry. + *
+ *+ * Note: An ACL entry is positive by default and can only become + * negative by calling this method. + *
+ * + * @since Android 1.0 */ void setNegativePermissions(); /** - * @com.intel.drl.spec_ref + * Returns whether this ACL entry is negative. + * + * @return {@code true} if this ACL entry is negative, {@code false} if it's positive. + * @since Android 1.0 */ boolean isNegative(); /** - * @com.intel.drl.spec_ref + * Adds the specified permission to this ACL entry. + * + * @param permission + * the permission to be added. + * @return {@code true} if the specified permission is added, {@code false} if the + * permission was already in this entry. + * @since Android 1.0 */ boolean addPermission(Permission permission); /** - * @com.intel.drl.spec_ref + * Removes the specified permission from this ACL entry. + * + * @param permission + * the permission to be removed. + * @return {@code true} if the permission is removed, {@code false} if the permission was + * not in this entry. + * @since Android 1.0 */ boolean removePermission(Permission permission); /** - * @com.intel.drl.spec_ref + * Checks whether the specified permission is in this ACL entry. + * + * @param permission + * the permission to check. + * @return {@code true} if the permission is in this entry, otherwise {@code false}. + * @since Android 1.0 */ boolean checkPermission(Permission permission); /** - * @com.intel.drl.spec_ref + * Returns the list of permissions of this ACL entry. + * + * @return the list of permissions of this ACL entry, + * @since Android 1.0 */ Enumeration+ * It can be granted or denied to a {@link java.security.Principal Principal} + * using an {@link Acl}. + *
* + * @since Android 1.0 */ - public interface Permission { /** - * @com.intel.drl.spec_ref + * Checks whether the specified object equals this permission. + * + * @param another + * the permission object to compare to this permission. + * @return true if the specified permission object is equal to this, false + * if not. + * @since Android 1.0 */ boolean equals(Object another); /** - * @com.intel.drl.spec_ref + * Returns the string representation of this permission. + * + * @return the string representation of this permission. + * @since Android 1.0 */ String toString(); } diff --git a/security/src/main/java/java/security/acl/package.html b/security/src/main/java/java/security/acl/package.html index 9d23cf9..3102fc2 100644 --- a/security/src/main/java/java/security/acl/package.html +++ b/security/src/main/java/java/security/acl/package.html @@ -5,10 +5,11 @@-This package provides all the classes and all the interfaces needed to build Access Control List. -Functionality for generating new entries in an ACL {@link java.security.acl.AclEntry}; -for the creation of new owner {@link java.security.acl.Owner} and for the registration of +This package provides the classes and the interfaces needed to build Access Control Lists. +Functionality for generating new entries in an ACL {@link java.security.acl.AclEntry}, +for the creation of new owners {@link java.security.acl.Owner}, and for the registration of new permissions {@link java.security.acl.Permission} are provided.
+@since Android 1.0 diff --git a/security/src/main/java/java/security/cert/CRL.java b/security/src/main/java/java/security/cert/CRL.java index 74c0bf5..b0f3e30 100644 --- a/security/src/main/java/java/security/cert/CRL.java +++ b/security/src/main/java/java/security/cert/CRL.java @@ -15,25 +15,26 @@ * limitations under the License. */ -/** -* @author Vladimir N. Molotkov -* @version $Revision$ -*/ - package java.security.cert; /** - * This class represents Certificate Revocation Lists (CRLs). They are used to - * indicate that a given Certificate has expired already. + * This class represents Certificate Revocation Lists (CRLs) maintained by a + * certificate authority. They are used to indicate that a given Certificate has + * expired and consequently has become invalid. * * @see CertificateFactory + * @since Android 1.0 */ public abstract class CRL { // The CRL type private final String type; /** - * @com.intel.drl.spec_ref + * Creates a new certificate revocation list of the specified type. + * + * @param type + * the type for the CRL. + * @since Android 1.0 */ protected CRL(String type) { this.type = type; @@ -42,28 +43,29 @@ public abstract class CRL { /** * Returns the type of this CRL. * - * @return String the type of this CRL. + * @return the type of this CRL. + * @since Android 1.0 */ public final String getType() { return type; } /** - * Returns if a given Certificate has been revoked or not. + * Returns whether the specified certificate is revoked by this CRL. * * @param cert - * Certificate The Certificate to test - * - * @return true if the certificate has been revoked false if the certificate - * has not been revoked yet + * the certificate to check. + * @return {@code true} if the certificate is revoked by this CRL, otherwise + * {@code false}. + * @since Android 1.0 */ public abstract boolean isRevoked(Certificate cert); /** - * Returns a string containing a concise, human-readable description of the - * receiver. + * Returns the string representation of this instance. * - * @return a printable representation for the receiver. + * @return the string representation of this instance. + * @since Android 1.0 */ public abstract String toString(); } diff --git a/security/src/main/java/java/security/cert/CRLException.java b/security/src/main/java/java/security/cert/CRLException.java index e8ca9cb..625d7d3 100644 --- a/security/src/main/java/java/security/cert/CRLException.java +++ b/security/src/main/java/java/security/cert/CRLException.java @@ -25,42 +25,52 @@ package java.security.cert; import java.security.GeneralSecurityException; /** - * @com.intel.drl.spec_ref + * The exception that is thrown if errors occur during handling of {@code CRL}s. * + * @since Android 1.0 */ public class CRLException extends GeneralSecurityException { - /** - * @com.intel.drl.spec_ref - */ private static final long serialVersionUID = -6694728944094197147L; /** - * Constructs a new instance of this class with its walkback and message - * filled in. + * Creates a new {@code CRLException} with the specified message. * * @param msg - * String The detail message for the exception. + * the detail message for this exception. + * @since Android 1.0 */ public CRLException(String msg) { super(msg); } /** - * Constructs a new instance of this class with its walkback filled in. + * Creates a new {@code CRLException}. + * + * @since Android 1.0 */ public CRLException() { } /** - * @com.intel.drl.spec_ref + * Creates a new {@code CRLException} with the specified message and cause. + * + * @param message + * the detail message for this exception. + * @param cause + * the cause for this exception. + * @since Android 1.0 */ public CRLException(String message, Throwable cause) { super(message, cause); } /** - * @com.intel.drl.spec_ref + * Creates a new {@code CRLException} with the specified cause. + * + * @param cause + * the cause for this exception. + * @since Android 1.0 */ public CRLException(Throwable cause) { super(cause); diff --git a/security/src/main/java/java/security/cert/CRLSelector.java b/security/src/main/java/java/security/cert/CRLSelector.java index c6e606e..ee2d39e 100644 --- a/security/src/main/java/java/security/cert/CRLSelector.java +++ b/security/src/main/java/java/security/cert/CRLSelector.java @@ -15,26 +15,39 @@ * limitations under the License. */ -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - package java.security.cert; /** - * @com.intel.drl.spec_ref + * The interface specification for determining whether a CRL meets some criteria + * to select CRL objects among a set of {@code CRL}s. + *+ * The implementations of this interface are typically used to define the + * criteria for selecting {@code CRL}s from a {@code CertStore}. + *
* + * @see CertStore + * @see CRL + * @since Android 1.0 */ public interface CRLSelector extends Cloneable { /** - * @com.intel.drl.spec_ref + * Clones this {@code CRLSelector} instance. + * + * @return the cloned instance. + * @since Android 1.0 */ public Object clone(); /** - * @com.intel.drl.spec_ref + * Checks whether the defined criteria of this instance match the specified + * CRL. + * + * @param crl + * the CRL to be evaluated. + * @return {@code true} if the CRL matches the criteria, {@code false} + * otherwise. + * @since Android 1.0 */ public boolean match(CRL crl); } \ No newline at end of file diff --git a/security/src/main/java/java/security/cert/CertPath.java b/security/src/main/java/java/security/cert/CertPath.java index 6de5c09..2874a4d 100644 --- a/security/src/main/java/java/security/cert/CertPath.java +++ b/security/src/main/java/java/security/cert/CertPath.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Vladimir N. Molotkov -* @version $Revision$ -*/ - package java.security.cert; import java.io.ByteArrayInputStream; @@ -35,49 +30,59 @@ import org.apache.harmony.security.internal.nls.Messages; /** * An immutable certificate path that can be validated. All certificates in the * path are of the same type (i.e., X509). + *+ * A {@code CertPath} can be represented as a byte array in at least one + * supported encoding scheme (i.e. PkiPath or PKCS7) when serialized. + *
+ *+ * When a {@code List} of the certificates is obtained it must be immutable. + *
+ *+ * A {@code CertPath} must be thread-safe without requiring coordinated access. + *
* - * ACertPath
can be represented as a byte array in at least one
- * supported encoding when serialized.
- *
- * When a List
of the certificates is obtained it must be
- * immutable.
- *
- * A CertPath
must be thread-safe without requiring coordinated
- * access.
+ * @see Certificate
+ * @since Android 1.0
*/
public abstract class CertPath implements Serializable {
- /**
- * @com.intel.drl.spec_ref
- */
+
private static final long serialVersionUID = 6068470306649138683L;
// Standard name of the type of certificates in this path
private final String type;
/**
- * @com.intel.drl.spec_ref
+ * Creates a new {@code CertPath} instance for the specified certificate
+ * type.
+ *
+ * @param type
+ * the certificate type.
+ * @since Android 1.0
*/
protected CertPath(String type) {
this.type = type;
}
/**
- * Returns the type of Certificate
in the
- * CertPath
+ * Returns the type of {@code Certificate} in this instance.
*
- * @return Certificate
type
+ * @return the certificate type.
+ * @since Android 1.0
*/
public String getType() {
return type;
}
/**
- * Returns true if Certificate
s in the list are the same
+ * Returns {@code true} if {@code Certificate}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
- * CertPath
to be compared for equality
+ * {@code CertPath} to be compared for equality.
+ * @return {@code true} if the object are equal, {@code false} otherwise.
+ * @since Android 1.0
*/
+ @Override
public boolean equals(Object other) {
if (this == other) {
return true;
@@ -94,11 +99,14 @@ public abstract class CertPath implements Serializable {
}
/**
- * Overrides Object.hashCode() Defined as: hashCode = 31 *
- * path.getType().hashCode() + path.getCertificates().hashCode();
+ * Overrides {@code Object.hashCode()}. The function is defined as follows: String
representation of the
- * CertPath
- * Certificate
s. It is the result of
- * calling toString
on all Certificate
s in
- * the List
. Certificate
s
+ * Returns a {@code String} representation of this {@code CertPath}
+ * instance.
*
- * @return string representation of CertPath
+ * @return a string representation of this instance.
+ * @since Android 1.0
*/
public String toString() {
StringBuffer sb = new StringBuffer(getType());
@@ -120,58 +126,68 @@ public abstract class CertPath implements Serializable {
sb.append(getCertificates().size());
sb.append(": [\n"); //$NON-NLS-1$
int n=1;
- for (Iterator i=getCertificates().iterator();
+ // BEGIN android-changed
+ for (Iterator extends Certificate> i=getCertificates().iterator();
i.hasNext(); n++) {
sb.append("---------------certificate "); //$NON-NLS-1$
sb.append(n);
sb.append("---------------\n"); //$NON-NLS-1$
sb.append(((Certificate)i.next()).toString());
}
+ // END android-changed
sb.append("\n]"); //$NON-NLS-1$
return sb.toString();
}
/**
- * Returns an immutable List of the Certificate
s contained
- * in the CertPath
.
+ * Returns an immutable List of the {@code Certificate}s contained
+ * in the {@code CertPath}.
*
- * @return list of Certificate
s in the CertPath
+ * @return a list of {@code Certificate}s in the {@code CertPath}.
+ * @since Android 1.0
*/
public abstract List extends Certificate> getCertificates();
/**
- * Returns an encoding of the CertPath
using the default
- * encoding
+ * Returns an encoding of the {@code CertPath} using the default encoding.
*
- * @return default encoding of the CertPath
+ * @return default encoding of the {@code CertPath}.
* @throws CertificateEncodingException
+ * if the encoding fails.
+ * @since Android 1.0
*/
public abstract byte[] getEncoded()
throws CertificateEncodingException;
/**
- * Returns an encoding of the CertPath
using the specified
- * encoding
+ * Returns an encoding of the {@code CertPath} using the specified encoding.
*
* @param encoding
- * encoding that should be generated
- * @return default encoding of the CertPath
+ * encoding that should be generated.
+ * @return default encoding of the {@code CertPath}.
* @throws CertificateEncodingException
+ * if the encoding fails.
+ * @since Android 1.0
*/
public abstract byte[] getEncoded(String encoding)
throws CertificateEncodingException;
/**
- * Return an Iterator
over the supported encodings for a
+ * Returns an {@code Iterator} over the supported encodings for a
* representation of the certificate path.
*
- * @return Iterator
over supported encodings (as
- * String
s)
+ * @return {@code Iterator} over supported encodings (as {@code String}s).
+ * @since Android 1.0
*/
public abstract Iterator+ * This interface is for grouping purposes of {@code CertPath} parameter + * implementations. + *
+ * @since Android 1.0 */ public interface CertPathParameters extends Cloneable { /** - * @com.intel.drl.spec_ref + * Clones this {@code CertPathParameters} instance. + * + * @return the cloned instance. + * @since Android 1.0 */ public Object clone(); } \ No newline at end of file diff --git a/security/src/main/java/java/security/cert/CertPathValidator.java b/security/src/main/java/java/security/cert/CertPathValidator.java index 683c968..f95bd03 100644 --- a/security/src/main/java/java/security/cert/CertPathValidator.java +++ b/security/src/main/java/java/security/cert/CertPathValidator.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - package java.security.cert; import java.security.AccessController; @@ -34,10 +29,12 @@ import org.apache.harmony.security.internal.nls.Messages; /** - * + * This class provides the functionality for validating certification paths + * (certificate chains) establishing a trust chain from a certificate to a trust + * anchor. * + * @since Android 1.0 */ - public class CertPathValidator { // Store CertPathValidator implementation service name private static final String SERVICE = "CertPathValidator"; //$NON-NLS-1$ @@ -62,8 +59,15 @@ public class CertPathValidator { private final String algorithm; /** - * - * + * Creates a new {@code CertPathValidator} instance. + * + * @param validatorSpi + * the implementation delegate. + * @param provider + * the security provider. + * @param algorithm + * the name of the algorithm. + * @since Android 1.0 */ protected CertPathValidator(CertPathValidatorSpi validatorSpi, Provider provider, String algorithm) { @@ -73,25 +77,36 @@ public class CertPathValidator { } /** - * - * + * Returns the certification path algorithm name. + * + * @return the certification path algorithm name. + * @since Android 1.0 */ public final String getAlgorithm() { return algorithm; } /** - * - * + * Returns the security provider. + * + * @return the provider. + * @since Android 1.0 */ public final Provider getProvider() { return provider; } /** - * + * Returns a new certification path validator for the specified algorithm. * - * throws NullPointerException if algorithm is null + * @param algorithm + * the algorithm name. + * @return a certification path validator for the requested algorithm. + * @throws NoSuchAlgorithmException + * if no installed provider provides the specified algorithm. + * @throws NullPointerException + * if algorithm is {@code null}. + * @since Android 1.0 */ public static CertPathValidator getInstance(String algorithm) throws NoSuchAlgorithmException { @@ -106,9 +121,24 @@ public class CertPathValidator { } /** - * + * Returns a new certification path validator for the specified algorithm + * from the specified provider. * - * throws NullPointerException if algorithm is null + * @param algorithm + * the algorithm name. + * @param provider + * the security provider name. + * @return a certification path validator for the requested algorithm. + * @throws NoSuchAlgorithmException + * if the specified security provider cannot provide the + * requested algorithm. + * @throws NoSuchProviderException + * if no provider with the specified name can be found. + * @throws NullPointerException + * if algorithm is {@code null}. + * @throws IllegalArgumentException + * if provider is {@code null} or empty. + * @since Android 1.0 */ public static CertPathValidator getInstance(String algorithm, String provider) throws NoSuchAlgorithmException, @@ -124,9 +154,22 @@ public class CertPathValidator { } /** - * + * Returns a new certification path validator for the specified algorithm + * from the specified provider. * - * throws NullPointerException if algorithm is null + * @param algorithm + * the algorithm name. + * @param provider + * the security provider name. + * @return a certification path validator for the requested algorithm. + * @throws NoSuchAlgorithmException + * if the specified provider cannot provide the requested + * algorithm. + * @throws IllegalArgumentException + * if provider is {@code null}. + * @throws NullPointerException + * if algorithm is {@code null}. + * @since Android 1.0 */ public static CertPathValidator getInstance(String algorithm, Provider provider) throws NoSuchAlgorithmException { @@ -144,8 +187,23 @@ public class CertPathValidator { } /** - * + * Validates the {@code CertPath} with the algorithm of this {@code + * CertPathValidator} using the specified algorithm parameters. * + * @param certPath + * the certification path to be validated. + * @param params + * the certification path validator algorithm parameters. + * @return the validation result. + * @throws CertPathValidatorException + * if the validation fails, or the algorithm of the specified + * certification path cannot be validated using the algorithm of + * this instance. + * @throws InvalidAlgorithmParameterException + * if the specified algorithm parameters cannot be used with + * this algorithm. + * @see CertPathValidatorResult + * @since Android 1.0 */ public final CertPathValidatorResult validate(CertPath certPath, CertPathParameters params) throws CertPathValidatorException, @@ -154,8 +212,13 @@ public class CertPathValidator { } /** - * - * + * Returns the default {@code CertPathValidator} type from the Security + * Properties. + * + * @return the default {@code CertPathValidator} type from the Security + * Properties, or the string {@code "PKIX"} if it cannot be + * determined. + * @since Android 1.0 */ public static final String getDefaultType() { String defaultType = AccessController diff --git a/security/src/main/java/java/security/cert/CertPathValidatorException.java b/security/src/main/java/java/security/cert/CertPathValidatorException.java index 18343a6..072785c 100644 --- a/security/src/main/java/java/security/cert/CertPathValidatorException.java +++ b/security/src/main/java/java/security/cert/CertPathValidatorException.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - package java.security.cert; import java.security.GeneralSecurityException; @@ -27,33 +22,50 @@ import java.security.GeneralSecurityException; import org.apache.harmony.security.internal.nls.Messages; /** - * @com.intel.drl.spec_ref + * The exception that is thrown when a certification path (or certificate chain) + * cannot be validated. + *+ * A {@code CertPathValidatorException} may optionally include the certification + * path instance that failed the validation and the index of the failed + * certificate. + *
* + * @since Android 1.0 */ public class CertPathValidatorException extends GeneralSecurityException { - /** - * @com.intel.drl.spec_ref - */ + private static final long serialVersionUID = -3083180014971893139L; /** - * @com.intel.drl.spec_ref - * - * Serialized field for storing certPath which is defined in constructor - * CertPathValidatorException(msg, cause, certPath, index) + * the certification path. */ private CertPath certPath; /** - * @com.intel.drl.spec_ref - * - * Serialized field for storing index which is defined in constructor - * CertPathValidatorException(msg, cause, certPath, index) + * the index of the certificate. */ private int index = -1; /** - * @com.intel.drl.spec_ref + * Creates a new {@code CertPathValidatorException} with the specified + * message , cause, certification path and certificate index in the + * certification path. + * + * @param msg + * the detail message for this exception. + * @param cause + * the cause. + * @param certPath + * the certification path that failed the validation. + * @param index + * the index of the failed certificate. + * @throws IllegalArgumentException + * if {@code certPath} is {@code null} and index is not {@code + * -1}. + * @throws IndexOutOfBoundsException + * if {@code certPath} is not {@code null} and index is not + * referencing an certificate in the certification path. + * @since Android 1.0 */ public CertPathValidatorException(String msg, Throwable cause, CertPath certPath, int index) { @@ -72,41 +84,68 @@ public class CertPathValidatorException extends GeneralSecurityException { } /** - * @com.intel.drl.spec_ref + * Creates a new {@code CertPathValidatorException} with the specified + * message and cause. + * + * @param msg + * the detail message for this exception. + * @param cause + * the cause why the path could not be validated. + * @since Android 1.0 */ public CertPathValidatorException(String msg, Throwable cause) { super(msg, cause); } /** - * @com.intel.drl.spec_ref + * Creates a new {@code CertPathValidatorException} with the specified + * cause. + * + * @param cause + * the cause why the path could not be validated. + * @since Android 1.0 */ public CertPathValidatorException(Throwable cause) { super(cause); } /** - * @com.intel.drl.spec_ref + * Creates a new {@code CertPathValidatorException} with the specified + * message. + * + * @param msg + * the detail message for this exception. + * @since Android 1.0 */ public CertPathValidatorException(String msg) { super(msg); } /** - * @com.intel.drl.spec_ref + * Creates a new {@code CertPathValidatorException}. + * + * @since Android 1.0 */ public CertPathValidatorException() { } /** - * @com.intel.drl.spec_ref + * Returns the certification path that failed validation. + * + * @return the certification path that failed validation, or {@code null} if + * none was specified. + * @since Android 1.0 */ public CertPath getCertPath() { return certPath; } /** - * @com.intel.drl.spec_ref + * Returns the index of the failed certificate in the certification path. + * + * @return the index of the failed certificate in the certification path, or + * {@code -1} if none was specified. + * @since Android 1.0 */ public int getIndex() { return index; diff --git a/security/src/main/java/java/security/cert/CertPathValidatorResult.java b/security/src/main/java/java/security/cert/CertPathValidatorResult.java index ffbf353..42540e4 100644 --- a/security/src/main/java/java/security/cert/CertPathValidatorResult.java +++ b/security/src/main/java/java/security/cert/CertPathValidatorResult.java @@ -15,21 +15,22 @@ * limitations under the License. */ -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - package java.security.cert; /** - * @com.intel.drl.spec_ref - * + * The interface specification for certification path validation results. + *+ * This interface is for grouping purposes of validation result implementations. + *
+ * @since Android 1.0 */ public interface CertPathValidatorResult extends Cloneable { /** - * @com.intel.drl.spec_ref + * Clones this {@code CertPathValidatorResult} instance. + * + * @return the cloned instance. + * @since Android 1.0 */ public Object clone(); } \ No newline at end of file diff --git a/security/src/main/java/java/security/cert/CertPathValidatorSpi.java b/security/src/main/java/java/security/cert/CertPathValidatorSpi.java index abcfaed..5573679 100644 --- a/security/src/main/java/java/security/cert/CertPathValidatorSpi.java +++ b/security/src/main/java/java/security/cert/CertPathValidatorSpi.java @@ -15,30 +15,43 @@ * limitations under the License. */ -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - package java.security.cert; import java.security.InvalidAlgorithmParameterException; /** - * @com.intel.drl.spec_ref + * The Service Provider Interface (SPI) for the {@code + * CertPathValidator} class to be implemented by security providers. * + * @since Android 1.0 */ - public abstract class CertPathValidatorSpi { /** - * @com.intel.drl.spec_ref + * Creates a new {@code CertPathValidatorSpi} instance. + * + * @since Android 1.0 */ public CertPathValidatorSpi() { } /** - * @com.intel.drl.spec_ref + * Validates the {@code CertPath} with the algorithm of this {@code + * CertPathValidator} using the specified algorithm parameters. + * + * @param certPath + * the certification path to be validated. + * @param params + * the certification path validator algorithm parameters. + * @return the validation result. + * @throws CertPathValidatorException + * if the validation fails, or the algorithm of the specified + * certification path cannot be validated using the algorithm of + * this instance. + * @throws InvalidAlgorithmParameterException + * if the specified algorithm parameters cannot be used with + * this algorithm. + * @since Android 1.0 */ public abstract CertPathValidatorResult engineValidate(CertPath certPath, CertPathParameters params) throws CertPathValidatorException, diff --git a/security/src/main/java/java/security/cert/CertSelector.java b/security/src/main/java/java/security/cert/CertSelector.java index cb0b9ec..0316ad3 100644 --- a/security/src/main/java/java/security/cert/CertSelector.java +++ b/security/src/main/java/java/security/cert/CertSelector.java @@ -23,18 +23,36 @@ package java.security.cert; /** - * @com.intel.drl.spec_ref + * The interface specification to determine whether a {@code + * Certificate} meets some criteria. + *+ * The implementations of this interface are typically used to define the + * criteria for selecting {@code Certificate}s from a {@code CertStore}. + *
* + * @see CertStore + * @see Certificate + * @since Android 1.0 */ public interface CertSelector extends Cloneable { /** - * @com.intel.drl.spec_ref + * Clones this {@code CertSelector} instance. + * + * @return the cloned instance. + * @since Android 1.0 */ public Object clone(); /** - * @com.intel.drl.spec_ref + * Checks whether the defined criteria of this instance match the specified + * certificate. + * + * @param cert + * the certificate to be evaluated. + * @return {@code true} if the certificate matches the criteria, {@code + * false} otherwise. + * @since Android 1.0 */ public boolean match(Certificate cert); } \ No newline at end of file diff --git a/security/src/main/java/java/security/cert/CertStore.java b/security/src/main/java/java/security/cert/CertStore.java index 24b8b1a..a5c8260 100644 --- a/security/src/main/java/java/security/cert/CertStore.java +++ b/security/src/main/java/java/security/cert/CertStore.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - package java.security.cert; import java.security.AccessController; @@ -35,10 +30,12 @@ import org.apache.harmony.security.internal.nls.Messages; /** - * @com.intel.drl.spec_ref + * This class provides the functionality to retrieve {@code Certificate}s and + * {@code CRL}s from a read-only repository. This repository may be very large + * and may store trusted as well as untrusted certificates. * + * @since Android 1.0 */ - public class CertStore { // Store spi implementation service name @@ -67,7 +64,17 @@ public class CertStore { private final CertStoreParameters certStoreParams; /** - * @com.intel.drl.spec_ref + * Creates a new {@code CertStore} instance. + * + * @param storeSpi + * the implementation delegate. + * @param provider + * the security provider. + * @param type + * the certificate store type. + * @param params + * the certificate store parameters (may be {@code null}. + * @since Android 1.0 */ protected CertStore(CertStoreSpi storeSpi, Provider provider, String type, CertStoreParameters params) { @@ -78,10 +85,23 @@ public class CertStore { } /** - * @com.intel.drl.spec_ref + * Creates a new {@code CertStore} instance with the specified type and + * initialized with the specified parameters. * - * throws NullPointerException if type is null (instead of - * NoSuchAlgorithmException as in 1.4 release) + * @param type + * the certificate store type. + * @param params + * the certificate store parameters (may be {@code null}). + * @return the new certificate store instance. + * @throws NoSuchAlgorithmException + * if no provider can provide the specified certificate store + * type. + * @throws InvalidAlgorithmParameterException + * if the specified parameters cannot be used to initialize this + * certificate store instance. + * @throws NullPointerException + * if the {@code type} is {@code null}. + * @since Android 1.0 */ public static CertStore getInstance(String type, CertStoreParameters params) throws InvalidAlgorithmParameterException, NoSuchAlgorithmException { @@ -105,12 +125,29 @@ public class CertStore { } /** - * @com.intel.drl.spec_ref + * Creates a new {@code CertStore} instance from the specified provider with + * the specified type and initialized with the specified parameters. * - * throws NullPointerException if type is null (instead of - * NoSuchAlgorithmException as in 1.4 release) - * - * FIXME: IllegalArgumentException when provider is empty + * @param type + * the certificate store type. + * @param params + * the certificate store parameters (may be {@code null}). + * @param provider + * the name of the provider. + * @return the new certificate store instance. + * @throws NoSuchAlgorithmException + * if the specified provider cannot provide the requested + * certificate store type. + * @throws NoSuchProviderException + * if no provider with the specified name can be found. + * @throws InvalidAlgorithmParameterException + * if the specified parameters cannot be used to initialize this + * certificate store instance. + * @throws IllegalArgumentException + * if provider is null of empty. + * @throws NullPointerException + * if {@code type} is {@code null}. + * @since Android 1.0 */ public static CertStore getInstance(String type, CertStoreParameters params, String provider) @@ -127,10 +164,26 @@ public class CertStore { } /** - * @com.intel.drl.spec_ref - * - * throws NullPointerException if type is null (instead of - * NoSuchAlgorithmException as in 1.4 release) + * Creates a new {@code CertStore} instance from the specified provider with + * the specified type and initialized with the specified parameters. + * @param type + * the certificate store type. + * @param params + * the certificate store parameters (may be {@code null}). + * @param provider + * the name of the provider. + * @return the new certificate store instance. + * @throws NoSuchAlgorithmException + * if the specified provider cannot provide the requested + * certificate store type. + * @throws InvalidAlgorithmParameterException + * if the specified parameters cannot be used to initialize this + * certificate store instance. + * @throws IllegalArgumentException + * if provider is {@code null}. + * @throws NullPointerException + * if {@code type} is {@code null}. + * @since Android 1.0 */ public static CertStore getInstance(String type, CertStoreParameters params, Provider provider) @@ -158,21 +211,32 @@ public class CertStore { } /** - * @com.intel.drl.spec_ref + * Returns the certificate store type. + * + * @return the certificate store type. + * @since Android 1.0 */ public final String getType() { return type; } /** - * @com.intel.drl.spec_ref + * Returns the security provider. + * + * @return the security provider. + * @since Android 1.0 */ public final Provider getProvider() { return provider; } /** - * @com.intel.drl.spec_ref + * Returns a copy of the certificate store parameters that were used to + * initialize this instance. + * + * @return a copy of the certificate store parameters or {@code null} if + * none were specified. + * @since Android 1.0 */ public final CertStoreParameters getCertStoreParameters() { if (certStoreParams == null) { @@ -183,7 +247,17 @@ public class CertStore { } /** - * @com.intel.drl.spec_ref + * Returns the list of {@code Certificate}s for the specified {@code + * CertSelector} from this certificate store. + * + * @param selector + * the selector containing the criteria to search for + * certificates in this certificate store. + * @return the list of {@code Certificate}s that match the criteria of the + * specified selector. + * @throws CertStoreException + * if error(s) occur. + * @since Android 1.0 */ public final Collection extends Certificate> getCertificates(CertSelector selector) throws CertStoreException { @@ -191,7 +265,17 @@ public class CertStore { } /** - * @com.intel.drl.spec_ref + * Returns the list of {@code CRL}s for the specified {@code CRLSelector} + * from this certificate store. + * + * @param selector + * the selector containing the criteria to search for certificate + * revocation lists in this store. + * @return the list of {@code CRL}s that match the criteria of the specified + * selector + * @throws CertStoreException + * if error(s) occur. + * @since Android 1.0 */ public final Collection extends CRL> getCRLs(CRLSelector selector) throws CertStoreException { @@ -199,8 +283,14 @@ public class CertStore { } /** - * @com.intel.drl.spec_ref - */ + * Returns the default {@code CertStore} type from the Security + * Properties. + * + * @return the default {@code CertStore} type from the Security + * Properties, or the string {@code "LDAP"} if it cannot be + * determined. + * @since Android 1.0 + */ public static final String getDefaultType() { String defaultType = AccessController .doPrivileged(new java.security.PrivilegedActiontrue
if the object is the same as this object
- * false
if it is different from this object
+ * the object to compare with this object.
+ * @return {@code true} if the object is the same as this object, {@code
+ * false} if it is different from this object.
* @see #hashCode
+ * @since Android 1.0
*/
public boolean equals(Object other) {
// obj equal to itself
@@ -96,13 +97,13 @@ public abstract class Certificate implements Serializable {
}
/**
- * Returns an integer hash code for the receiver. Any two objects which
- * answer true
when passed to equals
must
- * answer the same value for this method.
- *
- * @return the receiver's hash
+ * Returns an integer hash code for the certificate. Any two objects which
+ * return {@code true} when passed to {@code equals} must return the same
+ * value for this method.
*
+ * @return the certificate's hash
* @see #equals
+ * @since Android 1.0
*/
public int hashCode() {
try {
@@ -121,6 +122,9 @@ public abstract class Certificate implements Serializable {
* Returns the encoded representation for this certificate.
*
* @return the encoded representation for this certificate.
+ * @throws CertificateEncodingException
+ * if the encoding fails.
+ * @since Android 1.0
*/
public abstract byte[] getEncoded() throws CertificateEncodingException;
@@ -130,17 +134,17 @@ public abstract class Certificate implements Serializable {
* @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
+ * @throws CertificateException
+ * if encoding errors are detected.
+ * @throws NoSuchAlgorithmException
+ * if an unsupported algorithm is detected.
+ * @throws InvalidKeyException
+ * if an invalid key is detected.
+ * @throws NoSuchProviderException
+ * if there is no default provider.
+ * @throws SignatureException
+ * if signature errors are detected.
+ * @since Android 1.0
*/
public abstract void verify(PublicKey key)
throws CertificateException,
@@ -150,25 +154,25 @@ public abstract class Certificate implements Serializable {
SignatureException;
/**
- * Verifies that this certificate was signed with the given public key. Uses
- * the signature algorithm given by the provider.
+ * Verifies that this certificate was signed with the given public key. It
+ * 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
+ * if encoding errors are detected.
* @exception NoSuchAlgorithmException
- * if an unsupported algorithm is detected
+ * if an unsupported algorithm is detected.
* @exception InvalidKeyException
- * if an invalid key is detected
+ * if an invalid key is detected.
* @exception NoSuchProviderException
- * if there is no default provider
+ * if the specified provider does not exists.
* @exception SignatureException
- * if signature errors are detected
+ * if signature errors are detected.
+ * @since Android 1.0
*/
public abstract void verify(PublicKey key, String sigProvider)
throws CertificateException,
@@ -179,9 +183,10 @@ public abstract class Certificate implements Serializable {
/**
* Returns a string containing a concise, human-readable description of the
- * receiver.
+ * certificate.
*
- * @return a printable representation for the receiver.
+ * @return a printable representation for the certificate.
+ * @since Android 1.0
*/
public abstract String toString();
@@ -189,11 +194,17 @@ public abstract class Certificate implements Serializable {
* Returns the public key corresponding to this certificate.
*
* @return the public key corresponding to this certificate.
+ * @since Android 1.0
*/
public abstract PublicKey getPublicKey();
/**
- * @com.intel.drl.spec_ref
+ * Returns an alternate object to be serialized.
+ *
+ * @return the object to serialize.
+ * @throws ObjectStreamException
+ * if the creation of the alternate object fails.
+ * @since Android 1.0
*/
protected Object writeReplace() throws ObjectStreamException {
try {
@@ -205,13 +216,13 @@ public abstract class Certificate implements Serializable {
}
/**
- * @com.intel.drl.spec_ref
+ * The alternate {@code Serializable} class to be used for serialization and
+ * deserialization of {@code Certificate} objects.
*
+ * @since Android 1.0
*/
protected static class CertificateRep implements Serializable {
- /**
- * @com.intel.drl.spec_ref
- */
+
private static final long serialVersionUID = -8563758940495660020L;
// The standard name of the certificate type
private final String type;
@@ -226,7 +237,14 @@ public abstract class Certificate implements Serializable {
};
/**
- * @com.intel.drl.spec_ref
+ * Creates a new {@code CertificateRep} instance with the specified
+ * certificate type and encoded data.
+ *
+ * @param type
+ * the certificate type.
+ * @param data
+ * the encoded data.
+ * @since Android 1.0
*/
protected CertificateRep(String type, byte[] data) {
this.type = type;
@@ -234,7 +252,13 @@ public abstract class Certificate implements Serializable {
}
/**
- * @com.intel.drl.spec_ref
+ * Deserializes a {@code Certificate} from a serialized {@code
+ * CertificateRep} object.
+ *
+ * @return the deserialized {@code Certificate}.
+ * @throws ObjectStreamException
+ * if deserialization fails.
+ * @since Android 1.0
*/
protected Object readResolve() throws ObjectStreamException {
try {
diff --git a/security/src/main/java/java/security/cert/CertificateEncodingException.java b/security/src/main/java/java/security/cert/CertificateEncodingException.java
index 089f487..188d084 100644
--- a/security/src/main/java/java/security/cert/CertificateEncodingException.java
+++ b/security/src/main/java/java/security/cert/CertificateEncodingException.java
@@ -15,50 +15,59 @@
* limitations under the License.
*/
-/**
-* @author Vera Y. Petrashkova
-* @version $Revision$
-*/
-
package java.security.cert;
/**
- * This class represents an encoding exception for a certificate.
+ * The exception that is thrown when an error occurs while a {@code Certificate}
+ * is being encoded.
+ *
+ * @since Android 1.0
*/
public class CertificateEncodingException extends CertificateException {
- /**
- * @com.intel.drl.spec_ref
- */
+
private static final long serialVersionUID = 6219492851589449162L;
/**
- * Constructs a new instance of this class with its walkback and message
- * filled in.
+ * Creates a new {@code CertificateEncodingException} with the specified
+ * message.
*
* @param msg
- * String The detail message for the exception.
+ * The detail message for the exception.
+ * @since Android 1.0
*/
public CertificateEncodingException(String msg) {
super(msg);
}
/**
- * Constructs a new instance of this class with its walkback filled in.
+ * Creates a new {@code CertificateEncodingException}.
+ *
+ * @since Android 1.0
*/
public CertificateEncodingException() {
}
/**
- * @com.intel.drl.spec_ref
- *
+ * Creates a new {@code CertificateEncodingException} with the specified
+ * message and cause.
+ *
+ * @param message
+ * the detail message for the exception.
+ * @param cause
+ * the cause.
+ * @since Android 1.0
*/
public CertificateEncodingException(String message, Throwable cause) {
super(message, cause);
}
/**
- * @com.intel.drl.spec_ref
- *
+ * Creates a new {@code CertificateEncodingException} with the specified
+ * cause.
+ *
+ * @param cause
+ * the cause.
+ * @since Android 1.0
*/
public CertificateEncodingException(Throwable cause) {
super(cause);
diff --git a/security/src/main/java/java/security/cert/CertificateException.java b/security/src/main/java/java/security/cert/CertificateException.java
index c36512c..674d617 100644
--- a/security/src/main/java/java/security/cert/CertificateException.java
+++ b/security/src/main/java/java/security/cert/CertificateException.java
@@ -15,54 +15,58 @@
* limitations under the License.
*/
-/**
-* @author Vera Y. Petrashkova
-* @version $Revision$
-*/
-
package java.security.cert;
import java.security.GeneralSecurityException;
/**
- * This class represents a general certificate exception.
+ * The base class for all {@code Certificate} related exceptions.
+ *
+ * @since Android 1.0
*/
public class CertificateException extends GeneralSecurityException {
- /**
- * @com.intel.drl.spec_ref
- *
- */
private static final long serialVersionUID = 3192535253797119798L;
/**
- * Constructs a new instance of this class with its walkback and message
- * filled in.
+ * Creates a new {@code CertificateException} with the specified message.
*
* @param msg
- * String The detail message for the exception.
+ * the detail message for the exception.
+ * @since Android 1.0
*/
public CertificateException(String msg) {
super(msg);
}
/**
- * Constructs a new instance of this class with its walkback filled in.
+ * Creates a new {@code CertificateException}.
+ *
+ * @since Android 1.0
*/
public CertificateException() {
}
/**
- * @com.intel.drl.spec_ref
- *
+ * Creates a new {@code CertificateException} with the specified message and
+ * cause.
+ *
+ * @param message
+ * the detail message for the exception.
+ * @param cause
+ * the cause.
+ * @since Android 1.0
*/
public CertificateException(String message, Throwable cause) {
super(message, cause);
}
/**
- * @com.intel.drl.spec_ref
- *
+ * Creates a new {@code CertificateException} with the specified cause.
+ *
+ * @param cause
+ * the cause
+ * @since Android 1.0
*/
public CertificateException(Throwable cause) {
super(cause);
diff --git a/security/src/main/java/java/security/cert/CertificateExpiredException.java b/security/src/main/java/java/security/cert/CertificateExpiredException.java
index b3549a2..fe3fc1f 100644
--- a/security/src/main/java/java/security/cert/CertificateExpiredException.java
+++ b/security/src/main/java/java/security/cert/CertificateExpiredException.java
@@ -15,37 +15,33 @@
* limitations under the License.
*/
-/**
-* @author Vera Y. Petrashkova
-* @version $Revision$
-*/
-
package java.security.cert;
/**
- * This class indicates that a given certificate has expired.
+ * The exception that is thrown when a {@code Certificate} has expired.
+ *
+ * @since Android 1.0
*/
public class CertificateExpiredException extends CertificateException {
- /**
- * @com.intel.drl.spec_ref
- *
- */
private static final long serialVersionUID = 9071001339691533771L;
/**
- * Constructs a new instance of this class with its walkback and message
- * filled in.
+ * Creates a new {@code CertificateExpiredException} with the specified
+ * message.
*
* @param msg
- * String The detail message for the exception.
+ * the detail message for this exception
+ * @since Android 1.0
*/
public CertificateExpiredException(String msg) {
super(msg);
}
/**
- * Constructs a new instance of this class with its walkback filled in.
+ * Creates a new {@code CertificateExpiredException}.
+ *
+ * @since Android 1.0
*/
public CertificateExpiredException() {
}
diff --git a/security/src/main/java/java/security/cert/CertificateFactory.java b/security/src/main/java/java/security/cert/CertificateFactory.java
index 746b251..b4213d4 100644
--- a/security/src/main/java/java/security/cert/CertificateFactory.java
+++ b/security/src/main/java/java/security/cert/CertificateFactory.java
@@ -15,11 +15,6 @@
* limitations under the License.
*/
-/**
-* @author Vera Y. Petrashkova
-* @version $Revision$
-*/
-
package java.security.cert;
import java.io.InputStream;
@@ -36,9 +31,15 @@ import org.apache.harmony.security.internal.nls.Messages;
/**
- * This class provides the functionality of a certificate factory algorithm.
+ * This class implements the functionality of a certificate factory algorithm,
+ * relying on parsing a stream of bytes.
+ * + * It defines methods for parsing certificate chains (certificate paths) and + * Certificate Revocation Lists (CRLs). + *
+ * + * @since Android 1.0 */ - public class CertificateFactory { // Store CertificateFactory service name @@ -57,8 +58,15 @@ public class CertificateFactory { private final String type; /** - * @com.intel.drl.spec_ref - * + * Creates a new {@code CertificateFactory} instance. + * + * @param certFacSpi + * the implementation delegate. + * @param provider + * the associated provider. + * @param type + * the certificate type. + * @since Android 1.0 */ protected CertificateFactory(CertificateFactorySpi certFacSpi, Provider provider, String type) { @@ -68,18 +76,18 @@ public class CertificateFactory { } /** - * Returns a new CertificateFactory of the given type. + * Creates a new {@code CertificateFactory} instance that provides the + * requested certificate type. * * @param type - * java.lang.String Type of certificate desired - * @return CertificateFactory a concrete implementation for the certificate - * type desired. - * - * @exception CertificateException - * If the type cannot be found - * - * @exception NullPointerException - * If the type is null + * the certificate type. + * @return the new {@code CertificateFactory} instance. + * @throws CertificateException + * if the specified certificate type is not available at any + * installed provider. + * @throws NullPointerException + * if {@code type} is {@code null}. + * @since Android 1.0 */ public static final CertificateFactory getInstance(String type) throws CertificateException { @@ -98,10 +106,25 @@ public class CertificateFactory { } /** - * @com.intel.drl.spec_ref + * Creates a new {@code CertificateFactory} instance from the specified + * provider that provides the requested certificate type. * - * throws NullPointerException if algorithm is null (instead of - * CertificateException as in 1.4 release) + * @param type + * the certificate type. + * @param provider + * the name of the provider providing certificates of the + * specified type. + * @return the new {@code CertificateFactory} instance. + * @throws CertificateException + * if the specified certificate type is not available by the + * specified provider. + * @throws NoSuchProviderException + * if no provider with the specified name can be found. + * @throws IllegalArgumentException + * if the specified provider name is {@code null} or empty. + * @throws NullPointerException + * it {@code type} is {@code null}. + * @since Android 1.0 */ public static final CertificateFactory getInstance(String type, String provider) throws CertificateException, @@ -117,21 +140,23 @@ public class CertificateFactory { } /** - * Returns a new CertificateFactory of the given type. + * Creates a new {@code CertificateFactory} instance from the specified + * provider that provides the requested certificate type. * * @param type - * java.lang.String Type of certificate desired + * the certificate type. * @param provider - * java.security.Provider Provider which has to implement the - * algorithm - * @return CertificateFactory a concrete implementation for the certificate - * type desired. - * - * @exception CertificateException - * If the type cannot be found - * - * @exception NullPointerException - * If algorithm is null + * the name of the provider providing certificates of the + * specified type. + * @return the new {@code CertificateFactory} instance. + * @throws CertificateException + * if the specified certificate type is not available at the + * specified provider. + * @throws IllegalArgumentException + * if the specified provider is {@code null}. + * @throws NullPointerException + * is {@code type} is {@code null}. + * @since Android 1.0 */ public static final CertificateFactory getInstance(String type, Provider provider) throws CertificateException { @@ -153,35 +178,37 @@ public class CertificateFactory { } /** - * Returns the Provider of the certificate factory represented by the - * receiver. + * Returns the {@code Provider} of the certificate factory represented by + * the certificate. * - * @return Provider an instance of a subclass of java.security.Provider + * @return the provider of this certificate factory. + * @since Android 1.0 */ public final Provider getProvider() { return provider; } /** - * Returns the Certificate type + * Returns the Certificate type. * - * @return String type of certificate being used + * @return type of certificate being used. + * @since Android 1.0 */ public final String getType() { return type; } /** - * Generates and initializes a Certificate from data from the - * provided input stream. + * Generates and initializes a {@code Certificate} from the provided input + * stream. * * @param inStream - * InputStream Stream from where data is read to create the - * Certificate - * - * @return Certificate an initialized Certificate - * @exception CertificateException - * if parsing problems are detected + * the stream from where data is read to create the {@code + * Certificate}. + * @return an initialized Certificate. + * @throws CertificateException + * if parsing problems are detected. + * @since Android 1.0 */ public final Certificate generateCertificate(InputStream inStream) throws CertificateException { @@ -189,53 +216,52 @@ public class CertificateFactory { } /** - * Returns an Iterator over the supported CertPath encodings (as Strings). - * The first element is the default encoding. + * Returns an {@code Iterator} over the supported {@code CertPath} encodings + * (as Strings). The first element is the default encoding scheme to apply. * - * @return Iterator Iterator over supported CertPath encodings (as Strings) + * @return an iterator over supported {@link CertPath} encodings (as + * Strings). + * @since Android 1.0 */ public final IteratorCertPath
from data from the provided
- * InputStream
. The default encoding is assumed.
+ * Generates a {@code CertPath} (a certificate chain) from the provided
+ * {@code InputStream}. The default encoding scheme is applied.
*
* @param inStream
- * InputStream with PKCS7 or PkiPath encoded data
- *
- * @return CertPath a CertPath initialized from the provided data
- *
+ * {@code InputStream} with encoded data.
+ * @return a {@code CertPath} initialized from the provided data.
* @throws CertificateException
- * if parsing problems are detected
+ * if parsing problems are detected.
+ * @since Android 1.0
*/
public final CertPath generateCertPath(InputStream inStream)
throws CertificateException {
- Iterator it = getCertPathEncodings();
+ IteratorCertPath
from data from the provided
- * InputStream
. The encoding is that specified by the
- * encoding parameter.
+ * Generates a {@code CertPath} (a certificate chain) from the provided
+ * {@code InputStream} and the specified encoding scheme.
*
* @param inStream
- * InputStream containing certificate path data in specified
- * encoding
+ * {@code InputStream} containing certificate path data in
+ * specified encoding.
* @param encoding
- * encoding of the data in the input stream
- *
- * @return CertPath a CertPath initialized from the provided data
- *
+ * encoding of the data in the input stream.
+ * @return a {@code CertPath} initialized from the provided data.
* @throws CertificateException
- * if parsing problems are detected
+ * if parsing problems are detected.
* @throws UnsupportedOperationException
- * if the provider does not implement this method
+ * if the provider does not implement this method.
+ * @since Android 1.0
*/
public final CertPath generateCertPath(InputStream inStream, String encoding)
throws CertificateException {
@@ -243,19 +269,18 @@ public class CertificateFactory {
}
/**
- * Generates a CertPath
from the provided List of
- * Certificates. The encoding is the default encoding.
+ * Generates a {@code CertPath} from the provided list of certificates. The
+ * encoding is the default encoding.
*
* @param certificates
- * List containing certificates in a format supported by the
- * CertificateFactory
- *
- * @return CertPath a CertPath initialized from the provided data
- *
+ * the list containing certificates in a format supported by the
+ * {@code CertificateFactory}.
+ * @return a {@code CertPath} initialized from the provided data.
* @throws CertificateException
- * if parsing problems are detected
+ * if parsing problems are detected.
* @throws UnsupportedOperationException
- * if the provider does not implement this method
+ * if the provider does not implement this method.
+ * @since Android 1.0
*/
public final CertPath generateCertPath(List extends Certificate> certificates)
throws CertificateException {
@@ -263,16 +288,16 @@ public class CertificateFactory {
}
/**
- * Generates and initializes a collection of Certificates from
- * data from the provided input stream.
+ * Generates and initializes a collection of (unrelated) certificates from
+ * the provided input stream.
*
* @param inStream
- * InputStream Stream from where data is read to create the
- * Certificates
- *
- * @return Collection an initialized collection of Certificates
- * @exception CertificateException
- * if parsing problems are detected
+ * the stream from which the data is read to create the
+ * collection.
+ * @return an initialized collection of certificates.
+ * @throws CertificateException
+ * if parsing problems are detected.
+ * @since Android 1.0
*/
public final Collection extends Certificate> generateCertificates(InputStream inStream)
throws CertificateException {
@@ -280,32 +305,30 @@ public class CertificateFactory {
}
/**
- * Generates and initializes a Certificate Revocation List from data from
+ * Generates and initializes a Certificate Revocation List (CRL) from
* the provided input stream.
*
* @param inStream
- * InputStream Stream from where data is read to create the CRL
- *
- * @return CRL an initialized Certificate Revocation List
+ * the stream from where data is read to create the CRL.
+ * @return an initialized CRL.
* @exception CRLException
- * if parsing problems are detected
+ * if parsing problems are detected.
+ * @since Android 1.0
*/
public final CRL generateCRL(InputStream inStream) throws CRLException {
return spiImpl.engineGenerateCRL(inStream);
}
/**
- * Generates and initializes a collection of Certificate Revocation List
- * from data from the provided input stream.
+ * Generates and initializes a collection of Certificate Revocation
+ * List (CRL) from the provided input stream.
*
* @param inStream
- * InputStream Stream from where data is read to create the CRLs
- *
- * @return Collection an initialized collection of Certificate Revocation
- * List
+ * the stream from which the data is read to create the CRLs.
+ * @return an initialized collection of CRLs.
* @exception CRLException
- * if parsing problems are detected
- *
+ * if parsing problems are detected.
+ * @since Android 1.0
*/
public final Collection extends CRL> generateCRLs(InputStream inStream)
throws CRLException {
diff --git a/security/src/main/java/java/security/cert/CertificateFactorySpi.java b/security/src/main/java/java/security/cert/CertificateFactorySpi.java
index d0f6ec6..ed6ffed 100644
--- a/security/src/main/java/java/security/cert/CertificateFactorySpi.java
+++ b/security/src/main/java/java/security/cert/CertificateFactorySpi.java
@@ -15,11 +15,6 @@
* limitations under the License.
*/
-/**
-* @author Vera Y. Petrashkova
-* @version $Revision$
-*/
-
package java.security.cert;
import java.io.InputStream;
@@ -30,88 +25,90 @@ import java.util.List;
import org.apache.harmony.security.internal.nls.Messages;
/**
- * This class is a Service Provider Interface (therefore the Spi suffix) for
- * certificate factories to be supplied by providers.
+ * This class defines the Service Provider Interface (SPI) for the
+ * {@code CertificateFactory} class. This SPI must be implemented for each
+ * certificate type a security provider wishes to support.
+ *
+ * @since Android 1.0
*/
public abstract class CertificateFactorySpi {
/**
* Constructs a new instance of this class.
+ *
+ * @since Android 1.0
*/
public CertificateFactorySpi() {
}
/**
- * Generates and initializes a Certificate from data from the
- * provided input stream.
+ * Generates and initializes a {@code Certificate} from the provided input
+ * stream.
*
* @param inStream
- * InputStream Stream from where data is read to create the
- * Certificate
- *
- * @return Certificate an initialized Certificate
+ * the stream from which the data is read to create the
+ * certificate.
+ * @return an initialized certificate.
* @exception CertificateException
- * if parsing problems are detected
+ * if parsing problems are detected.
+ * @since Android 1.0
*/
public abstract Certificate engineGenerateCertificate(InputStream inStream)
throws CertificateException;
/**
- * Generates and initializes a collection of Certificates from
- * data from the provided input stream.
+ * Generates and initializes a collection of certificates from the provided
+ * input stream.
*
* @param inStream
- * InputStream Stream from where data is read to create the
- * Certificates
- *
- * @return Collection an initialized collection of Certificates
+ * the stream from where data is read to create the certificates.
+ * @return a collection of certificates.
* @exception CertificateException
- * if parsing problems are detected
+ * if parsing problems are detected.
+ * @since Android 1.0
*/
public abstract Collection extends Certificate>
engineGenerateCertificates(InputStream inStream) throws CertificateException;
/**
- * Generates and initializes a Certificate Revocation List from data from
+ * Generates and initializes a Certificate Revocation List (CRL) from
* the provided input stream.
*
* @param inStream
- * InputStream Stream from where data is read to create the CRL
- *
- * @return CRL an initialized Certificate Revocation List
+ * the stream from where data is read to create the CRL.
+ * @return an CRL instance.
* @exception CRLException
- * if parsing problems are detected
+ * if parsing problems are detected.
+ * @since Android 1.0
*/
public abstract CRL engineGenerateCRL(InputStream inStream)
throws CRLException;
/**
- * Generates and initializes a collection of Certificate Revocation List
- * from data from the provided input stream.
+ * Generates and initializes a collection of Certificate Revocation
+ * List (CRL) from the provided input stream.
*
* @param inStream
- * InputStream Stream from where data is read to create the CRLs
- *
- * @return Collection an initialized collection of Certificate Revocation
- * List
+ * the stream from which the data is read to create the CRLs.
+ * @return a collection of CRLs.
* @exception CRLException
- * if parsing problems are detected
+ * if parsing problems are detected.
+ * @since Android 1.0
*/
public abstract Collection extends CRL>
engineGenerateCRLs(InputStream inStream) throws CRLException;
/**
- * Generates a CertPath
from data from the provided
- * InputStream
. The default encoding is assumed.
+ * Generates a {@code CertPath} from the provided {@code InputStream}. The
+ * default encoding scheme is applied.
*
* @param inStream
- * InputStream with PKCS7 or PkiPath encoded data
- *
- * @return CertPath a CertPath initialized from the provided data
- *
+ * an input stream with encoded data.
+ * @return a {@code CertPath} initialized from the provided data.
* @throws CertificateException
- * if parsing problems are detected
+ * if parsing problems are detected.
+ * @since Android 1.0
*/
public CertPath engineGenerateCertPath(InputStream inStream)
throws CertificateException {
@@ -120,22 +117,20 @@ public abstract class CertificateFactorySpi {
}
/**
- * Generates a CertPath
from data from the provided
- * InputStream
. The encoding is that specified by the
- * encoding parameter.
+ * Generates a {@code CertPath} from the provided {@code
+ * InputStream} in the specified encoding.
*
* @param inStream
- * InputStream containing certificate path data in specified
- * encoding
+ * an input stream containing certificate path data in specified
+ * encoding.
* @param encoding
- * encoding of the data in the input stream
- *
- * @return CertPath a CertPath initialized from the provided data
- *
+ * the encoding of the data in the input stream.
+ * @return a {@code CertPath} initialized from the provided data
* @throws CertificateException
- * if parsing problems are detected
+ * if parsing problems are detected.
* @throws UnsupportedOperationException
- * if the provider does not implement this method
+ * if the provider does not implement this method.
+ * @since Android 1.0
*/
public CertPath engineGenerateCertPath(InputStream inStream, String encoding)
throws CertificateException {
@@ -144,19 +139,18 @@ public abstract class CertificateFactorySpi {
}
/**
- * Generates a CertPath
from the provided List of
- * Certificates. The encoding is the default encoding.
+ * Generates a {@code CertPath} from the provided list of certificates. The
+ * encoding is the default encoding.
*
* @param certificates
- * List containing certificates in a format supported by the
- * CertificateFactory
- *
- * @return CertPath a CertPath initialized from the provided data
- *
+ * the list containing certificates in a format supported by the
+ * {@code CertificateFactory}.
+ * @return a {@code CertPath} initialized from the provided data.
* @throws CertificateException
- * if parsing problems are detected
+ * if parsing problems are detected.
* @throws UnsupportedOperationException
- * if the provider does not implement this method
+ * if the provider does not implement this method.
+ * @since Android 1.0
*/
public CertPath engineGenerateCertPath(List extends Certificate> certificates)
throws CertificateException {
@@ -165,10 +159,12 @@ public abstract class CertificateFactorySpi {
}
/**
- * Returns an Iterator over the supported CertPath encodings (as Strings).
- * The first element is the default encoding.
+ * Returns an {@code Iterator} over the supported {@code CertPath} encodings
+ * (as Strings). The first element is the default encoding.
*
- * @return Iterator Iterator over supported CertPath encodings (as Strings)
+ * @return an iterator over supported {@code CertPath} encodings (as
+ * Strings).
+ * @since Android 1.0
*/
public Iterator+ * It is used to specify the {@code Collection} where the {@code CertStore} will + * retrieve the certificates and CRLs from. + *
* + * @since Android 1.0 */ public class CollectionCertStoreParameters implements CertStoreParameters { + // BEGIN android-changed // Default empty and immutable collection. // Used ifCollectionCertStoreParameters
instance
// created by the no arg constructor
- private static final Collection defaultCollection = Collections.EMPTY_SET;
+ private static final Collection> defaultCollection = Collections.EMPTY_SET;
// A Collection
of Certificate
s
// and CRL
s
- private final Collection collection;
+ private final Collection> collection;
+ // END android-changed
/**
- * @com.intel.drl.spec_ref
+ * Creates a new {@code CollectionCertStoreParameters} without a collection.
+ * + * The default collection is an empty and unmodifiable {@code Collection}. + *
+ * @since Android 1.0 */ public CollectionCertStoreParameters() { this.collection = defaultCollection; } /** - * @com.intel.drl.spec_ref + * Creates a new {@code CollectionCertStoreParameters} with the specified + * collection. + *+ * The specified collection is not copied and therefore may be modified at + * any time. + *
+ * + * @param collection + * the collection where the {@code Certificate}s and {@code CRL}s + * will be retrieved from. + * @throws NullPointerException + * if {@code collection is null}. + * @since Android 1.0 */ public CollectionCertStoreParameters(Collection> collection) { this.collection = collection; @@ -56,21 +74,33 @@ public class CollectionCertStoreParameters implements CertStoreParameters { } /** - * @com.intel.drl.spec_ref + * Clones this {@code CollectionCertStoreParameters} instance, but not the + * underlying collection. + * + * @return the cloned instance. + * @since Android 1.0 */ public Object clone() { return new CollectionCertStoreParameters(collection); } /** - * @com.intel.drl.spec_ref + * Returns the collection where the {@code Certificate}s and {@code CRL}s + * are retrieved from. + * + * @return the collection where the {@code Certificate}s and {@code CRL}s + * will be retrieved from. + * @since Android 1.0 */ public Collection> getCollection() { return collection; } /** - * @com.intel.drl.spec_ref + * Returns the string representation of this instance. + * + * @return the string representation of this instance. + * @since Android 1.0 */ public String toString() { StringBuffer sb = diff --git a/security/src/main/java/java/security/cert/LDAPCertStoreParameters.java b/security/src/main/java/java/security/cert/LDAPCertStoreParameters.java index d965c42..9145848 100644 --- a/security/src/main/java/java/security/cert/LDAPCertStoreParameters.java +++ b/security/src/main/java/java/security/cert/LDAPCertStoreParameters.java @@ -15,16 +15,12 @@ * limitations under the License. */ -/** -* @author Vladimir N. Molotkov -* @version $Revision$ -*/ - package java.security.cert; /** - * @com.intel.drl.spec_ref + * The parameters to initialize a LDAP {@code CertStore} instance. * + * @since Android 1.0 */ public class LDAPCertStoreParameters implements CertStoreParameters { // Default LDAP server name @@ -38,7 +34,16 @@ public class LDAPCertStoreParameters implements CertStoreParameters { private final int port; /** - * @com.intel.drl.spec_ref + * Creates a new {@code LDAPCertStoreParameters} instance with the specified + * server name and port. + * + * @param serverName + * the LDAP server name. + * @param port + * the port. + * @throws NullPointerException + * is {@code serverName} is {@code null}. + * @since Android 1.0 */ public LDAPCertStoreParameters(String serverName, int port) { this.port = port; @@ -49,7 +54,13 @@ public class LDAPCertStoreParameters implements CertStoreParameters { } /** - * @com.intel.drl.spec_ref + * Creates a new {@code LDAPCertStoreParameters} instance with default + * parameters. + *+ * The default parameters are server name "localhost" and port 389. + *
+ * + * @since Android 1.0 */ public LDAPCertStoreParameters() { this.serverName = DEFAULT_LDAP_SERVER_NAME; @@ -57,7 +68,14 @@ public class LDAPCertStoreParameters implements CertStoreParameters { } /** - * @com.intel.drl.spec_ref + * Creates a new {@code LDAPCertStoreParameters} instance with the specified + * server name and default port 389. + * + * @param serverName + * the LDAP server name. + * @throws NullPointerException + * if {@code serverName} is {@code null}. + * @since Android 1.0 */ public LDAPCertStoreParameters(String serverName) { this.port = DEFAULT_LDAP_PORT; @@ -68,28 +86,42 @@ public class LDAPCertStoreParameters implements CertStoreParameters { } /** - * @com.intel.drl.spec_ref + * Clones this {@code LDAPCertStoreParameters} instance. + * + * @return the cloned instance. + * @since Android 1.0 */ public Object clone() { return new LDAPCertStoreParameters(serverName, port); } /** - * @com.intel.drl.spec_ref + * Returns the LDAP server port. + * + * @return the LDAP server port. + * @since Android 1.0 */ public int getPort() { return port; } /** - * @com.intel.drl.spec_ref + * Returns the LDAP server name. + * + * @return the LDAP server name. + * @since Android 1.0 */ public String getServerName() { return serverName; } /** - * @com.intel.drl.spec_ref + * Returns the string representation of this {@code LDAPCertStoreParameters} + * instance. + * + * @return the string representation of this {@code LDAPCertStoreParameters} + * instance. + * @since Android 1.0 */ public String toString() { StringBuffer sb = diff --git a/security/src/main/java/java/security/cert/PKIXBuilderParameters.java b/security/src/main/java/java/security/cert/PKIXBuilderParameters.java index c6df05a..a047a80 100644 --- a/security/src/main/java/java/security/cert/PKIXBuilderParameters.java +++ b/security/src/main/java/java/security/cert/PKIXBuilderParameters.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Vladimir N. Molotkov -* @version $Revision$ -*/ - package java.security.cert; import java.security.InvalidAlgorithmParameterException; @@ -31,15 +26,36 @@ import java.util.Set; import org.apache.harmony.security.internal.nls.Messages; /** - * @com.intel.drl.spec_ref + * The parameter specification for a PKIX {@code CertPathBuilder} + * algorithm used to {@link CertPathBuilder#build(CertPathParameters) build} + * certificate chains validated with the PKIX certification path validation. + *+ * The parameters must be created with trusted certificate authorities + * and constraints for the target certificates. + *
* + * @see CertPathBuilder + * @see CertPathParameters + * @since Android 1.0 */ public class PKIXBuilderParameters extends PKIXParameters { // Maximum certificate path length (5 by default) private int maxPathLength = 5; /** - * @com.intel.drl.spec_ref + * Creates a new {@code PKIXBuilderParameters} instance with the specified + * set of {@code TrustAnchor} and certificate constraints. + * + * @param trustAnchors + * the set of {@code TrustAnchors}. + * @param targetConstraints + * the certificate constraints. + * @throws InvalidAlgorithmParameterException + * if {@code trustAnchors} is empty. + * @throws ClassCastException + * if one of the items in {@code trustAnchors} is not an + * instance of {@code java.security.cert.TrustAnchor}. + * @since Android 1.0 */ public PKIXBuilderParameters(Set+ * This is the maximum number of non-self-signed certificates in a + * certification path. + *
+ * + * @return the maximum length of a certification path, or {@code -1} if it + * is unlimited. + * @since Android 1.0 */ public int getMaxPathLength() { return maxPathLength; } /** - * @com.intel.drl.spec_ref + * Set the maximum length of a certification path. + *+ * This is the maximum number of non-self-signed certificates in a + * certification path. + *
+ * + * @param maxPathLength + * the maximum length of a certification path. + * @throws InvalidParameterException + * if {@code maxPathLength} is less than {@code -1}. + * @since Android 1.0 */ public void setMaxPathLength(int maxPathLength) { if (maxPathLength < -1) { @@ -78,7 +124,12 @@ public class PKIXBuilderParameters extends PKIXParameters { } /** - * @com.intel.drl.spec_ref + * Returns a string representation of this {@code PKIXBuilderParameters} + * instance. + * + * @return a string representation of this {@code PKIXBuilderParameters} + * instance. + * @since Android 1.0 */ public String toString() { StringBuffer sb = new StringBuffer("[\n"); //$NON-NLS-1$ diff --git a/security/src/main/java/java/security/cert/PKIXCertPathBuilderResult.java b/security/src/main/java/java/security/cert/PKIXCertPathBuilderResult.java index d0a34ba..6064194 100644 --- a/security/src/main/java/java/security/cert/PKIXCertPathBuilderResult.java +++ b/security/src/main/java/java/security/cert/PKIXCertPathBuilderResult.java @@ -15,10 +15,6 @@ * limitations under the License. */ -/** -* @author Vladimir N. Molotkov -* @version $Revision$ -*/ package java.security.cert; @@ -27,8 +23,10 @@ import java.security.PublicKey; import org.apache.harmony.security.internal.nls.Messages; /** - * @com.intel.drl.spec_ref + * The result of the PKIX certification path builder, returned by + * {@link CertPathBuilder#build(CertPathParameters)}. * + * @since Android 1.0 */ public class PKIXCertPathBuilderResult extends PKIXCertPathValidatorResult implements CertPathBuilderResult { @@ -36,7 +34,22 @@ public class PKIXCertPathBuilderResult extends PKIXCertPathValidatorResult private final CertPath certPath; /** - * @com.intel.drl.spec_ref + * Creates a new {@code PKIXCertPathBuilderResult} instance with the + * specified validated certification path, the trust anchor of the + * certification path, the policy tree and the public key of the subject. + * + * @param certPath + * the validated certification path. + * @param trustAnchor + * the trust anchor. + * @param policyTree + * the policy tree (or {@code null} if not used). + * @param subjectPublicKey + * the public key. + * @throws NullPointerException + * if the {@code cerPath}, {@code trustAnchor} or {@code + * subjectPolicyKey} is {@code null}. + * @since Android 1.0 */ public PKIXCertPathBuilderResult(CertPath certPath, TrustAnchor trustAnchor, PolicyNode policyTree, PublicKey subjectPublicKey) { @@ -48,14 +61,22 @@ public class PKIXCertPathBuilderResult extends PKIXCertPathValidatorResult } /** - * @com.intel.drl.spec_ref + * Returns the validated certification path. + * + * @return the validated certification path. + * @since Android 1.0 */ public CertPath getCertPath() { return certPath; } /** - * @com.intel.drl.spec_ref + * Returns a string representation of this {@code PKIXCertPathBuilderResult} + * instance. + * + * @return a string representation of this {@code PKIXCertPathBuilderResult} + * instance. + * @since Android 1.0 */ public String toString() { StringBuffer sb = new StringBuffer(super.toString()); diff --git a/security/src/main/java/java/security/cert/PKIXCertPathChecker.java b/security/src/main/java/java/security/cert/PKIXCertPathChecker.java index f448bee..5614878 100644 --- a/security/src/main/java/java/security/cert/PKIXCertPathChecker.java +++ b/security/src/main/java/java/security/cert/PKIXCertPathChecker.java @@ -26,18 +26,42 @@ import java.util.Collection; import java.util.Set; /** - * @com.intel.drl.spec_ref + * The class specifying the interface to extend the certification path + * validation algorithm by checks to perform on an {@code X509Certificate}. + *+ * The checks are added to a certification path validation using the + * {@link PKIXParameters#setCertPathCheckers(java.util.List) + * setCertPathCheckers} or + * {@link PKIXBuilderParameters#addCertPathChecker(PKIXCertPathChecker) + * addCertPathChecker} of the {@code PKIXParameters} and {@code + * PKIXBuilderParameters} class respectively. The + * {@link #check(Certificate, Collection) check} method will be called for each + * certificate processed by a {@code CertPathBuilder} of {@code + * CertPathValidator}. + *
+ *+ * A {@code PKIXCertPathChecker} implementation must support reverse + * checking (from trusted CA to target) and may support forward checking + * (from target to trusted CA). The return value of {@code + * isForwardCheckingSupported} indicates whether forward checking is supported. + *
* + * @since Android 1.0 */ public abstract class PKIXCertPathChecker implements Cloneable { /** - * @com.intel.drl.spec_ref + * Creates a new {@code PKIXCertPathChecker} instance. + * + * @since Android 1.0 */ protected PKIXCertPathChecker() {} /** - * @com.intel.drl.spec_ref + * Clones this {@code PKIXCertPathChecker} instance. + * + * @return the cloned instance. + * @since Android 1.0 */ public Object clone() { try { @@ -48,23 +72,55 @@ public abstract class PKIXCertPathChecker implements Cloneable { } /** - * @com.intel.drl.spec_ref + * Initializes this {@code PKIXCertPathChecker} instance for specified + * checking direction. + * + * @param forward + * the direction of the certification path processing, {@code + * true} if the certificates are processed in forward direction + * (from target to trusted CA), {@code false} if processed in + * reverse direction (from trusted CA to target). + * @throws CertPathValidatorException + * if initialization of this {@code PKIXCertPathChecker} + * instance fails, or if it cannot process certificates in the + * specified order. + * @since Android 1.0 */ public abstract void init(boolean forward) throws CertPathValidatorException; /** - * @com.intel.drl.spec_ref + * Returns whether this {@code PKIXCertPathChecker} instance supports + * forward checking. + * + * @return {@code true} if this {@code PKIXCertPathChecker} instance + * supports forward checking, otherwise {@code false}. + * @since Android 1.0 */ public abstract boolean isForwardCheckingSupported(); /** - * @com.intel.drl.spec_ref + * Returns the list of extensions of X.509 certificates that this {@code + * PKIXCertPathChecker} is able to process. + * + * @return the list of extensions of X.509 certificates that this {@code + * PKIXCertPathChecker} is able to process, or {@code null} if there + * are none. + * @since Android 1.0 */ public abstract Set+ * The parameters must be created with trusted certificate authorities + * (trust anchors). + *
* + * @see CertPathValidator + * @see CertPathParameters + * @since Android 1.0 */ public class PKIXParameters implements CertPathParameters { // Set of trust anchors - most trusted CAs @@ -70,7 +72,14 @@ public class PKIXParameters implements CertPathParameters { private boolean policyQualifiersRejected = true; /** - * @com.intel.drl.spec_ref + * Creates a new {@code PKIXParameters} instance with the specified set of + * trusted certificate authorities. + * + * @param trustAnchors + * the trusted CAs. + * @throws InvalidAlgorithmParameterException + * if {@code trustAnchors} is empty. + * @since Android 1.0 */ public PKIXParameters(Set+ * The list is unmodifiable and the entries in the list are cloned. + *
+ * + * @return the list of checkers for the certification path. + * @since Android 1.0 */ public List+ * The list is copied and the entries are cloned. + *
+ * + * @param certPathCheckers + * the list of checkers for the certification path, or {@code + * null} to clear the checkers. + * @since Android 1.0 */ public void setCertPathCheckers(List+ * If set, the specified provider will be preferred for creating signatures. + * If not set, the first provider found supporting creation of signatures + * will be used. + * + * @param sigProvider + * the name of the preferred signature provider, or {@code null} + * if none is preferred. + * @since Android 1.0 */ public void setSigProvider(String sigProvider) { this.sigProvider = sigProvider; } /** - * @com.intel.drl.spec_ref + * Returns the constraints that are required for the target certificate. + * + * @return the constraints for the target certificate, or {@code null} if + * none are set. + * @since Android 1.0 */ public CertSelector getTargetCertConstraints() { return (targetCertConstraints == null ? null @@ -403,7 +556,12 @@ public class PKIXParameters implements CertPathParameters { } /** - * @com.intel.drl.spec_ref + * Sets the constraints that are required for the target certificate. + * + * @param targetCertConstraints + * the constraints for the target certificate, or {@code null} if + * none should be used. + * @since Android 1.0 */ public void setTargetCertConstraints(CertSelector targetCertConstraints) { this.targetCertConstraints = (targetCertConstraints == null ? null @@ -411,7 +569,10 @@ public class PKIXParameters implements CertPathParameters { } /** - * @com.intel.drl.spec_ref + * Clones this {@code PKIXParameters} instance. + * + * @return the cloned instance. + * @since Android 1.0 */ public Object clone() { try { @@ -431,7 +592,10 @@ public class PKIXParameters implements CertPathParameters { } /** - * @com.intel.drl.spec_ref + * Returns a string representation of this {@code PKIXParameters} instance. + * + * @return a string representation of this {@code PKIXParameters} instance. + * @since Android 1.0 */ public String toString() { StringBuffer sb = diff --git a/security/src/main/java/java/security/cert/PolicyNode.java b/security/src/main/java/java/security/cert/PolicyNode.java index 24ddd5b..c112a8a 100644 --- a/security/src/main/java/java/security/cert/PolicyNode.java +++ b/security/src/main/java/java/security/cert/PolicyNode.java @@ -15,54 +15,81 @@ * limitations under the License. */ -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - package java.security.cert; import java.util.Iterator; import java.util.Set; /** - * @com.intel.drl.spec_ref + * The interface to a valid policy tree node for the PKIX certification path + * validation algorithm. + *
+ * Instances of this class are one of the outputs of the PKIX certification path + * validation algorithm. + *
* + * @since Android 1.0 */ public interface PolicyNode { /** - * @com.intel.drl.spec_ref + * Returns the list of children of this node as an {@code Iterator}. + * + * @return the list of children of this node as an {@code Iterator}. + * @since Android 1.0 */ public Iterator extends PolicyNode> getChildren(); /** - * @com.intel.drl.spec_ref + * Returns the depth of this node in the policy tree. + *+ * the depth is zero based. + *
+ * + * @return the depth of this node in the policy tree. + * @since Android 1.0 */ public int getDepth(); /** - * @com.intel.drl.spec_ref + * Returns the expected policies for the next certificate to be valid. + * + * @return the expected policies. + * @since Android 1.0 */ public Set+ * It is a trusted certificate authority (CA) and includes the public key + * of the CA, the CA's name and the constraints for the validation of + * certification paths. The constructor also allows to specify a binary + * representation of a so called "Name Constraints" extension as a byte array. + *
* + * @since Android 1.0 */ public class TrustAnchor { // Most trusted CA as a X500Principal @@ -50,7 +53,21 @@ public class TrustAnchor { private final byte[] nameConstraints; /** - * @com.intel.drl.spec_ref + * Creates a new {@code TrustAnchor} with the specified certificate and name + * constraints. + *+ * The name constraints will be used as additional constraints during the + * validation of certification paths. + *
+ * + * @param trustedCert + * the trusted certificate + * @param nameConstraints + * the ASN.1 DER encoded form of the name constraints or {@code + * null} if none. + * @throws IllegalArgumentException + * if the decoding of the name constraints fail. + * @since Android 1.0 */ public TrustAnchor(X509Certificate trustedCert, byte[] nameConstraints) { if (trustedCert == null) { @@ -72,7 +89,25 @@ public class TrustAnchor { } /** - * @com.intel.drl.spec_ref + * Creates a new {@code TrustAnchor} with the specified certificate + * authority name, its public key and the specified name constraints. + *+ * The name constraints will be used as additional constraints during the + * validation of certification paths. + *
+ * + * @param caName + * the X.500 name of the certificate authority in RFC 2253 + * {@code String} format. + * @param caPublicKey + * the public key of the certificate authority + * @param nameConstraints + * the ASN.1 DER encoded form of the name constraints or {@code + * null} if none. + * @throws IllegalArgumentException + * if the {@code caName} is empty or if decoding of the name + * constraints fail. + * @since Android 1.0 */ public TrustAnchor(String caName, PublicKey caPublicKey, byte[] nameConstraints) { @@ -105,7 +140,24 @@ public class TrustAnchor { } /** - * @com.intel.drl.spec_ref + * Creates a new {@code TrustAnchor} with the specified certificate + * authority name as principal, its public key and the specified name + * constraints. + *+ * The name constraints will be used as additional constraints during the + * validation of certification paths. + *
+ * + * @param caPrincipal + * the name of the certificate authority as X500 principal. + * @param caPublicKey + * the public key of the certificate authority. + * @param nameConstraints + * the ASN.1 DER encoded form of the name constraints or {@code + * null} if none. + * @throws IllegalArgumentException + * if decoding of the name constraints fail. + * @since Android 1.0 */ public TrustAnchor(X500Principal caPrincipal, PublicKey caPublicKey, byte[] nameConstraints) { @@ -132,7 +184,10 @@ public class TrustAnchor { } /** - * @com.intel.drl.spec_ref + * Returns a copy of the name constraints in ASN.1 DER encoded form. + * + * @return a copy of the name constraints in ASN.1 DER encoded form. + * @since Android 1.0 */ public final byte[] getNameConstraints() { if (nameConstraints == null) { @@ -145,35 +200,58 @@ public class TrustAnchor { } /** - * @com.intel.drl.spec_ref + * Returns the certificate of this trusted certificate authority. + * + * @return the certificate of this CA or {@code null}, if the trust anchor + * of this instance was not created with a certificate. + * @since Android 1.0 */ public final X509Certificate getTrustedCert() { return trustedCert; } /** - * @com.intel.drl.spec_ref + * Returns the name of the certificate authority as {@code X500Principal}. + * + * @return the name of the certificate authority or {@code null} if the + * trust anchor of this instance was not created with a {@code + * X500Principal}. + * @since Android 1.0 */ public final X500Principal getCA() { return caPrincipal; } /** - * @com.intel.drl.spec_ref + * Returns the name of the certificate authority as {@code String} in RFC + * 2253 format. + * + * @return the name of the certificate authority as {@code String} in RFC + * 2253 format or {@code null} if the trust anchor of this instance + * was not created with a CA name. + * @since Android 1.0 */ public final String getCAName() { return caName; } /** - * @com.intel.drl.spec_ref + * Returns the public key of the certificate authority. + * + * @return the public key of the certificate authority or {@code null} if + * the trust anchor if this instance was not created with a public + * key. + * @since Android 1.0 */ public final PublicKey getCAPublicKey() { return caPublicKey; } /** - * @com.intel.drl.spec_ref + * Returns a string representation of this {@code TrustAnchor} instance. + * + * @return a string representation of this {@code TrustAnchor} instance. + * @since Android 1.0 */ public String toString() { StringBuffer sb = new StringBuffer("TrustAnchor: [\n"); //$NON-NLS-1$ diff --git a/security/src/main/java/java/security/cert/X509CRL.java b/security/src/main/java/java/security/cert/X509CRL.java index e502f2f..eabdb68 100644 --- a/security/src/main/java/java/security/cert/X509CRL.java +++ b/security/src/main/java/java/security/cert/X509CRL.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Alexander Y. Kleymenov -* @version $Revision$ -*/ - package java.security.cert; import java.io.ByteArrayInputStream; @@ -42,19 +37,36 @@ import javax.security.auth.x500.X500Principal; import org.apache.harmony.security.internal.nls.Messages; /** - * @com.intel.drl.spec_ref + * Abstract base class for X.509 certificate revocation lists (CRL). + *+ * More information regarding CRL can be found in RFC 2459, + * "Internet X.509 Public Key Infrastructure Certificate and CRL Profile" at http://www.ietf.org/rfc/rfc2459.txt + * . + *
+ * + * @since Android 1.0 */ public abstract class X509CRL extends CRL implements X509Extension { /** - * @com.intel.drl.spec_ref + * Creates a new {@code X509CRL} instance. + * + * @since Android 1.0 */ protected X509CRL() { super("X.509"); //$NON-NLS-1$ } /** - * @com.intel.drl.spec_ref + * Returns whether the specified object equals to this instance. + * + * @param other + * the object to compare. + * @return {@code true} if the specified object is equal to this, otherwise + * {@code false}. + * @since Android 1.0 */ public boolean equals(Object other) { if (other == this) { @@ -72,7 +84,10 @@ public abstract class X509CRL extends CRL implements X509Extension { } /** - * @com.intel.drl.spec_ref + * Returns the hashcode of this CRL instance. + * + * @return the hashcode. + * @since Android 1.0 */ public int hashCode() { try { @@ -88,13 +103,33 @@ public abstract class X509CRL extends CRL implements X509Extension { } /** - * @com.intel.drl.spec_ref + * Returns this CRL in ASN.1 DER encoded form. + * + * @return this CRL in ASN.1 DER encoded form. + * @throws CRLException + * if encoding fails. + * @since Android 1.0 */ public abstract byte[] getEncoded() throws CRLException; /** - * @com.intel.drl.spec_ref + * Verifies this CRL by verifying that this CRL was signed with the + * corresponding private key to the specified public key. + * + * @param key + * the public key to verify this CRL with. + * @throws CRLException + * if encoding or decoding fails. + * @throws NoSuchAlgorithmException + * if a needed algorithm is not present. + * @throws InvalidKeyException + * if the specified key is invalid. + * @throws NoSuchProviderException + * if no provider can be found. + * @throws SignatureException + * if errors occur on signatures. + * @since Android 1.0 */ public abstract void verify(PublicKey key) throws CRLException, NoSuchAlgorithmException, @@ -102,7 +137,25 @@ public abstract class X509CRL extends CRL implements X509Extension { SignatureException; /** - * @com.intel.drl.spec_ref + * Verifies this CRL by verifying that this CRL was signed with the + * corresponding private key to the specified public key. The signature + * verification engine of the specified provider will be used. + * + * @param key + * the public key to verify this CRL with. + * @param sigProvider + * the name of the provider for the signature algorithm. + * @throws CRLException + * if encoding decoding fails. + * @throws NoSuchAlgorithmException + * if a needed algorithm is not present. + * @throws InvalidKeyException + * if the specified key is invalid. + * @throws NoSuchProviderException + * if the specified provider cannot be found. + * @throws SignatureException + * if errors occur on signatures. + * @since Android 1.0 */ public abstract void verify(PublicKey key, String sigProvider) throws CRLException, NoSuchAlgorithmException, @@ -110,17 +163,27 @@ public abstract class X509CRL extends CRL implements X509Extension { SignatureException; /** - * @com.intel.drl.spec_ref + * Returns the version number of this CRL. + * + * @return the version number of this CRL. + * @since Android 1.0 */ public abstract int getVersion(); /** - * @com.intel.drl.spec_ref + * Do not use, use {@link #getIssuerX500Principal()} instead. Returns + * the issuer as an implementation specific Principal object. + * + * @return the issuer distinguished name. + * @since Android 1.0 */ public abstract Principal getIssuerDN(); /** - * @com.intel.drl.spec_ref + * Returns the issuer distinguished name of this CRL. + * + * @return the issuer distinguished name of this CRL. + * @since Android 1.0 */ public X500Principal getIssuerX500Principal() { try { @@ -140,22 +203,41 @@ public abstract class X509CRL extends CRL implements X509Extension { } /** - * @com.intel.drl.spec_ref + * Returns the {@code thisUpdate} value of this CRL. + * + * @return the {@code thisUpdate} value of this CRL. + * @since Android 1.0 */ public abstract Date getThisUpdate(); /** - * @com.intel.drl.spec_ref + * Returns the {@code nextUpdate} value of this CRL. + * + * @return the {@code nextUpdate} value of this CRL, or {@code null} if none + * is present. + * @since Android 1.0 */ public abstract Date getNextUpdate(); /** - * @com.intel.drl.spec_ref + * Returns the CRL entry with the specified certificate serial number. + * + * @param serialNumber + * the certificate serial number to search for a CRL entry. + * @return the entry for the specified certificate serial number, or {@code + * null} if not found. + * @since Android 1.0 */ public abstract X509CRLEntry getRevokedCertificate(BigInteger serialNumber); /** - * @com.intel.drl.spec_ref + * Returns the CRL entry for the specified certificate. + * + * @param certificate + * the certificate to search a CRL entry for. + * @return the entry for the specified certificate, or {@code null} if not + * found. + * @since Android 1.0 */ public X509CRLEntry getRevokedCertificate(X509Certificate certificate) { if (certificate == null) { @@ -165,32 +247,55 @@ public abstract class X509CRL extends CRL implements X509Extension { } /** - * @com.intel.drl.spec_ref + * Returns the set of revoked certificates. + * + * @return the set of revoked certificates, or {@code null} if no revoked + * certificates are in this CRL. + * @since Android 1.0 */ public abstract Set extends X509CRLEntry> getRevokedCertificates(); /** - * @com.intel.drl.spec_ref + * Returns the {@code tbsCertList} information of this CRL in DER encoded + * form. + * + * @return the CRL information in DER encoded form. + * @throws CRLException + * if encoding fails. + * @since Android 1.0 */ public abstract byte[] getTBSCertList() throws CRLException; /** - * @com.intel.drl.spec_ref + * Returns the signature bytes of this CRL. + * + * @return the signature bytes of this CRL. + * @since Android 1.0 */ public abstract byte[] getSignature(); /** - * @com.intel.drl.spec_ref + * Returns the name of the signature algorithm. + * + * @return the name of the signature algorithm. + * @since Android 1.0 */ public abstract String getSigAlgName(); /** - * @com.intel.drl.spec_ref + * Returns the OID of the signature algorithm. + * + * @return the OID of the signature algorithm. + * @since Android 1.0 */ public abstract String getSigAlgOID(); /** - * @com.intel.drl.spec_ref + * Returns the parameters of the signature algorithm in DER encoded form. + * + * @return the parameters of the signature algorithm in DER encoded form, or + * {@code null} if not present. + * @since Android 1.0 */ public abstract byte[] getSigAlgParams(); } diff --git a/security/src/main/java/java/security/cert/X509CRLEntry.java b/security/src/main/java/java/security/cert/X509CRLEntry.java index d726f9d..35fb78b 100644 --- a/security/src/main/java/java/security/cert/X509CRLEntry.java +++ b/security/src/main/java/java/security/cert/X509CRLEntry.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Alexander Y. Kleymenov -* @version $Revision$ -*/ - package java.security.cert; import java.math.BigInteger; @@ -31,17 +26,28 @@ import java.util.Date; import javax.security.auth.x500.X500Principal; /** - * @com.intel.drl.spec_ref + * Abstract base class for entries in a certificate revocation list (CRL). + * + * @see X509CRL + * @since Android 1.0 */ public abstract class X509CRLEntry implements X509Extension { /** - * @com.intel.drl.spec_ref + * Creates a new {@code X509CRLEntry} instance. + * + * @since Android 1.0 */ public X509CRLEntry() {} /** - * @com.intel.drl.spec_ref + * Returns whether the specified object equals to this instance. + * + * @param other + * the object to compare. + * @return {@code true} if the specified object equals to this instance, + * otherwise {@code false}. + * @since Android 1.0 */ public boolean equals(Object other) { if (other == this) { @@ -59,7 +65,10 @@ public abstract class X509CRLEntry implements X509Extension { } /** - * @com.intel.drl.spec_ref + * Returns the hashcode of this instance. + * + * @return the hashcode of this instance. + * @since Android 1.0 */ public int hashCode() { int res = 0; @@ -74,31 +83,56 @@ public abstract class X509CRLEntry implements X509Extension { } /** - * @com.intel.drl.spec_ref + * Returns this entry in ASN.1 DER encoded form. + * + * @return the encoded form of this entry. + * @throws CRLException + * if encoding fails. + * @since Android 1.0 */ public abstract byte[] getEncoded() throws CRLException; /** - * @com.intel.drl.spec_ref + * Returns the serial number of the revoked certificate. + * + * @return the serial number of the revoked certificate. + * @since Android 1.0 */ public abstract BigInteger getSerialNumber(); + /** + * Returns the issuer of the revoked certificate. + * + * @return the issuer of the revoked certificate, or {@code null} if the + * issuer is equal to the CRL issuer. + * @since Android 1.0 + */ public X500Principal getCertificateIssuer() { return null; } /** - * @com.intel.drl.spec_ref + * Returns the date when the certificate is revoked. + * + * @return the date when the certificate is revoked. + * @since Android 1.0 */ public abstract Date getRevocationDate(); /** - * @com.intel.drl.spec_ref + * Returns whether this CRL entry has extensions. + * + * @return {@code true} is this CRL entry has extensions, otherwise {@code + * false}. + * @since Android 1.0 */ public abstract boolean hasExtensions(); /** - * @com.intel.drl.spec_ref + * Returns a string representation of this instance. + * + * @return a string representation of this instance. + * @since Android 1.0 */ public abstract String toString(); } diff --git a/security/src/main/java/java/security/cert/X509CRLSelector.java b/security/src/main/java/java/security/cert/X509CRLSelector.java index d679e99..c1b5f45 100644 --- a/security/src/main/java/java/security/cert/X509CRLSelector.java +++ b/security/src/main/java/java/security/cert/X509CRLSelector.java @@ -15,10 +15,6 @@ * limitations under the License. */ -/** - * @author Alexander Y. Kleymenov - * @version $Revision$ - */ package java.security.cert; @@ -36,7 +32,14 @@ import org.apache.harmony.security.internal.nls.Messages; import org.apache.harmony.security.x501.Name; /** - * @com.intel.drl.spec_ref + * A CRL selector ({@code CRLSelector} for selecting {@code + * X509CRL}s that match the specified criteria. + *+ * When constructed, all criteria are set to default values that will match any + * {@code X509CRL}. + *
+ * + * @since Android 1.0 */ public class X509CRLSelector implements CRLSelector { @@ -56,12 +59,23 @@ public class X509CRLSelector implements CRLSelector { private X509Certificate certificateChecking; /** - * @com.intel.drl.spec_ref + * Creates a new {@code X509CertSelector}. + * + * @since Android 1.0 */ public X509CRLSelector() { } /** - * @com.intel.drl.spec_ref + * Sets the criterion for the issuer distinguished names. + *+ * The CRL issuer must match at least one of the specified distinguished + * names. + *
+ * + * @param issuers + * the list of issuer distinguished names to match, or {@code + * null} if any issuer distinguished name will do. + * @since Android 1.0 */ public void setIssuers(Collection+ * The CRL issuer must match at least one of the specified distinguished + * names. + *
+ *+ * The specified parameter {@code names} is a collection with an entry for + * each name to be included in the criterion. The name is specified as a + * {@code String} or a byte array specifying the name (in RFC 2253 or ASN.1 + * DER encoded form) + *
+ * + * @param names + * the list of issuer distinguished names to match, or {@code + * null} if any issuer distinguished name will do. + * @throws IOException + * if parsing fails. + * @since Android 1.0 */ public void setIssuerNames(Collection> names) throws IOException { if (names == null) { @@ -106,7 +139,15 @@ public class X509CRLSelector implements CRLSelector { } /** - * @com.intel.drl.spec_ref + * Adds an issuer to the criterion for the issuer distinguished names. + *+ * The CRL issuer must match at least one of the specified distinguished + * names. + *
+ * + * @param issuer + * the issuer to add to the criterion + * @since Android 1.0 */ public void addIssuer(X500Principal issuer) { if (issuer == null) { @@ -131,7 +172,19 @@ public class X509CRLSelector implements CRLSelector { } /** - * @com.intel.drl.spec_ref + * Do not use:, use {@link #addIssuer(X500Principal)} or + * {@link #addIssuerName(byte[])} instead. It can fail to match some CRLs + * because of a loss of encoding information in a RFC 2253 string. + *+ * Adds an issuer to the criterion for the issuer distinguished names. The + * CRK issuer must match at least one of the specified distinguished names. + *
+ * + * @param iss_name + * the RFC 2253 encoded name. + * @throws IOException + * if parsing fails. + * @since Android 1.0 */ public void addIssuerName(String iss_name) throws IOException { if (issuerNames == null) { @@ -149,7 +202,17 @@ public class X509CRLSelector implements CRLSelector { } /** - * @com.intel.drl.spec_ref + * Adds an issuer to the criterion for the issuer distinguished names. + *+ * The CRL issuer must match at least one of the specified distinguished + * names. + *
+ * + * @param iss_name + * the issuer to add to the criterion in ASN.1 DER encoded form. + * @throws IOException + * if parsing fails. + * @since Android 1.0 */ public void addIssuerName(byte[] iss_name) throws IOException { if (iss_name == null) { @@ -165,21 +228,48 @@ public class X509CRLSelector implements CRLSelector { } /** - * @com.intel.drl.spec_ref + * Sets the criterion for the minimum CRL number. + *+ * The CRL must have a number extension with a value greater than or equal + * to the specified parameter. + *
+ * + * @param minCRL + * the minimum CRL number or null to not check the minimum CRL + * number + * @since Android 1.0 */ public void setMinCRLNumber(BigInteger minCRL) { this.minCRL = minCRL; } /** - * @com.intel.drl.spec_ref + * Sets the criterion for the maximum CRL number. + *+ * The CRL must have a number extension with a value less than or equal to + * the specified parameter. + *
+ * + * @param maxCRL + * the maximum CRL number or null to not check the maximum CRL + * number. + * @since Android 1.0 */ public void setMaxCRLNumber(BigInteger maxCRL) { this.maxCRL = maxCRL; } /** - * @com.intel.drl.spec_ref + * Sets the criterion for the CRL update period. + *+ * The CRL's {@code thisUpdate} value must be equal or before the specified + * date and the {@code nextUpdate} value must be after the specified date. + *
+ * + * @param dateAndTime + * the date to search for valid CRL's or {@code null} to not + * check the date. + * @since Android 1.0 */ public void setDateAndTime(Date dateAndTime) { if (dateAndTime == null) { @@ -190,14 +280,26 @@ public class X509CRLSelector implements CRLSelector { } /** - * @com.intel.drl.spec_ref + * Sets a certificate hint to find CRLs. It's not a criterion but may help + * finding relevant CRLs. + * + * @param cert + * the certificate hint or {@code null}. + * @since Android 1.0 */ public void setCertificateChecking(X509Certificate cert) { this.certificateChecking = cert; } /** - * @com.intel.drl.spec_ref + * Returns the criterion for the issuer distinguished names. + *+ * The CRL issuer must match at least one of the distinguished names. + *
+ * + * @return the unmodifiable list of issuer distinguished names to match, or + * {@code null} if any issuer distinguished name will do. + * @since Android 1.0 */ public Collection+ * The CRL issuer must match at least one of the distinguished names. + *
+ * + * @return a copy of the list of issuer distinguished names to match, or + * {@code null} if any issuer distinguished name will do. + * @since Android 1.0 */ public Collection