Commit 2f9e468e authored by Elliott Hughes's avatar Elliott Hughes
Browse files

Update libcore/security to Harmony r823222.

Squashed commit of the following:

commit e3083dde77b71fa817c8a52d9edafcb6325cfc25
Author: Elliott Hughes <enh@google.com>
Date:   Fri Oct 9 13:10:11 2009 -0700

    security_dalvik

commit 0fc0101e5dbfb3e3044702579ab8087a4e07984a
Author: Elliott Hughes <enh@google.com>
Date:   Fri Oct 9 13:09:48 2009 -0700

    security_527399
parent cb570246
......@@ -15,15 +15,6 @@
* limitations under the License.
*/
/**
* @author Alexander V. Astapchuk
* @version $Revision$
*/
// BEGIN android-note
// Added Deprecated annotation.
// END android-note
package java.security;
import java.io.Serializable;
......@@ -34,11 +25,10 @@ import org.apache.harmony.security.internal.nls.Messages;
/**
* {@code Identity} represents an identity like a person or a company.
*
*
* @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 {
......@@ -56,18 +46,15 @@ public abstract class Identity implements Principal, Serializable {
/**
* Constructs a new instance of {@code Identity}.
*
* @since Android 1.0
*/
protected Identity() {
}
/**
* Creates a new instance of {@code Identity} with the specified name.
*
*
* @param name
* the name of this {@code Identity}.
* @since Android 1.0
*/
public Identity(String name) {
this.name = name;
......@@ -76,7 +63,7 @@ public abstract class Identity implements Principal, Serializable {
/**
* Creates a new instance of {@code Identity} with the specified name and
* the scope of this {@code Identity}.
*
*
* @param name
* the name of this {@code Identity}.
* @param scope
......@@ -84,7 +71,6 @@ public abstract class Identity implements Principal, Serializable {
* @throws KeyManagementException
* if an {@code Identity} with the same name is already present
* in the specified scope.
* @since Android 1.0
*/
public Identity(String name, IdentityScope scope)
throws KeyManagementException {
......@@ -101,8 +87,7 @@ public abstract class Identity implements Principal, Serializable {
* 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.
* </p>
*
*
* @param certificate
* the {@code Certificate} to be added to this {@code Identity}.
* @throws KeyManagementException
......@@ -110,7 +95,6 @@ public abstract class Identity implements Principal, Serializable {
* @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 {
......@@ -163,7 +147,7 @@ public abstract class Identity implements Principal, Serializable {
* the {@code SecurityPermission} {@code "removeIdentityCertificate"} to be
* granted, otherwise a {@code SecurityException} will be thrown.
* <p>
*
*
* @param certificate
* the {@code Certificate} to be removed.
* @throws KeyManagementException
......@@ -171,7 +155,6 @@ public abstract class Identity implements Principal, Serializable {
* @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 {
......@@ -196,9 +179,8 @@ 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) {
......@@ -219,13 +201,11 @@ public abstract class Identity implements Principal, Serializable {
* <p>
* To be equal, two {@code Identity} objects need to have the same name and
* the same public keys.
* </p>
*
*
* @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)) {
......@@ -245,12 +225,11 @@ 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) {
......@@ -264,9 +243,8 @@ 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;
......@@ -281,8 +259,7 @@ public abstract class Identity implements Principal, Serializable {
* 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.
* </p>
*
*
* @param key
* the {@code PublicKey} to be set.
* @throws KeyManagementException
......@@ -291,7 +268,6 @@ public abstract class Identity implements Principal, Serializable {
* @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();
......@@ -315,9 +291,8 @@ 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;
......@@ -332,13 +307,12 @@ public abstract class Identity implements Principal, Serializable {
* 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();
......@@ -353,9 +327,8 @@ 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;
......@@ -369,14 +342,14 @@ public abstract class Identity implements Principal, Serializable {
* 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
*/
@Override
public final boolean equals(Object obj) {
if (this == obj) {
return true;
......@@ -397,9 +370,8 @@ 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;
......@@ -412,12 +384,12 @@ 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
*/
@Override
public int hashCode() {
int hash = 0;
if (name != null) {
......@@ -439,22 +411,22 @@ public abstract class Identity implements Principal, Serializable {
* 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.
* </p>
*
*
* @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
*/
@Override
@SuppressWarnings("nls")
public String toString() {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkSecurityAccess("printIdentity"); //$NON-NLS-1$
sm.checkSecurityAccess("printIdentity");
}
String s = (this.name == null? "" : this.name);
String s = (this.name == null ? "" : this.name);
if (scope != null) {
s += " [" + scope.getName() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
s += " [" + scope.getName() + "]";
}
return s;
}
......
......@@ -15,29 +15,17 @@
* limitations under the License.
*/
/**
* @author Aleksei Y. Semenov
* @version $Revision$
*/
// BEGIN android-note
// Added Deprecated annotation.
// END android-note
package java.security;
import java.util.Enumeration;
import org.apache.harmony.security.SystemScope;
/**
* {@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 {
......@@ -49,8 +37,6 @@ public abstract class IdentityScope extends Identity {
/**
* Constructs a new instance of {@code IdentityScope}.
*
* @since Android 1.0
*/
protected IdentityScope() {
super();
......@@ -59,10 +45,9 @@ public abstract class IdentityScope extends Identity {
/**
* 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);
......@@ -71,14 +56,13 @@ public abstract class IdentityScope extends Identity {
/**
* 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 {
......@@ -87,9 +71,8 @@ public abstract class IdentityScope extends Identity {
/**
* Returns the system's scope.
*
*
* @return the system's scope.
* @since Android 1.0
*/
public static IdentityScope getSystemScope() {
/*
......@@ -116,10 +99,9 @@ public abstract class IdentityScope extends Identity {
/**
* 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();
......@@ -131,21 +113,19 @@ public abstract class IdentityScope extends Identity {
/**
* 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();
/**
* 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);
......@@ -153,13 +133,12 @@ public abstract class IdentityScope extends Identity {
* 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());
......@@ -169,36 +148,33 @@ public abstract class IdentityScope extends Identity {
* 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);
/**
* 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;
/**
* 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;
......@@ -206,22 +182,21 @@ public abstract class IdentityScope extends Identity {
/**
* 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<Identity> identities();
/**
* Returns a string containing a concise, human-readable description of this
* {@code IdentityScope}.
*
*
* @return a printable representation for this {@code IdentityScope}.
* @since Android 1.0
*/
@Override
public String toString() {
return new StringBuffer(super.toString())
return new StringBuilder(super.toString())
.append("[").append(size()).append("]").toString(); //$NON-NLS-1$ //$NON-NLS-2$
}
}
......@@ -15,31 +15,22 @@
* limitations under the License.
*/
/**
* @author Vera Y. Petrashkova
* @version $Revision$
*/
package java.security;
/**
* {@code InvalidAlgorithmParameterException} indicates the occurrence of
* invalid algorithm parameters.
*
* @since Android 1.0
*/
public class InvalidAlgorithmParameterException extends
GeneralSecurityException {
private static final long serialVersionUID = 2864672297499471472L;
/**
* Constructs a new instance of {@code InvalidAlgorithmParameterException}
* with the given message.
*
*
* @param msg
* the detail message for this exception.
* @since Android 1.0
*/
public InvalidAlgorithmParameterException(String msg) {
super(msg);
......@@ -47,8 +38,6 @@ public class InvalidAlgorithmParameterException extends
/**
* Constructs a new instance of {@code InvalidAlgorithmParameterException}.
*
* @since Android 1.0
*/
public InvalidAlgorithmParameterException() {
}
......@@ -56,12 +45,11 @@ public class InvalidAlgorithmParameterException extends
/**
* Constructs a new instance of {@code InvalidAlgorithmParameterException} 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 InvalidAlgorithmParameterException(String message, Throwable cause) {
super(message, cause);
......@@ -70,10 +58,9 @@ public class InvalidAlgorithmParameterException extends
/**
* Constructs a new instance of {@code InvalidAlgorithmParameterException}
* with the cause.
*
*
* @param cause
* the exception which is the cause for this exception.
* @since Android 1.0
*/
public InvalidAlgorithmParameterException(Throwable cause) {
super(cause);
......
......@@ -15,18 +15,11 @@
* limitations under the License.
*/
/**
* @author Vera Y. Petrashkova
* @version $Revision$
*/
package java.security;
/**
* {@code InvalidKeyException} indicates exceptional conditions, caused by an
* invalid key.
*
* @since Android 1.0
*/
public class InvalidKeyException extends KeyException {
......@@ -35,10 +28,9 @@ public class InvalidKeyException extends KeyException {
/**
* Constructs a new instance of {@code InvalidKeyException} with the given
* message.
*
*
* @param msg
* the detail message for this exception.
* @since Android 1.0
*/
public InvalidKeyException(String msg) {
super(msg);
......@@ -46,8 +38,6 @@ public class InvalidKeyException extends KeyException {
/**
* Constructs a new instance of {@code InvalidKeyException}.
*
* @since Android 1.0
*/
public InvalidKeyException() {
}
......@@ -55,12 +45,11 @@ public class InvalidKeyException extends KeyException {
/**
* Constructs a new instance of {@code InvalidKeyException} 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 InvalidKeyException(String message, Throwable cause) {
super(message, cause);
......@@ -68,10 +57,9 @@ public class InvalidKeyException extends KeyException {
/**
* Constructs a new instance of {@code InvalidKeyException} with the cause.
*
*
* @param cause
* the exception which is the cause for this exception.
* @since Android 1.0
*/
public InvalidKeyException(Throwable cause) {
super(cause);
......
......@@ -15,18 +15,11 @@
* limitations under the License.
*/
/**
* @author Vera Y. Petrashkova
* @version $Revision$
*/
package java.security;
/**
* {@code InvalidParameterException} indicates exceptional conditions, caused by
* invalid parameters.
*
* @since Android 1.0
*/
public class InvalidParameterException extends IllegalArgumentException {
......@@ -35,10 +28,9 @@ public class InvalidParameterException extends IllegalArgumentException {
/**
* Constructs a new instance of {@code InvalidParameterException} with the
* given message.
*
*
* @param msg
* the detail message for this exception.
* @since Android 1.0
*/
public InvalidParameterException(String msg) {
super(msg);
......@@ -46,8 +38,6 @@ public class InvalidParameterException extends IllegalArgumentException {
/**
* Constructs a new instance of {@code InvalidParameterException}.
*
* @since Android 1.0
*/
public InvalidParameterException() {
}
......
......@@ -15,11 +15,6 @@
* limitations under the License.
*/
/**
* @author Vera Y. Petrashkova
* @version $Revision$
*/
package java.security;
import java.io.Serializable;
......@@ -29,14 +24,11 @@ import java.io.Serializable;
*
* @see PublicKey
* @see PrivateKey
* @since Android 1.0
*/
public interface Key extends Serializable {
/**
* The {@code serialVersionUID} to be compatible with JDK1.1.
*
* @since Android 1.0
*/
public static final long serialVersionUID = 6603384152749567654L;
......@@ -46,7 +38,6 @@ public interface Key extends Serializable {
*
* @return the name of the algorithm of this key or {@code null} if the
* algorithm is unknown.
* @since Android 1.0
*/
public String getAlgorithm();
......@@ -56,7 +47,6 @@ public interface Key extends Serializable {
*
* @return the name of the format used to encode this key, or {@code null}
* if it can not be encoded.
* @since Android 1.0
*/
public String getFormat();
......@@ -66,7 +56,6 @@ public interface Key extends Serializable {
*
* @return the encoded form of this key, or {@code null} if encoding is not
* supported by this key.
* @since Android 1.0
*/
public byte[] getEncoded();
}
......@@ -15,17 +15,10 @@
* limitations under the License.
*/
/**
* @author Vera Y. Petrashkova
* @version $Revision$
*/
package java.security;
/**
* {@code KeyException} is the common superclass of all key related exceptions.
*
* @since Android 1.0
*/
public class KeyException extends GeneralSecurityException {
......@@ -33,10 +26,9 @@ public class KeyException extends GeneralSecurityException {
/**
* Constructs a new instance of {@code KeyException} with the given message.
*
*
* @param msg
* the detail message for this exception.
* @since Android 1.0
*/
public KeyException(String msg) {
super(msg);
......@@ -44,8 +36,6 @@ public class KeyException extends GeneralSecurityException {
/**
* Constructs a new instance of {@code KeyException}.
*
* @since Android 1.0
*/
public KeyException() {
}
......@@ -53,12 +43,11 @@ public class KeyException extends GeneralSecurityException {
/**
* Constructs a new instance of {@code KeyException} 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 KeyException(String message, Throwable cause) {
super(message, cause);
......@@ -66,10 +55,9 @@ public class KeyException extends GeneralSecurityException {
/**
* Constructs a new instance of {@code KeyException} with the cause.
*
*
* @param cause
* the exception which is the cause for this exception.
* @since Android 1.0
*/
public KeyException(Throwable cause) {
super(cause);
......
......@@ -15,11 +15,6 @@
* limitations under the License.
*/
/**
* @author Boris V. Kuznetsov
* @version $Revision$
*/
package java.security;
import java.security.spec.InvalidKeySpecException;
......@@ -33,8 +28,6 @@ import org.apache.harmony.security.internal.nls.Messages;
* public and private key objects and convert keys between their external
* representation, that can be easily transported and their internal
* representation.
*
* @since Android 1.0
*/
public class KeyFactory {
// The service name.
......@@ -63,7 +56,6 @@ public class KeyFactory {
* the provider.
* @param algorithm
* the algorithm to use.
* @since Android 1.0
*/
protected KeyFactory(KeyFactorySpi keyFacSpi,
Provider provider,
......@@ -83,7 +75,6 @@ public class KeyFactory {
* algorithm.
* @throws NoSuchAlgorithmException
* if no provider provides the requested algorithm.
* @since Android 1.0
*/
public static KeyFactory getInstance(String algorithm)
throws NoSuchAlgorithmException {
......@@ -112,16 +103,16 @@ public class KeyFactory {
* if the requested provider is not available.
* @throws IllegalArgumentException
* if {@code provider} is {@code null} or empty.
* @since Android 1.0
*/
@SuppressWarnings("nls")
public static KeyFactory getInstance(String algorithm, String provider)
throws NoSuchAlgorithmException, NoSuchProviderException {
if ((provider == null) || (provider.length() == 0)) {
throw new IllegalArgumentException(Messages.getString("security.02")); //$NON-NLS-1$
throw new IllegalArgumentException(Messages.getString("security.02"));
}
Provider p = Security.getProvider(provider);
if (p == null) {
throw new NoSuchProviderException(Messages.getString("security.03", provider)); //$NON-NLS-1$ //$NON-NLS-2$
throw new NoSuchProviderException(Messages.getString("security.03", provider));
}
return getInstance(algorithm, p);
}
......@@ -138,7 +129,6 @@ public class KeyFactory {
* algorithm from the specified provider.
* @throws NoSuchAlgorithmException
* if the provider does not provide the requested algorithm.
* @since Android 1.0
*/
public static KeyFactory getInstance(String algorithm, Provider provider)
throws NoSuchAlgorithmException {
......@@ -158,19 +148,17 @@ public class KeyFactory {
* Returns the provider associated with this {@code KeyFactory}.
*
* @return the provider associated with this {@code KeyFactory}.
* @since Android 1.0
*/
public final Provider getProvider() {
return provider;
}
/**
* Returns the name of the algorithm associated with this {@code KeyFactory}
* .
* Returns the name of the algorithm associated with this {@code
* KeyFactory}.
*
* @return the name of the algorithm associated with this {@code KeyFactory}
* .
* @since Android 1.0
* @return the name of the algorithm associated with this {@code
* KeyFactory}.
*/
public final String getAlgorithm() {
return algorithm;
......@@ -185,7 +173,6 @@ public class KeyFactory {
* @return the public key
* @throws InvalidKeySpecException
* if the specified {@code keySpec} is invalid
* @since Android 1.0
*/
public final PublicKey generatePublic(KeySpec keySpec)
throws InvalidKeySpecException {
......@@ -201,7 +188,6 @@ public class KeyFactory {
* @return the private key.
* @throws InvalidKeySpecException
* if the specified {@code keySpec} is invalid.
* @since Android 1.0
*/
public final PrivateKey generatePrivate(KeySpec keySpec)
throws InvalidKeySpecException {
......@@ -211,6 +197,9 @@ public class KeyFactory {
/**
* Returns the key specification for the specified key.
*
* @param <T>
* The key type
*
* @param key
* the key from which the specification is requested.
* @param keySpec
......@@ -219,7 +208,6 @@ public class KeyFactory {
* @throws InvalidKeySpecException
* if the key can not be processed, or the requested requested
* {@code KeySpec} is inappropriate for the given key.
* @since Android 1.0
*/
public final <T extends KeySpec> T getKeySpec(Key key,
Class<T> keySpec)
......@@ -236,7 +224,6 @@ public class KeyFactory {
* @throws InvalidKeyException
* if the specified key can not be translated by this key
* factory.
* @since Android 1.0
*/
public final Key translateKey(Key key)
throws InvalidKeyException {
......
......@@ -15,11 +15,6 @@
* limitations under the License.
*/
/**
* @author Boris V. Kuznetsov
* @version $Revision$
*/
package java.security;
import java.security.spec.InvalidKeySpecException;
......@@ -30,7 +25,6 @@ import java.security.spec.KeySpec;
* {@link KeyFactory}.
*
* @see KeyFactory
* @since Android 1.0
*/
public abstract class KeyFactorySpi {
......@@ -43,7 +37,6 @@ public abstract class KeyFactorySpi {
* @return the public key.
* @throws InvalidKeySpecException
* if the specified {@code keySpec} is invalid.
* @since Android 1.0
*/
protected abstract PublicKey engineGeneratePublic(KeySpec keySpec)
throws InvalidKeySpecException;
......@@ -57,7 +50,6 @@ public abstract class KeyFactorySpi {
* @return the private key.
* @throws InvalidKeySpecException
* if the specified {@code keySpec} is invalid.
* @since Android 1.0
*/
protected abstract PrivateKey engineGeneratePrivate(KeySpec keySpec)
throws InvalidKeySpecException;
......@@ -73,7 +65,6 @@ public abstract class KeyFactorySpi {
* @throws InvalidKeySpecException
* if the key can not be processed, or the requested requested
* {@code KeySpec} is inappropriate for the given key.
* @since Android 1.0
*/
protected abstract <T extends KeySpec> T engineGetKeySpec(Key key, Class<T> keySpec)
throws InvalidKeySpecException;
......@@ -88,7 +79,6 @@ public abstract class KeyFactorySpi {
* @throws InvalidKeyException
* if the specified key can not be translated by this key
* factory.
* @since Android 1.0
*/
protected abstract Key engineTranslateKey(Key key) throws InvalidKeyException;
......
......@@ -15,18 +15,11 @@
* limitations under the License.
*/
/**
* @author Vera Y. Petrashkova
* @version $Revision$
*/
package java.security;
/**
* {@code KeyManagementException} is a general exception, thrown to indicate an
* exception during processing an operation concerning key management.
*
* @since Android 1.0
*/
public class KeyManagementException extends KeyException {
......@@ -35,10 +28,9 @@ public class KeyManagementException extends KeyException {
/**
* Constructs a new instance of {@code KeyManagementException} with the
* given message.
*
*
* @param msg
* the detail message for this exception.
* @since Android 1.0
*/
public KeyManagementException(String msg) {
super(msg);
......@@ -46,8 +38,6 @@ public class KeyManagementException extends KeyException {
/**
* Constructs a new instance of {@code KeyManagementException}.
*
* @since Android 1.0
*/
public KeyManagementException() {
}
......@@ -55,12 +45,11 @@ public class KeyManagementException extends KeyException {
/**
* Constructs a new instance of {@code KeyManagementException} 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 KeyManagementException(String message, Throwable cause) {
super(message, cause);
......@@ -69,13 +58,12 @@ public class KeyManagementException extends KeyException {
/**
* Constructs a new instance of {@code KeyManagementException} with the
* cause.
*
*
* @param cause
* the exception which is the cause for this exception.
* @since Android 1.0
*/
public KeyManagementException(Throwable cause) {
super(cause);
}
}
\ No newline at end of file
}
......@@ -15,11 +15,6 @@
* limitations under the License.
*/
/**
* @author Vladimir N. Molotkov
* @version $Revision$
*/
package java.security;
import java.io.Serializable;
......@@ -30,7 +25,6 @@ import java.io.Serializable;
*
* @see PrivateKey
* @see PublicKey
* @since Android 1.0
*/
public final class KeyPair implements Serializable {
......@@ -41,12 +35,11 @@ public final class KeyPair implements Serializable {
/**
* Constructs a new instance of {@code KeyPair} with a public key and the
* corresponding private key.
*
*
* @param publicKey
* the public key.
* @param privateKey
* the private key.
* @since Android 1.0
*/
public KeyPair(PublicKey publicKey, PrivateKey privateKey) {
this.privateKey = privateKey;
......@@ -55,9 +48,8 @@ public final class KeyPair implements Serializable {
/**
* Returns the private key.
*
*
* @return the private key.
* @since Android 1.0
*/
public PrivateKey getPrivate() {
return privateKey;
......@@ -65,9 +57,8 @@ public final class KeyPair implements Serializable {
/**
* Returns the public key.
*
*
* @return the public key.
* @since Android 1.0
*/
public PublicKey getPublic() {
return publicKey;
......
......@@ -15,11 +15,6 @@
* limitations under the License.
*/
/**
* @author Vera Y. Petrashkova
* @version $Revision$
*/
package java.security;
import java.security.spec.AlgorithmParameterSpec;
......@@ -32,9 +27,8 @@ import org.apache.harmony.security.internal.nls.Messages;
* {@code KeyPairGenerator} is an engine class which is capable of generating a
* private key and its related public key utilizing the algorithm it was
* initialized with.
*
*
* @see KeyPairGeneratorSpi
* @since Android 1.0
*/
public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
......@@ -56,10 +50,9 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
/**
* Constructs a new instance of {@code KeyPairGenerator} with the name of
* the algorithm to use.
*
*
* @param algorithm
* the name of algorithm to use
* @since Android 1.0
*/
protected KeyPairGenerator(String algorithm) {
this.algorithm = algorithm;
......@@ -67,9 +60,8 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
/**
* Returns the name of the algorithm of this {@code KeyPairGenerator}.
*
*
* @return the name of the algorithm of this {@code KeyPairGenerator}
* @since Android 1.0
*/
public String getAlgorithm() {
return algorithm;
......@@ -86,7 +78,6 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
* @throws NoSuchAlgorithmException if the specified algorithm is not available
* @throws NullPointerException
* if {@code algorithm} is {@code null}
* @since Android 1.0
*/
public static KeyPairGenerator getInstance(String algorithm)
throws NoSuchAlgorithmException {
......@@ -101,11 +92,10 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
result.algorithm = algorithm;
result.provider = engine.provider;
return result;
} else {
result = new KeyPairGeneratorImpl((KeyPairGeneratorSpi) engine.spi,
engine.provider, algorithm);
return result;
}
result = new KeyPairGeneratorImpl((KeyPairGeneratorSpi) engine.spi,
engine.provider, algorithm);
return result;
}
}
......@@ -123,7 +113,6 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
* @throws NoSuchProviderException if the specified provider is not available
* @throws NullPointerException
* if {@code algorithm} is {@code null}
* @since Android 1.0
*/
public static KeyPairGenerator getInstance(String algorithm, String provider)
throws NoSuchAlgorithmException, NoSuchProviderException {
......@@ -151,7 +140,6 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
* @throws NoSuchAlgorithmException if the specified algorithm is not available
* @throws NullPointerException
* if {@code algorithm} is {@code null}
* @since Android 1.0
*/
public static KeyPairGenerator getInstance(String algorithm,
Provider provider) throws NoSuchAlgorithmException {
......@@ -169,19 +157,17 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
result.algorithm = algorithm;
result.provider = provider;
return result;
} else {
result = new KeyPairGeneratorImpl((KeyPairGeneratorSpi) engine.spi,
provider, algorithm);
return result;
}
result = new KeyPairGeneratorImpl((KeyPairGeneratorSpi) engine.spi,
provider, algorithm);
return result;
}
}
/**
* Returns the provider associated with this {@code KeyPairGenerator}.
*
*
* @return the provider associated with this {@code KeyPairGenerator}
* @since Android 1.0
*/
public final Provider getProvider() {
return provider;
......@@ -191,10 +177,9 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
* Initializes this {@code KeyPairGenerator} with the given key size. The
* default parameter set and a default {@code SecureRandom} instance will be
* used.
*
*
* @param keysize
* the size of the key (number of bits)
* @since Android 1.0
*/
public void initialize(int keysize) {
initialize(keysize, random);
......@@ -204,12 +189,11 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
* Initializes this {@code KeyPairGenerator} with the given {@code
* AlgorithmParameterSpec}. A default {@code SecureRandom} instance will be
* used.
*
*
* @param param
* the parameters to use
* @throws InvalidAlgorithmParameterException
* if the specified parameters are not supported
* @since Android 1.0
*/
public void initialize(AlgorithmParameterSpec param)
throws InvalidAlgorithmParameterException {
......@@ -221,9 +205,8 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
* is called.
* <p>
* 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();
......@@ -234,10 +217,10 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
* is called.
* <p>
* This does exactly the same as {@link #genKeyPair()}.
*
*
* @return a new unique {@code KeyPair} each time this method is called
* @since Android 1.0
*/
@Override
public KeyPair generateKeyPair() {
return null;
}
......@@ -245,28 +228,28 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
/**
* 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
*/
@Override
public void initialize(int keysize, SecureRandom random) {
}
/**
* 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
*/
@Override
public void initialize(AlgorithmParameterSpec param, SecureRandom random)
throws InvalidAlgorithmParameterException {
}
......@@ -294,18 +277,21 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
// implementation of initialize(int keysize, SecureRandom random)
// using corresponding spi initialize() method
@Override
public void initialize(int keysize, SecureRandom random) {
spiImpl.initialize(keysize, random);
}
// implementation of generateKeyPair()
// using corresponding spi generateKeyPair() method
@Override
public KeyPair generateKeyPair() {
return spiImpl.generateKeyPair();
}
// implementation of initialize(int keysize, SecureRandom random)
// using corresponding spi initialize() method
@Override
public void initialize(AlgorithmParameterSpec param, SecureRandom random)
throws InvalidAlgorithmParameterException {
spiImpl.initialize(param, random);
......@@ -313,4 +299,4 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
}
}
\ No newline at end of file
}
......@@ -15,11 +15,6 @@
* limitations under the License.
*/
/**
* @author Vera Y. Petrashkova
* @version $Revision$
*/
package java.security;
import java.security.spec.AlgorithmParameterSpec;
......@@ -31,14 +26,10 @@ import org.apache.harmony.security.internal.nls.Messages;
* definition for {@link KeyPairGenerator}.
*
* @see KeyPairGenerator
* @since Android 1.0
*/
public abstract class KeyPairGeneratorSpi {
/**
* Constructs a new instance of {@code KeyPairGeneratorSpi}.
*
* @since Android 1.0
*/
public KeyPairGeneratorSpi() {
}
......@@ -46,38 +37,35 @@ public abstract class KeyPairGeneratorSpi {
/**
* 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();
/**
* 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);
/**
* 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 {
throw new UnsupportedOperationException(Messages.getString("security.2E")); //$NON-NLS-1$
}
}
\ No newline at end of file
}
......@@ -15,11 +15,6 @@
* limitations under the License.
*/
/**
* @author Vladimir N. Molotkov
* @version $Revision$
*/
package java.security;
import java.io.IOException;
......@@ -38,8 +33,6 @@ import org.apache.harmony.security.internal.nls.Messages;
/**
* {@code KeyRep} is a standardized representation for serialized {@link Key}
* objects.
*
* @since Android 1.0
*/
public class KeyRep implements Serializable {
......@@ -57,7 +50,7 @@ public class KeyRep implements Serializable {
* 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
......@@ -70,7 +63,6 @@ public class KeyRep implements Serializable {
* @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) {
......@@ -107,12 +99,11 @@ public class KeyRep implements Serializable {
* initialized with a {@link X509EncodedKeySpec} using the encoded key
* bytes.
* </ul>
*
*
* @return the resolved {@code Key} object.
* @throws ObjectStreamException
* if the {@code Type}|format combination is not recognized, or
* the resolution of any key parameter fails.
* @since Android 1.0
*/
protected Object readResolve() throws ObjectStreamException {
switch (type) {
......@@ -174,10 +165,8 @@ public class KeyRep implements Serializable {
/**
* {@code Type} enumerates the supported key types.
* @since Android 1.0
*/
public static enum Type {
/**
* Type for secret keys.
*/
......
......@@ -15,18 +15,12 @@
* limitations under the License.
*/
/**
* @author Vera Y. Petrashkova
* @version $Revision$
*/
package java.security;
/**
* {@code KeyStoreException} is a general {@code KeyStore} exception.
*
* @see KeyStore
* @since Android 1.0
*/
public class KeyStoreException extends GeneralSecurityException {
......@@ -35,10 +29,9 @@ public class KeyStoreException extends GeneralSecurityException {
/**
* 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);
......@@ -46,8 +39,6 @@ public class KeyStoreException extends GeneralSecurityException {
/**
* Constructs a new instance of {@code KeyStoreException}.
*
* @since Android 1.0
*/
public KeyStoreException() {
}
......@@ -55,12 +46,11 @@ public class KeyStoreException extends GeneralSecurityException {
/**
* 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);
......@@ -69,10 +59,9 @@ public class KeyStoreException extends GeneralSecurityException {
/**
* 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);
......
......@@ -33,16 +33,15 @@ 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
......@@ -53,41 +52,37 @@ public abstract class KeyStoreSpi {
* 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);
......@@ -95,8 +90,7 @@ public abstract class KeyStoreSpi {
* Associates the given alias with the key, password and certificate chain.
* <p>
* If the specified alias already exists, it will be reassigned.
* </p>
*
*
* @param alias
* the alias for the key.
* @param key
......@@ -111,7 +105,6 @@ public abstract class KeyStoreSpi {
* @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;
......@@ -120,8 +113,7 @@ public abstract class KeyStoreSpi {
* Associates the given alias with a key and a certificate chain.
* <p>
* If the specified alias already exists, it will be reassigned.
* </p>
*
*
* @param alias
* the alias for the key.
* @param key
......@@ -133,7 +125,6 @@ public abstract class KeyStoreSpi {
* @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;
......@@ -142,8 +133,7 @@ public abstract class KeyStoreSpi {
* Associates the given alias with a certificate.
* <p>
* If the specified alias already exists, it will be reassigned.
* </p>
*
*
* @param alias
* the alias for the certificate.
* @param cert
......@@ -152,7 +142,6 @@ public abstract class KeyStoreSpi {
* 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;
......@@ -160,12 +149,11 @@ public abstract class KeyStoreSpi {
/**
* 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;
......@@ -173,63 +161,57 @@ public abstract class KeyStoreSpi {
/**
* 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<String> engineAliases();
/**
* Indicates whether the given alias is present in this {@code KeyStoreSpi}.
*
*
* @param alias
* the alias of an entry.
* @return {@code true} if the alias exists, {@code false} otherwise.
* @since Android 1.0
*/
public abstract boolean engineContainsAlias(String alias);
/**
* Returns the number of entries stored in this {@code KeyStoreSpi}.
*
*
* @return the number of entries stored in this {@code KeyStoreSpi}.
* @since Android 1.0
*/
public abstract int engineSize();
/**
* Indicates whether the specified alias is associated with either a
* {@link KeyStore.PrivateKeyEntry} or a {@link KeyStore.SecretKeyEntry}.
*
*
* @param alias
* the alias of an entry.
* @return {@code true} if the given alias is associated with a key entry.
* @since Android 1.0
*/
public abstract boolean engineIsKeyEntry(String alias);
/**
* Indicates whether the specified alias is associated with a
* {@link KeyStore.TrustedCertificateEntry}.
*
*
* @param alias
* the alias of an entry.
* @return {@code true} if the given alias is associated with a certificate
* entry.
* @since Android 1.0
*/
public abstract boolean engineIsCertificateEntry(String alias);
/**
* Returns the alias associated with the first entry whose certificate
* matches the specified certificate.
*
*
* @param cert
* the certificate to find the associated entry's alias for.
* @return the alias or {@code null} if no entry with the specified
* certificate can be found.
* @since Android 1.0
*/
public abstract String engineGetCertificateAlias(Certificate cert);
......@@ -237,7 +219,7 @@ public abstract class KeyStoreSpi {
* Writes this {@code KeyStoreSpi} to the specified {@code OutputStream}.
* The data written to the {@code OutputStream} is protected by the
* specified password.
*
*
* @param stream
* the {@code OutputStream} to write the store's data to.
* @param password
......@@ -249,7 +231,6 @@ public abstract class KeyStoreSpi {
* @throws CertificateException
* if the an exception occurred while storing the certificates
* of this code {@code KeyStoreSpi}.
* @since Android 1.0
*/
public abstract void engineStore(OutputStream stream, char[] password)
throws IOException, NoSuchAlgorithmException, CertificateException;
......@@ -257,7 +238,7 @@ public abstract class KeyStoreSpi {
/**
* Stores this {@code KeyStoreSpi} using the specified {@code
* LoadStoreParameter}.
*
*
* @param param
* the {@code LoadStoreParameter} that specifies how to store
* this {@code KeyStoreSpi}, maybe {@code null}.
......@@ -271,7 +252,6 @@ public abstract class KeyStoreSpi {
* @throws IllegalArgumentException
* if the given {@link KeyStore.LoadStoreParameter} is not
* recognized.
* @since Android 1.0
*/
public void engineStore(KeyStore.LoadStoreParameter param)
throws IOException, NoSuchAlgorithmException, CertificateException {
......@@ -281,7 +261,7 @@ public abstract class KeyStoreSpi {
/**
* Loads this {@code KeyStoreSpi} from the given {@code InputStream}.
* Utilizes the given password to verify the stored data.
*
*
* @param stream
* the {@code InputStream} to load this {@code KeyStoreSpi}'s
* data from.
......@@ -294,7 +274,6 @@ public abstract class KeyStoreSpi {
* @throws CertificateException
* if the an exception occurred while loading the certificates
* of this code {@code KeyStoreSpi}.
* @since Android 1.0
*/
public abstract void engineLoad(InputStream stream, char[] password)
throws IOException, NoSuchAlgorithmException, CertificateException;
......@@ -302,7 +281,7 @@ public abstract class KeyStoreSpi {
/**
* Loads this {@code KeyStoreSpi} using the specified {@code
* LoadStoreParameter}.
*
*
* @param param
* the {@code LoadStoreParameter} that specifies how to load this
* {@code KeyStoreSpi}, maybe {@code null}.
......@@ -316,7 +295,6 @@ public abstract class KeyStoreSpi {
* @throws IllegalArgumentException
* if the given {@link KeyStore.LoadStoreParameter} is not
* recognized.
* @since Android 1.0
*/
public void engineLoad(KeyStore.LoadStoreParameter param)
throws IOException, NoSuchAlgorithmException, CertificateException {
......@@ -351,7 +329,7 @@ public abstract class KeyStoreSpi {
/**
* Returns the {@code Entry} with the given alias, using the specified
* {@code ProtectionParameter}.
*
*
* @param alias
* the alias of the requested entry.
* @param protParam
......@@ -365,7 +343,6 @@ public abstract class KeyStoreSpi {
* if the entry can not be recovered.
* @throws KeyStoreException
* if this operation fails
* @since Android 1.0
*/
public KeyStore.Entry engineGetEntry(String alias,
KeyStore.ProtectionParameter protParam) throws KeyStoreException,
......@@ -417,8 +394,7 @@ public abstract class KeyStoreSpi {
* specified {@code ProtectionParameter}.
* <p>
* If the specified alias already exists, it will be reassigned.
* </p>
*
*
* @param alias
* the alias for the entry.
* @param entry
......@@ -427,7 +403,6 @@ public abstract class KeyStoreSpi {
* 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 {
......@@ -486,14 +461,13 @@ public abstract class KeyStoreSpi {
/**
* 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) {
......
......@@ -15,11 +15,6 @@
* limitations under the License.
*/
/**
* @author Boris V. Kuznetsov
* @version $Revision$
*/
package java.security;
import java.nio.ByteBuffer;
......@@ -31,12 +26,11 @@ import org.apache.harmony.security.internal.nls.Messages;
* {@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
private static final String SERVICE = "MessageDigest"; //$NON-NLS-1$
......@@ -55,7 +49,6 @@ public abstract class MessageDigest extends MessageDigestSpi {
*
* @param algorithm
* the name of algorithm to use
* @since Android 1.0
*/
protected MessageDigest(String algorithm) {
this.algorithm = algorithm;
......@@ -73,7 +66,6 @@ public abstract class MessageDigest extends MessageDigestSpi {
* 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 {
......@@ -88,11 +80,9 @@ public abstract class MessageDigest extends MessageDigestSpi {
result.algorithm = algorithm;
result.provider = engine.provider;
return result;
} else {
result = new MessageDigestImpl((MessageDigestSpi) engine.spi,
engine.provider, algorithm);
return result;
}
return new MessageDigestImpl((MessageDigestSpi) engine.spi,
engine.provider, algorithm);
}
}
......@@ -112,16 +102,17 @@ public abstract class MessageDigest extends MessageDigestSpi {
* 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 {
if ((provider == null) || (provider.length() == 0)) {
throw new IllegalArgumentException(Messages.getString("security.02")); //$NON-NLS-1$
throw new IllegalArgumentException(Messages
.getString("security.02")); //$NON-NLS-1$
}
Provider p = Security.getProvider(provider);
if (p == null) {
throw new NoSuchProviderException(Messages.getString("security.03", provider)); //$NON-NLS-1$
throw new NoSuchProviderException(Messages.getString(
"security.03", provider)); //$NON-NLS-1$
}
return getInstance(algorithm, p);
}
......@@ -140,12 +131,12 @@ public abstract class MessageDigest extends MessageDigestSpi {
* 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 {
if (provider == null) {
throw new IllegalArgumentException(Messages.getString("security.04")); //$NON-NLS-1$
throw new IllegalArgumentException(Messages
.getString("security.04")); //$NON-NLS-1$
}
if (algorithm == null) {
throw new NullPointerException(Messages.getString("security.01")); //$NON-NLS-1$
......@@ -158,19 +149,16 @@ public abstract class MessageDigest extends MessageDigestSpi {
result.algorithm = algorithm;
result.provider = provider;
return result;
} else {
result = new MessageDigestImpl((MessageDigestSpi) engine.spi,
provider, algorithm);
return result;
}
result = new MessageDigestImpl((MessageDigestSpi) engine.spi,
provider, algorithm);
return result;
}
}
/**
* 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();
......@@ -200,11 +188,10 @@ public abstract class MessageDigest extends MessageDigestSpi {
* @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 ||
// offset < 0 || len < 0 ||
// offset < 0 || len < 0 ||
// checks for negative values are commented out intentionally
// see HARMONY-1120 for details
(long) offset + (long) len > input.length) {
......@@ -221,7 +208,6 @@ public abstract class MessageDigest extends MessageDigestSpi {
* the {@code byte} array
* @throws NullPointerException
* if {@code input} is {@code null}
* @since Android 1.0
*/
public void update(byte[] input) {
if (input == null) {
......@@ -259,11 +245,10 @@ public abstract class MessageDigest extends MessageDigestSpi {
* 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 ||
// offset < 0 || len < 0 ||
// offset < 0 || len < 0 ||
// checks for negative values are commented out intentionally
// see HARMONY-1148 for details
(long) offset + (long) len > buf.length) {
......@@ -282,7 +267,6 @@ public abstract class MessageDigest extends MessageDigestSpi {
* the {@code byte} array
* @return the computed one way hash value
* @see #reset()
* @since Android 1.0
*/
public byte[] digest(byte[] input) {
update(input);
......@@ -294,8 +278,8 @@ public abstract class MessageDigest extends MessageDigestSpi {
* {@code MessageDigest} including the name of its algorithm.
*
* @return a printable representation for this {@code MessageDigest}
* @since Android 1.0
*/
@Override
public String toString() {
return "MESSAGE DIGEST " + algorithm; //$NON-NLS-1$
}
......@@ -309,7 +293,6 @@ public abstract class MessageDigest extends MessageDigestSpi {
* @param digestb
* 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) {
......@@ -327,7 +310,6 @@ public abstract class MessageDigest extends MessageDigestSpi {
* Returns the name of the algorithm of this {@code MessageDigest}.
*
* @return the name of the algorithm of this {@code MessageDigest}
* @since Android 1.0
*/
public final String getAlgorithm() {
return algorithm;
......@@ -337,7 +319,6 @@ public abstract class MessageDigest extends MessageDigestSpi {
* Returns the provider associated with this {@code MessageDigest}.
*
* @return the provider associated with this {@code MessageDigest}
* @since Android 1.0
*/
public final Provider getProvider() {
return provider;
......@@ -349,7 +330,6 @@ public abstract class MessageDigest extends MessageDigestSpi {
* {@code 0} is returned.
*
* @return the digest length in bytes, or {@code 0}
* @since Android 1.0
*/
public final int getDigestLength() {
int l = engineGetDigestLength();
......@@ -367,12 +347,12 @@ public abstract class MessageDigest extends MessageDigestSpi {
}
}
@Override
public Object clone() throws CloneNotSupportedException {
if (this instanceof Cloneable) {
return super.clone();
} else {
throw new CloneNotSupportedException();
}
throw new CloneNotSupportedException();
}
/**
......@@ -380,7 +360,6 @@ public abstract class MessageDigest extends MessageDigestSpi {
*
* @param input
* the {@code ByteBuffer}
* @since Android 1.0
*/
public final void update(ByteBuffer input) {
engineUpdate(input);
......@@ -392,7 +371,7 @@ public abstract class MessageDigest extends MessageDigestSpi {
*
*/
private static class MessageDigestImpl extends MessageDigest {
// MessageDigestSpi implementation
private MessageDigestSpi spiImpl;
......@@ -405,38 +384,44 @@ public abstract class MessageDigest extends MessageDigestSpi {
}
// engineReset() implementation
@Override
protected void engineReset() {
spiImpl.engineReset();
}
// engineDigest() implementation
@Override
protected byte[] engineDigest() {
return spiImpl.engineDigest();
}
// engineGetDigestLength() implementation
@Override
protected int engineGetDigestLength() {
return spiImpl.engineGetDigestLength();
}
// engineUpdate() implementation
@Override
protected void engineUpdate(byte arg0) {
spiImpl.engineUpdate(arg0);
}
// engineUpdate() implementation
@Override
protected void engineUpdate(byte[] arg0, int arg1, int arg2) {
spiImpl.engineUpdate(arg0, arg1, arg2);
}
// Returns a clone if the spiImpl is cloneable
@Override
public Object clone() throws CloneNotSupportedException {
if (spiImpl instanceof Cloneable) {
MessageDigestSpi spi = (MessageDigestSpi) spiImpl.clone();
return new MessageDigestImpl(spi, getProvider(), getAlgorithm());
} else {
throw new CloneNotSupportedException();
}
throw new CloneNotSupportedException();
}
}
}
......@@ -15,11 +15,6 @@
* limitations under the License.
*/
/**
* @author Boris V. Kuznetsov
* @version $Revision$
*/
package java.security;
import java.nio.ByteBuffer;
......@@ -33,7 +28,6 @@ import org.apache.harmony.security.internal.nls.Messages;
* a fingerprint for a stream of bytes.
*
* @see MessageDigest
* @since Android 1.0
*/
public abstract class MessageDigestSpi {
......@@ -42,7 +36,6 @@ public abstract class MessageDigestSpi {
* 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;
......@@ -54,10 +47,9 @@ public abstract class MessageDigestSpi {
* @param input
* the {@code byte} to update this {@code MessageDigestSpi} with.
* @see #engineReset()
* @since Android 1.0
*/
protected abstract void engineUpdate(byte input);
/**
* Updates this {@code MessageDigestSpi} using the given {@code byte[]}.
*
......@@ -70,7 +62,6 @@ public abstract class MessageDigestSpi {
* @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);
......@@ -79,7 +70,6 @@ public abstract class MessageDigestSpi {
*
* @param input
* the {@code ByteBuffer}.
* @since Android 1.0
*/
protected void engineUpdate(ByteBuffer input) {
if (!input.hasRemaining()) {
......@@ -107,7 +97,6 @@ public abstract class MessageDigestSpi {
*
* @return the computed one way hash value.
* @see #engineReset()
* @since Android 1.0
*/
protected abstract byte[] engineDigest();
......@@ -129,7 +118,6 @@ public abstract class MessageDigestSpi {
* 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 {
......@@ -156,11 +144,10 @@ public abstract class MessageDigestSpi {
/**
* 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();
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
......
......@@ -15,18 +15,11 @@
* limitations under the License.
*/
/**
* @author Vera Y. Petrashkova
* @version $Revision$
*/
package java.security;
/**
* {@code NoSuchAlgorithmException} indicates that a requested algorithm could
* not be found.
*
* @since Android 1.0
*/
public class NoSuchAlgorithmException extends GeneralSecurityException {
......@@ -35,10 +28,9 @@ public class NoSuchAlgorithmException extends GeneralSecurityException {
/**
* Constructs a new instance of {@code NoSuchAlgorithmException} with the
* given message.
*
*
* @param msg
* the detail message for this exception.
* @since Android 1.0
*/
public NoSuchAlgorithmException(String msg) {
super(msg);
......@@ -46,8 +38,6 @@ public class NoSuchAlgorithmException extends GeneralSecurityException {
/**
* Constructs a new instance of {@code NoSuchAlgorithmException}.
*
* @since Android 1.0
*/
public NoSuchAlgorithmException() {
}
......@@ -55,12 +45,11 @@ public class NoSuchAlgorithmException extends GeneralSecurityException {
/**
* 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);
......@@ -69,10 +58,9 @@ public class NoSuchAlgorithmException extends GeneralSecurityException {
/**
* 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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment