You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ml...@apache.org on 2006/04/26 09:54:24 UTC
svn commit: r397136 [1/3] - in
/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security:
./ cert/
Author: mloenko
Date: Wed Apr 26 00:54:18 2006
New Revision: 397136
URL: http://svn.apache.org/viewcvs?rev=397136&view=rev
Log:
applied path from HARMONY-277
copy java.security javadoc from archive implementation to modules/security
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/AccessControlException.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/AllPermission.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/BasicPermission.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/CodeSource.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/DigestException.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/DigestInputStream.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/DigestOutputStream.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/DomainCombiner.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/GeneralSecurityException.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Guard.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/GuardedObject.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/InvalidAlgorithmParameterException.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/InvalidKeyException.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/InvalidParameterException.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Key.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/KeyException.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/KeyStore.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/MessageDigest.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/MessageDigestSpi.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/NoSuchAlgorithmException.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/NoSuchProviderException.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Permission.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/PermissionCollection.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Permissions.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Policy.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Principal.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/PrivilegedActionException.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/ProtectionDomain.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Provider.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/PublicKey.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SecureClassLoader.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SecureRandom.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SecureRandomSpi.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Security.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SecurityPermission.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/SignatureException.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/UnrecoverableKeyException.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/UnresolvedPermission.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CRL.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CRLException.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertPath.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/Certificate.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateEncodingException.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateException.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateExpiredException.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateFactory.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateFactorySpi.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateNotYetValidException.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/CertificateParsingException.java
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/AccessControlException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/AccessControlException.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/AccessControlException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/AccessControlException.java Wed Apr 26 00:54:18 2006
@@ -22,9 +22,10 @@
package java.security;
/**
- * @com.intel.drl.spec_ref
+ * This runtime exception is thrown when an access control check indicates that
+ * access should not be granted.
+ *
*/
-
public class AccessControlException extends SecurityException {
private static final long serialVersionUID = 5138225684096988535L;
@@ -34,24 +35,39 @@
*/
private Permission perm; // Named as demanded by Serialized Form.
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback and message
+ * filled in.
+ *
+ *
+ * @param message
+ * String The detail message for the exception.
+ */
public AccessControlException(String message) {
super(message);
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback, message and
+ * associated permission all filled in.
+ *
+ *
+ * @param message
+ * String The detail message for the exception.
+ * @param perm
+ * Permission The failed permission.
+ */
public AccessControlException(String message, Permission perm) {
super(message);
this.perm = perm;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers the receiver's permission.
+ *
+ *
+ * @return Permission the receiver's permission
+ */
public Permission getPermission() {
return perm;
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/AllPermission.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/AllPermission.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/AllPermission.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/AllPermission.java Wed Apr 26 00:54:18 2006
@@ -29,7 +29,9 @@
import java.util.NoSuchElementException;
/**
- * @com.intel.drl.spec_ref
+ * Subclass of Permission whose instances imply all other permissions. Granting
+ * this permission is equivalent to disabling security.
+ *
*/
public final class AllPermission extends Permission {
@@ -39,51 +41,87 @@
// Actions name
private static final String ALL_ACTIONS = "<all actions>";
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class. The two argument version is
+ * provided for class <code>Policy</code> so that it has a consistant call
+ * pattern across all Permissions. The name and action list are both
+ * ignored.
+ *
+ * @param name
+ * java.lang.String ignored.
+ * @param actions
+ * java.lang.String ignored.
+ */
public AllPermission(String name, String actions) {
super(ALL_PERMISSIONS);
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class.
+ */
public AllPermission() {
super(ALL_PERMISSIONS);
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Compares the argument to the receiver, and answers true if they represent
+ * the <em>same</em> object using a class specific comparison. All
+ * AllPermissions are equal to eachother.
+ *
+ * @param obj
+ * the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object
+ * <code>false</code> if it is different from this object
+ * @see #hashCode
+ */
public boolean equals(Object obj) {
return (obj instanceof AllPermission);
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers an integer hash code for the receiver. Any two objects which
+ * answer <code>true</code> when passed to <code>equals</code> must
+ * answer the same value for this method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
public int hashCode() {
return 1;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers the actions associated with the receiver. Since AllPermission
+ * objects allow all actions, answer with the string "<all actions>".
+ *
+ * @return String the actions associated with the receiver.
+ */
public String getActions() {
return ALL_ACTIONS;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Indicates whether the argument permission is implied by the receiver.
+ * AllPermission objects imply all other permissions.
+ *
+ * @return boolean <code>true</code> if the argument permission is implied
+ * by the receiver, and <code>false</code> if it is not.
+ * @param permission
+ * java.security.Permission the permission to check
+ */
public boolean implies(Permission permission) {
return true;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers a new PermissionCollection for holding permissions of this class.
+ * Answer null if any permission collection can be used.
+ *
+ * @return a new PermissionCollection or null
+ *
+ * @see java.security.BasicPermissionCollection
+ */
public PermissionCollection newPermissionCollection() {
return new AllPermissionCollection();
}
@@ -165,9 +203,15 @@
}
}
- /**
- * Returns true if this collection is not empty.
- */
+ /**
+ * Indicates whether the argument permission is implied by the receiver.
+ * AllPermission objects imply all other permissions.
+ *
+ * @return boolean <code>true</code> if the argument permission is implied
+ * by the receiver, and <code>false</code> if it is not.
+ * @param permission
+ * java.security.Permission the permission to check
+ */
public boolean implies(Permission permission) {
return all != null;
}
@@ -195,4 +239,4 @@
all = new AllPermission();
}
}
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/BasicPermission.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/BasicPermission.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/BasicPermission.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/BasicPermission.java Wed Apr 26 00:54:18 2006
@@ -35,24 +35,35 @@
import java.util.Map;
/**
- * @com.intel.drl.spec_ref
+ * Superclass of permissions which have names but no action lists.
+ *
*/
+
public abstract class BasicPermission extends Permission implements
Serializable {
private static final long serialVersionUID = 6279438298436773498L;
- /**
- * @com.intel.drl.spec_ref.
- */
+ /**
+ * Creates an instance of this class with the given name and action list.
+ *
+ * @param name
+ * String the name of the new permission.
+ */
public BasicPermission(String name) {
super(name);
checkName(name);
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Creates an instance of this class with the given name and action list.
+ * The action list is ignored.
+ *
+ * @param name
+ * String the name of the new permission.
+ * @param action
+ * String ignored.
+ */
public BasicPermission(String name, String action) {
super(name);
checkName(name);
@@ -70,9 +81,17 @@
}
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Compares the argument to the receiver, and answers true if they represent
+ * the <em>same</em> object using a class specific comparison. In this
+ * case, the receiver and the object must have the same class and name.
+ *
+ * @param obj
+ * the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object
+ * <code>false</code> if it is different from this object
+ * @see #hashCode
+ */
public boolean equals(Object obj) {
if (obj == this) {
return true;
@@ -84,23 +103,37 @@
return false;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers an integer hash code for the receiver. Any two objects which
+ * answer <code>true</code> when passed to <code>equals</code> must
+ * answer the same value for this method.
+ *
+ * @return int the receiver's hash
+ *
+ * @see #equals
+ */
public int hashCode() {
return getName().hashCode();
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers the actions associated with the receiver. BasicPermission objects
+ * have no actions, so answer the empty string.
+ *
+ * @return String the actions associated with the receiver.
+ */
public String getActions() {
return "";
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Indicates whether the argument permission is implied by the receiver.
+ *
+ * @return boolean <code>true</code> if the argument permission is implied
+ * by the receiver, and <code>false</code> if it is not.
+ * @param permission
+ * java.security.Permission the permission to check
+ */
public boolean implies(Permission permission) {
if (permission != null && permission.getClass() == this.getClass()) {
return nameImplies(getName(), permission.getName());
@@ -137,9 +170,21 @@
return true;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers a new PermissionCollection for holding permissions of this class.
+ * Answer null if any permission collection can be used.
+ * <p>
+ * Note: For BasicPermission (and subclasses which do not override this
+ * method), the collection which is returned does <em>not</em> 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
+ *
+ * @see java.security.BasicPermissionCollection
+ */
public PermissionCollection newPermissionCollection() {
return new BasicPermissionCollection();
}
@@ -229,12 +274,14 @@
return Collections.enumeration(items.values());
}
- /**
- * Checks if the particular permission is implied by this collection.
- *
- * @see java.security.BasicPermission
- * @see java.security.PermissionCollection#implies(java.security.Permission)
- */
+ /**
+ * Indicates whether the argument permission is implied by the receiver.
+ *
+ * @return boolean <code>true</code> if the argument permission is implied
+ * by the receiver, and <code>false</code> if it is not.
+ * @param permission
+ * java.security.Permission the permission to check
+ */
public boolean implies(Permission permission) {
if (permission == null || permission.getClass() != permClass) {
return false;
@@ -321,4 +368,4 @@
}
}
}
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/CodeSource.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/CodeSource.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/CodeSource.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/CodeSource.java Wed Apr 26 00:54:18 2006
@@ -70,9 +70,15 @@
// Cached factory used to build CertPath-s in <code>getCodeSigners()</code>.
private transient CertificateFactory factory;
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its url and certificates
+ * fields filled in from the arguments.
+ *
+ * @param location
+ * URL the URL.
+ * @param certs
+ * Certificate[] the Certificates.
+ */
public CodeSource(URL location, Certificate[] certs) {
this.location = location;
if (certs != null) {
@@ -92,9 +98,19 @@
}
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Compares the argument to the receiver, and answers true if they represent
+ * the <em>same</em> object using a class specific comparison. In this
+ * case, the receiver and the object must have the same URL and the same
+ * collection of certificates.
+ *
+ *
+ * @param obj
+ * the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object
+ * <code>false</code> if it is different from this object
+ * @see #hashCode
+ */
public boolean equals(Object obj) {
if (obj == this) {
return true;
@@ -130,9 +146,12 @@
return true;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers the certificates held onto by the receiver.
+ *
+ *
+ * @return Certificate[] the receiver's certificates
+ */
public final Certificate[] getCertificates() {
getCertificatesNoClone();
if (certs == null) {
@@ -259,16 +278,26 @@
return null;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers the receiver's location.
+ *
+ *
+ * @return URL the receiver's URL
+ */
public final URL getLocation() {
return location;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers an integer hash code for the receiver. Any two objects which
+ * answer <code>true</code> when passed to <code>.equals</code> must
+ * answer the same value for this method.
+ *
+ *
+ * @return int the receiver's hash.
+ *
+ * @see #equals
+ */
public int hashCode() {
//
// hashCode() is undocumented there. Should we also use certs[i] to
@@ -277,9 +306,15 @@
return location == null ? 0 : location.hashCode();
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Indicates whether the argument code source is implied by the receiver.
+ *
+ *
+ * @return boolean <code>true</code> if the argument code source is
+ * implied by the receiver, and <code>false</code> if it is not.
+ * @param cs
+ * CodeSource the code source to check
+ */
public boolean implies(CodeSource cs) {
//
// Here, javadoc:N refers to the appropriate item in the API spec for
@@ -426,9 +461,13 @@
return true;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers a string containing a concise, human-readable description of the
+ * receiver.
+ *
+ *
+ * @return a printable representation for the receiver.
+ */
public String toString() {
//FIXME 1.5 StringBuffer => StringBuilder
StringBuffer buf = new StringBuffer();
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/DigestException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/DigestException.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/DigestException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/DigestException.java Wed Apr 26 00:54:18 2006
@@ -22,7 +22,7 @@
package java.security;
/**
- * @com.intel.drl.spec_ref
+ * This class represents exceptions for message digest computation.
*
*/
public class DigestException extends GeneralSecurityException {
@@ -32,16 +32,22 @@
*/
private static final long serialVersionUID = 5821450303093652515L;
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback and message
+ * filled in.
+ *
+ *
+ * @param msg
+ * String The detail message for the exception.
+ */
public DigestException(String msg) {
super(msg);
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback filled in.
+ *
+ */
public DigestException() {
}
@@ -58,4 +64,4 @@
public DigestException(Throwable cause) {
super(cause);
}
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/DigestInputStream.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/DigestInputStream.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/DigestInputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/DigestInputStream.java Wed Apr 26 00:54:18 2006
@@ -47,23 +47,44 @@
this.digest = digest;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers the MessageDigest which the receiver uses when computing the
+ * hash.
+ *
+ *
+ * @return MessageDigest the digest the receiver uses when computing the
+ * hash.
+ *
+ */
public MessageDigest getMessageDigest() {
return digest;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Sets the MessageDigest which the receiver will use when computing the
+ * hash.
+ *
+ *
+ * @param digest
+ * MessageDigest the digest to use when computing the hash.
+ *
+ * @see MessageDigest
+ * @see #on
+ */
public void setMessageDigest(MessageDigest digest) {
this.digest = digest;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Reads the next byte and answers it as an int. Updates the digest for the
+ * byte if this fuction is enabled.
+ *
+ *
+ * @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.
+ */
public int read() throws IOException {
// read the next byte
int byteRead = in.read();
@@ -93,16 +114,27 @@
return bytesRead;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Enables or disables the digest function (default is on).
+ *
+ *
+ * @param on
+ * boolean true if the digest should be computed, and false
+ * otherwise.
+ *
+ * @see MessageDigest
+ */
public void on(boolean on) {
isOn = on;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers a string containing a concise, human-readable description of the
+ * receiver.
+ *
+ *
+ * @return String a printable representation for the receiver.
+ */
public String toString() {
return super.toString() + ", " + digest.toString() +
(isOn ? ", is on" : ", is off");
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/DigestOutputStream.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/DigestOutputStream.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/DigestOutputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/DigestOutputStream.java Wed Apr 26 00:54:18 2006
@@ -47,16 +47,30 @@
this.digest = digest;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers the MessageDigest which the receiver uses when computing the
+ * hash.
+ *
+ *
+ * @return MessageDigest the digest the receiver uses when computing the
+ * hash.
+ */
+
public MessageDigest getMessageDigest() {
return digest;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Sets the MessageDigest which the receiver will use when computing the
+ * hash.
+ *
+ *
+ * @param digest
+ * MessageDigest the digest to use when computing the hash.
+ *
+ * @see MessageDigest
+ * @see #on
+ */
public void setMessageDigest(MessageDigest digest) {
this.digest = digest;
}
@@ -85,16 +99,27 @@
out.write(b, off, len);
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Enables or disables the digest function (default is on).
+ *
+ *
+ * @param on
+ * boolean true if the digest should be computed, and false
+ * otherwise.
+ *
+ * @see MessageDigest
+ */
public void on(boolean on) {
isOn = on;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers a string containing a concise, human-readable description of the
+ * receiver.
+ *
+ *
+ * @return String a printable representation for the receiver.
+ */
public String toString() {
return super.toString() + ", " + digest.toString() +
(isOn ? ", is on" : ", is off");
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/DomainCombiner.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/DomainCombiner.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/DomainCombiner.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/DomainCombiner.java Wed Apr 26 00:54:18 2006
@@ -22,7 +22,9 @@
package java.security;
/**
- * @com.intel.drl.spec_ref
+ * A DomainCombiner is a way to update the protection domains from an
+ * AccessControlContext
+ *
*/
public interface DomainCombiner {
/**
@@ -30,4 +32,4 @@
*/
ProtectionDomain[] combine(ProtectionDomain[] current,
ProtectionDomain[] assigned);
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/GeneralSecurityException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/GeneralSecurityException.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/GeneralSecurityException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/GeneralSecurityException.java Wed Apr 26 00:54:18 2006
@@ -22,7 +22,8 @@
package java.security;
/**
- * @com.intel.drl.spec_ref
+ * This class represents the general security exception. Subclasses will
+ * represents specific security problems.
*
*/
public class GeneralSecurityException extends Exception {
@@ -31,16 +32,22 @@
*/
private static final long serialVersionUID = 894798122053539237L;
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback and message
+ * filled in.
+ *
+ *
+ * @param msg
+ * String The detail message for the exception.
+ */
public GeneralSecurityException(String msg) {
super(msg);
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback filled in.
+ *
+ */
public GeneralSecurityException() {
}
@@ -57,4 +64,4 @@
public GeneralSecurityException(Throwable cause) {
super(cause);
}
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Guard.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Guard.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Guard.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Guard.java Wed Apr 26 00:54:18 2006
@@ -22,7 +22,8 @@
package java.security;
/**
- * @com.intel.drl.spec_ref
+ * This interface is implemented by objects which wish to control access to
+ * other objects.
*
*/
public interface Guard {
@@ -31,4 +32,4 @@
* @com.intel.drl.spec_ref
*/
public void checkGuard(Object object) throws SecurityException;
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/GuardedObject.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/GuardedObject.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/GuardedObject.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/GuardedObject.java Wed Apr 26 00:54:18 2006
@@ -25,7 +25,8 @@
import java.io.Serializable;
/**
- * @com.intel.drl.spec_ref
+ * GuardedObject controls access to an object, by checking all requests for the
+ * object with a Guard.
*
*/
public class GuardedObject implements Serializable {
@@ -45,17 +46,31 @@
*/
private final Guard guard;
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a GuardedObject to protect access to the specified Object
+ * using the specified Guard.
+ *
+ * @param object
+ * the Object to guard
+ * @param guard
+ * the Guard
+ */
public GuardedObject(Object object, Guard guard) {
this.object = object;
this.guard = guard;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * 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
+ * <code>SecurityException</code> is thrown.
+ *
+ *
+ * @return the guarded object
+ *
+ * @exception java.lang.SecurityException
+ * If access is not granted to the object
+ */
public Object getObject() throws SecurityException {
if (guard != null) {
guard.checkGuard(object);
@@ -72,4 +87,4 @@
}
out.defaultWriteObject();
}
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/InvalidAlgorithmParameterException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/InvalidAlgorithmParameterException.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/InvalidAlgorithmParameterException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/InvalidAlgorithmParameterException.java Wed Apr 26 00:54:18 2006
@@ -22,7 +22,7 @@
package java.security;
/**
- * @com.intel.drl.spec_ref
+ * This class represents invalid algorithm parameters to cryprographic services.
*
*/
public class InvalidAlgorithmParameterException extends
@@ -32,16 +32,22 @@
*/
private static final long serialVersionUID = 2864672297499471472L;
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback and message
+ * filled in.
+ *
+ *
+ * @param msg
+ * String The detail message for the exception.
+ */
public InvalidAlgorithmParameterException(String msg) {
super(msg);
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback filled in.
+ *
+ */
public InvalidAlgorithmParameterException() {
}
@@ -58,4 +64,4 @@
public InvalidAlgorithmParameterException(Throwable cause) {
super(cause);
}
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/InvalidKeyException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/InvalidKeyException.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/InvalidKeyException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/InvalidKeyException.java Wed Apr 26 00:54:18 2006
@@ -22,8 +22,10 @@
package java.security;
/**
- * @com.intel.drl.spec_ref
+ * Used when invalid cryptography keys are used.
*
+ * @see Throwable
+ * @see Error
*/
public class InvalidKeyException extends KeyException {
@@ -32,16 +34,22 @@
*/
private static final long serialVersionUID = 5698479920593359816L;
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback and message
+ * filled in.
+ *
+ *
+ * @param msg
+ * String The detail message for the exception.
+ */
public InvalidKeyException(String msg) {
super(msg);
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback filled in.
+ *
+ */
public InvalidKeyException() {
}
@@ -58,4 +66,4 @@
public InvalidKeyException(Throwable cause) {
super(cause);
}
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/InvalidParameterException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/InvalidParameterException.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/InvalidParameterException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/InvalidParameterException.java Wed Apr 26 00:54:18 2006
@@ -22,7 +22,7 @@
package java.security;
/**
- * @com.intel.drl.spec_ref
+ * This exception is thrown when an invalid parameter is passed to a method.
*
*/
public class InvalidParameterException extends IllegalArgumentException {
@@ -32,16 +32,22 @@
*/
private static final long serialVersionUID = -857968536935667808L;
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback and message
+ * filled in.
+ *
+ *
+ * @param msg
+ * String The detail message for the exception.
+ */
public InvalidParameterException(String msg) {
super(msg);
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback filled in.
+ *
+ */
public InvalidParameterException() {
}
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Key.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Key.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Key.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Key.java Wed Apr 26 00:54:18 2006
@@ -24,8 +24,9 @@
import java.io.Serializable;
/**
- * @com.intel.drl.spec_ref
+ * Defines the basic properties of all key objects.
*
+ * @see PublicKey
*/
public interface Key extends Serializable {
/**
@@ -34,17 +35,25 @@
public static final long serialVersionUID = 6603384152749567654L;
/**
- * @com.intel.drl.spec_ref
+ * Answers the name of the algorithm that this key will work
+ * with. If the algorithm is unknown, it answers null.
+ *
+ * @return String the receiver's algorithm
*/
public String getAlgorithm();
/**
- * @com.intel.drl.spec_ref
+ * Answers the name of the format used to encode the key, or null
+ * if it can not be encoded.
+ *
+ * @return String the receiver's encoding format
*/
public String getFormat();
/**
- * @com.intel.drl.spec_ref
+ * Answers the encoded form of the receiver.
+ *
+ * @return byte[] the encoded form of the receiver
*/
public byte[] getEncoded();
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/KeyException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/KeyException.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/KeyException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/KeyException.java Wed Apr 26 00:54:18 2006
@@ -22,8 +22,12 @@
package java.security;
/**
- * @com.intel.drl.spec_ref
+ * This class is the superclass of all classes which represent problems with
+ * keys.
*
+ *
+ * @see Throwable
+ * @see Error
*/
public class KeyException extends GeneralSecurityException {
@@ -32,16 +36,22 @@
*/
private static final long serialVersionUID = -7483676942812432108L;
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback and message
+ * filled in.
+ *
+ *
+ * @param msg
+ * String The detail message for the exception.
+ */
public KeyException(String msg) {
super(msg);
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback filled in.
+ *
+ */
public KeyException() {
}
@@ -58,4 +68,4 @@
public KeyException(Throwable cause) {
super(cause);
}
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/KeyStore.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/KeyStore.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/KeyStore.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/KeyStore.java Wed Apr 26 00:54:18 2006
@@ -1056,4 +1056,4 @@
.toString());
}
}
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/MessageDigest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/MessageDigest.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/MessageDigest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/MessageDigest.java Wed Apr 26 00:54:18 2006
@@ -1,330 +1,367 @@
-/*
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
-* @author Boris V. Kuznetsov
-* @version $Revision$
-*/
-
-package java.security;
-
-import java.nio.ByteBuffer;
-
-import org.apache.harmony.security.fortress.Engine;
-
-
-/**
- * @com.intel.drl.spec_ref
- *
- */
-
-public abstract class MessageDigest extends MessageDigestSpi {
-
- // The service name
- private static final String SERVICE = "MessageDigest";
-
- // Used to access common engine functionality
- private static Engine engine = new Engine(SERVICE);
-
- // The provider
- private Provider provider;
-
- // The algorithm.
- private String algorithm;
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- protected MessageDigest(String algorithm) {
- this.algorithm = algorithm;
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public static MessageDigest getInstance(String algorithm)
- throws NoSuchAlgorithmException {
- if (algorithm == null) {
- throw new NullPointerException("Algorithm is null");
- }
- MessageDigest result;
- synchronized (engine) {
- engine.getInstance(algorithm, null);
- if (engine.spi instanceof MessageDigest) {
- result = (MessageDigest) engine.spi;
- result.algorithm = algorithm;
- result.provider = engine.provider;
- return result;
- } else {
- result = new MessageDigestImpl((MessageDigestSpi) engine.spi,
- engine.provider, algorithm);
- return result;
- }
- }
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public static MessageDigest getInstance(String algorithm, String provider)
- throws NoSuchAlgorithmException, NoSuchProviderException {
- if ((provider == null) || (provider.length() == 0)) {
- throw new IllegalArgumentException(
- "Provider is null or empty string");
- }
- Provider p = Security.getProvider(provider);
- if (p == null) {
- throw new NoSuchProviderException("Provider " + provider
- + " is not available");
- }
- return getInstance(algorithm, p);
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public static MessageDigest getInstance(String algorithm, Provider provider)
- throws NoSuchAlgorithmException {
- if (provider == null) {
- throw new IllegalArgumentException("Provider is null");
- }
- if (algorithm == null) {
- throw new NullPointerException("Algorithm is null");
- }
- MessageDigest result;
- synchronized (engine) {
- engine.getInstance(algorithm, provider, null);
- if (engine.spi instanceof MessageDigest) {
- result = (MessageDigest) engine.spi;
- result.algorithm = algorithm;
- result.provider = provider;
- return result;
- } else {
- result = new MessageDigestImpl((MessageDigestSpi) engine.spi,
- provider, algorithm);
- return result;
- }
- }
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public void reset() {
- engineReset();
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public void update(byte arg0) {
- engineUpdate(arg0);
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public void update(byte[] input, int offset, int len) {
- if (input == null || offset < 0 || len < 0 ||
- offset + len > input.length) {
- throw new IllegalArgumentException(
- "Incorrect offset/len parameters");
- }
- engineUpdate(input, offset, len);
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public void update(byte[] input) {
- if (input == null) {
- throw new NullPointerException("Null input parameter");
- }
- engineUpdate(input, 0, input.length);
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public byte[] digest() {
- return engineDigest();
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public int digest(byte[] buf, int offset, int len) throws DigestException {
- if (buf == null || offset < 0 || len < 0 ||
- offset + len > buf.length) {
- throw new IllegalArgumentException(
- "Incorrect offset/len parameters");
- }
- return engineDigest(buf, offset, len);
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public byte[] digest(byte[] input) {
- update(input);
- return digest();
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public String toString() {
- return "MESSAGE DIGEST " + algorithm;
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public static boolean isEqual(byte[] digesta, byte[] digestb) {
- if (digesta.length != digestb.length) {
- return false;
- }
- for (int i = 0; i < digesta.length; i++) {
- if (digesta[i] != digestb[i]) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public final String getAlgorithm() {
- return algorithm;
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public final Provider getProvider() {
- return provider;
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public final int getDigestLength() {
- int l = engineGetDigestLength();
- if (l != 0) {
- return l;
- }
- if (!(this instanceof Cloneable)) {
- return 0;
- }
- try {
- MessageDigest md = (MessageDigest) clone();
- return md.digest().length;
- } catch (CloneNotSupportedException e) {
- return 0;
- }
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public Object clone() throws CloneNotSupportedException {
- if (this instanceof Cloneable) {
- return super.clone();
- } else {
- throw new CloneNotSupportedException();
- }
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public final void update(ByteBuffer input) {
- engineUpdate(input);
- }
-
- /**
- *
- * The internal MessageDigest implementation
- *
- */
- private static class MessageDigestImpl extends MessageDigest {
-
- // MessageDigestSpi implementation
- private MessageDigestSpi spiImpl;
-
- // MessageDigestImpl ctor
- private MessageDigestImpl(MessageDigestSpi messageDigestSpi,
- Provider provider, String algorithm) {
- super(algorithm);
- super.provider = provider;
- spiImpl = messageDigestSpi;
- }
-
- // engineReset() implementation
- protected void engineReset() {
- spiImpl.engineReset();
- }
-
- // engineDigest() implementation
- protected byte[] engineDigest() {
- return spiImpl.engineDigest();
- }
-
- // engineGetDigestLength() implementation
- protected int engineGetDigestLength() {
- return spiImpl.engineGetDigestLength();
- }
-
- // engineUpdate() implementation
- protected void engineUpdate(byte arg0) {
- spiImpl.engineUpdate(arg0);
- }
-
- // engineUpdate() implementation
- protected void engineUpdate(byte[] arg0, int arg1, int arg2) {
- spiImpl.engineUpdate(arg0, arg1, arg2);
- }
-
- // Returns a clone if the spiImpl is cloneable
- public Object clone() throws CloneNotSupportedException {
- if (spiImpl instanceof Cloneable) {
- MessageDigestSpi spi = (MessageDigestSpi) spiImpl.clone();
- return new MessageDigestImpl(spi, getProvider(), getAlgorithm());
- } else {
- throw new CloneNotSupportedException();
- }
- }
- }
-}
\ No newline at end of file
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+* @author Boris V. Kuznetsov
+* @version $Revision$
+*/
+
+package java.security;
+
+import java.nio.ByteBuffer;
+
+import org.apache.harmony.security.fortress.Engine;
+
+
+/**
+ * @com.intel.drl.spec_ref
+ *
+ */
+
+public abstract class MessageDigest extends MessageDigestSpi {
+
+ // The service name
+ private static final String SERVICE = "MessageDigest";
+
+ // Used to access common engine functionality
+ private static Engine engine = new Engine(SERVICE);
+
+ // The provider
+ private Provider provider;
+
+ // The algorithm.
+ private String algorithm;
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ protected MessageDigest(String algorithm) {
+ this.algorithm = algorithm;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ public static MessageDigest getInstance(String algorithm)
+ throws NoSuchAlgorithmException {
+ if (algorithm == null) {
+ throw new NullPointerException("Algorithm is null");
+ }
+ MessageDigest result;
+ synchronized (engine) {
+ engine.getInstance(algorithm, null);
+ if (engine.spi instanceof MessageDigest) {
+ result = (MessageDigest) engine.spi;
+ result.algorithm = algorithm;
+ result.provider = engine.provider;
+ return result;
+ } else {
+ result = new MessageDigestImpl((MessageDigestSpi) engine.spi,
+ engine.provider, algorithm);
+ return result;
+ }
+ }
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ public static MessageDigest getInstance(String algorithm, String provider)
+ throws NoSuchAlgorithmException, NoSuchProviderException {
+ if ((provider == null) || (provider.length() == 0)) {
+ throw new IllegalArgumentException(
+ "Provider is null or empty string");
+ }
+ Provider p = Security.getProvider(provider);
+ if (p == null) {
+ throw new NoSuchProviderException("Provider " + provider
+ + " is not available");
+ }
+ return getInstance(algorithm, p);
+ }
+
+ /**
+ * Answers 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.
+ *
+ *
+ * @param algorithm
+ * java.lang.String Name of the algorithm desired
+ * @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
+ */
+ public static MessageDigest getInstance(String algorithm, Provider provider)
+ throws NoSuchAlgorithmException {
+ if (provider == null) {
+ throw new IllegalArgumentException("Provider is null");
+ }
+ if (algorithm == null) {
+ throw new NullPointerException("Algorithm is null");
+ }
+ MessageDigest result;
+ synchronized (engine) {
+ engine.getInstance(algorithm, provider, null);
+ if (engine.spi instanceof MessageDigest) {
+ result = (MessageDigest) engine.spi;
+ result.algorithm = algorithm;
+ result.provider = provider;
+ return result;
+ } else {
+ result = new MessageDigestImpl((MessageDigestSpi) engine.spi,
+ provider, algorithm);
+ return result;
+ }
+ }
+ }
+
+ /**
+ * Puts the receiver back in an initial state, such that it is ready to
+ * compute a new hash.
+ *
+ * @see java.security.MessageDigest.Wrapper#engineReset()
+ */
+ 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
+ *
+ * @see #reset()
+ */
+ public void update(byte arg0) {
+ engineUpdate(arg0);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ public void update(byte[] input, int offset, int len) {
+ if (input == null || offset < 0 || len < 0 ||
+ offset + len > input.length) {
+ throw new IllegalArgumentException(
+ "Incorrect offset/len parameters");
+ }
+ engineUpdate(input, offset, len);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ public void update(byte[] input) {
+ if (input == null) {
+ throw new NullPointerException("Null input parameter");
+ }
+ engineUpdate(input, 0, input.length);
+ }
+
+ /**
+ * Computes and answers the final hash value that the receiver represents.
+ * After the digest is computed the receiver is reset.
+ *
+ * @return the hash the receiver computed
+ *
+ * @see #reset
+ */
+ public byte[] digest() {
+ return engineDigest();
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ public int digest(byte[] buf, int offset, int len) throws DigestException {
+ if (buf == null || offset < 0 || len < 0 ||
+ offset + len > buf.length) {
+ throw new IllegalArgumentException(
+ "Incorrect offset/len parameters");
+ }
+ return engineDigest(buf, offset, len);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ public byte[] digest(byte[] input) {
+ update(input);
+ return digest();
+ }
+
+ /**
+ * Answers a string containing a concise, human-readable description of the
+ * receiver.
+ *
+ * @return a printable representation for the receiver.
+ */
+ public String toString() {
+ return "MESSAGE DIGEST " + algorithm;
+ }
+
+ /**
+ * Does a simply byte-per-byte compare of the two digests.
+ *
+ * @param digesta
+ * One of the digests to compare
+ * @param digestb
+ * The digest to compare to
+ *
+ * @return <code>true</code> if the two hashes are equal
+ * <code>false</code> if the two hashes are not equal
+ */
+ public static boolean isEqual(byte[] digesta, byte[] digestb) {
+ if (digesta.length != digestb.length) {
+ return false;
+ }
+ for (int i = 0; i < digesta.length; i++) {
+ if (digesta[i] != digestb[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Answers the standard Java Security name for the algorithm being used by
+ * the receiver.
+ *
+ * @return String the name of the algorithm
+ */
+ public final String getAlgorithm() {
+ return algorithm;
+ }
+
+ /**
+ * Returns the Provider of the digest represented by the receiver.
+ *
+ * @return Provider an instance of a subclass of java.security.Provider
+ */
+ public final Provider getProvider() {
+ return provider;
+ }
+
+ /**
+ * Return the engine digest length in bytes. Default is 0.
+ *
+ * @return int the engine digest length in bytes
+ *
+ */
+ public final int getDigestLength() {
+ int l = engineGetDigestLength();
+ if (l != 0) {
+ return l;
+ }
+ if (!(this instanceof Cloneable)) {
+ return 0;
+ }
+ try {
+ MessageDigest md = (MessageDigest) clone();
+ return md.digest().length;
+ } catch (CloneNotSupportedException e) {
+ return 0;
+ }
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ public Object clone() throws CloneNotSupportedException {
+ if (this instanceof Cloneable) {
+ return super.clone();
+ } else {
+ throw new CloneNotSupportedException();
+ }
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ public final void update(ByteBuffer input) {
+ engineUpdate(input);
+ }
+
+ /**
+ *
+ * The internal MessageDigest implementation
+ *
+ */
+ private static class MessageDigestImpl extends MessageDigest {
+
+ // MessageDigestSpi implementation
+ private MessageDigestSpi spiImpl;
+
+ // MessageDigestImpl ctor
+ private MessageDigestImpl(MessageDigestSpi messageDigestSpi,
+ Provider provider, String algorithm) {
+ super(algorithm);
+ super.provider = provider;
+ spiImpl = messageDigestSpi;
+ }
+
+ // engineReset() implementation
+ protected void engineReset() {
+ spiImpl.engineReset();
+ }
+
+ // engineDigest() implementation
+ protected byte[] engineDigest() {
+ return spiImpl.engineDigest();
+ }
+
+ // engineGetDigestLength() implementation
+ protected int engineGetDigestLength() {
+ return spiImpl.engineGetDigestLength();
+ }
+
+ // engineUpdate() implementation
+ protected void engineUpdate(byte arg0) {
+ spiImpl.engineUpdate(arg0);
+ }
+
+ // engineUpdate() implementation
+ protected void engineUpdate(byte[] arg0, int arg1, int arg2) {
+ spiImpl.engineUpdate(arg0, arg1, arg2);
+ }
+
+ // Returns a clone if the spiImpl is cloneable
+ public Object clone() throws CloneNotSupportedException {
+ if (spiImpl instanceof Cloneable) {
+ MessageDigestSpi spi = (MessageDigestSpi) spiImpl.clone();
+ return new MessageDigestImpl(spi, getProvider(), getAlgorithm());
+ } else {
+ throw new CloneNotSupportedException();
+ }
+ }
+ }
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/MessageDigestSpi.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/MessageDigestSpi.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/MessageDigestSpi.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/MessageDigestSpi.java Wed Apr 26 00:54:18 2006
@@ -1,128 +1,133 @@
-/*
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
-* @author Boris V. Kuznetsov
-* @version $Revision$
-*/
-
-package java.security;
-
-import java.nio.ByteBuffer;
-
-/**
- * @com.intel.drl.spec_ref
- *
- */
-
-public abstract class MessageDigestSpi {
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- protected int engineGetDigestLength() {
- return 0;
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- protected abstract void engineUpdate(byte input);
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- protected abstract void engineUpdate(byte[] input, int offset, int len);
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- protected void engineUpdate(ByteBuffer input) {
- if (!input.hasRemaining()) {
- return;
- }
- byte[] tmp;
- if (input.hasArray()) {
- tmp = input.array();
- int offset = input.arrayOffset();
- int position = input.position();
- int limit = input.limit();
- engineUpdate(tmp, offset+position, limit - position);
- input.position(limit);
- } else {
- tmp = new byte[input.limit() - input.position()];
- input.get(tmp);
- engineUpdate(tmp, 0, tmp.length);
- }
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- protected abstract byte[] engineDigest();
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- protected int engineDigest(byte[] buf, int offset, int len)
- throws DigestException {
- if (len < engineGetDigestLength()) {
- engineReset();
- throw new DigestException("The value of len parameter is less than the actual digest length");
- }
- if (offset < 0) {
- engineReset();
- throw new DigestException("Invalid negative offset");
- }
- if (offset + len > buf.length) {
- engineReset();
- throw new DigestException("Incorrect offset or len value");
- }
- byte tmp[] = engineDigest();
- if (tmp != null) {
- if (len < tmp.length ) {
- throw new DigestException("The value of len parameter is less than the actual digest length.");
- }
- System.arraycopy(tmp, 0, buf, offset, tmp.length);
- return tmp.length;
- }
- return 0;
- }
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- protected abstract void engineReset();
-
- /**
- * @com.intel.drl.spec_ref
- *
- */
- public Object clone() throws CloneNotSupportedException {
- if (this instanceof Cloneable) {
- return super.clone();
- } else {
- throw new CloneNotSupportedException();
- }
- }
-}
+/*
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+* @author Boris V. Kuznetsov
+* @version $Revision$
+*/
+
+package java.security;
+
+import java.nio.ByteBuffer;
+
+
+/**
+ * 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.
+ *
+ */
+public abstract class MessageDigestSpi {
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ protected int engineGetDigestLength() {
+ return 0;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ protected abstract void engineUpdate(byte input);
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ protected abstract void engineUpdate(byte[] input, int offset, int len);
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ protected void engineUpdate(ByteBuffer input) {
+ if (!input.hasRemaining()) {
+ return;
+ }
+ byte[] tmp;
+ if (input.hasArray()) {
+ tmp = input.array();
+ int offset = input.arrayOffset();
+ int position = input.position();
+ int limit = input.limit();
+ engineUpdate(tmp, offset+position, limit - position);
+ input.position(limit);
+ } else {
+ tmp = new byte[input.limit() - input.position()];
+ input.get(tmp);
+ engineUpdate(tmp, 0, tmp.length);
+ }
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ protected abstract byte[] engineDigest();
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ protected int engineDigest(byte[] buf, int offset, int len)
+ throws DigestException {
+ if (len < engineGetDigestLength()) {
+ engineReset();
+ throw new DigestException("The value of len parameter is less than the actual digest length");
+ }
+ if (offset < 0) {
+ engineReset();
+ throw new DigestException("Invalid negative offset");
+ }
+ if (offset + len > buf.length) {
+ engineReset();
+ throw new DigestException("Incorrect offset or len value");
+ }
+ byte tmp[] = engineDigest();
+ if (tmp != null) {
+ if (len < tmp.length ) {
+ throw new DigestException("The value of len parameter is less than the actual digest length.");
+ }
+ System.arraycopy(tmp, 0, buf, offset, tmp.length);
+ return tmp.length;
+ }
+ return 0;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ protected abstract void engineReset();
+
+ /**
+ * @com.intel.drl.spec_ref
+ *
+ */
+ public Object clone() throws CloneNotSupportedException {
+ if (this instanceof Cloneable) {
+ return super.clone();
+ } else {
+ throw new CloneNotSupportedException();
+ }
+ }
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/NoSuchAlgorithmException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/NoSuchAlgorithmException.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/NoSuchAlgorithmException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/NoSuchAlgorithmException.java Wed Apr 26 00:54:18 2006
@@ -22,8 +22,10 @@
package java.security;
/**
- * @com.intel.drl.spec_ref
+ * Instances of this class are thrown when an attempt is made to access an
+ * algorithm which is not provided by the library.
*
+ * @see Throwable
*/
public class NoSuchAlgorithmException extends GeneralSecurityException {
@@ -32,16 +34,22 @@
*/
private static final long serialVersionUID = -7443947487218346562L;
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback and message
+ * filled in.
+ *
+ *
+ * @param msg
+ * String The detail message for the exception.
+ */
public NoSuchAlgorithmException(String msg) {
super(msg);
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback filled in.
+ *
+ */
public NoSuchAlgorithmException() {
}
@@ -58,4 +66,4 @@
public NoSuchAlgorithmException(Throwable cause) {
super(cause);
}
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/NoSuchProviderException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/NoSuchProviderException.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/NoSuchProviderException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/NoSuchProviderException.java Wed Apr 26 00:54:18 2006
@@ -22,8 +22,11 @@
package java.security;
/**
- * @com.intel.drl.spec_ref
+ * Instances of this class are thrown when an attempt is made to access a
+ * provider by name which is not currently available.
*
+ *
+ * @see Throwable
*/
public class NoSuchProviderException extends GeneralSecurityException {
/**
@@ -31,16 +34,21 @@
*/
private static final long serialVersionUID = 8488111756688534474L;
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback and message
+ * filled in.
+ *
+ * @param msg
+ * String The detail message for the exception.
+ */
public NoSuchProviderException(String msg) {
super(msg);
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its walkback filled in.
+ *
+ */
public NoSuchProviderException() {
}
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Permission.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Permission.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Permission.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Permission.java Wed Apr 26 00:54:18 2006
@@ -24,7 +24,8 @@
import java.io.Serializable;
/**
- * @com.intel.drl.spec_ref
+ * Abstract superclass of all classes which represent permission to access
+ * system resources.
*
*/
public abstract class Permission implements Guard, Serializable {
@@ -41,31 +42,57 @@
*/
public abstract boolean equals(Object obj);
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers an integer hash code for the receiver. Any two objects which
+ * answer <code>true</code> when passed to <code>.equals</code> must
+ * answer the same value for this method.
+ *
+ *
+ * @return int the receiver's hash.
+ *
+ * @see #equals
+ */
public abstract int hashCode();
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers 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.
+ *
+ *
+ * @return String the receiver's actions.
+ */
public abstract String getActions();
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Indicates whether the argument permission is implied by the receiver.
+ *
+ *
+ * @return boolean <code>true</code> if the argument permission is implied
+ * by the receiver, and <code>false</code> if it is not.
+ * @param permission
+ * Permission the permission to check.
+ */
public abstract boolean implies(Permission permission);
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Constructs a new instance of this class with its name set to the
+ * argument.
+ *
+ *
+ * @param name
+ * String the name of the permission.
+ */
public Permission(String name) {
this.name = name;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers the name of the receiver.
+ *
+ *
+ * @return String the receiver's name.
+ */
public final String getName() {
return name;
}
@@ -80,20 +107,29 @@
}
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers a new PermissionCollection for holding permissions of this class.
+ * Answer null if any permission collection can be used.
+ *
+ *
+ * @return PermissionCollection or null a suitable permission collection for
+ * instances of the class of the receiver.
+ */
public PermissionCollection newPermissionCollection() {
return null;
}
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Answers a string containing a concise, human-readable description of the
+ * receiver.
+ *
+ *
+ * @return String a printable representation for the receiver.
+ */
public String toString() {
String actions = getActions();
actions = (actions == null || actions.length() == 0) ? "" : " "
+ getActions();
return "(" + getClass().getName() + " " + getName() + actions + ")";
}
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/PermissionCollection.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/PermissionCollection.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/PermissionCollection.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/PermissionCollection.java Wed Apr 26 00:54:18 2006
@@ -27,7 +27,8 @@
import java.util.List;
/**
- * @com.intel.drl.spec_ref
+ * Abstract superclass of classes which are collections of Permission objects.
+ *
*/
public abstract class PermissionCollection implements Serializable {
@@ -42,36 +43,65 @@
private boolean readOnly; // = false;
/**
- * @com.intel.drl.spec_ref
+ * Adds the argument to the collection.
+ *
+ *
+ * @param permission
+ * java.security.Permission the permission to add to the
+ * collection.
+ * @exception IllegalStateException
+ * if the collection is read only.
*/
public abstract void add(Permission permission);
/**
- * @com.intel.drl.spec_ref
+ * Answers an enumeration of the permissions in the receiver.
+ *
+ *
+ * @return Enumeration the permissions in the receiver.
*/
public abstract Enumeration<Permission> elements();
/**
- * @com.intel.drl.spec_ref
+ * Indicates whether the argument permission is implied by the permissions
+ * contained in the receiver.
+ *
+ *
+ * @return boolean <code>true</code> if the argument permission is implied
+ * by the permissions in the receiver, and <code>false</code> if
+ * it is not.
+ * @param permission
+ * java.security.Permission the permission to check
*/
public abstract boolean implies(Permission permission);
/**
- * @com.intel.drl.spec_ref
+ * Indicates whether new permissions can be added to the receiver.
+ *
+ *
+ * @return boolean <code>true</code> if the receiver is read only
+ * <code>false</code> if new elements can still be added to the
+ * receiver.
*/
public boolean isReadOnly() {
return readOnly;
}
/**
- * @com.intel.drl.spec_ref
+ * Marks the receiver as read only, so that no new permissions can be added
+ * to it.
+ *
*/
public void setReadOnly() {
readOnly = true;
}
/**
- * @com.intel.drl.spec_ref
+ * Answers a string containing a concise, human-readable description of the
+ * receiver.
+ *
+ *
+ * @return a printable representation for the receiver.
*/
public String toString() {
List elist = new ArrayList(100);
@@ -95,4 +125,4 @@
}
return result.append("\n)").toString();
}
-}
\ No newline at end of file
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Permissions.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Permissions.java?rev=397136&r1=397135&r2=397136&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Permissions.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Permissions.java Wed Apr 26 00:54:18 2006
@@ -35,7 +35,8 @@
import java.util.NoSuchElementException;
/**
- * @com.intel.drl.spec_ref
+ * A heterogeneous collection of permissions.
+ *
*/
public final class Permissions extends PermissionCollection implements
Serializable {
@@ -57,9 +58,14 @@
*/
private boolean allEnabled; // = false;
- /**
- * @com.intel.drl.spec_ref
- */
+ /**
+ * Adds the argument to the collection.
+ *
+ *
+ * @param permission
+ * java.security.Permission the permission to add to the
+ * collection
+ */
public void add(Permission permission) {
if (isReadOnly()) {
throw new SecurityException("collection is read-only");
@@ -94,7 +100,10 @@
}
/**
- * @com.intel.drl.spec_ref
+ * Answers an enumeration of the permissions in the receiver.
+ *
+ *
+ * @return Enumeration the permissions in the receiver.
*/
public Enumeration<Permission> elements() {
return new MetaEnumeration(klasses.values().iterator());
@@ -157,14 +166,17 @@
}
}
- /**
- * @com.intel.drl.spec_ref
- * 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.
- */
+ /**
+ * Indicates whether the argument permission is implied by the permissions
+ * contained in the receiver.
+ *
+ *
+ * @return boolean <code>true</code> if the argument permission is implied
+ * by the permissions in the receiver, and <code>false</code> if
+ * it is not.
+ * @param permission
+ * java.security.Permission the permission to check
+ */
public boolean implies(Permission permission) {
if (allEnabled) {
return true;
@@ -266,27 +278,39 @@
*/
private final Hashtable perms = new Hashtable();
- /**
- * Adds passed permission (of any type) to the collection. The read-only
- * flag is ignored, as this class is used as internal storage only.
- */
+ /**
+ * Adds the argument to the collection.
+ *
+ *
+ * @param permission
+ * java.security.Permission the permission to add to the
+ * collection
+ */
public void add(Permission permission) {
perms.put(permission, permission);
}
- /**
- * Returns enumeration of contained elements.
- */
+ /**
+ * Answers an enumeration of the permissions in the receiver.
+ *
+ *
+ * @return Enumeration the permissions in the receiver.
+ */
public Enumeration elements() {
return perms.elements();
}
- /**
- * Checks if this collection implies the particular permission.
- *
- * @return true if some of contained permissions implies the passed
- * permission, false otherwise
- */
+ /**
+ * Indicates whether the argument permission is implied by the permissions
+ * contained in the receiver.
+ *
+ *
+ * @return boolean <code>true</code> if the argument permission is implied
+ * by the permissions in the receiver, and <code>false</code> if
+ * it is not.
+ * @param permission
+ * java.security.Permission the permission to check
+ */
public boolean implies(Permission permission) {
for (Enumeration elements = elements(); elements.hasMoreElements();) {
if (((Permission)elements.nextElement()).implies(permission)) {
@@ -295,4 +319,4 @@
}
return false;
}
-}
\ No newline at end of file
+}