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,18 +15,11 @@
* limitations under the License.
*/
/**
* @author Alexander V. Astapchuk
* @version $Revision$
*/
package java.security;
/**
* {@code AccessControlException} is thrown if the access control infrastructure
* denies protected access due to missing permissions.
*
* @since Android 1.0
*/
public class AccessControlException extends SecurityException {
......@@ -37,10 +30,9 @@ public class AccessControlException extends SecurityException {
/**
* Constructs a new instance of {@code AccessControlException} with the
* given message.
*
*
* @param message
* the detail message for this exception.
* @since Android 1.0
*/
public AccessControlException(String message) {
super(message);
......@@ -49,12 +41,11 @@ public class AccessControlException extends SecurityException {
/**
* Constructs a new instance of {@code AccessControlException} with the
* given message and the requested {@code Permission} which was not granted.
*
*
* @param message
* the detail message for the exception.
* @param perm
* the requested {@code Permission} which was not granted.
* @since Android 1.0
*/
public AccessControlException(String message, Permission perm) {
super(message);
......@@ -64,9 +55,8 @@ public class AccessControlException extends SecurityException {
/**
* Returns the requested permission that caused this Exception or {@code
* null} if there is no corresponding {@code Permission}.
*
*
* @return the requested permission that caused this Exception, maybe {@code null}.
* @since Android 1.0
*/
public Permission getPermission() {
return perm;
......
......@@ -15,11 +15,6 @@
* limitations under the License.
*/
/**
* @author Vera Y. Petrashkova
* @version $Revision$
*/
package java.security;
import java.security.spec.AlgorithmParameterSpec;
......@@ -30,8 +25,6 @@ import org.apache.harmony.security.internal.nls.Messages;
/**
* {@code AlgorithmParameterGenerator} is an engine class which is capable of
* generating parameters for the algorithm it was initialized with.
*
* @since Android 1.0
*/
public class AlgorithmParameterGenerator {
......@@ -56,14 +49,13 @@ public class AlgorithmParameterGenerator {
/**
* Constructs a new instance of {@code AlgorithmParameterGenerator} with the
* given arguments.
*
*
* @param paramGenSpi
* a concrete implementation, this engine instance delegates to.
* @param provider
* the provider.
* @param algorithm
* the name of the algorithm.
* @since Android 1.0
*/
protected AlgorithmParameterGenerator(
AlgorithmParameterGeneratorSpi paramGenSpi, Provider provider,
......@@ -75,9 +67,8 @@ public class AlgorithmParameterGenerator {
/**
* Returns the name of the algorithm.
*
*
* @return the name of the algorithm.
* @since Android 1.0
*/
public final String getAlgorithm() {
return algorithm;
......@@ -95,7 +86,6 @@ public class AlgorithmParameterGenerator {
* if the specified algorithm is not available.
* @throws NullPointerException
* if {@code algorithm} is {@code null}.
* @since Android 1.0
*/
public static AlgorithmParameterGenerator getInstance(String algorithm)
throws NoSuchAlgorithmException {
......@@ -127,7 +117,6 @@ public class AlgorithmParameterGenerator {
* if the specified provider is not available.
* @throws NullPointerException
* if {@code algorithm} is {@code null}.
* @since Android 1.0
*/
public static AlgorithmParameterGenerator getInstance(String algorithm,
String provider) throws NoSuchAlgorithmException,
......@@ -157,7 +146,6 @@ public class AlgorithmParameterGenerator {
* if the specified algorithm is not available.
* @throws NullPointerException
* if {@code algorithm} is {@code null}.
* @since Android 1.0
*/
public static AlgorithmParameterGenerator getInstance(String algorithm,
Provider provider) throws NoSuchAlgorithmException {
......@@ -178,10 +166,9 @@ public class AlgorithmParameterGenerator {
/**
* Returns the provider associated with this {@code
* AlgorithmParameterGenerator}.
*
*
* @return the provider associated with this {@code
* AlgorithmParameterGenerator}.
* @since Android 1.0
*/
public final Provider getProvider() {
return provider;
......@@ -191,10 +178,9 @@ public class AlgorithmParameterGenerator {
* Initializes this {@code AlgorithmParameterGenerator} with the given size.
* The default parameter set and a default {@code SecureRandom} instance
* will be used.
*
*
* @param size
* the size (in number of bits).
* @since Android 1.0
*/
public final void init(int size) {
spiImpl.engineInit(size, randm);
......@@ -204,12 +190,11 @@ public class AlgorithmParameterGenerator {
* Initializes this {@code AlgorithmParameterGenerator} with the given size
* and the given {@code SecureRandom}. The default parameter set will be
* used.
*
*
* @param size
* the size (in number of bits).
* @param random
* the source of randomness.
* @since Android 1.0
*/
public final void init(int size, SecureRandom random) {
spiImpl.engineInit(size, random);
......@@ -219,12 +204,11 @@ public class AlgorithmParameterGenerator {
* Initializes this {@code AlgorithmParameterGenerator} with the given {@code
* AlgorithmParameterSpec}. A default {@code SecureRandom} instance will be
* used.
*
*
* @param genParamSpec
* the parameters to use.
* @throws InvalidAlgorithmParameterException
* if the specified parameters are not supported.
* @since Android 1.0
*/
public final void init(AlgorithmParameterSpec genParamSpec)
throws InvalidAlgorithmParameterException {
......@@ -234,14 +218,13 @@ public class AlgorithmParameterGenerator {
/**
* Initializes this {@code AlgorithmParameterGenerator} with the given
* {@code AlgorithmParameterSpec} and the given {@code SecureRandom}.
*
*
* @param genParamSpec
* the parameters to use.
* @param random
* the source of randomness.
* @throws InvalidAlgorithmParameterException
* if the specified parameters are not supported.
* @since Android 1.0
*/
public final void init(AlgorithmParameterSpec genParamSpec,
SecureRandom random) throws InvalidAlgorithmParameterException {
......@@ -251,11 +234,10 @@ public class AlgorithmParameterGenerator {
/**
* Computes and returns {@code AlgorithmParameters} for this generator's
* algorithm.
*
*
* @return {@code AlgorithmParameters} for this generator's algorithm.
* @since Android 1.0
*/
public final AlgorithmParameters generateParameters() {
return spiImpl.engineGenerateParameters();
}
}
\ 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;
......@@ -29,14 +24,11 @@ import java.security.spec.AlgorithmParameterSpec;
* (SPI) definition for {@code AlgorithmParameterGenerator}.
*
* @see AlgorithmParameterGenerator
* @since Android 1.0
*/
public abstract class AlgorithmParameterGeneratorSpi {
/**
* Constructs a new instance of {@code AlgorithmParameterGeneratorSpi} .
*
* @since Android 1.0
*/
public AlgorithmParameterGeneratorSpi() {
}
......@@ -45,26 +37,24 @@ public abstract class AlgorithmParameterGeneratorSpi {
* Initializes this {@code AlgorithmParameterGeneratorSpi} with the given
* size and the given {@code SecureRandom}. The default parameter set
* will be used.
*
*
* @param size
* the size (in number of bits).
* @param random
* the source of randomness.
* @since Android 1.0
*/
protected abstract void engineInit(int size, SecureRandom random);
/**
* Initializes this {@code AlgorithmParameterGeneratorSpi} with the given
* {@code AlgorithmParameterSpec} and the given {@code SecureRandom}.
*
*
* @param genParamSpec
* the parameters to use.
* @param random
* the source of randomness.
* @throws InvalidAlgorithmParameterException
* if the specified parameters are not supported.
* @since Android 1.0
*/
protected abstract void engineInit(AlgorithmParameterSpec genParamSpec,
SecureRandom random) throws InvalidAlgorithmParameterException;
......@@ -72,9 +62,8 @@ public abstract class AlgorithmParameterGeneratorSpi {
/**
* Computes and returns {@code AlgorithmParameters} for this generator's
* algorithm.
*
*
* @return {@code AlgorithmParameters} for this generator's algorithm.
* @since Android 1.0
*/
protected abstract AlgorithmParameters engineGenerateParameters();
}
\ No newline at end of file
}
......@@ -15,11 +15,6 @@
* limitations under the License.
*/
/**
* @author Boris V. Kuznetsov
* @version $Revision$
*/
package java.security;
import java.io.IOException;
......@@ -33,8 +28,6 @@ import org.apache.harmony.security.internal.nls.Messages;
/**
* {@code AlgorithmParameters} is an engine class which provides algorithm
* parameters.
*
* @since Android 1.0
*/
public class AlgorithmParameters {
/**
......@@ -70,20 +63,16 @@ public class AlgorithmParameters {
/**
* Constructs a new instance of {@code AlgorithmParameters} with the given
* arguments.
*
*
* @param algPramSpi
* the concrete implementation.
* @param provider
* the security provider.
* @param algorithm
* the name of the algorithm.
* @since Android 1.0
*/
protected AlgorithmParameters(AlgorithmParametersSpi algPramSpi,
Provider provider, String algorithm) {
// BEGIN android-note
// renamed parameter
// END android-note
this.provider = provider;
this.algorithm = algorithm;
this.spiImpl = algPramSpi;
......@@ -92,7 +81,7 @@ public class AlgorithmParameters {
/**
* Returns a new instance of {@code AlgorithmParameters} for the specified
* algorithm.
*
*
* @param algorithm
* the name of the algorithm to use.
* @return a new instance of {@code AlgorithmParameters} for the specified
......@@ -101,7 +90,6 @@ public class AlgorithmParameters {
* if the specified algorithm is not available.
* @throws NullPointerException
* if {@code algorithm} is {@code null}.
* @since Android 1.0
*/
public static AlgorithmParameters getInstance(String algorithm)
throws NoSuchAlgorithmException {
......@@ -118,7 +106,7 @@ public class AlgorithmParameters {
/**
* Returns a new instance of {@code AlgorithmParameters} from the specified
* provider for the specified algorithm.
*
*
* @param algorithm
* the name of the algorithm to use.
* @param provider
......@@ -133,7 +121,6 @@ public class AlgorithmParameters {
* if {@code provider} is {@code null} or of length zero.
* @throws NullPointerException
* if {@code algorithm} is {@code null}.
* @since Android 1.0
*/
public static AlgorithmParameters getInstance(String algorithm,
String provider) throws NoSuchAlgorithmException,
......@@ -152,7 +139,7 @@ public class AlgorithmParameters {
/**
* Returns a new instance of {@code AlgorithmParameters} from the specified
* provider for the specified algorithm.
*
*
* @param algorithm
* the name of the algorithm to use.
* @param provider
......@@ -165,7 +152,6 @@ public class AlgorithmParameters {
* if {@code algorithm} is {@code null}.
* @throws IllegalArgumentException
* if {@code provider} is {@code null}.
* @since Android 1.0
*/
public static AlgorithmParameters getInstance(String algorithm,
Provider provider) throws NoSuchAlgorithmException {
......@@ -184,9 +170,8 @@ public class AlgorithmParameters {
/**
* Returns the provider associated with this {@code AlgorithmParameters}.
*
*
* @return the provider associated with this {@code AlgorithmParameters}.
* @since Android 1.0
*/
public final Provider getProvider() {
return provider;
......@@ -194,9 +179,8 @@ public class AlgorithmParameters {
/**
* Returns the name of the algorithm.
*
*
* @return the name of the algorithm.
* @since Android 1.0
*/
public final String getAlgorithm() {
return algorithm;
......@@ -205,14 +189,13 @@ public class AlgorithmParameters {
/**
* Initializes this {@code AlgorithmParameters} with the specified {@code
* AlgorithmParameterSpec}.
*
*
* @param paramSpec
* the parameter specification.
* @throws InvalidParameterSpecException
* if this {@code AlgorithmParameters} has already been
* initialized or the given {@code paramSpec} is not appropriate
* for initializing this {@code AlgorithmParameters}.
* @since Android 1.0
*/
public final void init(AlgorithmParameterSpec paramSpec)
throws InvalidParameterSpecException {
......@@ -228,13 +211,12 @@ public class AlgorithmParameters {
* Initializes this {@code AlgorithmParameters} with the specified {@code
* byte[]} using the default decoding format for parameters. The default
* encoding format is ASN.1.
*
*
* @param params
* the encoded parameters.
* @throws IOException
* if this {@code AlgorithmParameters} has already been
* initialized, or the parameter could not be encoded.
* @since Android 1.0
*/
public final void init(byte[] params) throws IOException {
if (initialized) {
......@@ -247,7 +229,7 @@ public class AlgorithmParameters {
/**
* Initializes this {@code AlgorithmParameters} with the specified {@code
* byte[]} using the specified decoding format.
*
*
* @param params
* the encoded parameters.
* @param format
......@@ -255,7 +237,6 @@ public class AlgorithmParameters {
* @throws IOException
* if this {@code AlgorithmParameters} has already been
* initialized, or the parameter could not be encoded.
* @since Android 1.0
*/
public final void init(byte[] params, String format) throws IOException {
if (initialized) {
......@@ -268,7 +249,7 @@ public class AlgorithmParameters {
/**
* Returns the {@code AlgorithmParameterSpec} for this {@code
* AlgorithmParameters}.
*
*
* @param paramSpec
* the type of the parameter specification in which this
* parameters should be converted.
......@@ -278,7 +259,6 @@ public class AlgorithmParameters {
* if this {@code AlgorithmParameters} has already been
* initialized, or if this parameters could not be converted to
* the specified class.
* @since Android 1.0
*/
public final <T extends AlgorithmParameterSpec> T getParameterSpec(Class<T> paramSpec)
throws InvalidParameterSpecException {
......@@ -292,12 +272,11 @@ public class AlgorithmParameters {
/**
* Returns this {@code AlgorithmParameters} in their default encoding
* format. The default encoding format is ASN.1.
*
*
* @return the encoded parameters.
* @throws IOException
* if this {@code AlgorithmParameters} has already been
* initialized, or if this parameters could not be encoded.
* @since Android 1.0
*/
public final byte[] getEncoded() throws IOException {
if (!initialized) {
......@@ -309,14 +288,13 @@ public class AlgorithmParameters {
/**
* Returns this {@code AlgorithmParameters} in the specified encoding
* format.
*
*
* @param format
* the name of the encoding format.
* @return the encoded parameters.
* @throws IOException
* if this {@code AlgorithmParameters} has already been
* initialized, or if this parameters could not be encoded.
* @since Android 1.0
*/
public final byte[] getEncoded(String format) throws IOException {
if (!initialized) {
......@@ -328,10 +306,10 @@ public class AlgorithmParameters {
/**
* Returns a string containing a concise, human-readable description of this
* {@code AlgorithmParameters}.
*
*
* @return a printable representation for this {@code AlgorithmParameters}.
* @since Android 1.0
*/
@Override
public final String toString() {
if (!initialized) {
return null;
......
......@@ -15,11 +15,6 @@
* limitations under the License.
*/
/**
* @author Boris V. Kuznetsov
* @version $Revision$
*/
package java.security;
import java.io.IOException;
......@@ -37,14 +32,13 @@ public abstract class AlgorithmParametersSpi {
/**
* Initializes this {@code AlgorithmParametersSpi} with the specified
* {@code AlgorithmParameterSpec}.
*
*
* @param paramSpec
* the parameter specification.
* @throws InvalidParameterSpecException
* if this {@code AlgorithmParametersSpi} has already been
* initialized or the given {@code paramSpec} is not appropriate
* for initializing this {@code AlgorithmParametersSpi}.
* @since Android 1.0
*/
protected abstract void engineInit(AlgorithmParameterSpec paramSpec)
throws InvalidParameterSpecException;
......@@ -53,20 +47,19 @@ public abstract class AlgorithmParametersSpi {
* Initializes this {@code AlgorithmParametersSpi} with the specified
* {@code byte[]} using the default decoding format for parameters. The
* default encoding format is ASN.1.
*
*
* @param params
* the encoded parameters.
* @throws IOException
* if this {@code AlgorithmParametersSpi} has already been
* initialized, or the parameter could not be encoded.
* @since Android 1.0
*/
protected abstract void engineInit(byte[] params) throws IOException;
/**
* Initializes this {@code AlgorithmParametersSpi} with the specified
* {@code byte[]} using the specified decoding format.
*
*
* @param params
* the encoded parameters.
* @param format
......@@ -74,7 +67,6 @@ public abstract class AlgorithmParametersSpi {
* @throws IOException
* if this {@code AlgorithmParametersSpi} has already been
* initialized, or the parameter could not be encoded.
* @since Android 1.0
*/
protected abstract void engineInit(byte[] params, String format)
throws IOException;
......@@ -82,7 +74,7 @@ public abstract class AlgorithmParametersSpi {
/**
* Returns the {@code AlgorithmParameterSpec} for this {@code
* AlgorithmParametersSpi}.
*
*
* @param paramSpec
* the type of the parameter specification in which this
* parameters should be converted.
......@@ -92,7 +84,6 @@ public abstract class AlgorithmParametersSpi {
* if this {@code AlgorithmParametersSpi} has already been
* initialized, or if this parameters could not be converted to
* the specified class.
* @since Android 1.0
*/
protected abstract <T extends AlgorithmParameterSpec> T engineGetParameterSpec(
Class<T> paramSpec) throws InvalidParameterSpecException;
......@@ -100,25 +91,23 @@ public abstract class AlgorithmParametersSpi {
/**
* Returns the parameters in their default encoding format. The default
* encoding format is ASN.1.
*
*
* @return the encoded parameters.
* @throws IOException
* if this {@code AlgorithmParametersSpi} has already been
* initialized, or if this parameters could not be encoded.
* @since Android 1.0
*/
protected abstract byte[] engineGetEncoded() throws IOException;
/**
* Returns the parameters in the specified encoding format.
*
*
* @param format
* the name of the encoding format.
* @return the encoded parameters.
* @throws IOException
* if this {@code AlgorithmParametersSpi} has already been
* initialized, or if this parameters could not be encoded.
* @since Android 1.0
*/
protected abstract byte[] engineGetEncoded(String format)
throws IOException;
......@@ -126,11 +115,10 @@ public abstract class AlgorithmParametersSpi {
/**
* Returns a string containing a concise, human-readable description of this
* {@code AlgorithmParametersSpi}.
*
*
* @return a printable representation for this {@code
* AlgorithmParametersSpi}.
* @since Android 1.0
*/
protected abstract String engineToString();
}
\ No newline at end of file
}
......@@ -22,11 +22,12 @@ package java.security;
* {@code AllPermission} represents the permission to perform any operation.
* Since its {@link #implies(Permission)} method always returns {@code true},
* granting this permission is equivalent to disabling security.
*
* @since Android 1.0
*/
public final class AllPermission extends Permission {
/**
* @serial
*/
private static final long serialVersionUID = -2916474571451318075L;
// Permission name
......@@ -40,12 +41,11 @@ public final class AllPermission extends Permission {
* version is provided for class {@code Policy} so that it has a consistent
* call pattern across all permissions. The name and action list are both
* ignored.
*
*
* @param name
* ignored.
* @param actions
* ignored.
* @since Android 1.0
*/
public AllPermission(String name, String actions) {
super(ALL_PERMISSIONS);
......@@ -53,8 +53,6 @@ public final class AllPermission extends Permission {
/**
* Constructs a new instance of {@code AllPermission}.
*
* @since Android 1.0
*/
public AllPermission() {
super(ALL_PERMISSIONS);
......@@ -65,15 +63,15 @@ public final class AllPermission extends Permission {
* equality and returns {@code true} if the specified object is equal,
* {@code false} otherwise. To be equal, the given object needs to be an
* instance of {@code AllPermission}.
*
*
* @param obj
* object to be compared for equality with this {@code
* AllPermission}.
* @return {@code true} if the specified object is equal to this {@code
* AllPermission}, otherwise {@code false}.
* @since Android 1.0
* @see #hashCode
*/
@Override
public boolean equals(Object obj) {
return (obj instanceof AllPermission);
}
......@@ -82,12 +80,12 @@ public final class AllPermission extends Permission {
* Returns the hash code value for this {@code AllPermission}. Returns the
* same hash code for {@code AllPermission}s that are equal to each other as
* required by the general contract of {@link Object#hashCode}.
*
*
* @return the hash code value for this {@code AllPermission}.
* @see Object#equals(Object)
* @see AllPermission#equals(Object)
* @since Android 1.0
*/
@Override
public int hashCode() {
return 1;
}
......@@ -96,10 +94,10 @@ public final class AllPermission extends Permission {
* Returns the actions associated with this {@code AllPermission}. Since
* {@code AllPermission} objects allow all actions, this method returns
* always the string "&lt;all actions&gt;".
*
*
* @return the actions associated with this {@code AllPermission}.
* @since Android 1.0
*/
@Override
public String getActions() {
return ALL_ACTIONS;
}
......@@ -107,12 +105,12 @@ public final class AllPermission extends Permission {
/**
* Indicates whether the given permission is implied by this permission.
* {@code AllPermission} objects imply all other permissions.
*
*
* @return always {@code true}.
* @param permission
* the permission to check.
* @since Android 1.0
*/
@Override
public boolean implies(Permission permission) {
return true;
}
......@@ -120,10 +118,10 @@ public final class AllPermission extends Permission {
/**
* Returns a new {@code PermissionCollection} for holding permissions of
* this class.
*
*
* @return a new {@code PermissionCollection}.
* @since Android 1.0
*/
@Override
public PermissionCollection newPermissionCollection() {
return new AllPermissionCollection();
}
......
......@@ -32,13 +32,9 @@ import org.apache.harmony.security.internal.nls.Messages;
* single added instance.
*
* @see AllPermission
* @since Android 1.0
*/
final class AllPermissionCollection extends PermissionCollection {
/**
* @com.intel.drl.spec_ref
*/
private static final long serialVersionUID = -4023755556366636806L;
private static final ObjectStreamField[] serialPersistentFields = { new ObjectStreamField(
......@@ -50,6 +46,7 @@ final class AllPermissionCollection extends PermissionCollection {
/**
* Adds an {@code AllPermission} to the collection.
*/
@Override
public void add(Permission permission) {
if (isReadOnly()) {
throw new SecurityException(Messages.getString("security.15")); //$NON-NLS-1$
......@@ -64,6 +61,7 @@ final class AllPermissionCollection extends PermissionCollection {
/**
* Returns the enumeration of the collection.
*/
@Override
public Enumeration<Permission> elements() {
return new SingletonEnumeration<Permission>(all);
}
......@@ -78,6 +76,7 @@ final class AllPermissionCollection extends PermissionCollection {
/**
* Constructor taking the single element.
* @param single the element
*/
public SingletonEnumeration(E single) {
element = single;
......@@ -112,6 +111,7 @@ final class AllPermissionCollection extends PermissionCollection {
* @param permission
* the permission to check.
*/
@Override
public boolean implies(Permission permission) {
return all != null;
}
......@@ -137,4 +137,4 @@ final class AllPermissionCollection extends PermissionCollection {
all = new AllPermission();
}
}
}
\ No newline at end of file
}
......@@ -15,11 +15,6 @@
* limitations under the License.
*/
/**
* @author Boris V. Kuznetsov
* @version $Revision$
*/
package java.security;
import javax.security.auth.Subject;
......@@ -29,11 +24,12 @@ import javax.security.auth.login.LoginException;
/**
* {@code AuthProvider} is an abstract superclass for Java Security {@code
* Provider} which provide login and logout.
*
* @since Android 1.0
*/
public abstract class AuthProvider extends Provider {
/**
* @serial
*/
private static final long serialVersionUID = 4197859053084546461L;
/**
......@@ -46,7 +42,6 @@ public abstract class AuthProvider extends Provider {
* the version of the provider.
* @param info
* a description of the provider.
* @since Android 1.0
*/
protected AuthProvider(String name, double version, String info) {
super(name, version, info);
......@@ -71,7 +66,6 @@ public abstract class AuthProvider extends Provider {
* @throws SecurityException
* if a {@code SecurityManager} is installed and the caller does
* not have permission to invoke this method.
* @since Android 1.0
*/
public abstract void login(Subject subject, CallbackHandler handler) throws LoginException;
......@@ -82,14 +76,12 @@ public abstract class AuthProvider extends Provider {
* the {@code SecurityPermission} {@code authProvider.NAME} (where NAME is
* the provider name) to be granted, otherwise a {@code SecurityException}
* will be thrown.
* </p>
*
*
* @throws LoginException
* if the logout fails.
* @throws SecurityException
* if a {@code SecurityManager} is installed and the caller does
* not have permission to invoke this method.
* @since Android 1.0
*/
public abstract void logout() throws LoginException;
......@@ -101,20 +93,18 @@ public abstract class AuthProvider extends Provider {
* If no handler is set, this {@code AuthProvider} uses the {@code
* CallbackHandler} specified by the {@code
* auth.login.defaultCallbackHandler} security property.
* </p><p>
* <p>
* If a {@code SecurityManager} is installed, code calling this method needs
* the {@code SecurityPermission} {@code authProvider.NAME} (where NAME is
* the provider name) to be granted, otherwise a {@code SecurityException}
* will be thrown.
* </p>
*
*
* @param handler
* the handler to obtain authentication information from the
* caller.
* @throws SecurityException
* if a {@code SecurityManager} is installed and the caller does
* not have permission to invoke this method.
* @since Android 1.0
*/
public abstract void setCallbackHandler(CallbackHandler handler);
}
......@@ -15,11 +15,6 @@
* limitations under the License.
*/
/**
* @author Alexey V. Varlamov
* @version $Revision$
*/
package java.security;
import java.io.IOException;
......@@ -38,14 +33,13 @@ import org.apache.harmony.security.internal.nls.Messages;
* For example:
*
* <pre>
* com.google.android.* grants all permissions under the com.google.android permission hierarchy
* * grants all permissions
* java.io.* grants all permissions under the java.io permission hierarchy
* * grants all permissions
* </pre>
* </p><p>
* <p>
* While this class ignores the action list in the
* {@link #BasicPermission(String, String)} constructor, subclasses may
* implement actions on top of this class.
* </p>
*/
public abstract class BasicPermission extends Permission implements
Serializable {
......@@ -55,12 +49,11 @@ public abstract class BasicPermission extends Permission implements
/**
* Constructs a new instance of {@code BasicPermission} with the specified
* name.
*
*
* @param name
* the name of the permission.
* @throws NullPointerException if {@code name} is {@code null}.
* @throws IllegalArgumentException if {@code name.length() == 0}.
* @since Android 1.0
*/
public BasicPermission(String name) {
super(name);
......@@ -70,7 +63,7 @@ public abstract class BasicPermission extends Permission implements
/**
* Constructs a new instance of {@code BasicPermission} with the specified
* name. The {@code action} parameter is ignored.
*
*
* @param name
* the name of the permission.
* @param action
......@@ -79,7 +72,6 @@ public abstract class BasicPermission extends Permission implements
* if {@code name} is {@code null}.
* @throws IllegalArgumentException
* if {@code name.length() == 0}.
* @since Android 1.0
*/
public BasicPermission(String name, String action) {
super(name);
......@@ -105,15 +97,14 @@ public abstract class BasicPermission extends Permission implements
* <p>
* The {@link #implies(Permission)} method should be used for making access
* control checks.
* </p>
*
*
* @param obj
* object to be compared for equality with this {@code
* BasicPermission}.
* @return {@code true} if the specified object is equal to this {@code
* BasicPermission}, otherwise {@code false}.
* @since Android 1.0
*/
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
......@@ -129,12 +120,12 @@ public abstract class BasicPermission extends Permission implements
* Returns the hash code value for this {@code BasicPermission}. Returns the
* same hash code for {@code BasicPermission}s that are equal to each other
* as required by the general contract of {@link Object#hashCode}.
*
*
* @return the hash code value for this {@code BasicPermission}.
* @see Object#equals(Object)
* @see BasicPermission#equals(Object)
* @since Android 1.0
*/
@Override
public int hashCode() {
return getName().hashCode();
}
......@@ -142,23 +133,23 @@ public abstract class BasicPermission extends Permission implements
/**
* Returns the actions associated with this permission. Since {@code
* BasicPermission} instances have no actions, an empty string is returned.
*
*
* @return an empty string.
* @since Android 1.0
*/
@Override
public String getActions() {
return ""; //$NON-NLS-1$
}
/**
* Indicates whether the specified permission is implied by this permission.
*
*
* @param permission
* the permission to check against this permission.
* @return {@code true} if the specified permission is implied by this
* permission, {@code false} otherwise.
* @since Android 1.0
*/
@Override
public boolean implies(Permission permission) {
if (permission != null && permission.getClass() == this.getClass()) {
return nameImplies(getName(), permission.getName());
......@@ -204,12 +195,11 @@ public abstract class BasicPermission extends Permission implements
* 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.
* </p>
*
*
* @return an empty {@link PermissionCollection} for holding permissions.
* @see BasicPermissionCollection
* @since Android 1.0
*/
@Override
public PermissionCollection newPermissionCollection() {
return new BasicPermissionCollection();
}
......@@ -222,4 +212,4 @@ public abstract class BasicPermission extends Permission implements
in.defaultReadObject();
checkName(this.getName());
}
}
\ No newline at end of file
}
......@@ -37,7 +37,6 @@ import org.apache.harmony.security.internal.nls.Messages;
*
* @see BasicPermission
* @see PermissionCollection
* @since Android 1.0
*/
final class BasicPermissionCollection extends PermissionCollection {
......@@ -63,6 +62,7 @@ final class BasicPermissionCollection extends PermissionCollection {
*
* @see java.security.PermissionCollection#add(java.security.Permission)
*/
@Override
public void add(Permission permission) {
if (isReadOnly()) {
throw new SecurityException(Messages.getString("security.15")); //$NON-NLS-1$
......@@ -82,8 +82,6 @@ final class BasicPermissionCollection extends PermissionCollection {
permission));
} else {
// this is the first element provided that another thread did not add
// BEGIN android-changed
// copied from a newer version of harmony
synchronized (this) {
if (permClass != null && inClass != permClass) {
throw new IllegalArgumentException(Messages.getString("security.16", //$NON-NLS-1$
......@@ -91,7 +89,6 @@ final class BasicPermissionCollection extends PermissionCollection {
}
permClass = inClass;
}
// END android-changed
}
String name = permission.getName();
......@@ -102,6 +99,7 @@ final class BasicPermissionCollection extends PermissionCollection {
/**
* Returns enumeration of contained elements.
*/
@Override
public Enumeration<Permission> elements() {
return Collections.enumeration(items.values());
}
......@@ -115,6 +113,7 @@ final class BasicPermissionCollection extends PermissionCollection {
* the permission to check.
* @see Permission
*/
@Override
public boolean implies(Permission permission) {
if (permission == null || permission.getClass() != permClass) {
return false;
......@@ -162,16 +161,10 @@ final class BasicPermissionCollection extends PermissionCollection {
* <dd>The class to which all {@code BasicPermission}s in this
* BasicPermissionCollection belongs.
* <dt>Hashtable&lt;K,V&gt; permissions
* <dd>The
*
* <pre>
* BasicPermission
* </pre>
*
* s in this {@code BasicPermissionCollection}. All {@code BasicPermission}s
* in the collection must belong to the same class. The Hashtable is indexed
* by the {@code BasicPermission} name; the value of the Hashtable entry is
* the permission.
* <dd>The {@code BasicPermission}s in this collection. All {@code
* BasicPermission}s in the collection must belong to the same class. The
* Hashtable is indexed by the {@code BasicPermission} name; the value of
* the Hashtable entry is the permission.
* </dl>
*/
private void writeObject(java.io.ObjectOutputStream out) throws IOException {
......@@ -191,8 +184,6 @@ final class BasicPermissionCollection extends PermissionCollection {
ObjectInputStream.GetField fields = in.readFields();
items = new HashMap<String, Permission>();
// BEGIN android-changed
// copied from a newer version of harmony
synchronized (this) {
permClass = (Class<? extends Permission>)fields.get("permClass", null); //$NON-NLS-1$
items.putAll((Hashtable<String, Permission>) fields.get(
......@@ -207,6 +198,5 @@ final class BasicPermissionCollection extends PermissionCollection {
throw new InvalidObjectException(Messages.getString("security.25")); //$NON-NLS-1$
}
}
// END android-changed
}
}
......@@ -15,15 +15,6 @@
* limitations under the License.
*/
/**
* @author Vera Y. Petrashkova
* @version $Revision$
*/
// BEGIN android-note
// Added Deprecated annotation.
// END android-note
package java.security;
import java.io.IOException;
......@@ -36,9 +27,8 @@ import java.io.OutputStream;
* validity of itself. It's in the responsibility of the application to verify
* the validity of its certificates.
*
* @deprecated Replaced by behavior in {@link javax.security.cert}
* @deprecated Replaced by behavior in {@link java.security.cert}
* @see java.security.cert.Certificate
* @since Android 1.0
*/
@Deprecated
public interface Certificate {
......@@ -47,7 +37,7 @@ public interface Certificate {
* Decodes a certificate from the given {@code InputStream}. The format of
* the data to encode must be that identified by {@link #getFormat()} and
* encoded by {@link #encode(OutputStream)}.
*
*
* @param stream
* the {@code InputStream} to read from.
* @throws KeyException
......@@ -56,7 +46,6 @@ public interface Certificate {
* if an exception is thrown by accessing the provided stream.
* @see #encode(OutputStream)
* @see #getFormat()
* @since Android 1.0
*/
public void decode(InputStream stream) throws KeyException, IOException;
......@@ -64,7 +53,7 @@ public interface Certificate {
* Encodes this certificate to an output stream. The
* {@link #decode(InputStream)} method must be able to decode the format
* written by this method.
*
*
* @param stream
* the {@code OutputStream} to encode this certificate to.
* @throws KeyException
......@@ -72,15 +61,13 @@ public interface Certificate {
* @throws IOException
* if an exception is thrown by accessing the provided stream.
* @see #decode(InputStream)
* @since Android 1.0
*/
public void encode(OutputStream stream) throws KeyException, IOException;
/**
* Returns a string identifying the format of this certificate.
*
*
* @return a string identifying the format of this certificate.
* @since Android 1.0
*/
public String getFormat();
......@@ -88,42 +75,38 @@ public interface Certificate {
* Returns the guarantor of this certificate. That guarantor guarantees,
* that the public key of this certificate is from the principal returned by
* {@link #getPrincipal()}.
*
*
* @return the guarantor of this certificate.
* @see #getPrincipal()
* @since Android 1.0
*/
public Principal getGuarantor();
/**
* Returns the principal of this certificate. The principal is guaranteed by
* the guarantor returned by {@link #getGuarantor()}.
*
*
* @return the principal of this certificate.
* @see #getGuarantor()
* @since Android 1.0
*/
public Principal getPrincipal();
/**
* Returns the public key of this certificate. The public key is guaranteed
* by the guarantor to belong to the principal.
*
*
* @return the public key of this certificate.
* @see #getGuarantor()
* @see Certificate#getPrincipal()
* @since Android 1.0
*/
public PublicKey getPublicKey();
/**
* Returns a string containing a concise, human-readable description of the
* this {@code Certificate}.
*
*
* @param detailed
* whether or not this method should return detailed information.
* @return a string representation of this certificate.
* @since Android 1.0
*/
public String toString(boolean detailed);
}
......@@ -15,11 +15,6 @@
* limitations under the License.
*/
/**
* @author Alexander V. Astapchuk
* @version $Revision$
*/
package java.security;
import java.io.Serializable;
......@@ -29,8 +24,6 @@ import org.apache.harmony.security.internal.nls.Messages;
/**
* {@code CodeSigner} represents a signer of code. Instances are immutable.
*
* @since Android 1.0
*/
public final class CodeSigner implements Serializable {
......@@ -45,7 +38,7 @@ public final class CodeSigner implements Serializable {
/**
* Constructs a new instance of {@code CodeSigner}.
*
*
* @param signerCertPath
* the certificate path associated with this code signer.
* @param timestamp
......@@ -53,7 +46,6 @@ public final class CodeSigner implements Serializable {
* null}.
* @throws NullPointerException
* if {@code signerCertPath} is {@code null}.
* @since Android 1.0
*/
public CodeSigner(CertPath signerCertPath, Timestamp timestamp) {
if (signerCertPath == null) {
......@@ -68,14 +60,14 @@ public final class CodeSigner implements Serializable {
* Returns {@code true} if the specified object is also an instance of
* {@code CodeSigner}, the two {@code CodeSigner} encapsulate the same
* certificate path and the same time stamp, if present in both.
*
*
* @param obj
* object to be compared for equality with this {@code
* CodeSigner}.
* @return {@code true} if the specified object is equal to this {@code
* CodeSigner}, otherwise {@code false}.
* @since Android 1.0
*/
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
......@@ -93,9 +85,8 @@ public final class CodeSigner implements Serializable {
/**
* Returns the certificate path associated with this {@code CodeSigner}.
*
*
* @return the certificate path associated with this {@code CodeSigner}.
* @since Android 1.0
*/
public CertPath getSignerCertPath() {
return signerCertPath;
......@@ -103,10 +94,9 @@ public final class CodeSigner implements Serializable {
/**
* Returns the time stamp associated with this {@code CodeSigner}.
*
*
* @return the time stamp associated with this {@code CodeSigner}, maybe
* {@code null}.
* @since Android 1.0
*/
public Timestamp getTimestamp() {
return timestamp;
......@@ -116,12 +106,12 @@ public final class CodeSigner implements Serializable {
* Returns the hash code value for this {@code CodeSigner}. Returns the same
* hash code for {@code CodeSigner}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 CodeSigner}.
* @see Object#equals(Object)
* @see CodeSigner#equals(Object)
* @since Android 1.0
*/
@Override
public int hashCode() {
if (hash == 0) {
hash = signerCertPath.hashCode()
......@@ -134,14 +124,13 @@ public final class CodeSigner implements Serializable {
* Returns a string containing a concise, human-readable description of the
* this {@code CodeSigner} including its first certificate and its time
* stamp, if present.
*
*
* @return a printable representation for this {@code CodeSigner}.
* @since Android 1.0
*/
@Override
public String toString() {
// There is no any special reason for '256' here, it's taken abruptly
// FIXME: 1.5 StringBuffer => StringBuilder
StringBuffer buf = new StringBuffer(256);
StringBuilder buf = new StringBuilder(256);
// The javadoc says nothing, and the others implementations behavior seems as
// dumping only the first certificate. Well, let's do the same.
buf.append("CodeSigner [").append(signerCertPath.getCertificates().get(0)); //$NON-NLS-1$
......@@ -151,4 +140,4 @@ public final class CodeSigner implements Serializable {
buf.append("]"); //$NON-NLS-1$
return buf.toString();
}
}
\ No newline at end of file
}
......@@ -15,11 +15,6 @@
* limitations under the License.
*/
/**
* @author Alexander V. Astapchuk
* @version $Revision$
*/
package java.security;
import java.io.ByteArrayInputStream;
......@@ -48,10 +43,9 @@ import org.apache.harmony.security.internal.nls.Messages;
* {@code CodeSource} encapsulates the location from where code is loaded and
* the certificates that were used to verify that code. This information is used
* by {@code SecureClassLoader} to define protection domains for loaded classes.
*
*
* @see SecureClassLoader
* @see ProtectionDomain
* @since Android 1.0
*/
public class CodeSource implements Serializable {
......@@ -76,14 +70,13 @@ public class CodeSource implements Serializable {
/**
* Constructs a new instance of {@code CodeSource} with the specified
* {@code URL} and the {@code Certificate}s.
*
*
* @param location
* the {@code URL} representing the location from where code is
* loaded, maybe {@code null}.
* @param certs
* the {@code Certificate} used to verify the code, loaded from
* the specified {@code location}, maybe {@code null}.
* @since Android 1.0
*/
public CodeSource(URL location, Certificate[] certs) {
this.location = location;
......@@ -96,14 +89,13 @@ public class CodeSource implements Serializable {
/**
* Constructs a new instance of {@code CodeSource} with the specified
* {@code URL} and the {@code CodeSigner}s.
*
*
* @param location
* the {@code URL} representing the location from where code is
* loaded, maybe {@code null}.
* @param signers
* the {@code CodeSigner}s of the code, loaded from the specified
* {@code location}. Maybe {@code null}.
* @since Android 1.0
*/
public CodeSource(URL location, CodeSigner[] signers) {
this.location = location;
......@@ -119,14 +111,14 @@ public class CodeSource implements Serializable {
* {@code CodeSource}, points to the same {@code URL} location and the two
* code sources encapsulate the same {@code Certificate}s. The order of the
* {@code Certificate}s is ignored by this method.
*
*
* @param obj
* object to be compared for equality with this {@code
* CodeSource}.
* @return {@code true} if the specified object is equal to this {@code
* CodeSource}, otherwise {@code false}.
* @since Android 1.0
*/
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
......@@ -169,11 +161,9 @@ public class CodeSource implements Serializable {
* <p>
* External modifications of the returned {@code Certificate[]} has no
* impact on this {@code CodeSource}.
* </p>
*
*
* @return the certificates of this {@code CodeSource} or {@code null} if
* there is none.
* @since Android 1.0
*/
public final Certificate[] getCertificates() {
getCertificatesNoClone();
......@@ -213,10 +203,9 @@ public class CodeSource implements Serializable {
* {@link #CodeSource(URL, Certificate[])} constructor was used to create
* this instance, the signers are obtained from the supplied certificates.
* Only X.509 certificates are analyzed.
*
*
* @return the signers of this {@code CodeSource}, or {@code null} if there
* is none.
* @since Android 1.0
*/
public final CodeSigner[] getCodeSigners() {
if (signers != null) {
......@@ -308,9 +297,8 @@ public class CodeSource implements Serializable {
/**
* Returns the location of this {@code CodeSource}.
*
*
* @return the location of this {@code CodeSource}, maybe {@code null}.
* @since Android 1.0
*/
public final URL getLocation() {
return location;
......@@ -321,12 +309,12 @@ public class CodeSource implements Serializable {
* Returns the same hash code for {@code CodeSource}s that are
* equal to each other as required by the general contract of
* {@link Object#hashCode}.
*
*
* @return the hash code value for this {@code CodeSource}.
* @see Object#equals(Object)
* @see CodeSource#equals(Object)
* @since Android 1.0
*/
@Override
public int hashCode() {
//
// hashCode() is undocumented there. Should we also use certs[i] to
......@@ -385,21 +373,20 @@ public class CodeSource implements Serializable {
* location file with the '/' appended to it.
* </ul>
* Examples for locations that imply the location
* "http://code.google.com/android/security.apk":
*
* "http://harmony.apache.org/milestones/M9/apache-harmony.jar":
*
* <pre>
* http:
* http://&#42;/android/*
* http://*.google.com/android/*
* http://code.google.com/android/-
* http://code.google.com/android/security.apk
* http://&#42;/milestones/M9/*
* http://*.apache.org/milestones/M9/*
* http://harmony.apache.org/milestones/-
* http://harmony.apache.org/milestones/M9/apache-harmony.jar
* </pre>
*
*
* @param cs
* the code source to check.
* @return {@code true} if the argument code source is implied by this
* {@code CodeSource}, otherwise {@code false}.
* @since Android 1.0
*/
public boolean implies(CodeSource cs) {
//
......@@ -551,10 +538,10 @@ public class CodeSource implements Serializable {
* Returns a string containing a concise, human-readable description of the
* this {@code CodeSource} including its location, its certificates and its
* signers.
*
*
* @return a printable representation for this {@code CodeSource}.
* @since Android 1.0
*/
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
buf.append("CodeSource, url="); //$NON-NLS-1$
......
......@@ -15,17 +15,10 @@
* limitations under the License.
*/
/**
* @author Vera Y. Petrashkova
* @version $Revision$
*/
package java.security;
/**
*{@code DigestException} is a general message digest exception.
*
*@since Android 1.0
*/
public class DigestException extends GeneralSecurityException {
......@@ -34,10 +27,9 @@ public class DigestException extends GeneralSecurityException {
/**
* Constructs a new instance of {@code DigestException} with the
* given message.
*
*
* @param msg
* the detail message for this exception.
* @since Android 1.0
*/
public DigestException(String msg) {
super(msg);
......@@ -45,8 +37,6 @@ public class DigestException extends GeneralSecurityException {
/**
* Constructs a new instance of {@code DigestException}.
*
* @since Android 1.0
*/
public DigestException() {
}
......@@ -54,12 +44,11 @@ public class DigestException extends GeneralSecurityException {
/**
* Constructs a new instance of {@code DigestException} with the
* given message and the cause.
*
*
* @param message
* the detail message for this exception.
* @param cause
* the exception which is the cause for this exception.
* @since Android 1.0
*/
public DigestException(String message, Throwable cause) {
super(message, cause);
......@@ -68,10 +57,9 @@ public class DigestException extends GeneralSecurityException {
/**
* Constructs a new instance of {@code DigestException} with the
* cause.
*
*
* @param cause
* the exception which is the cause for this exception.
* @since Android 1.0
*/
public DigestException(Throwable cause) {
super(cause);
......
......@@ -15,11 +15,6 @@
* limitations under the License.
*/
/**
* @author Vladimir N. Molotkov
* @version $Revision$
*/
package java.security;
import java.io.FilterInputStream;
......@@ -29,15 +24,11 @@ import java.io.InputStream;
/**
* {@code DigestInputStream} is a {@code FilterInputStream} which maintains an
* associated message digest.
*
* @since Android 1.0
*/
public class DigestInputStream extends FilterInputStream {
/**
* The message digest for this stream.
*
* @since Android 1.0
*/
protected MessageDigest digest;
......@@ -47,12 +38,11 @@ public class DigestInputStream extends FilterInputStream {
/**
* Constructs a new instance of this {@code DigestInputStream}, using the
* given {@code stream} and the {@code digest}.
*
*
* @param stream
* the input stream.
* @param digest
* the message digest.
* @since Android 1.0
*/
public DigestInputStream(InputStream stream, MessageDigest digest) {
super(stream);
......@@ -61,9 +51,8 @@ public class DigestInputStream extends FilterInputStream {
/**
* Returns the message digest for this stream.
*
*
* @return the message digest for this stream.
* @since Android 1.0
*/
public MessageDigest getMessageDigest() {
return digest;
......@@ -71,10 +60,9 @@ public class DigestInputStream extends FilterInputStream {
/**
* Sets the message digest which this stream will use.
*
*
* @param digest
* the message digest which this stream will use.
* @since Android 1.0
*/
public void setMessageDigest(MessageDigest digest) {
this.digest = digest;
......@@ -85,13 +73,12 @@ public class DigestInputStream extends FilterInputStream {
* for the byte if this function is {@link #on(boolean)}.
* <p>
* This operation is blocking.
* </p>
*
*
* @return the byte which was read or -1 at end of stream.
* @throws IOException
* if reading the source stream causes an {@code IOException}.
* @since Android 1.0
*/
@Override
public int read() throws IOException {
// read the next byte
int byteRead = in.read();
......@@ -111,8 +98,7 @@ public class DigestInputStream extends FilterInputStream {
* {@link #on(boolean)}.
* <p>
* This operation is blocking.
* </p>
*
*
* @param b
* the byte array in which to store the bytes
* @param off
......@@ -124,8 +110,8 @@ public class DigestInputStream extends FilterInputStream {
* filtered stream has been reached while reading
* @throws IOException
* if reading the source stream causes an {@code IOException}
* @since Android 1.0
*/
@Override
public int read(byte[] b, int off, int len) throws IOException {
// read next up to len bytes
int bytesRead = in.read(b, off, len);
......@@ -141,11 +127,11 @@ public class DigestInputStream extends FilterInputStream {
/**
* Enables or disables the digest function (default is on).
*
*
* @param on
* {@code true} if the digest should be computed, {@code false}
* otherwise.
* @since Android 1.0
* @see MessageDigest
*/
public void on(boolean on) {
isOn = on;
......@@ -154,10 +140,10 @@ public class DigestInputStream extends FilterInputStream {
/**
* Returns a string containing a concise, human-readable description of this
* {@code DigestInputStream} including the digest.
*
*
* @return a printable representation for this {@code DigestInputStream}.
* @since Android 1.0
*/
@Override
public String toString() {
return super.toString() + ", " + digest.toString() + //$NON-NLS-1$
(isOn ? ", is on" : ", is off"); //$NON-NLS-1$ //$NON-NLS-2$
......
......@@ -15,11 +15,6 @@
* limitations under the License.
*/
/**
* @author Vladimir N. Molotkov
* @version $Revision$
*/
package java.security;
import java.io.FilterOutputStream;
......@@ -34,8 +29,6 @@ public class DigestOutputStream extends FilterOutputStream {
/**
* The message digest for this stream.
*
* @since Android 1.0
*/
protected MessageDigest digest;
......@@ -45,12 +38,11 @@ public class DigestOutputStream extends FilterOutputStream {
/**
* Constructs a new instance of this {@code DigestOutputStream}, using the
* given {@code stream} and the {@code digest}.
*
*
* @param stream
* the output stream.
* @param digest
* the message digest.
* @since Android 1.0
*/
public DigestOutputStream(OutputStream stream, MessageDigest digest) {
super(stream);
......@@ -59,9 +51,8 @@ public class DigestOutputStream extends FilterOutputStream {
/**
* Returns the message digest for this stream.
*
*
* @return the message digest for this stream.
* @since Android 1.0
*/
public MessageDigest getMessageDigest() {
return digest;
......@@ -69,10 +60,9 @@ public class DigestOutputStream extends FilterOutputStream {
/**
* Sets the message digest which this stream will use.
*
*
* @param digest
* the message digest which this stream will use.
* @since Android 1.0
*/
public void setMessageDigest(MessageDigest digest) {
this.digest = digest;
......@@ -81,13 +71,13 @@ public class DigestOutputStream extends FilterOutputStream {
/**
* Writes the specified {@code int} to the stream. Updates the digest if
* this function is {@link #on(boolean)}.
*
*
* @param b
* the byte to be written.
* @throws IOException
* if writing to the stream causes a {@code IOException}
* @since Android 1.0
*/
@Override
public void write(int b) throws IOException {
// update digest only if digest functionality is on
if (isOn) {
......@@ -100,7 +90,7 @@ public class DigestOutputStream extends FilterOutputStream {
/**
* Writes {@code len} bytes into the stream, starting from the specified
* offset. Updates the digest if this function is {@link #on(boolean)}.
*
*
* @param b
* the buffer to write to.
* @param off
......@@ -109,8 +99,8 @@ public class DigestOutputStream extends FilterOutputStream {
* the number of bytes in {@code b} to write.
* @throws IOException
* if writing to the stream causes an {@code IOException}.
* @since Android 1.0
*/
@Override
public void write(byte[] b, int off, int len) throws IOException {
// update digest only if digest functionality is on
if (isOn) {
......@@ -122,11 +112,11 @@ public class DigestOutputStream extends FilterOutputStream {
/**
* Enables or disables the digest function (default is on).
*
*
* @param on
* {@code true} if the digest should be computed, {@code false}
* otherwise.
* @since Android 1.0
* @see MessageDigest
*/
public void on(boolean on) {
isOn = on;
......@@ -135,10 +125,10 @@ public class DigestOutputStream extends FilterOutputStream {
/**
* Returns a string containing a concise, human-readable description of this
* {@code DigestOutputStream} including the digest.
*
*
* @return a printable representation for this {@code DigestOutputStream}.
* @since Android 1.0
*/
@Override
public String toString() {
return super.toString() + ", " + digest.toString() + //$NON-NLS-1$
(isOn ? ", is on" : ", is off"); //$NON-NLS-1$ //$NON-NLS-2$
......
......@@ -15,11 +15,6 @@
* limitations under the License.
*/
/**
* @author Alexander V. Astapchuk
* @version $Revision$
*/
package java.security;
/**
......@@ -29,7 +24,6 @@ package java.security;
* @see AccessControlContext
* @see AccessControlContext#AccessControlContext(AccessControlContext,
* DomainCombiner)
* @since Android 1.0
*/
public interface DomainCombiner {
......@@ -37,7 +31,7 @@ public interface DomainCombiner {
* Returns a combination of the two provided {@code ProtectionDomain}
* arrays. Implementers can simply merge the two arrays into one, remove
* duplicates and perform other optimizations.
*
*
* @param current
* the protection domains of the current execution thread (since
* the most recent call to {@link AccessController#doPrivileged}
......@@ -47,7 +41,6 @@ public interface DomainCombiner {
* null}.
* @return a single {@code ProtectionDomain} array computed from the two
* provided arrays.
* @since Android 1.0
*/
ProtectionDomain[] combine(ProtectionDomain[] current,
ProtectionDomain[] assigned);
......
......@@ -15,18 +15,11 @@
* limitations under the License.
*/
/**
* @author Vera Y. Petrashkova
* @version $Revision$
*/
package java.security;
/**
* {@code GeneralSecurityException} is a general security exception and the
* superclass for all security specific exceptions.
*
* @since Android 1.0
*/
public class GeneralSecurityException extends Exception {
......@@ -35,10 +28,9 @@ public class GeneralSecurityException extends Exception {
/**
* Constructs a new instance of {@code GeneralSecurityException} with the
* given message.
*
*
* @param msg
* the detail message for this exception.
* @since Android 1.0
*/
public GeneralSecurityException(String msg) {
super(msg);
......@@ -46,8 +38,6 @@ public class GeneralSecurityException extends Exception {
/**
* Constructs a new instance of {@code GeneralSecurityException}.
*
* @since Android 1.0
*/
public GeneralSecurityException() {
}
......@@ -55,12 +45,11 @@ public class GeneralSecurityException extends Exception {
/**
* Constructs a new instance of {@code GeneralSecurityException} with the
* given message and the cause.
*
*
* @param message
* the detail message for this exception.
* @param cause
* the exception which is the cause for this exception.
* @since Android 1.0
*/
public GeneralSecurityException(String message, Throwable cause) {
super(message, cause);
......@@ -69,10 +58,9 @@ public class GeneralSecurityException extends Exception {
/**
* Constructs a new instance of {@code GeneralSecurityException} with the
* cause.
*
*
* @param cause
* the exception which is the cause for this exception.
* @since Android 1.0
*/
public GeneralSecurityException(Throwable cause) {
super(cause);
......
......@@ -15,17 +15,10 @@
* limitations under the License.
*/
/**
* @author Alexey V. Varlamov
* @version $Revision$
*/
package java.security;
/**
* {@code Guard} implementors protect access to other objects.
*
* @since Android 1.0
*/
public interface Guard {
......@@ -33,12 +26,11 @@ public interface Guard {
* Checks whether access to the specified {@code Object} should be granted.
* This method returns silently if access is granted, otherwise a {@code
* SecurityException} is thrown.
*
*
* @param object
* the object to be protected by this {@code Guard}.
* @throws SecurityException
* if access is not granted.
* @since Android 1.0
*/
public void checkGuard(Object object) throws SecurityException;
}
......@@ -15,11 +15,6 @@
* limitations under the License.
*/
/**
* @author Alexey V. Varlamov
* @version $Revision$
*/
package java.security;
import java.io.IOException;
......@@ -28,8 +23,6 @@ import java.io.Serializable;
/**
* {@code GuardedObject} controls access to an object, by checking all requests
* for the object with a {@code Guard}.
*
* @since Android 1.0
*/
public class GuardedObject implements Serializable {
......@@ -42,13 +35,12 @@ public class GuardedObject implements Serializable {
/**
* Constructs a new instance of {@code GuardedObject} which protects access
* to the specified {@code Object} using the specified {@code Guard}.
*
*
* @param object
* the {@code Object} to protect.
* @param guard
* the {@code Guard} which protects the specified {@code Object},
* maybe {@code null}.
* @since Android 1.0
*/
public GuardedObject(Object object, Guard guard) {
this.object = object;
......@@ -59,11 +51,10 @@ public class GuardedObject implements Serializable {
* Returns the guarded {@code Object} if the associated {@code Guard}
* permits access. If access is not granted, then a {@code
* SecurityException} is thrown.
*
*
* @return the guarded object.
* @exception SecurityException
* if access is not granted to the guarded object.
* @since Android 1.0
*/
public Object getObject() throws SecurityException {
if (guard != null) {
......
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