diff options
Diffstat (limited to 'security/src')
260 files changed, 2095 insertions, 4623 deletions
diff --git a/security/src/main/java/java/security/AccessControlException.java b/security/src/main/java/java/security/AccessControlException.java index 1710e77..ae23ab1 100644 --- a/security/src/main/java/java/security/AccessControlException.java +++ b/security/src/main/java/java/security/AccessControlException.java @@ -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; diff --git a/security/src/main/java/java/security/AlgorithmParameterGenerator.java b/security/src/main/java/java/security/AlgorithmParameterGenerator.java index 199efa1..6814813 100644 --- a/security/src/main/java/java/security/AlgorithmParameterGenerator.java +++ b/security/src/main/java/java/security/AlgorithmParameterGenerator.java @@ -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 +} diff --git a/security/src/main/java/java/security/AlgorithmParameterGeneratorSpi.java b/security/src/main/java/java/security/AlgorithmParameterGeneratorSpi.java index 9ddff23..44b3def 100644 --- a/security/src/main/java/java/security/AlgorithmParameterGeneratorSpi.java +++ b/security/src/main/java/java/security/AlgorithmParameterGeneratorSpi.java @@ -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 +} diff --git a/security/src/main/java/java/security/AlgorithmParameters.java b/security/src/main/java/java/security/AlgorithmParameters.java index aaefe1b..d659200 100644 --- a/security/src/main/java/java/security/AlgorithmParameters.java +++ b/security/src/main/java/java/security/AlgorithmParameters.java @@ -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; diff --git a/security/src/main/java/java/security/AlgorithmParametersSpi.java b/security/src/main/java/java/security/AlgorithmParametersSpi.java index 3bc8891..41b30bc 100644 --- a/security/src/main/java/java/security/AlgorithmParametersSpi.java +++ b/security/src/main/java/java/security/AlgorithmParametersSpi.java @@ -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 +} diff --git a/security/src/main/java/java/security/AllPermission.java b/security/src/main/java/java/security/AllPermission.java index f4b8aad..c12bb27 100644 --- a/security/src/main/java/java/security/AllPermission.java +++ b/security/src/main/java/java/security/AllPermission.java @@ -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 "<all actions>". - * + * * @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(); } diff --git a/security/src/main/java/java/security/AllPermissionCollection.java b/security/src/main/java/java/security/AllPermissionCollection.java index 000365d..5b28420 100644 --- a/security/src/main/java/java/security/AllPermissionCollection.java +++ b/security/src/main/java/java/security/AllPermissionCollection.java @@ -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 +} diff --git a/security/src/main/java/java/security/AuthProvider.java b/security/src/main/java/java/security/AuthProvider.java index 5a3be77..15324b3 100644 --- a/security/src/main/java/java/security/AuthProvider.java +++ b/security/src/main/java/java/security/AuthProvider.java @@ -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); } diff --git a/security/src/main/java/java/security/BasicPermission.java b/security/src/main/java/java/security/BasicPermission.java index 1d566ec..aa49cba 100644 --- a/security/src/main/java/java/security/BasicPermission.java +++ b/security/src/main/java/java/security/BasicPermission.java @@ -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 +} diff --git a/security/src/main/java/java/security/BasicPermissionCollection.java b/security/src/main/java/java/security/BasicPermissionCollection.java index eb80503..820ae7f 100644 --- a/security/src/main/java/java/security/BasicPermissionCollection.java +++ b/security/src/main/java/java/security/BasicPermissionCollection.java @@ -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<K,V> 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 } } diff --git a/security/src/main/java/java/security/Certificate.java b/security/src/main/java/java/security/Certificate.java index bf9a1ae..b30352d 100644 --- a/security/src/main/java/java/security/Certificate.java +++ b/security/src/main/java/java/security/Certificate.java @@ -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); } diff --git a/security/src/main/java/java/security/CodeSigner.java b/security/src/main/java/java/security/CodeSigner.java index 0719e8f..24d2b55 100644 --- a/security/src/main/java/java/security/CodeSigner.java +++ b/security/src/main/java/java/security/CodeSigner.java @@ -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 +} diff --git a/security/src/main/java/java/security/CodeSource.java b/security/src/main/java/java/security/CodeSource.java index f4da89c..96a4b8c5 100644 --- a/security/src/main/java/java/security/CodeSource.java +++ b/security/src/main/java/java/security/CodeSource.java @@ -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://*/android/* - * http://*.google.com/android/* - * http://code.google.com/android/- - * http://code.google.com/android/security.apk + * http://*/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$ diff --git a/security/src/main/java/java/security/DigestException.java b/security/src/main/java/java/security/DigestException.java index d579885..0d0a1ee 100644 --- a/security/src/main/java/java/security/DigestException.java +++ b/security/src/main/java/java/security/DigestException.java @@ -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); diff --git a/security/src/main/java/java/security/DigestInputStream.java b/security/src/main/java/java/security/DigestInputStream.java index 0db7613..26433fa 100644 --- a/security/src/main/java/java/security/DigestInputStream.java +++ b/security/src/main/java/java/security/DigestInputStream.java @@ -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$ diff --git a/security/src/main/java/java/security/DigestOutputStream.java b/security/src/main/java/java/security/DigestOutputStream.java index 858f8dd..f4cd659 100644 --- a/security/src/main/java/java/security/DigestOutputStream.java +++ b/security/src/main/java/java/security/DigestOutputStream.java @@ -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$ diff --git a/security/src/main/java/java/security/DomainCombiner.java b/security/src/main/java/java/security/DomainCombiner.java index 501c419..36433b3 100644 --- a/security/src/main/java/java/security/DomainCombiner.java +++ b/security/src/main/java/java/security/DomainCombiner.java @@ -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); diff --git a/security/src/main/java/java/security/GeneralSecurityException.java b/security/src/main/java/java/security/GeneralSecurityException.java index 2a1cacb..78fca29 100644 --- a/security/src/main/java/java/security/GeneralSecurityException.java +++ b/security/src/main/java/java/security/GeneralSecurityException.java @@ -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); diff --git a/security/src/main/java/java/security/Guard.java b/security/src/main/java/java/security/Guard.java index 1e4d270..b652054 100644 --- a/security/src/main/java/java/security/Guard.java +++ b/security/src/main/java/java/security/Guard.java @@ -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; } diff --git a/security/src/main/java/java/security/GuardedObject.java b/security/src/main/java/java/security/GuardedObject.java index a64d634..34a5113 100644 --- a/security/src/main/java/java/security/GuardedObject.java +++ b/security/src/main/java/java/security/GuardedObject.java @@ -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) { diff --git a/security/src/main/java/java/security/Identity.java b/security/src/main/java/java/security/Identity.java index 7111029..d55cd3a 100644 --- a/security/src/main/java/java/security/Identity.java +++ b/security/src/main/java/java/security/Identity.java @@ -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; } diff --git a/security/src/main/java/java/security/IdentityScope.java b/security/src/main/java/java/security/IdentityScope.java index 93729dc..60ab3e8 100644 --- a/security/src/main/java/java/security/IdentityScope.java +++ b/security/src/main/java/java/security/IdentityScope.java @@ -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$ } } diff --git a/security/src/main/java/java/security/InvalidAlgorithmParameterException.java b/security/src/main/java/java/security/InvalidAlgorithmParameterException.java index 0d8a607..26d9f97 100644 --- a/security/src/main/java/java/security/InvalidAlgorithmParameterException.java +++ b/security/src/main/java/java/security/InvalidAlgorithmParameterException.java @@ -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); diff --git a/security/src/main/java/java/security/InvalidKeyException.java b/security/src/main/java/java/security/InvalidKeyException.java index 95d864e..f08fc51 100644 --- a/security/src/main/java/java/security/InvalidKeyException.java +++ b/security/src/main/java/java/security/InvalidKeyException.java @@ -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); diff --git a/security/src/main/java/java/security/InvalidParameterException.java b/security/src/main/java/java/security/InvalidParameterException.java index ac10448..6ad4645 100644 --- a/security/src/main/java/java/security/InvalidParameterException.java +++ b/security/src/main/java/java/security/InvalidParameterException.java @@ -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() { } diff --git a/security/src/main/java/java/security/Key.java b/security/src/main/java/java/security/Key.java index 1359ab2..28d24ff 100644 --- a/security/src/main/java/java/security/Key.java +++ b/security/src/main/java/java/security/Key.java @@ -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(); } diff --git a/security/src/main/java/java/security/KeyException.java b/security/src/main/java/java/security/KeyException.java index b01f75b..721c896 100644 --- a/security/src/main/java/java/security/KeyException.java +++ b/security/src/main/java/java/security/KeyException.java @@ -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); diff --git a/security/src/main/java/java/security/KeyFactory.java b/security/src/main/java/java/security/KeyFactory.java index 7c4966f..21ad6b2 100644 --- a/security/src/main/java/java/security/KeyFactory.java +++ b/security/src/main/java/java/security/KeyFactory.java @@ -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 { diff --git a/security/src/main/java/java/security/KeyFactorySpi.java b/security/src/main/java/java/security/KeyFactorySpi.java index 7d3154e..0de00b2 100644 --- a/security/src/main/java/java/security/KeyFactorySpi.java +++ b/security/src/main/java/java/security/KeyFactorySpi.java @@ -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; diff --git a/security/src/main/java/java/security/KeyManagementException.java b/security/src/main/java/java/security/KeyManagementException.java index 295ec03..00a5b3c 100644 --- a/security/src/main/java/java/security/KeyManagementException.java +++ b/security/src/main/java/java/security/KeyManagementException.java @@ -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 +} diff --git a/security/src/main/java/java/security/KeyPair.java b/security/src/main/java/java/security/KeyPair.java index 6399427..b86593b 100644 --- a/security/src/main/java/java/security/KeyPair.java +++ b/security/src/main/java/java/security/KeyPair.java @@ -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; diff --git a/security/src/main/java/java/security/KeyPairGenerator.java b/security/src/main/java/java/security/KeyPairGenerator.java index 5682aa2..2a17e98 100644 --- a/security/src/main/java/java/security/KeyPairGenerator.java +++ b/security/src/main/java/java/security/KeyPairGenerator.java @@ -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 +} diff --git a/security/src/main/java/java/security/KeyPairGeneratorSpi.java b/security/src/main/java/java/security/KeyPairGeneratorSpi.java index 272c305..e2e22c1 100644 --- a/security/src/main/java/java/security/KeyPairGeneratorSpi.java +++ b/security/src/main/java/java/security/KeyPairGeneratorSpi.java @@ -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 +} diff --git a/security/src/main/java/java/security/KeyRep.java b/security/src/main/java/java/security/KeyRep.java index ec1d364..29ccd22 100644 --- a/security/src/main/java/java/security/KeyRep.java +++ b/security/src/main/java/java/security/KeyRep.java @@ -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. */ diff --git a/security/src/main/java/java/security/KeyStore.java b/security/src/main/java/java/security/KeyStore.java index 699a9df..02ac01d 100644 --- a/security/src/main/java/java/security/KeyStore.java +++ b/security/src/main/java/java/security/KeyStore.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - package java.security; import java.io.File; @@ -29,6 +24,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.security.cert.Certificate; import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; import java.util.Arrays; import java.util.Date; import java.util.Enumeration; @@ -46,14 +42,12 @@ import org.apache.harmony.security.internal.nls.Messages; * {@code KeyStore} is responsible for maintaining cryptographic keys and their * owners. * <p> - * The type of the system key store can be changed by setting the {@code + * The type of the system key store can be changed by setting the {@code * 'keystore.type'} property in the file named {@code * JAVA_HOME/lib/security/java.security}. - * </p> - * + * * @see Certificate * @see PrivateKey - * @since Android 1.0 */ public class KeyStore { @@ -88,14 +82,13 @@ public class KeyStore { /** * Constructs a new instance of {@code KeyStore} with the given arguments. - * + * * @param keyStoreSpi * the concrete key store. * @param provider * the provider. * @param type * the type of the {@code KeyStore} to be constructed. - * @since Android 1.0 */ protected KeyStore(KeyStoreSpi keyStoreSpi, Provider provider, String type) { this.type = type; @@ -118,7 +111,7 @@ public class KeyStore { /** * Returns a new instance of {@code KeyStore} with the specified type. - * + * * @param type * the type of the returned {@code KeyStore}. * @return a new instance of {@code KeyStore} with the specified type. @@ -128,7 +121,6 @@ public class KeyStore { * @throws NullPointerException * if {@code type} is {@code null}. * @see #getDefaultType - * @since Android 1.0 */ public static KeyStore getInstance(String type) throws KeyStoreException { if (type == null) { @@ -147,7 +139,7 @@ public class KeyStore { /** * Returns a new instance of {@code KeyStore} from the specified provider * with the given type. - * + * * @param type * the type of the returned {@code KeyStore}. * @param provider @@ -161,8 +153,10 @@ public class KeyStore { * if the specified provider is not available. * @throws IllegalArgumentException * if {@code provider} is {@code null} or the empty string. + * @throws NullPointerException + * if {@code type} is {@code null} (instead of + * NoSuchAlgorithmException) as in 1.4 release * @see #getDefaultType - * @since Android 1.0 */ public static KeyStore getInstance(String type, String provider) throws KeyStoreException, NoSuchProviderException { @@ -183,7 +177,7 @@ public class KeyStore { /** * Returns a new instance of {@code KeyStore} from the specified provider * with the given type. - * + * * @param type * the type of the returned {@code KeyStore}. * @param provider @@ -195,8 +189,10 @@ public class KeyStore { * KeyStore}. * @throws IllegalArgumentException * if {@code provider} is {@code null} or the empty string. + * @throws NullPointerException + * if {@code type} is {@code null} (instead of + * NoSuchAlgorithmException) as in 1.4 release * @see #getDefaultType - * @since Android 1.0 */ public static KeyStore getInstance(String type, Provider provider) throws KeyStoreException { @@ -225,10 +221,8 @@ public class KeyStore { * The default is specified in the {@code 'keystore.type'} property in the * file named {@code JAVA_HOME/lib/security/java.security}. If this property * is not set, {@code "jks"} will be used. - * </p> - * + * * @return the default type for {@code KeyStore} instances - * @since Android 1.0 */ public static final String getDefaultType() { String dt = AccessController.doPrivileged( @@ -243,9 +237,8 @@ public class KeyStore { /** * Returns the provider associated with this {@code KeyStore}. - * + * * @return the provider associated with this {@code KeyStore}. - * @since Android 1.0 */ public final Provider getProvider() { return provider; @@ -253,9 +246,8 @@ public class KeyStore { /** * Returns the type of this {@code KeyStore}. - * + * * @return the type of this {@code KeyStore}. - * @since Android 1.0 */ public final String getType() { return type; @@ -264,7 +256,7 @@ public class KeyStore { /** * 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 @@ -277,7 +269,6 @@ public class KeyStore { * if the algorithm for recovering the key is not available. * @throws UnrecoverableKeyException * if the key can not be recovered. - * @since Android 1.0 */ public final Key getKey(String alias, char[] password) throws KeyStoreException, NoSuchAlgorithmException, @@ -292,14 +283,13 @@ public class KeyStore { /** * Returns the certificate chain for the entry with the given alias. - * + * * @param alias * the alias for the entry. * @return the certificate chain for the entry with the given alias, or * {@code null} if the specified alias is not bound to an entry. * @throws KeyStoreException * if this {@code KeyStore} is not initialized. - * @since Android 1.0 */ public final Certificate[] getCertificateChain(String alias) throws KeyStoreException { @@ -313,14 +303,13 @@ public class KeyStore { /** * Returns the trusted certificate for the entry with the given alias. - * + * * @param alias * the alias for the entry. * @return the trusted certificate for the entry with the given alias, or * {@code null} if the specified alias is not bound to an entry. * @throws KeyStoreException * if this {@code KeyStore} is not initialized. - * @since Android 1.0 */ public final Certificate getCertificate(String alias) throws KeyStoreException { @@ -334,14 +323,13 @@ public class KeyStore { /** * Returns the creation date of the entry with the given alias. - * + * * @param alias * the alias for the entry. * @return the creation date, or {@code null} if the specified alias is not * bound to an entry. * @throws KeyStoreException * if this {@code KeyStore} is not initialized. - * @since Android 1.0 */ public final Date getCreationDate(String alias) throws KeyStoreException { if (!isInit) { @@ -356,8 +344,7 @@ public class KeyStore { * 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 @@ -371,7 +358,8 @@ public class KeyStore { * @throws IllegalArgumentException * if {@code key} is a {@code PrivateKey} and {@code chain} does * not contain any certificates. - * @since Android 1.0 + * @throws NullPointerException + * if {@code alias} is {@code null}. */ public final void setKeyEntry(String alias, Key key, char[] password, Certificate[] chain) throws KeyStoreException { @@ -394,13 +382,11 @@ public class KeyStore { * Associates the given alias with a key and a certificate chain. * <p> * If the specified alias already exists, it will be reassigned. - * </p> * <p> * If this {@code KeyStore} is of type {@code "jks"}, {@code key} must be * encoded conform to the PKS#8 standard as an * {@link javax.crypto.EncryptedPrivateKeyInfo}. - * </p> - * + * * @param alias * the alias for the key. * @param key @@ -408,11 +394,13 @@ public class KeyStore { * @param chain * the certificate chain. * @throws KeyStoreException - * if this {@code KeyStore} is not initialized. + * if this {@code KeyStore} is not initialized or if {@code key} + * is null. * @throws IllegalArgumentException * if {@code key} is a {@code PrivateKey} and {@code chain} * does. - * @since Android 1.0 + * @throws NullPointerException + * if {@code alias} is {@code null}. */ public final void setKeyEntry(String alias, byte[] key, Certificate[] chain) throws KeyStoreException { @@ -428,8 +416,7 @@ public class KeyStore { * 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 @@ -438,7 +425,8 @@ public class KeyStore { * if this {@code KeyStore} is not initialized, or an existing * alias is not associated to an entry containing a trusted * certificate, or this method fails for any other reason. - * @since Android 1.0 + * @throws NullPointerException + * if {@code alias} is {@code null}. */ public final void setCertificateEntry(String alias, Certificate cert) throws KeyStoreException { @@ -453,32 +441,35 @@ public class KeyStore { /** * Deletes the entry identified with the given alias from this {@code * KeyStore}. - * + * * @param alias * the alias for the entry. * @throws KeyStoreException * if this {@code KeyStore} is not initialized, or if the entry * can not be deleted. - * @since Android 1.0 + * @throws NullPointerException + * if {@code alias} is {@code null}. */ public final void deleteEntry(String alias) throws KeyStoreException { - // BEGIN android-changed if (!isInit) { + // BEGIN android-changed throwNotInitialized(); + // END android-changed + } + if (alias == null) { + throw new NullPointerException(Messages.getString("security.3F")); //$NON-NLS-1$ } - // END android-changed implSpi.engineDeleteEntry(alias); } /** * Returns an {@code Enumeration} over all alias names stored in this * {@code KeyStore}. - * + * * @return an {@code Enumeration} over all alias names stored in this * {@code KeyStore}. * @throws KeyStoreException * if this {@code KeyStore} is not initialized. - * @since Android 1.0 */ public final Enumeration<String> aliases() throws KeyStoreException { if (!isInit) { @@ -491,13 +482,14 @@ public class KeyStore { /** * Indicates whether the given alias is present in this {@code KeyStore}. - * + * * @param alias * the alias of an entry. * @return {@code true} if the alias exists, {@code false} otherwise. * @throws KeyStoreException * if this {@code KeyStore} is not initialized. - * @since Android 1.0 + * @throws NullPointerException + * if {@code alias} is {@code null}. */ public final boolean containsAlias(String alias) throws KeyStoreException { if (!isInit) { @@ -513,11 +505,10 @@ public class KeyStore { /** * Returns the number of entries stored in this {@code KeyStore}. - * + * * @return the number of entries stored in this {@code KeyStore}. * @throws KeyStoreException * if this {@code KeyStore} is not initialized. - * @since Android 1.0 */ public final int size() throws KeyStoreException { if (!isInit) { @@ -531,56 +522,63 @@ public class KeyStore { /** * Indicates whether the specified alias is associated with either a * {@link PrivateKeyEntry} or a {@link SecretKeyEntry}. - * + * * @param alias * the alias of an entry. * @return {@code true} if the given alias is associated with a key entry. * @throws KeyStoreException * if this {@code KeyStore} is not initialized. - * @since Android 1.0 + * @throws NullPointerException + * if {@code alias} is {@code null}. */ public final boolean isKeyEntry(String alias) throws KeyStoreException { - // BEGIN android-changed if (!isInit) { + // BEGIN android-changed throwNotInitialized(); + // END android-changed + } + if (alias == null) { + throw new NullPointerException(Messages.getString("security.3F")); //$NON-NLS-1$ } - // END android-changed return implSpi.engineIsKeyEntry(alias); } /** * Indicates whether the specified alias is associated with a * {@link TrustedCertificateEntry}. - * + * * @param alias * the alias of an entry. * @return {@code true} if the given alias is associated with a certificate * entry. * @throws KeyStoreException * if this {@code KeyStore} is not initialized. - * @since Android 1.0 + * @throws NullPointerException + * if {@code alias} is {@code null}. */ public final boolean isCertificateEntry(String alias) throws KeyStoreException { - // BEGIN android-changed if (!isInit) { + // BEGIN android-changed throwNotInitialized(); + // END android-changed + } + if (alias == null) { + throw new NullPointerException(Messages.getString("security.3F")); //$NON-NLS-1$ } - // END android-changed return implSpi.engineIsCertificateEntry(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. * @throws KeyStoreException * if this {@code KeyStore} is not initialized. - * @since Android 1.0 */ public final String getCertificateAlias(Certificate cert) throws KeyStoreException { @@ -596,7 +594,7 @@ public class KeyStore { * Writes this {@code KeyStore} 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 @@ -610,7 +608,6 @@ public class KeyStore { * @throws CertificateException * if an exception occurred while storing the certificates of * this {@code KeyStore}. - * @since Android 1.0 */ public final void store(OutputStream stream, char[] password) throws KeyStoreException, IOException, NoSuchAlgorithmException, @@ -620,23 +617,15 @@ public class KeyStore { throwNotInitialized(); // END android-changed } - // BEGIN android-removed - // copied from a newer version of harmony - // Just delegate stream and password to implSpi - // if (stream == null) { - // throw new IOException(Messages.getString("security.51")); //$NON-NLS-1$ - // } - // if (password == null) { - // throw new IOException(Messages.getString("security.50")); //$NON-NLS-1$ - // } - // END android-removed + + //Just delegate stream and password to implSpi implSpi.engineStore(stream, password); } /** * Stores this {@code KeyStore} using the specified {@code * LoadStoreParameter}. - * + * * @param param * the {@code LoadStoreParameter} that specifies how to store * this {@code KeyStore}, maybe {@code null}. @@ -651,7 +640,6 @@ public class KeyStore { * this {@code KeyStore}. * @throws IllegalArgumentException * if the given {@link LoadStoreParameter} is not recognized. - * @since Android 1.0 */ public final void store(LoadStoreParameter param) throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException { @@ -669,7 +657,7 @@ public class KeyStore { * {@code KeyStore} or to initialize a {@code KeyStore} which does not rely * on an {@code InputStream}. This {@code KeyStore} utilizes the given * password to verify the stored data. - * + * * @param stream * the {@code InputStream} to load this {@code KeyStore}'s data * from or {@code null}. @@ -682,7 +670,6 @@ public class KeyStore { * @throws CertificateException * if an exception occurred while loading the certificates of * this {@code KeyStore}. - * @since Android 1.0 */ public final void load(InputStream stream, char[] password) throws IOException, NoSuchAlgorithmException, CertificateException { @@ -693,7 +680,7 @@ public class KeyStore { /** * Loads this {@code KeyStore} using the specified {@code * LoadStoreParameter}. - * + * * @param param * the {@code LoadStoreParameter} that specifies how to load this * {@code KeyStore}, maybe {@code null}. @@ -706,7 +693,6 @@ public class KeyStore { * this {@code KeyStore}. * @throws IllegalArgumentException * if the given {@link LoadStoreParameter} is not recognized. - * @since Android 1.0 */ public final void load(LoadStoreParameter param) throws IOException, NoSuchAlgorithmException, CertificateException { @@ -717,7 +703,7 @@ public class KeyStore { /** * Returns the {@code Entry} with the given alias, using the specified * {@code ProtectionParameter}. - * + * * @param alias * the alias of the requested entry. * @param param @@ -731,7 +717,8 @@ public class KeyStore { * if the entry can not be recovered. * @throws KeyStoreException * if this {@code KeyStore} is not initialized. - * @since Android 1.0 + * @throws NullPointerException + * if {@code alias} is {@code null}. */ public final Entry getEntry(String alias, ProtectionParameter param) throws NoSuchAlgorithmException, UnrecoverableEntryException, @@ -753,8 +740,7 @@ public class KeyStore { * specified {@code ProtectionParameter}. * <p> * If the specified alias already exists, it will be reassigned. - * </p> - * + * * @param alias * the alias for the entry. * @param entry @@ -763,7 +749,9 @@ public class KeyStore { * the {@code ProtectionParameter} to protect the entry. * @throws KeyStoreException * if this {@code KeyStore} is not initialized. - * @since Android 1.0 + * @throws NullPointerException + * if {@code alias} is {@code null} or {@code entry} is {@code + * null}. */ public final void setEntry(String alias, Entry entry, ProtectionParameter param) throws KeyStoreException { @@ -784,7 +772,7 @@ public class KeyStore { /** * Indicates whether the entry for the given alias is assignable to the * provided {@code Class}. - * + * * @param alias * the alias for the entry. * @param entryClass @@ -793,7 +781,6 @@ public class KeyStore { * the specified {@code entryClass}. * @throws KeyStoreException * if this {@code KeyStore} is not initialized. - * @since Android 1.0 */ public final boolean entryInstanceOf(String alias, Class<? extends KeyStore.Entry> entryClass) @@ -815,25 +802,20 @@ public class KeyStore { /** * {@code Builder} is used to construct new instances of {@code KeyStore}. - * - * @since Android 1.0 */ public abstract static class Builder { /** * Constructs a new instance of {@code Builder}. - * - * @since Android 1.0 */ protected Builder() { } /** * Returns the {@code KeyStore} created by this {@code Builder}. - * + * * @return the {@code KeyStore} created by this {@code Builder}. * @throws KeyStoreException * if an error occurred during construction. - * @since Android 1.0 */ public abstract KeyStore getKeyStore() throws KeyStoreException; @@ -841,7 +823,7 @@ public class KeyStore { * Returns the {@code ProtectionParameter} to be used when a {@code * Entry} with the specified alias is requested. Before this method is * invoked, {@link #getKeyStore()} must be called. - * + * * @param alias * the alias for the entry. * @return the {@code ProtectionParameter} to be used when a {@code @@ -854,18 +836,14 @@ public class KeyStore { * invocation of this method. * @throws NullPointerException * if {@code alias} is {@code null}. - * @since Android 1.0 */ public abstract ProtectionParameter getProtectionParameter(String alias) throws KeyStoreException; - // BEGIN android-note - // renamed parameter - // END android-note /** * Returns a new {@code Builder} that holds the given {@code KeyStore} * and the given {@code ProtectionParameter}. - * + * * @param keyStore * the {@code KeyStore} to be held. * @param protectionParameter @@ -878,7 +856,6 @@ public class KeyStore { * {@code null}. * @throws IllegalArgumentException * if the given {@code KeyStore} is not initialized. - * @since Android 1.0 */ public static Builder newInstance(KeyStore keyStore, ProtectionParameter protectionParameter) { @@ -903,8 +880,7 @@ public class KeyStore { * If {@code provider} is {@code null}, all installed providers are * searched, otherwise the key store from the specified provider is * used. - * </p> - * + * * @param type * the type of the {@code KeyStore} to be constructed. * @param provider @@ -926,7 +902,6 @@ public class KeyStore { * {@code PasswordProtection} or {@code * CallbackHandlerProtection}, {@code file} is not a file or * does not exist at all. - * @since Android 1.0 */ public static Builder newInstance(String type, Provider provider, File file, ProtectionParameter protectionParameter) { @@ -965,8 +940,7 @@ public class KeyStore { * If {@code provider} is {@code null}, all installed providers are * searched, otherwise the key store from the specified provider is * used. - * </p> - * + * * @param type * the type of the {@code KeyStore} to be constructed. * @param provider @@ -985,7 +959,6 @@ public class KeyStore { * {@code PasswordProtection} or {@code * CallbackHandlerProtection}, {@code file} is not a file or * does not exist at all. - * @since Android 1.0 */ public static Builder newInstance(String type, Provider provider, ProtectionParameter protectionParameter) { @@ -1062,6 +1035,7 @@ public class KeyStore { // // Result KeyStore object is returned. // + @Override public synchronized KeyStore getKeyStore() throws KeyStoreException { // If KeyStore was created but in final block some exception was // thrown @@ -1121,8 +1095,7 @@ public class KeyStore { isGetKeyStore = true; - keyStore = ks; - return keyStore; + return ks; } catch (KeyStoreException e) { // Store exception throw lastException = e; @@ -1139,6 +1112,7 @@ public class KeyStore { // Return: ProtectionParameter to get Entry which was saved in // KeyStore with defined alias // + @Override public synchronized ProtectionParameter getProtectionParameter( String alias) throws KeyStoreException { if (alias == null) { @@ -1151,13 +1125,8 @@ public class KeyStore { } } - // BEGIN android-note - // Added "static" to the class declaration below. - // END android-note /* * Implementation of LoadStoreParameter interface - * - * @author Vera Petrashkova */ private static class TmpLSParameter implements LoadStoreParameter { @@ -1166,6 +1135,7 @@ public class KeyStore { /** * Creates TmpLoadStoreParameter object + * @param protPar protection parameter */ public TmpLSParameter(ProtectionParameter protPar) { this.protPar = protPar; @@ -1183,8 +1153,6 @@ public class KeyStore { /** * {@code CallbackHandlerProtection} is a {@code ProtectionParameter} that * encapsulates a {@link CallbackHandler}. - * - * @since Android 1.0 */ public static class CallbackHandlerProtection implements ProtectionParameter { @@ -1194,12 +1162,11 @@ public class KeyStore { /** * Constructs a new instance of {@code CallbackHandlerProtection} with * the {@code CallbackHandler}. - * + * * @param handler * the {@code CallbackHandler}. * @throws NullPointerException * if {@code handler} is {@code null}. - * @since Android 1.0 */ public CallbackHandlerProtection(CallbackHandler handler) { if (handler == null) { @@ -1210,9 +1177,8 @@ public class KeyStore { /** * Returns the {@code CallbackHandler}. - * + * * @return the {@code CallbackHandler}. - * @since Android 1.0 */ public CallbackHandler getCallbackHandler() { return callbackHandler; @@ -1222,8 +1188,6 @@ public class KeyStore { /** * {@code Entry} is the common marker interface for a {@code KeyStore} * entry. - * - * @since Android 1.0 */ public static interface Entry { } @@ -1231,19 +1195,17 @@ public class KeyStore { /** * {@code LoadStoreParameter} represents a parameter that specifies how a * {@code KeyStore} can be loaded and stored. - * + * * @see KeyStore#load(LoadStoreParameter) * @see KeyStore#store(LoadStoreParameter) - * @since Android 1.0 */ public static interface LoadStoreParameter { /** * Returns the {@code ProtectionParameter} which is used to protect data * in the {@code KeyStore}. - * + * * @return the {@code ProtectionParameter} which is used to protect data * in the {@code KeyStore}, maybe {@code null}. - * @since Android 1.0 */ public ProtectionParameter getProtectionParameter(); } @@ -1251,8 +1213,6 @@ public class KeyStore { /** * {@code PasswordProtection} is a {@code ProtectionParameter} that protects * a {@code KeyStore} using a password. - * - * @since Android 1.0 */ public static class PasswordProtection implements ProtectionParameter, Destroyable { @@ -1266,27 +1226,22 @@ public class KeyStore { * Constructs a new instance of {@code PasswordProtection} with a * password. A copy of the password is stored in the new {@code * PasswordProtection} object. - * + * * @param password * the password, maybe {@code null}. - * @since Android 1.0 */ public PasswordProtection(char[] password) { - // BEGIN android-changed - // copied from a newer version of harmony - if (password != null) { - this.password = password.clone(); - } - // END android-changed + if (password != null) { + this.password = password.clone(); + } } /** * Returns the password. - * + * * @return the password. * @throws IllegalStateException * if the password has been destroyed. - * @since Android 1.0 */ public synchronized char[] getPassword() { if (isDestroyed) { @@ -1297,10 +1252,9 @@ public class KeyStore { /** * Destroys / invalidates the password. - * + * * @throws DestroyFailedException * if the password could not be invalidated. - * @since Android 1.0 */ public synchronized void destroy() throws DestroyFailedException { isDestroyed = true; @@ -1312,10 +1266,9 @@ public class KeyStore { /** * Indicates whether the password is invalidated. - * + * * @return {@code true} if the password is invalidated, {@code false} * otherwise. - * @since Android 1.0 */ public synchronized boolean isDestroyed() { return isDestroyed; @@ -1326,8 +1279,6 @@ public class KeyStore { * {@code ProtectionParameter} is a marker interface for protection * parameters. A protection parameter is used to protect the content of a * {@code KeyStore}. - * - * @since Android 1.0 */ public static interface ProtectionParameter { } @@ -1335,8 +1286,6 @@ public class KeyStore { /** * {@code PrivateKeyEntry} represents a {@code KeyStore} entry that * holds a private key. - * - * @since Android 1.0 */ public static final class PrivateKeyEntry implements Entry { // Store Certificate chain @@ -1348,7 +1297,7 @@ public class KeyStore { /** * Constructs a new instance of {@code PrivateKeyEntry} with the given * {@code PrivateKey} and the provided certificate chain. - * + * * @param privateKey * the private key. * @param chain @@ -1361,7 +1310,6 @@ public class KeyStore { * private key does not match the algorithm of the public * key of the first certificate or the certificates are not * all of the same type. - * @since Android 1.0 */ public PrivateKeyEntry(PrivateKey privateKey, Certificate[] chain) { if (privateKey == null) { @@ -1389,18 +1337,29 @@ public class KeyStore { } } // clone chain - this.chain = (Certificate[])chain.clone(); - // BEGIN android-changed - this.chain = new Certificate[chain.length]; - // END android-changed + boolean isAllX509Certificates = true; + // assert chain length > 0 + for(Certificate cert: chain){ + if(!(cert instanceof X509Certificate)){ + isAllX509Certificates = false; + break; + } + } + + if(isAllX509Certificates){ + this.chain = new X509Certificate[chain.length]; + } + else{ + this.chain = new Certificate[chain.length]; + } System.arraycopy(chain, 0, this.chain, 0, chain.length); this.privateKey = privateKey; } /** * Returns the private key. - * + * * @return the private key. - * @since Android 1.0 */ public PrivateKey getPrivateKey() { return privateKey; @@ -1408,22 +1367,17 @@ public class KeyStore { /** * Returns the certificate chain. - * + * * @return the certificate chain. - * @since Android 1.0 */ public Certificate[] getCertificateChain() { - // BEGIN android-changed - // copied from a newer version of harmony return chain.clone(); - // END android-changed } /** * Returns the certificate corresponding to the private key. - * + * * @return the certificate corresponding to the private key. - * @since Android 1.0 */ public Certificate getCertificate() { return chain[0]; @@ -1432,12 +1386,12 @@ public class KeyStore { /** * Returns a string containing a concise, human-readable description of * this {@code PrivateKeyEntry}. - * + * * @return a printable representation for this {@code PrivateKeyEntry}. - * @since Android 1.0 */ + @Override public String toString() { - StringBuffer sb = new StringBuffer( + StringBuilder sb = new StringBuilder( "PrivateKeyEntry: number of elements in certificate chain is "); //$NON-NLS-1$ sb.append(Integer.toString(chain.length)); sb.append("\n"); //$NON-NLS-1$ @@ -1452,8 +1406,6 @@ public class KeyStore { /** * {@code SecretKeyEntry} represents a {@code KeyStore} entry that * holds a secret key. - * - * @since Android 1.0 */ public static final class SecretKeyEntry implements Entry { @@ -1463,12 +1415,11 @@ public class KeyStore { /** * Constructs a new instance of {@code SecretKeyEntry} with the given * {@code SecretKey}. - * + * * @param secretKey * the secret key. * @throws NullPointerException * if {@code secretKey} is {@code null}. - * @since Android 1.0 */ public SecretKeyEntry(SecretKey secretKey) { if (secretKey == null) { @@ -1479,9 +1430,8 @@ public class KeyStore { /** * Returns the secret key. - * + * * @return the secret key. - * @since Android 1.0 */ public SecretKey getSecretKey() { return secretKey; @@ -1490,13 +1440,13 @@ public class KeyStore { /** * Returns a string containing a concise, human-readable description of * this {@code SecretKeyEntry}. - * + * * @return a printable representation for this {@code * SecretKeyEntry}. - * @since Android 1.0 */ + @Override public String toString() { - StringBuffer sb = new StringBuffer("SecretKeyEntry: algorithm - "); //$NON-NLS-1$ + StringBuilder sb = new StringBuilder("SecretKeyEntry: algorithm - "); //$NON-NLS-1$ sb.append(secretKey.getAlgorithm()); return sb.toString(); } @@ -1505,8 +1455,6 @@ public class KeyStore { /** * {@code TrustedCertificateEntry} represents a {@code KeyStore} entry that * holds a trusted certificate. - * - * @since Android 1.0 */ public static final class TrustedCertificateEntry implements Entry { @@ -1516,12 +1464,11 @@ public class KeyStore { /** * Constructs a new instance of {@code TrustedCertificateEntry} with the * given {@code Certificate}. - * + * * @param trustCertificate * the trusted certificate. * @throws NullPointerException * if {@code trustCertificate} is {@code null}. - * @since Android 1.0 */ public TrustedCertificateEntry(Certificate trustCertificate) { if (trustCertificate == null) { @@ -1532,9 +1479,8 @@ public class KeyStore { /** * Returns the trusted certificate. - * + * * @return the trusted certificate. - * @since Android 1.0 */ public Certificate getTrustedCertificate() { return trustCertificate; @@ -1543,11 +1489,11 @@ public class KeyStore { /** * Returns a string containing a concise, human-readable description of * this {@code TrustedCertificateEntry}. - * + * * @return a printable representation for this {@code * TrustedCertificateEntry}. - * @since Android 1.0 */ + @Override public String toString() { return "Trusted certificate entry:\n" + trustCertificate; //$NON-NLS-1$ } diff --git a/security/src/main/java/java/security/KeyStoreException.java b/security/src/main/java/java/security/KeyStoreException.java index 7c697f7..4327f7f 100644 --- a/security/src/main/java/java/security/KeyStoreException.java +++ b/security/src/main/java/java/security/KeyStoreException.java @@ -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); diff --git a/security/src/main/java/java/security/KeyStoreSpi.java b/security/src/main/java/java/security/KeyStoreSpi.java index b02f264..e884123 100644 --- a/security/src/main/java/java/security/KeyStoreSpi.java +++ b/security/src/main/java/java/security/KeyStoreSpi.java @@ -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) { diff --git a/security/src/main/java/java/security/MessageDigest.java b/security/src/main/java/java/security/MessageDigest.java index 97cbdcc..cb8fc08 100644 --- a/security/src/main/java/java/security/MessageDigest.java +++ b/security/src/main/java/java/security/MessageDigest.java @@ -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(); } } } diff --git a/security/src/main/java/java/security/MessageDigestSpi.java b/security/src/main/java/java/security/MessageDigestSpi.java index ae5ed32..52ad3cd 100644 --- a/security/src/main/java/java/security/MessageDigestSpi.java +++ b/security/src/main/java/java/security/MessageDigestSpi.java @@ -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(); } diff --git a/security/src/main/java/java/security/NoSuchAlgorithmException.java b/security/src/main/java/java/security/NoSuchAlgorithmException.java index 3324076..8ef2e3f 100644 --- a/security/src/main/java/java/security/NoSuchAlgorithmException.java +++ b/security/src/main/java/java/security/NoSuchAlgorithmException.java @@ -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); diff --git a/security/src/main/java/java/security/NoSuchProviderException.java b/security/src/main/java/java/security/NoSuchProviderException.java index f016ce6..57cda40 100644 --- a/security/src/main/java/java/security/NoSuchProviderException.java +++ b/security/src/main/java/java/security/NoSuchProviderException.java @@ -15,18 +15,11 @@ * limitations under the License. */ -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - package java.security; /** * {@code NoSuchProviderException} indicates that a requested security provider * could not be found. - * - * @since Android 1.0 */ public class NoSuchProviderException extends GeneralSecurityException { @@ -35,10 +28,9 @@ public class NoSuchProviderException extends GeneralSecurityException { /** * Constructs a new instance of {@code NoSuchProviderException} with the * given message. - * + * * @param msg * the detail message for this exception. - * @since Android 1.0 */ public NoSuchProviderException(String msg) { super(msg); @@ -46,8 +38,6 @@ public class NoSuchProviderException extends GeneralSecurityException { /** * Constructs a new instance of {@code NoSuchProviderException}. - * - * @since Android 1.0 */ public NoSuchProviderException() { } diff --git a/security/src/main/java/java/security/Permission.java b/security/src/main/java/java/security/Permission.java index 93e769c..26bdfcd 100644 --- a/security/src/main/java/java/security/Permission.java +++ b/security/src/main/java/java/security/Permission.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Alexey V. Varlamov -* @version $Revision$ -*/ - package java.security; import java.io.Serializable; @@ -29,8 +24,6 @@ import java.io.Serializable; * participate in the access control security framework around * {@link AccessController} and {@link AccessControlContext}. A permission * constitutes of a name and associated actions. - * - * @since Android 1.0 */ public abstract class Permission implements Guard, Serializable { @@ -45,46 +38,44 @@ public abstract class Permission implements Guard, Serializable { * <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 * Permission}. * @return {@code true} if the specified object is equal to this {@code * Permission}, otherwise {@code false}. - * @since Android 1.0 */ + @Override public abstract boolean equals(Object obj); /** * Returns the hash code value for this {@code Permission}. Returns the same * hash code for {@code Permission}s that are equal to each other as * required by the general contract of {@link Object#hashCode}. - * + * * @return the hash code value for this {@code Permission}. * @see Object#equals(Object) * @see Permission#equals(Object) - * @since Android 1.0 */ + @Override public abstract int hashCode(); /** * Returns a comma separated string identifying the actions associated with * this permission. The returned actions are in canonical form. For example: - * + * * <pre> - * sp0 = new SocketPermission("www.google.com", "connect,resolve") - * sp1 = new SocketPermission("www.google.com", "resolve,connect") + * sp0 = new SocketPermission("www.example.com", "connect,resolve") + * sp1 = new SocketPermission("www.example.com", "resolve,connect") * sp0.getActions().equals(sp1.getActions()) //yields true * </pre> - * + * * Both permissions return "connect,resolve" (in that order) if {@code * #getActions()} is invoked. Returns an empty String, if no actions are * associated with this permission. - * + * * @return the actions associated with this permission or an empty string if * no actions are associated with this permission. - * @since Android 1.0 */ public abstract String getActions(); @@ -92,21 +83,19 @@ public abstract class Permission implements Guard, Serializable { * Indicates whether the specified permission is implied by this permission. * The {@link AccessController} uses this method to check whether permission * protected access is allowed with the present policy. - * + * * @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 */ public abstract boolean implies(Permission permission); /** * Constructs a new instance of {@code Permission} with its name. - * + * * @param name * the name of the permission. - * @since Android 1.0 */ public Permission(String name) { this.name = name; @@ -114,9 +103,8 @@ public abstract class Permission implements Guard, Serializable { /** * Returns the name of this permission. - * + * * @return the name of this permission. - * @since Android 1.0 */ public final String getName() { return name; @@ -126,7 +114,7 @@ public abstract class Permission implements Guard, Serializable { * Invokes {@link SecurityManager#checkPermission(Permission)} with this * permission as its argument. This method implements the {@link Guard} * interface. - * + * * @param obj * as specified in {@link Guard#checkGuard(Object)} but ignored * in this implementation. @@ -134,7 +122,6 @@ public abstract class Permission implements Guard, Serializable { * if this permission is not granted. * @see Guard * @see SecurityManager#checkPermission(Permission) - * @since Android 1.0 */ public void checkGuard(Object obj) throws SecurityException { SecurityManager sm = System.getSecurityManager(); @@ -150,11 +137,9 @@ public abstract class Permission implements Guard, Serializable { * <p> * Subclasses may override this method to return an appropriate collection * for the specific permissions they implement. - * </p> - * + * * @return an empty {@link PermissionCollection} or {@code null} if any * permission collection can be used. - * @since Android 1.0 */ public PermissionCollection newPermissionCollection() { return null; @@ -163,10 +148,10 @@ public abstract class Permission implements Guard, Serializable { /** * Returns a string containing a concise, human-readable description of the * this {@code Permission} including its name and its actions. - * + * * @return a printable representation for this {@code Permission}. - * @since Android 1.0 */ + @Override public String toString() { String actions = getActions(); actions = (actions == null || actions.length() == 0) ? "" : " " //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/security/src/main/java/java/security/PermissionCollection.java b/security/src/main/java/java/security/PermissionCollection.java index 2502123..56b6cd0 100644 --- a/security/src/main/java/java/security/PermissionCollection.java +++ b/security/src/main/java/java/security/PermissionCollection.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Alexey V. Varlamov -* @version $Revision$ -*/ - package java.security; import java.io.Serializable; @@ -37,12 +32,8 @@ import java.util.List; * method returns {@code null}, then a {@code PermissionCollection} of any type * can be used. If a collection is returned, it must be used for holding several * permissions of the particular type. - * </p> * <p> * Subclasses must be implemented thread save. - * </p> - * - * @since Android 1.0 */ public abstract class PermissionCollection implements Serializable { @@ -57,7 +48,6 @@ public abstract class PermissionCollection implements Serializable { * the {@code Permission} to add. * @throws IllegalStateException * if the collection is read only. - * @since Android 1.0 */ public abstract void add(Permission permission); @@ -66,7 +56,6 @@ public abstract class PermissionCollection implements Serializable { * {@code PermissionCollection}. * * @return an enumeration over all {@link Permission}s. - * @since Android 1.0 */ public abstract Enumeration<Permission> elements(); @@ -78,7 +67,6 @@ public abstract class PermissionCollection implements Serializable { * the permission to check. * @return {@code true} if the given permission is implied by the * permissions in this collection, {@code false} otherwise. - * @since Android 1.0 */ public abstract boolean implies(Permission permission); @@ -88,7 +76,6 @@ public abstract class PermissionCollection implements Serializable { * * @return {@code true} if the receiver is read only, {@code false} if new * elements can still be added to this {@code PermissionCollection}. - * @since Android 1.0 */ public boolean isReadOnly() { return readOnly; @@ -97,8 +84,6 @@ public abstract class PermissionCollection implements Serializable { /** * Marks this {@code PermissionCollection} as read only, so that no new * permissions can be added to it. - * - * @since Android 1.0 */ public void setReadOnly() { readOnly = true; @@ -109,11 +94,11 @@ public abstract class PermissionCollection implements Serializable { * {@code PermissionCollection}. * * @return a printable representation for this {@code PermissionCollection}. - * @since Android 1.0 */ + @Override public String toString() { - List elist = new ArrayList(100); - Enumeration elenum = elements(); + List<String> elist = new ArrayList<String>(100); + Enumeration<Permission> elenum = elements(); String superStr = super.toString(); int totalLength = superStr.length() + 5; if (elenum != null) { @@ -125,12 +110,11 @@ public abstract class PermissionCollection implements Serializable { } int esize = elist.size(); totalLength += esize * 4; - //FIXME StringBuffer --> StringBuilder - StringBuffer result = new StringBuffer(totalLength).append(superStr) + StringBuilder result = new StringBuilder(totalLength).append(superStr) .append(" ("); //$NON-NLS-1$ for (int i = 0; i < esize; i++) { - result.append("\n ").append(elist.get(i).toString()); //$NON-NLS-1$ + result.append("\n ").append(elist.get(i).toString()); //$NON-NLS-1$ } - return result.append("\n)").toString(); //$NON-NLS-1$ + return result.append("\n)\n").toString(); //$NON-NLS-1$ } } diff --git a/security/src/main/java/java/security/Permissions.java b/security/src/main/java/java/security/Permissions.java index b9b13c6..e8d3375 100644 --- a/security/src/main/java/java/security/Permissions.java +++ b/security/src/main/java/java/security/Permissions.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Alexey V. Varlamov -* @version $Revision$ -*/ - package java.security; import java.io.IOException; @@ -44,8 +39,6 @@ import org.apache.harmony.security.internal.nls.Messages; * {@link Permission#newPermissionCollection()}. For permissions which do not * provide a dedicated {@code PermissionCollection}, a default permission * collection, based on a hash table, will be used. - * - * @since Android 1.0 */ public final class Permissions extends PermissionCollection implements Serializable { @@ -65,7 +58,7 @@ public final class Permissions extends PermissionCollection implements * Adds the given {@code Permission} to this heterogeneous {@code * PermissionCollection}. The {@code permission} is stored in its * appropriate {@code PermissionCollection}. - * + * * @param permission * the {@code Permission} to be added. * @throws SecurityException @@ -73,7 +66,6 @@ public final class Permissions extends PermissionCollection implements * {@code true}. * @throws NullPointerException * if {@code permission} is {@code null}. - * @since Android 1.0 */ public void add(Permission permission) { if (isReadOnly()) { @@ -223,9 +215,10 @@ public final class Permissions extends PermissionCollection implements Map perms = (Map)fields.get("perms", null); //$NON-NLS-1$ klasses = new HashMap(); synchronized (klasses) { - for (Iterator iter = perms.keySet().iterator(); iter.hasNext();) { - Class key = (Class)iter.next(); - PermissionCollection pc = (PermissionCollection)perms.get(key); + for (Iterator iter = perms.entrySet().iterator(); iter.hasNext();) { + Map.Entry entry = (Map.Entry) iter.next(); + Class key = (Class) entry.getKey(); + PermissionCollection pc = (PermissionCollection) entry.getValue(); if (key != pc.elements().nextElement().getClass()) { throw new InvalidObjectException(Messages.getString("security.22")); //$NON-NLS-1$ } diff --git a/security/src/main/java/java/security/PermissionsHash.java b/security/src/main/java/java/security/PermissionsHash.java index 69d2b07..4c9e0c9 100644 --- a/security/src/main/java/java/security/PermissionsHash.java +++ b/security/src/main/java/java/security/PermissionsHash.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Alexey V. Varlamov -* @version $Revision$ -*/ - package java.security; import java.util.Enumeration; @@ -30,28 +25,21 @@ import org.apache.harmony.security.internal.nls.Messages; /** * A default {@code PermissionCollection} implementation that uses a hashtable. * Each hashtable entry stores a Permission object as both the key and the - * value. <br> + * value. + * <p> * This {@code PermissionCollection} is intended for storing "neutral" - * permissions which do not require special collection. </br> - * - * @since Android 1.0 + * permissions which do not require special collection. */ final class PermissionsHash extends PermissionCollection { - /** - * @com.intel.drl.spec_ref - */ private static final long serialVersionUID = -8491988220802933440L; - /** - * @com.intel.drl.spec_ref - */ private final Hashtable perms = new Hashtable(); /** * Adds the argument to the collection. - * + * * @param permission * the permission to add to the collection. */ @@ -61,8 +49,7 @@ final class PermissionsHash extends PermissionCollection { /** * Returns an enumeration of the permissions in the receiver. - * - * + * * @return Enumeration the permissions in the receiver. */ public Enumeration elements() { @@ -72,8 +59,7 @@ final class PermissionsHash extends PermissionCollection { /** * Indicates whether the argument permission is implied by the permissions * contained in the receiver. - * - * + * * @return boolean <code>true</code> if the argument permission is implied * by the permissions in the receiver, and <code>false</code> if * it is not. diff --git a/security/src/main/java/java/security/Policy.java b/security/src/main/java/java/security/Policy.java index 21b13b0..d5719a3 100644 --- a/security/src/main/java/java/security/Policy.java +++ b/security/src/main/java/java/security/Policy.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Alexey V. Varlamov -* @version $Revision$ -*/ - package java.security; import java.util.Enumeration; @@ -36,12 +31,8 @@ import org.apache.harmony.security.fortress.PolicyUtils; * The system policy can be changed by setting the {@code 'policy.provider'} * property in the file named {@code JAVA_HOME/lib/security/java.security} to * the fully qualified class name of the desired {@code Policy}. - * </p> * <p> * Only one instance of a {@code Policy} is active at any time. - * </p> - * - * @since Android 1.0 */ public abstract class Policy { @@ -68,20 +59,16 @@ public abstract class Policy { * domain (i.e. system classes). System classes are always given * full permissions (i.e. AllPermission). This can not be changed by * installing a new policy. - * </p> - * + * * @param cs * the {@code CodeSource} to compute the permissions for. * @return the permissions that are granted to the specified {@code * CodeSource}. - * @since Android 1.0 */ public abstract PermissionCollection getPermissions(CodeSource cs); /** * Reloads the policy configuration for this {@code Policy} instance. - * - * @since Android 1.0 */ public abstract void refresh(); @@ -94,13 +81,11 @@ public abstract class Policy { * system domain (i.e. system classes). System classes are always * given full permissions (i.e. AllPermission). This can not be changed by * installing a new policy. - * </p> - * + * * @param domain * the {@code ProtectionDomain} to compute the permissions for. * @return the permissions that are granted to the specified {@code * CodeSource}. - * @since Android 1.0 */ public PermissionCollection getPermissions(ProtectionDomain domain) { if (domain != null) { @@ -112,7 +97,7 @@ public abstract class Policy { /** * Indicates whether the specified {@code Permission} is implied by the * {@code PermissionCollection} of the specified {@code ProtectionDomain}. - * + * * @param domain * the {@code ProtectionDomain} for which the permission should * be granted. @@ -121,7 +106,6 @@ public abstract class Policy { * verified. * @return {@code true} if the {@code Permission} is implied by the {@code * ProtectionDomain}, {@code false} otherwise. - * @since Android 1.0 */ public boolean implies(ProtectionDomain domain, Permission permission) { if (domain != null) { @@ -130,8 +114,8 @@ public abstract class Policy { if (total == null) { total = inherent; } else if (inherent != null) { - for (Enumeration en = inherent.elements(); en.hasMoreElements();) { - total.add((Permission)en.nextElement()); + for (Enumeration<Permission> en = inherent.elements(); en.hasMoreElements();) { + total.add(en.nextElement()); } } if (total != null && total.implies(permission)) { @@ -149,13 +133,11 @@ public abstract class Policy { * If a {@code SecurityManager} is installed, code calling this method needs * the {@code SecurityPermission} {@code getPolicy} to be granted, otherwise * a {@code SecurityException} will be thrown. - * </p> - * + * * @return the current system security policy. * @throws SecurityException * if a {@code SecurityManager} is installed and the caller does * not have permission to invoke this method. - * @since Android 1.0 */ public static Policy getPolicy() { SecurityManager sm = System.getSecurityManager(); @@ -170,7 +152,7 @@ public abstract class Policy { // In case of any error, including undefined provider name, // returns new instance of org.apache.harmony.security.FilePolicy provider. private static Policy getDefaultProvider() { - final String defaultClass = (String) AccessController + final String defaultClass = AccessController .doPrivileged(new PolicyUtils.SecurityPropertyAccessor( POLICY_PROVIDER)); if (defaultClass == null) { @@ -235,14 +217,12 @@ public abstract class Policy { * If a {@code SecurityManager} is installed, code calling this method needs * the {@code SecurityPermission} {@code setPolicy} to be granted, otherwise * a {@code SecurityException} will be thrown. - * </p> - * + * * @param policy * the {@code Policy} to set. * @throws SecurityException * if a {@code SecurityManager} is installed and the caller does * not have permission to invoke this method. - * @since Android 1.0 */ public static void setPolicy(Policy policy) { SecurityManager sm = System.getSecurityManager(); diff --git a/security/src/main/java/java/security/Principal.java b/security/src/main/java/java/security/Principal.java index 0716681..f86bc87 100644 --- a/security/src/main/java/java/security/Principal.java +++ b/security/src/main/java/java/security/Principal.java @@ -15,40 +15,31 @@ * limitations under the License. */ -/** -* @author Alexander V. Astapchuk -* @version $Revision$ -*/ - package java.security; /** * {@code Principal}s are objects which have identities. These can be * individuals, groups, corporations, unique program executions, etc. - * - * @since Android 1.0 */ public interface Principal { /** * Compares the specified object with this {@code Principal} for equality * and returns {@code true} if the specified object is equal, {@code false} * otherwise. - * + * * @param obj * object to be compared for equality with this {@code * Principal}. * @return {@code true} if the specified object is equal to this {@code * Principal}, otherwise {@code false}. - * @since Android 1.0 */ public boolean equals( Object obj ); /** * Returns the name of this {@code Principal}. - * + * * @return the name of this {@code Principal}. - * @since Android 1.0 */ public String getName(); @@ -60,16 +51,14 @@ public interface Principal { * @return the hash code value for this {@code Principal}. * @see Object#equals(Object) * @see Principal#equals(Object) - * @since Android 1.0 */ public int hashCode(); - - /** + + /** * Returns a string containing a concise, human-readable description of * this {@code Principal}. * * @return a printable representation for this {@code Principal}. - * @since Android 1.0 */ public String toString(); } diff --git a/security/src/main/java/java/security/PrivateKey.java b/security/src/main/java/java/security/PrivateKey.java index 8513b75..246f286 100644 --- a/security/src/main/java/java/security/PrivateKey.java +++ b/security/src/main/java/java/security/PrivateKey.java @@ -15,25 +15,17 @@ * limitations under the License. */ -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - package java.security; /** * {@code PrivateKey} is the common interface for private keys. * * @see PublicKey - * @since Android 1.0 */ public interface PrivateKey extends Key { - + /** * The {@code serialVersionUID} to be compatible with JDK1.1. - * - * @since Android 1.0 */ public static final long serialVersionUID = 6034044314589513430L; -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/PrivilegedAction.java b/security/src/main/java/java/security/PrivilegedAction.java index 5912cdc..1dbbe65 100644 --- a/security/src/main/java/java/security/PrivilegedAction.java +++ b/security/src/main/java/java/security/PrivilegedAction.java @@ -15,31 +15,23 @@ * limitations under the License. */ -/** -* @author Alexander V. Astapchuk -* @version $Revision$ -*/ - package java.security; /** * {@code PrivilegedAction} represents an action that can be executed privileged * regarding access control. Instances of {@code PrivilegedAction} can be * executed on {@code AccessController.doPrivileged()}. - * + * * @see AccessController * @see AccessController#doPrivileged(PrivilegedAction) * @see AccessController#doPrivileged(PrivilegedAction, AccessControlContext) * @see PrivilegedExceptionAction - * @since Android 1.0 */ public interface PrivilegedAction<T> { - /** * Returns the result of running the action. - * + * * @return the result of running the action. - * @since Android 1.0 */ public T run(); -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/PrivilegedActionException.java b/security/src/main/java/java/security/PrivilegedActionException.java index eaca2b2..a1f5b15 100644 --- a/security/src/main/java/java/security/PrivilegedActionException.java +++ b/security/src/main/java/java/security/PrivilegedActionException.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Alexander V. Astapchuk -* @version $Revision$ -*/ - package java.security; /** @@ -33,13 +28,11 @@ package java.security; * {@code AccessController#doPrivileged(PrivilegedExceptionAction, * AccessControlContext)} </br> * </ul> - * </p> - * + * * @see PrivilegedExceptionAction * @see AccessController#doPrivileged(PrivilegedExceptionAction) * @see AccessController#doPrivileged(PrivilegedExceptionAction, * AccessControlContext) - * @since Android 1.0 */ public class PrivilegedActionException extends Exception { @@ -50,10 +43,9 @@ public class PrivilegedActionException extends Exception { /** * Constructs a new instance of {@code PrivilegedActionException} with the * cause. - * + * * @param ex * the exception which is the cause for this exception. - * @since Android 1.0 */ public PrivilegedActionException(Exception ex) { super(ex); @@ -63,10 +55,9 @@ public class PrivilegedActionException extends Exception { /** * Returns the exception that was thrown by a * {@code PrivilegedExceptionAction}. - * + * * @return the exception that was thrown by a * {@code PrivilegedExceptionAction}. - * @since Android 1.0 */ public Exception getException() { return exception; // return ( getCause() instanceof Exception ) ? @@ -76,11 +67,11 @@ public class PrivilegedActionException extends Exception { /** * Returns the exception that was thrown by a * {@code PrivilegedExceptionAction}. - * + * * @return the exception that was thrown by a * {@code PrivilegedExceptionAction}. - * @since Android 1.0 */ + @Override public Throwable getCause() { return exception; } @@ -88,11 +79,11 @@ public class PrivilegedActionException extends Exception { /** * Returns a string containing a concise, human-readable description of this * {@code PrivilegedActionException}. - * + * * @return a printable representation for this {@code * PrivilegedActionException}. - * @since Android 1.0 */ + @Override public String toString() { String s = getClass().getName(); return exception == null ? s : s + ": " + exception; //$NON-NLS-1$ diff --git a/security/src/main/java/java/security/PrivilegedExceptionAction.java b/security/src/main/java/java/security/PrivilegedExceptionAction.java index dd3ae8d..bc072d5 100644 --- a/security/src/main/java/java/security/PrivilegedExceptionAction.java +++ b/security/src/main/java/java/security/PrivilegedExceptionAction.java @@ -15,34 +15,26 @@ * limitations under the License. */ -/** -* @author Alexander V. Astapchuk -* @version $Revision$ -*/ - package java.security; /** * {@code PrivilegedAction} represents an action, that can be executed * privileged regarding access control. Instances of {@code PrivilegedAction} * can be executed invoking {@code AccessController.doPrivileged()}. - * + * * @see AccessController * @see AccessController#doPrivileged(PrivilegedExceptionAction) * @see AccessController#doPrivileged(PrivilegedExceptionAction, * AccessControlContext) * @see PrivilegedAction - * @since Android 1.0 */ public interface PrivilegedExceptionAction<T> { - /** * Returns the result of running the action. - * + * * @return the result of running the action * @throws Exception * if an exception occurred. - * @since Android 1.0 */ T run() throws Exception; } diff --git a/security/src/main/java/java/security/ProtectionDomain.java b/security/src/main/java/java/security/ProtectionDomain.java index d41f4a8..1e85c4a 100644 --- a/security/src/main/java/java/security/ProtectionDomain.java +++ b/security/src/main/java/java/security/ProtectionDomain.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Alexander V. Astapchuk -* @version $Revision$ -*/ - package java.security; /** @@ -30,9 +25,6 @@ package java.security; * <p> * A class belongs to exactly one protection domain and the protection domain * can not be changed during the lifetime of the class. - * </p> - * - * @since Android 1.0 */ public class ProtectionDomain { @@ -60,17 +52,13 @@ public class ProtectionDomain { * collection is made immutable by calling * {@link PermissionCollection#setReadOnly()} and it is considered as * granted statically to this {@code ProtectionDomain}. - * </p> * <p> * The policy will not be consulted by access checks against this {@code * ProtectionDomain}. - * </p> * <p> - * If {@code permissions} is {@code null}, the method - * {@link ProtectionDomain#implies(Permission)} always returns {@code false} - * . - * </p> - * + * If {@code permissions} is {@code null}, the method {@link + * ProtectionDomain#implies(Permission)} always returns {@code false}. + * * @param cs * the code source associated with this domain, maybe {@code * null}. @@ -78,7 +66,6 @@ public class ProtectionDomain { * the {@code PermissionCollection} containing all permissions to * be statically granted to this {@code ProtectionDomain}, maybe * {@code null}. - * @since Android 1.0 */ public ProtectionDomain(CodeSource cs, PermissionCollection permissions) { this.codeSource = cs; @@ -91,7 +78,6 @@ public class ProtectionDomain { //dynamicPerms = false; } - /** * Constructs a new instance of {@code ProtectionDomain} with the specified * code source, the permissions, the class loader and the principals. @@ -102,12 +88,10 @@ public class ProtectionDomain { * permissions} collection is made immutable by calling * {@link PermissionCollection#setReadOnly()}. If access checks are * performed, the policy and the provided permission collection are checked. - * </p> * <p> * External modifications of the provided {@code principals} array has no * impact on this {@code ProtectionDomain}. - * </p> - * + * * @param cs * the code source associated with this domain, maybe {@code * null}. @@ -118,9 +102,8 @@ public class ProtectionDomain { * the class loader associated with this domain, maybe {@code * null}. * @param principals - * the principals associated with this domain, maybe {@code null} - * . - * @since Android 1.0 + * the principals associated with this domain, maybe {@code + * null}. */ public ProtectionDomain(CodeSource cs, PermissionCollection permissions, ClassLoader cl, Principal[] principals) { @@ -141,10 +124,9 @@ public class ProtectionDomain { /** * Returns the {@code ClassLoader} associated with this {@code * ProtectionDomain}. - * + * * @return the {@code ClassLoader} associated with this {@code * ProtectionDomain}, maybe {@code null}. - * @since Android 1.0 */ public final ClassLoader getClassLoader() { return classLoader; @@ -152,10 +134,9 @@ public class ProtectionDomain { /** * Returns the {@code CodeSource} of this {@code ProtectionDomain}. - * + * * @return the {@code CodeSource} of this {@code ProtectionDomain}, maybe * {@code null}. - * @since Android 1.0 */ public final CodeSource getCodeSource() { return codeSource; @@ -164,10 +145,9 @@ public class ProtectionDomain { /** * Returns the static permissions that are granted to this {@code * ProtectionDomain}. - * + * * @return the static permissions that are granted to this {@code * ProtectionDomain}, maybe {@code null}. - * @since Android 1.0 */ public final PermissionCollection getPermissions() { return permissions; @@ -177,9 +157,8 @@ public class ProtectionDomain { * Returns the principals associated with this {@code ProtectionDomain}. * Modifications of the returned {@code Principal} array has no impact on * this {@code ProtectionDomain}. - * + * * @return the principals associated with this {@code ProtectionDomain}. - * @since Android 1.0 */ public final Principal[] getPrincipals() { if( principals == null ) { @@ -199,19 +178,16 @@ public class ProtectionDomain { * specified permission is only checked against the permission collection * provided in the constructor. If {@code null} was provided, {@code false} * is returned. - * </p> * <p> * If this {@code ProtectionDomain} was constructed with * {@link #ProtectionDomain(CodeSource, PermissionCollection, ClassLoader, Principal[])} * , the specified permission is checked against the policy and the * permission collection provided in the constructor. - * </p> - * + * * @param permission * the permission to check against the domain. * @return {@code true} if the specified {@code permission} is implied by * this {@code ProtectionDomain}, {@code false} otherwise. - * @since Android 1.0 */ public boolean implies(Permission permission) { // First, test with the Policy, as the default Policy.implies() @@ -232,13 +208,12 @@ public class ProtectionDomain { /** * Returns a string containing a concise, human-readable description of the * this {@code ProtectionDomain}. - * + * * @return a printable representation for this {@code ProtectionDomain}. - * @since Android 1.0 */ + @Override public String toString() { - //FIXME: 1.5 use StreamBuilder here - StringBuffer buf = new StringBuffer(200); + StringBuilder buf = new StringBuilder(200); buf.append("ProtectionDomain\n"); //$NON-NLS-1$ buf.append("CodeSource=").append( //$NON-NLS-1$ codeSource == null ? "<null>" : codeSource.toString()).append( //$NON-NLS-1$ diff --git a/security/src/main/java/java/security/Provider.java b/security/src/main/java/java/security/Provider.java index 491470f..cf9c94d 100644 --- a/security/src/main/java/java/security/Provider.java +++ b/security/src/main/java/java/security/Provider.java @@ -15,15 +15,11 @@ * limitations under the License. */ -/** -* @author Boris V. Kuznetsov -* @version $Revision$ -*/ - package java.security; import java.io.IOException; import java.io.InputStream; +import java.io.NotActiveException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -37,14 +33,13 @@ import java.util.Properties; import java.util.Set; import org.apache.harmony.luni.util.TwoKeyHashMap; +import org.apache.harmony.security.Util; import org.apache.harmony.security.fortress.Services; import org.apache.harmony.security.internal.nls.Messages; /** * {@code Provider} is the abstract superclass for all security providers in the * Java security infrastructure. - * - * @since Android 1.0 */ public abstract class Provider extends Properties { private static final long serialVersionUID = -4298000515446427739L; @@ -99,14 +94,13 @@ public abstract class Provider extends Properties { /** * Constructs a new instance of {@code Provider} with its name, version and * description. - * + * * @param name * the name of the provider. * @param version * the version of the provider. * @param info * a description of the provider. - * @since Android 1.0 */ protected Provider(String name, double version, String info) { this.name = name; @@ -118,9 +112,8 @@ public abstract class Provider extends Properties { /** * Returns the name of this provider. - * + * * @return the name of this provider. - * @since Android 1.0 */ public String getName() { return name; @@ -128,9 +121,8 @@ public abstract class Provider extends Properties { /** * Returns the version number for the services being provided. - * + * * @return the version number for the services being provided. - * @since Android 1.0 */ public double getVersion() { return version; @@ -138,9 +130,8 @@ public abstract class Provider extends Properties { /** * Returns a description of the services being provided. - * + * * @return a description of the services being provided. - * @since Android 1.0 */ public String getInfo() { return info; @@ -151,12 +142,10 @@ public abstract class Provider extends Properties { * this {@code Provider} including its name and its version. * * @return a printable representation for this {@code Provider}. - * @since Android 1.0 */ + @Override public String toString() { - // BEGIN android-changed return name + " version " + version; //$NON-NLS-1$ - // END android-changed } /** @@ -167,13 +156,12 @@ public abstract class Provider extends Properties { * the {@code SecurityPermission} {@code clearProviderProperties.NAME} * (where NAME is the provider name) to be granted, otherwise a {@code * SecurityException} will be thrown. - * </p> - * + * * @throws SecurityException * if a {@code SecurityManager} is installed and the caller does * not have permission to invoke this method. - * @since Android 1.0 */ + @Override public synchronized void clear() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { @@ -203,6 +191,7 @@ public abstract class Provider extends Properties { servicesChanged(); } + @Override public synchronized void load(InputStream inStream) throws IOException { Properties tmp = new Properties(); tmp.load(inStream); @@ -216,15 +205,14 @@ public abstract class Provider extends Properties { * the {@code SecurityPermission} {@code putProviderProperty.NAME} (where * NAME is the provider name) to be granted, otherwise a {@code * SecurityException} will be thrown. - * </p> - * + * * @param t * the mappings to copy to this provider. * @throws SecurityException * if a {@code SecurityManager} is installed and the caller does * not have permission to invoke this method. - * @since Android 1.0 */ + @Override public synchronized void putAll(Map<?,?> t) { // Implementation note: @@ -265,14 +253,17 @@ public abstract class Provider extends Properties { } } + @Override public synchronized Set<Map.Entry<Object,Object>> entrySet() { return Collections.unmodifiableSet(super.entrySet()); } + @Override public Set<Object> keySet() { return Collections.unmodifiableSet(super.keySet()); } + @Override public Collection<Object> values() { return Collections.unmodifiableCollection(super.values()); } @@ -285,8 +276,7 @@ public abstract class Provider extends Properties { * the {@code SecurityPermission} {@code putProviderProperty.NAME} (where * NAME is the provider name) to be granted, otherwise a {@code * SecurityException} will be thrown. - * </p> - * + * * @param key * the name of the property. * @param value @@ -296,8 +286,8 @@ public abstract class Provider extends Properties { * @throws SecurityException * if a {@code SecurityManager} is installed and the caller does * not have permission to invoke this method. - * @since Android 1.0 */ + @Override public synchronized Object put(Object key, Object value) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { @@ -329,8 +319,7 @@ public abstract class Provider extends Properties { * the {@code SecurityPermission} {@code removeProviderProperty.NAME} (where * NAME is the provider name) to be granted, otherwise a {@code * SecurityException} will be thrown. - * </p> - * + * * @param key * the name of the property * @return the value that was mapped to the specified {@code key} ,or @@ -338,8 +327,8 @@ public abstract class Provider extends Properties { * @throws SecurityException * if a {@code SecurityManager} is installed and the caller does * not have the permission to invoke this method. - * @since Android 1.0 */ + @Override public synchronized Object remove(Object key) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { @@ -365,9 +354,9 @@ public abstract class Provider extends Properties { } /** - * returns true if the provider implements the specified algorithm. Caller + * Returns true if this provider implements the given algorithm. Caller * must specify the cryptographic service and specify constraints via the - * attribute name the attribute value + * attribute name and value. * * @param serv * Crypto service. @@ -386,33 +375,32 @@ public abstract class Provider extends Properties { alg = getPropertyIgnoreCase("Alg.Alias." + servAlg); //$NON-NLS-1$ if (alg != null) { servAlg = serv + "." + alg; //$NON-NLS-1$ - prop = getPropertyIgnoreCase(serv + "." + alg); //$NON-NLS-1$ + prop = getPropertyIgnoreCase(servAlg); } } if (prop != null) { if (attribute == null) { return true; - } else { - return checkAttribute(serv + "." + alg, attribute, val); //$NON-NLS-1$ } + return checkAttribute(servAlg, attribute, val); } return false; } - // returns true if the implementation meets the constraint expressed by the - // specified attribute name/value pair. + // Returns true if this provider has the same value as is given for the + // given attribute private boolean checkAttribute(String servAlg, String attribute, String val) { String attributeValue = getPropertyIgnoreCase(servAlg + ' ' + attribute); if (attributeValue != null) { - if (attribute.equalsIgnoreCase("KeySize")) { //$NON-NLS-1$ + if (Util.equalsIgnoreCase(attribute,"KeySize")) { //$NON-NLS-1$ // BEGIN android-changed if (Integer.parseInt(attributeValue) >= Integer.parseInt(val)) { return true; } // END android-changed } else { // other attributes - if (attributeValue.equalsIgnoreCase(val)) { + if (Util.equalsIgnoreCase(attributeValue, val)) { return true; } } @@ -469,14 +457,13 @@ public abstract class Provider extends Properties { * If two services match the requested type and algorithm, the one added * with the {@link #putService(Service)} is returned (as opposed to the one * added via {@link #put(Object, Object)}. - * + * * @param type * the type of the service (for example {@code KeyPairGenerator}) * @param algorithm * the algorithm name (case insensitive) * @return the requested service, or {@code null} if no such implementation * exists - * @since Android 1.0 */ public synchronized Provider.Service getService(String type, String algorithm) { @@ -485,11 +472,11 @@ public abstract class Provider extends Properties { } if (type.equals(lastServiceName) - && algorithm.equalsIgnoreCase(lastAlgorithm)) { + && Util.equalsIgnoreCase(algorithm, lastAlgorithm)) { return returnedService; } - String alg = algorithm.toUpperCase(); + String alg = Util.toUpperCase(algorithm); Object o = null; if (serviceTable != null) { o = serviceTable.get(type, alg); @@ -519,10 +506,9 @@ public abstract class Provider extends Properties { /** * Returns an unmodifiable {@code Set} of all services registered by this * provider. - * + * * @return an unmodifiable {@code Set} of all services registered by this * provider - * @since Android 1.0 */ public synchronized Set<Provider.Service> getServices() { updatePropertyServiceTable(); @@ -549,13 +535,12 @@ public abstract class Provider extends Properties { * the {@code SecurityPermission} {@code putProviderProperty.NAME} (where * NAME is the provider name) to be granted, otherwise a {@code * SecurityException} will be thrown. - * + * * @param s * the {@code Service} to register * @throws SecurityException * if a {@code SecurityManager} is installed and the caller does * not have permission to invoke this method - * @since Android 1.0 */ protected synchronized void putService(Provider.Service s) { if (s == null) { @@ -573,13 +558,13 @@ public abstract class Provider extends Properties { if (serviceTable == null) { serviceTable = new TwoKeyHashMap<String, String, Service>(128); } - serviceTable.put(s.type, s.algorithm.toUpperCase(), s); + serviceTable.put(s.type, Util.toUpperCase(s.algorithm), s); if (s.aliases != null) { if (aliasTable == null) { aliasTable = new TwoKeyHashMap<String, String, Service>(256); } for (Iterator<String> it = s.getAliases(); it.hasNext();) { - aliasTable.put(s.type, (it.next()).toUpperCase(), s); + aliasTable.put(s.type, Util.toUpperCase(it.next()), s); } } serviceInfoToProperties(s); @@ -593,7 +578,7 @@ public abstract class Provider extends Properties { * the {@code SecurityPermission} {@code removeProviderProperty.NAME} (where * NAME is the provider name) to be granted, otherwise a {@code * SecurityException} will be thrown. - * + * * @param s * the {@code Service} to remove * @throws SecurityException @@ -601,7 +586,6 @@ public abstract class Provider extends Properties { * not have permission to invoke this method * @throws NullPointerException * if {@code s} is {@code null} - * @since Android 1.0 */ protected synchronized void removeService(Provider.Service s) { if (s == null) { @@ -613,11 +597,11 @@ public abstract class Provider extends Properties { } servicesChanged(); if (serviceTable != null) { - serviceTable.remove(s.type, s.algorithm.toUpperCase()); + serviceTable.remove(s.type, Util.toUpperCase(s.algorithm)); } if (aliasTable != null && s.aliases != null) { for (Iterator<String> it = s.getAliases(); it.hasNext();) { - aliasTable.remove(s.type, (it.next()).toUpperCase()); + aliasTable.remove(s.type, Util.toUpperCase(it.next())); } } serviceInfoFromProperties(s); @@ -678,14 +662,14 @@ public abstract class Provider extends Properties { String algorithm = null; String attribute = null; int i; - if (k.startsWith("Alg.Alias.")) { // Alg.Alias.<crypto_service>.<aliasName>=<stanbdardName> //$NON-NLS-1$ + if (k.startsWith("Alg.Alias.")) { // Alg.Alias.<crypto_service>.<aliasName>=<standardName> //$NON-NLS-1$ String aliasName; String service_alias = k.substring(10); - i = service_alias.indexOf("."); //$NON-NLS-1$ + i = service_alias.indexOf('.'); serviceName = service_alias.substring(0, i); aliasName = service_alias.substring(i + 1); if (propertyAliasTable != null) { - propertyAliasTable.remove(serviceName, aliasName.toUpperCase()); + propertyAliasTable.remove(serviceName, Util.toUpperCase(aliasName)); } if (propertyServiceTable != null) { for (Iterator<Service> it = propertyServiceTable.values().iterator(); it @@ -699,22 +683,22 @@ public abstract class Provider extends Properties { } return; } - int j = k.indexOf("."); //$NON-NLS-1$ + int j = k.indexOf('.'); if (j == -1) { // unknown format return; } - i = k.indexOf(" "); //$NON-NLS-1$ + i = k.indexOf(' '); if (i == -1) { // <crypto_service>.<algorithm_or_type>=<className> serviceName = k.substring(0, j); algorithm = k.substring(j + 1); if (propertyServiceTable != null) { - Provider.Service ser = propertyServiceTable.remove(serviceName, algorithm.toUpperCase()); + Provider.Service ser = propertyServiceTable.remove(serviceName, Util.toUpperCase(algorithm)); if (ser != null && propertyAliasTable != null && ser.aliases != null) { for (Iterator<String> it = ser.aliases.iterator(); it.hasNext();) { - propertyAliasTable.remove(serviceName, (it - .next()).toUpperCase()); + propertyAliasTable.remove(serviceName, Util.toUpperCase(it + .next())); } } } @@ -724,8 +708,7 @@ public abstract class Provider extends Properties { serviceName = k.substring(0, j); algorithm = k.substring(j + 1, i); if (propertyServiceTable != null) { - Object o = propertyServiceTable.get(serviceName, algorithm - .toUpperCase()); + Object o = propertyServiceTable.get(serviceName, Util.toUpperCase(algorithm)); if (o != null) { s = (Provider.Service) o; s.attributes.remove(attribute); @@ -759,14 +742,14 @@ public abstract class Provider extends Properties { continue; } int i; - if (key.startsWith("Alg.Alias.")) { // Alg.Alias.<crypto_service>.<aliasName>=<stanbdardName> //$NON-NLS-1$ + if (key.startsWith("Alg.Alias.")) { // Alg.Alias.<crypto_service>.<aliasName>=<standardName> //$NON-NLS-1$ String aliasName; String service_alias = key.substring(10); - i = service_alias.indexOf("."); //$NON-NLS-1$ + i = service_alias.indexOf('.'); serviceName = service_alias.substring(0, i); aliasName = service_alias.substring(i + 1); algorithm = value; - String algUp = algorithm.toUpperCase(); + String algUp = Util.toUpperCase(algorithm); Object o = null; if (propertyServiceTable == null) { propertyServiceTable = new TwoKeyHashMap<String, String, Service>(128); @@ -782,7 +765,7 @@ public abstract class Provider extends Properties { propertyAliasTable = new TwoKeyHashMap<String, String, Service>(256); } propertyAliasTable.put(serviceName, - aliasName.toUpperCase(), s); + Util.toUpperCase(aliasName), s); } else { String className = (String) changedProperties .get(serviceName + "." + algorithm); //$NON-NLS-1$ @@ -795,21 +778,21 @@ public abstract class Provider extends Properties { if (propertyAliasTable == null) { propertyAliasTable = new TwoKeyHashMap<String, String, Service>(256); } - propertyAliasTable.put(serviceName, aliasName - .toUpperCase(), s); + propertyAliasTable.put(serviceName, Util.toUpperCase(aliasName + ), s); } } continue; } - int j = key.indexOf("."); //$NON-NLS-1$ + int j = key.indexOf('.'); if (j == -1) { // unknown format continue; } - i = key.indexOf(" "); //$NON-NLS-1$ + i = key.indexOf(' '); if (i == -1) { // <crypto_service>.<algorithm_or_type>=<className> serviceName = key.substring(0, j); algorithm = key.substring(j + 1); - String alg = algorithm.toUpperCase(); + String alg = Util.toUpperCase(algorithm); Object o = null; if (propertyServiceTable != null) { o = propertyServiceTable.get(serviceName, alg); @@ -834,7 +817,7 @@ public abstract class Provider extends Properties { serviceName = key.substring(0, j); algorithm = key.substring(j + 1, i); String attribute = key.substring(i + 1); - String alg = algorithm.toUpperCase(); + String alg = Util.toUpperCase(algorithm); Object o = null; if (propertyServiceTable != null) { o = propertyServiceTable.get(serviceName, alg); @@ -875,11 +858,12 @@ public abstract class Provider extends Properties { // These attributes should be placed in each Provider object: // Provider.id name, Provider.id version, Provider.id info, // Provider.id className + @SuppressWarnings("nls") private void putProviderInfo() { - super.put("Provider.id name", null != name ? name : "null"); //$NON-NLS-1$ - super.put("Provider.id version", versionString); //$NON-NLS-1$ - super.put("Provider.id info", null != info ? info : "null"); //$NON-NLS-1$ - super.put("Provider.id className", this.getClass().getName()); //$NON-NLS-1$ + super.put("Provider.id name", null != name ? name : "null"); + super.put("Provider.id version", versionString); + super.put("Provider.id info", null != info ? info : "null"); + super.put("Provider.id className", this.getClass().getName()); } // Searches for the property with the specified key in the provider @@ -894,7 +878,7 @@ public abstract class Provider extends Properties { } for (Enumeration<?> e = propertyNames(); e.hasMoreElements();) { String pname = (String) e.nextElement(); - if (key.equalsIgnoreCase(pname)) { + if (Util.equalsIgnoreCase(key, pname)) { return getProperty(pname); } } @@ -905,8 +889,6 @@ public abstract class Provider extends Properties { * {@code Service} represents a service in the Java Security infrastructure. * Each service describes its type, the algorithm it implements, to which * provider it belongs and other properties. - * - * @since Android 1.0 */ public static class Service { // The provider @@ -936,7 +918,7 @@ public abstract class Provider extends Properties { /** * Constructs a new instance of {@code Service} with the given * attributes. - * + * * @param provider * the provider to which this service belongs. * @param type @@ -955,7 +937,6 @@ public abstract class Provider extends Properties { * @throws NullPointerException * if {@code provider, type, algorithm} or {@code className} * is {@code null}. - * @since Android 1.0 */ public Service(Provider provider, String type, String algorithm, String className, List<String> aliases, Map<String, String> attributes) { @@ -1006,21 +987,19 @@ public abstract class Provider extends Properties { /** * Returns the type of this {@code Service}. For example {@code * KeyPairGenerator}. - * + * * @return the type of this {@code Service}. - * @since Android 1.0 */ public final String getType() { return type; } /** - * Returns the name of the algorithm implemented by this {@code Service} - * . - * - * @return the name of the algorithm implemented by this {@code Service} - * . - * @since Android 1.0 + * Returns the name of the algorithm implemented by this {@code + * Service}. + * + * @return the name of the algorithm implemented by this {@code + * Service}. */ public final String getAlgorithm() { return algorithm; @@ -1028,9 +1007,8 @@ public abstract class Provider extends Properties { /** * Returns the {@code Provider} this {@code Service} belongs to. - * + * * @return the {@code Provider} this {@code Service} belongs to. - * @since Android 1.0 */ public final Provider getProvider() { return provider; @@ -1038,9 +1016,8 @@ public abstract class Provider extends Properties { /** * Returns the name of the class implementing this {@code Service}. - * + * * @return the name of the class implementing this {@code Service}. - * @since Android 1.0 */ public final String getClassName() { return className; @@ -1048,14 +1025,13 @@ public abstract class Provider extends Properties { /** * Returns the value of the attribute with the specified {@code name}. - * + * * @param name * the name of the attribute. * @return the value of the attribute, or {@code null} if no attribute * with the given name is set. * @throws NullPointerException * if {@code name} is {@code null}. - * @since Android 1.0 */ public final String getAttribute(String name) { if (name == null) { @@ -1068,13 +1044,16 @@ public abstract class Provider extends Properties { } Iterator<String> getAliases() { + if(aliases == null){ + aliases = new ArrayList<String>(0); + } return aliases.iterator(); } /** * Creates and returns a new instance of the implementation described by * this {@code Service}. - * + * * @param constructorParameter * the parameter that is used by the constructor, or {@code * null} if the implementation does not declare a constructor @@ -1086,7 +1065,6 @@ public abstract class Provider extends Properties { * @throws InvalidParameterException * if the implementation does not support the specified * {@code constructorParameter}. - * @since Android 1.0 */ public Object newInstance(Object constructorParameter) throws NoSuchAlgorithmException { @@ -1122,39 +1100,37 @@ public abstract class Provider extends Properties { throw new NoSuchAlgorithmException(Messages.getString("security.199", //$NON-NLS-1$ type, algorithm), e); } - } else { - if (!supportsParameter(constructorParameter)) { - throw new InvalidParameterException( - Messages.getString("security.12", type)); //$NON-NLS-1$ - } + } + if (!supportsParameter(constructorParameter)) { + throw new InvalidParameterException( + Messages.getString("security.12", type)); //$NON-NLS-1$ + } - Class[] parameterTypes = new Class[1]; - Object[] initargs = { constructorParameter }; - try { - if (type.equalsIgnoreCase("CertStore")) { //$NON-NLS-1$ - parameterTypes[0] = Class - .forName("java.security.cert.CertStoreParameters"); //$NON-NLS-1$ - } else { - parameterTypes[0] = constructorParameter.getClass(); - } - return implementation.getConstructor(parameterTypes) - .newInstance(initargs); - } catch (Exception e) { - throw new NoSuchAlgorithmException(Messages.getString("security.199", //$NON-NLS-1$ - type, algorithm), e); + Class[] parameterTypes = new Class[1]; + Object[] initargs = { constructorParameter }; + try { + if (Util.equalsIgnoreCase(type,"CertStore")) { //$NON-NLS-1$ + parameterTypes[0] = Class + .forName("java.security.cert.CertStoreParameters"); //$NON-NLS-1$ + } else { + parameterTypes[0] = constructorParameter.getClass(); } + return implementation.getConstructor(parameterTypes) + .newInstance(initargs); + } catch (Exception e) { + throw new NoSuchAlgorithmException(Messages.getString("security.199", //$NON-NLS-1$ + type, algorithm), e); } } /** * Indicates whether this {@code Service} supports the specified * constructor parameter. - * + * * @param parameter * the parameter to test. * @return {@code true} if this {@code Service} supports the specified * constructor parameter, {@code false} otherwise. - * @since Android 1.0 */ public boolean supportsParameter(Object parameter) { return true; @@ -1163,10 +1139,10 @@ public abstract class Provider extends Properties { /** * Returns a string containing a concise, human-readable description of * this {@code Service}. - * + * * @return a printable representation for this {@code Service}. - * @since Android 1.0 */ + @Override public String toString() { String result = "Provider " + provider.getName() + " Service " //$NON-NLS-1$ //$NON-NLS-2$ + type + "." + algorithm + " " + className; //$NON-NLS-1$ //$NON-NLS-2$ @@ -1179,4 +1155,10 @@ public abstract class Provider extends Properties { return result; } } + + private void readObject(java.io.ObjectInputStream in) throws NotActiveException, IOException, ClassNotFoundException { + in.defaultReadObject(); + versionString = String.valueOf(version); + providerNumber = -1; + } } diff --git a/security/src/main/java/java/security/ProviderException.java b/security/src/main/java/java/security/ProviderException.java index d4def5b..22950f5 100644 --- a/security/src/main/java/java/security/ProviderException.java +++ b/security/src/main/java/java/security/ProviderException.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - package java.security; /** @@ -27,7 +22,6 @@ package java.security; * Providers}. * * @see Provider - * @since Android 1.0 */ public class ProviderException extends RuntimeException { @@ -36,10 +30,9 @@ public class ProviderException extends RuntimeException { /** * Constructs a new instance of {@code ProviderException} with the given * message. - * + * * @param msg * the detail message for this exception. - * @since Android 1.0 */ public ProviderException(String msg) { super(msg); @@ -47,8 +40,6 @@ public class ProviderException extends RuntimeException { /** * Constructs a new instance of {@code ProviderException}. - * - * @since Android 1.0 */ public ProviderException() { } @@ -56,12 +47,11 @@ public class ProviderException extends RuntimeException { /** * Constructs a new instance of {@code ProviderException} 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 ProviderException(String message, Throwable cause) { super(message, cause); @@ -69,12 +59,11 @@ public class ProviderException extends RuntimeException { /** * Constructs a new instance of {@code ProviderException} with the cause. - * + * * @param cause * the exception which is the cause for this exception. - * @since Android 1.0 */ public ProviderException(Throwable cause) { super(cause); } -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/PublicKey.java b/security/src/main/java/java/security/PublicKey.java index 4888a64..c197840 100644 --- a/security/src/main/java/java/security/PublicKey.java +++ b/security/src/main/java/java/security/PublicKey.java @@ -15,25 +15,16 @@ * limitations under the License. */ -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - package java.security; /** * {@code PublicKey} is the common interface for public keys. * * @see PrivateKey - * @since Android 1.0 */ public interface PublicKey extends Key { - /** * The {@code serialVersionUID} to be compatible with JDK1.1. - * - * @since Android 1.0 */ public static final long serialVersionUID = 7187392471159151072L; } diff --git a/security/src/main/java/java/security/SecureClassLoader.java b/security/src/main/java/java/security/SecureClassLoader.java index 7d08fc8..07bebc9 100644 --- a/security/src/main/java/java/security/SecureClassLoader.java +++ b/security/src/main/java/java/security/SecureClassLoader.java @@ -15,28 +15,20 @@ * limitations under the License. */ -/** -* @author Alexander V. Astapchuk -* @version $Revision$ -*/ - package java.security; import java.nio.ByteBuffer; import java.util.HashMap; - /** * {@code SecureClassLoader} represents a {@code ClassLoader} which associates * the classes it loads with a code source and provide mechanisms to allow the * relevant permissions to be retrieved. - * - * @since Android 1.0 */ public class SecureClassLoader extends ClassLoader { // A cache of ProtectionDomains for a given CodeSource - private HashMap pds = new HashMap(); + private HashMap<CodeSource, ProtectionDomain> pds = new HashMap<CodeSource, ProtectionDomain>(); /** * Constructs a new instance of {@code SecureClassLoader}. The default @@ -45,12 +37,10 @@ public class SecureClassLoader extends ClassLoader { * If a {@code SecurityManager} is installed, code calling this constructor * needs the {@code SecurityPermission} {@code checkCreateClassLoader} to be * granted, otherwise a {@code SecurityException} will be thrown. - * </p> - * + * * @throws SecurityException * if a {@code SecurityManager} is installed and the caller does * not have permission to invoke this constructor. - * @since Android 1.0 */ protected SecureClassLoader() { super(); @@ -63,14 +53,12 @@ public class SecureClassLoader extends ClassLoader { * If a {@code SecurityManager} is installed, code calling this constructor * needs the {@code SecurityPermission} {@code checkCreateClassLoader} to be * granted, otherwise a {@code SecurityException} will be thrown. - * </p> - * + * * @param parent * the parent {@code ClassLoader}. * @throws SecurityException * if a {@code SecurityManager} is installed and the caller does * not have permission to invoke this constructor. - * @since Android 1.0 */ protected SecureClassLoader(ClassLoader parent) { super(parent); @@ -79,12 +67,11 @@ public class SecureClassLoader extends ClassLoader { /** * Returns the {@code PermissionCollection} for the specified {@code * CodeSource}. - * + * * @param codesource * the code source. * @return the {@code PermissionCollection} for the specified {@code * CodeSource}. - * @since Android 1.0 */ protected PermissionCollection getPermissions(CodeSource codesource) { // Do nothing by default, ProtectionDomain will take care about @@ -95,7 +82,7 @@ public class SecureClassLoader extends ClassLoader { /** * Constructs a new class from an array of bytes containing a class * definition in class file format with an optional {@code CodeSource}. - * + * * @param name * the name of the new class. * @param b @@ -116,7 +103,6 @@ public class SecureClassLoader extends ClassLoader { * if the package to which this class is to be added, already * contains classes which were signed by different certificates, * or if the class name begins with "java." - * @since Android 1.0 */ protected final Class<?> defineClass(String name, byte[] b, int off, int len, CodeSource cs) { @@ -127,7 +113,7 @@ public class SecureClassLoader extends ClassLoader { /** * Constructs a new class from an array of bytes containing a class * definition in class file format with an optional {@code CodeSource}. - * + * * @param name * the name of the new class. * @param b @@ -141,7 +127,6 @@ public class SecureClassLoader extends ClassLoader { * if the package to which this class is to be added, already * contains classes which were signed by different certificates, * or if the class name begins with "java." - * @since Android 1.0 */ protected final Class<?> defineClass(String name, ByteBuffer b, CodeSource cs) { //FIXME 1.5 - remove b.array(), call super.defineClass(,ByteBuffer,) @@ -165,7 +150,7 @@ public class SecureClassLoader extends ClassLoader { // will have it's own ProtectionDomain, which does not look right. ProtectionDomain pd; synchronized (pds) { - if ((pd = (ProtectionDomain) pds.get(cs)) != null) { + if ((pd = pds.get(cs)) != null) { return pd; } PermissionCollection perms = getPermissions(cs); diff --git a/security/src/main/java/java/security/SecureRandom.java b/security/src/main/java/java/security/SecureRandom.java index e1d99e9..c697504 100644 --- a/security/src/main/java/java/security/SecureRandom.java +++ b/security/src/main/java/java/security/SecureRandom.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Boris V. Kuznetsov -* @version $Revision$ -*/ - package java.security; import java.util.Iterator; @@ -35,8 +30,6 @@ import org.apache.harmony.security.provider.crypto.SHA1PRNG_SecureRandomImpl; /** * {@code SecureRandom} is an engine class which is capable of generating * cryptographically secure pseudo-random numbers. - * - * @since Android 1.0 */ public class SecureRandom extends Random { @@ -50,7 +43,7 @@ public class SecureRandom extends Random { private Provider provider; - private SecureRandomSpi secureRandomSpi; + private SecureRandomSpi secureRandomSpi; private String algorithm; @@ -69,8 +62,6 @@ public class SecureRandom extends Random { * Constructs a new instance of {@code SecureRandom}. An implementation for * the highest-priority provider is returned. The constructed instance will * not have been seeded. - * - * @since Android 1.0 */ public SecureRandom() { super(0); @@ -97,7 +88,6 @@ public class SecureRandom extends Random { * * @param seed * the seed for this generator. - * @since Android 1.0 */ public SecureRandom(byte[] seed) { this(); @@ -125,7 +115,6 @@ public class SecureRandom extends Random { * the implementation. * @param provider * the security provider. - * @since Android 1.0 */ protected SecureRandom(SecureRandomSpi secureRandomSpi, Provider provider) { @@ -154,7 +143,6 @@ public class SecureRandom extends Random { * if the specified algorithm is not available. * @throws NullPointerException * if {@code algorithm} is {@code null}. - * @since Android 1.0 */ public static SecureRandom getInstance(String algorithm) throws NoSuchAlgorithmException { @@ -183,7 +171,6 @@ public class SecureRandom extends Random { * if the specified provider is not available. * @throws NullPointerException * if {@code algorithm} is {@code null}. - * @since Android 1.0 */ public static SecureRandom getInstance(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException { @@ -212,7 +199,6 @@ public class SecureRandom extends Random { * if the specified algorithm is not available. * @throws NullPointerException * if {@code algorithm} is {@code null}. - * @since Android 1.0 */ public static SecureRandom getInstance(String algorithm, Provider provider) throws NoSuchAlgorithmException { @@ -232,7 +218,6 @@ public class SecureRandom extends Random { * Returns the provider associated with this {@code SecureRandom}. * * @return the provider associated with this {@code SecureRandom}. - * @since Android 1.0 */ public final Provider getProvider() { return provider; @@ -242,7 +227,6 @@ public class SecureRandom extends Random { * Returns the name of the algorithm of this {@code SecureRandom}. * * @return the name of the algorithm of this {@code SecureRandom}. - * @since Android 1.0 */ public String getAlgorithm() { return algorithm; @@ -255,7 +239,6 @@ public class SecureRandom extends Random { * * @param seed * the new seed. - * @since Android 1.0 */ public synchronized void setSeed(byte[] seed) { secureRandomSpi.engineSetSeed(seed); @@ -268,8 +251,8 @@ public class SecureRandom extends Random { * * @param seed * the new seed. - * @since Android 1.0 */ + @Override public void setSeed(long seed) { if (seed == 0) { // skip call from Random return; @@ -293,8 +276,8 @@ public class SecureRandom extends Random { * * @param bytes * the {@code byte[]} to be filled with random bytes. - * @since Android 1.0 */ + @Override public synchronized void nextBytes(byte[] bytes) { secureRandomSpi.engineNextBytes(bytes); } @@ -307,8 +290,8 @@ public class SecureRandom extends Random { * number of bits to be generated. An input value should be in * the range [0, 32]. * @return an {@code int} containing the specified number of random bits. - * @since Android 1.0 */ + @Override protected final int next(int numBits) { if (numBits < 0) { numBits = 0; @@ -336,7 +319,6 @@ public class SecureRandom extends Random { * @param numBytes * the number of seed bytes. * @return the seed bytes - * @since Android 1.0 */ public static byte[] getSeed(int numBytes) { if (internalSecureRandom == null) { @@ -352,7 +334,6 @@ public class SecureRandom extends Random { * @param numBytes * the number of seed bytes. * @return the seed bytes. - * @since Android 1.0 */ public byte[] generateSeed(int numBytes) { return secureRandomSpi.engineGenerateSeed(numBytes); diff --git a/security/src/main/java/java/security/SecureRandomSpi.java b/security/src/main/java/java/security/SecureRandomSpi.java index 7ce880c..829464f 100644 --- a/security/src/main/java/java/security/SecureRandomSpi.java +++ b/security/src/main/java/java/security/SecureRandomSpi.java @@ -15,21 +15,15 @@ * limitations under the License. */ -/** -* @author Boris V. Kuznetsov -* @version $Revision$ -*/ - package java.security; import java.io.Serializable; /** * {@code SecureRandomSpi} is the <i>Service Provider Interface</i> (<b>SPI</b>) definition - * for {@link SecureRandom}. + * for {@link SecureRandom}. * * @see SecureRandom - * @since Android 1.0 */ public abstract class SecureRandomSpi implements Serializable { @@ -42,7 +36,6 @@ public abstract class SecureRandomSpi implements Serializable { * * @param seed * the new seed. - * @since Android 1.0 */ protected abstract void engineSetSeed(byte[] seed); @@ -52,7 +45,6 @@ public abstract class SecureRandomSpi implements Serializable { * * @param bytes * the {@code byte[]} to be filled with random bytes. - * @since Android 1.0 */ protected abstract void engineNextBytes(byte[] bytes); @@ -63,7 +55,6 @@ public abstract class SecureRandomSpi implements Serializable { * @param numBytes * the number of seed bytes. * @return the seed bytes - * @since Android 1.0 */ protected abstract byte[] engineGenerateSeed(int numBytes); } diff --git a/security/src/main/java/java/security/Security.java b/security/src/main/java/java/security/Security.java index 505a557..6ff38ad 100644 --- a/security/src/main/java/java/security/Security.java +++ b/security/src/main/java/java/security/Security.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Boris V. Kuznetsov -* @version $Revision$ -*/ - package java.security; import java.io.BufferedInputStream; @@ -39,7 +34,9 @@ import java.util.Iterator; import java.util.Map; import java.util.Properties; import java.util.Set; +import java.util.Map.Entry; +import org.apache.harmony.security.Util; import org.apache.harmony.security.fortress.Engine; import org.apache.harmony.security.fortress.PolicyUtils; import org.apache.harmony.security.fortress.SecurityAccess; @@ -50,8 +47,6 @@ import org.apache.harmony.security.internal.nls.Messages; * {@code Security} is the central class in the Java Security API. It manages * the list of security {@code Provider} that have been installed into this * runtime environment. - * - * @since Android 1.0 */ public final class Security { @@ -87,57 +82,40 @@ public final class Security { // END android-added // BEGIN android-removed - // File f = new File(System.getProperty("java.home") //$NON-NLS-1$ - // + File.separator + "lib" + File.separator //$NON-NLS-1$ - // + "security" + File.separator + "java.security"); //$NON-NLS-1$ //$NON-NLS-2$ - // if (f.exists()) { - // try { - // FileInputStream fis = new FileInputStream(f); - // InputStream is = new BufferedInputStream(fis); - // secprops.load(is); - // loaded = true; - // is.close(); - // } catch (IOException e) { - //// System.err.println("Could not load Security properties file: " - //// + e); - // } - // } - // - // if ("true".equalsIgnoreCase(secprops.getProperty("security.allowCustomPropertiesFile", "true"))) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - // String securityFile = System.getProperty("java.security.properties"); //$NON-NLS-1$ - // if (securityFile != null) { - // if (securityFile.startsWith("=")) { // overwrite //$NON-NLS-1$ - // secprops = new Properties(); - // loaded = false; - // securityFile = securityFile.substring(1); - // } - // try { - // securityFile = PolicyUtils.expand(securityFile, System.getProperties()); - // } catch (PolicyUtils.ExpansionFailedException e) { - //// System.err.println("Could not load custom Security properties file " - //// + securityFile +": " + e); - // } - // f = new File(securityFile); - // InputStream is; - // try { - // if (f.exists()) { - // FileInputStream fis = new FileInputStream(f); - // is = new BufferedInputStream(fis); - // } else { - // URL url = new URL(securityFile); - // is = new BufferedInputStream(url.openStream()); - // } - // secprops.load(is); - // loaded = true; - // is.close(); - // } catch (IOException e) { - // // System.err.println("Could not load custom Security properties file " - // // + securityFile +": " + e); - // } - // } - // } +// if (Util.equalsIgnoreCase("true", secprops.getProperty("security.allowCustomPropertiesFile", "true"))) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ +// String securityFile = System.getProperty("java.security.properties"); //$NON-NLS-1$ +// if (securityFile != null) { +// if (securityFile.startsWith("=")) { // overwrite //$NON-NLS-1$ +// secprops = new Properties(); +// loaded = false; +// securityFile = securityFile.substring(1); +// } +// try { +// securityFile = PolicyUtils.expand(securityFile, System.getProperties()); +// } catch (PolicyUtils.ExpansionFailedException e) { +//// System.err.println("Could not load custom Security properties file " +//// + securityFile +": " + e); +// } +// f = new File(securityFile); +// InputStream is; +// try { +// if (f.exists()) { +// FileInputStream fis = new FileInputStream(f); +// is = new BufferedInputStream(fis); +// } else { +// URL url = new URL(securityFile); +// is = new BufferedInputStream(url.openStream()); +// } +// secprops.load(is); +// loaded = true; +// is.close(); +// } catch (IOException e) { +// // System.err.println("Could not load custom Security properties file " +// // + securityFile +": " + e); +// } +// } +// } // END android-removed - if (!loaded) { registerDefaultProviders(); } @@ -161,12 +139,9 @@ public final class Security { secprops.put("security.provider.4", "org.bouncycastle.jce.provider.BouncyCastleProvider"); //$NON-NLS-1$ //$NON-NLS-2$ } - // BEGIN android-note - // added Deprecated annotation - // END android-note /** * Returns value for the specified algorithm with the specified name. - * + * * @param algName * the name of the algorithm. * @param propName @@ -174,7 +149,6 @@ public final class Security { * @return value of the property. * @deprecated Use {@link AlgorithmParameters} and {@link KeyFactory} * instead. - * @since Android 1.0 */ @Deprecated public static String getAlgorithmProperty(String algName, String propName) { @@ -189,7 +163,7 @@ public final class Security { for (Enumeration e = providers[i].propertyNames(); e .hasMoreElements();) { String pname = (String) e.nextElement(); - if (prop.equalsIgnoreCase(pname)) { + if (Util.equalsIgnoreCase(prop, pname)) { return providers[i].getProperty(pname); } } @@ -206,8 +180,7 @@ public final class Security { * the {@code SecurityPermission} {@code insertProvider.NAME} (where NAME is * the provider name) to be granted, otherwise a {@code SecurityException} * will be thrown. - * </p> - * + * * @param provider * the provider to insert. * @param position @@ -218,7 +191,6 @@ public final class Security { * @throws SecurityException * if a {@code SecurityManager} is installed and the caller does * not have permission to invoke this method. - * @since Android 1.0 */ public static synchronized int insertProviderAt(Provider provider, int position) { @@ -246,8 +218,7 @@ public final class Security { * the {@code SecurityPermission} {@code insertProvider.NAME} (where NAME is * the provider name) to be granted, otherwise a {@code SecurityException} * will be thrown. - * </p> - * + * * @param provider * the provider to be added. * @return the actual position or {@code -1} if the given {@code provider} @@ -255,7 +226,6 @@ public final class Security { * @throws SecurityException * if a {@code SecurityManager} is installed and the caller does * not have permission to invoke this method. - * @since Android 1.0 */ public static int addProvider(Provider provider) { return insertProviderAt(provider, 0); @@ -269,20 +239,17 @@ public final class Security { * <p> * Returns silently if {@code name} is {@code null} or no provider with the * specified name is installed. - * </p> * <p> * If a {@code SecurityManager} is installed, code calling this method needs * the {@code SecurityPermission} {@code removeProvider.NAME} (where NAME is * the provider name) to be granted, otherwise a {@code SecurityException} * will be thrown. - * </p> - * + * * @param name * the name of the provider to remove. * @throws SecurityException * if a {@code SecurityManager} is installed and the caller does * not have permission to invoke this method. - * @since Android 1.0 */ public static synchronized void removeProvider(String name) { // It is not clear from spec.: @@ -311,9 +278,8 @@ public final class Security { /** * Returns an array containing all installed providers. The providers are * ordered according their preference order. - * + * * @return an array containing all installed providers. - * @since Android 1.0 */ public static synchronized Provider[] getProviders() { return Services.getProviders(); @@ -323,11 +289,10 @@ public final class Security { * Returns the {@code Provider} with the specified name. Returns {@code * null} if name is {@code null} or no provider with the specified name is * installed. - * + * * @param name * the name of the requested provider. * @return the provider with the specified name, maybe {@code null}. - * @since Android 1.0 */ public static synchronized Provider getProvider(String name) { return Services.getProvider(name); @@ -337,15 +302,15 @@ public final class Security { * Returns the array of providers which meet the user supplied string * filter. The specified filter must be supplied in one of two formats: * <nl> - * <li> CRYPTO_SERVICE_NAME.ALGORITHM_OR_TYPE + * <li> CRYPTO_SERVICE_NAME.ALGORITHM_OR_TYPE * <p> - * (for example: "MessageDigest.SHA") + * (for example: "MessageDigest.SHA") * <li> CRYPTO_SERVICE_NAME.ALGORITHM_OR_TYPE * ATTR_NAME:ATTR_VALUE * <p> - * (for example: "Signature.MD5withRSA KeySize:512") + * (for example: "Signature.MD2withRSA KeySize:512") * </nl> - * + * * @param filter * case-insensitive filter. * @return the providers which meet the user supplied string filter {@code @@ -355,7 +320,6 @@ public final class Security { * if an unusable filter is supplied. * @throws NullPointerException * if {@code filter} is {@code null}. - * @since Android 1.0 */ public static Provider[] getProviders(String filter) { if (filter == null) { @@ -366,7 +330,7 @@ public final class Security { Messages.getString("security.2B")); //$NON-NLS-1$ } HashMap<String, String> hm = new HashMap<String, String>(); - int i = filter.indexOf(":"); //$NON-NLS-1$ + int i = filter.indexOf(':'); if ((i == filter.length() - 1) || (i == 0)) { throw new InvalidParameterException( Messages.getString("security.2B")); //$NON-NLS-1$ @@ -389,10 +353,10 @@ public final class Security { * be an empty string. <li> CRYPTO_SERVICE_NAME.ALGORITHM_OR_TYPE * ATTR_NAME:ATTR_VALUE * <p> - * for example: "Signature.MD5withRSA KeySize:512" where "KeySize:512" is + * for example: "Signature.MD2withRSA KeySize:512" where "KeySize:512" is * the value of the filter map entry. * </nl> - * + * * @param filter * case-insensitive filter. * @return the providers which meet the user supplied string filter {@code @@ -402,7 +366,6 @@ public final class Security { * if an unusable filter is supplied. * @throws NullPointerException * if {@code filter} is {@code null}. - * @since Android 1.0 */ public static synchronized Provider[] getProviders(Map<String,String> filter) { if (filter == null) { @@ -412,15 +375,15 @@ public final class Security { return null; } java.util.List<Provider> result = Services.getProvidersList(); - Set keys = filter.entrySet(); - Map.Entry entry; - for (Iterator it = keys.iterator(); it.hasNext();) { - entry = (Map.Entry) it.next(); - String key = (String) entry.getKey(); - String val = (String) entry.getValue(); + Set<Entry<String, String>> keys = filter.entrySet(); + Map.Entry<String, String> entry; + for (Iterator<Entry<String, String>> it = keys.iterator(); it.hasNext();) { + entry = it.next(); + String key = entry.getKey(); + String val = entry.getValue(); String attribute = null; - int i = key.indexOf(" "); //$NON-NLS-1$ - int j = key.indexOf("."); //$NON-NLS-1$ + int i = key.indexOf(' '); + int j = key.indexOf('.'); if (j == -1) { throw new InvalidParameterException( Messages.getString("security.2B")); //$NON-NLS-1$ @@ -451,7 +414,7 @@ public final class Security { Provider p; for (int k = 0; k < result.size(); k++) { try { - p = (Provider) result.get(k); + p = result.get(k); } catch (IndexOutOfBoundsException e) { break; } @@ -463,9 +426,8 @@ public final class Security { } if (result.size() > 0) { return result.toArray(new Provider[result.size()]); - } else { - return null; } + return null; } /** @@ -475,15 +437,13 @@ public final class Security { * the {@code SecurityPermission} {@code getProperty.KEY} (where KEY is the * specified {@code key}) to be granted, otherwise a {@code * SecurityException} will be thrown. - * </p> - * + * * @param key * the name of the requested security property. * @return the value of the security property. * @throws SecurityException * if a {@code SecurityManager} is installed and the caller does * not have permission to invoke this method. - * @since Android 1.0 */ public static String getProperty(String key) { if (key == null) { @@ -493,7 +453,11 @@ public final class Security { if (sm != null) { sm.checkSecurityAccess("getProperty." + key); //$NON-NLS-1$ } - return secprops.getProperty(key); + String property = secprops.getProperty(key); + if (property != null) { + property = property.trim(); + } + return property; } /** @@ -503,8 +467,7 @@ public final class Security { * the {@code SecurityPermission} {@code setProperty.KEY} (where KEY is the * specified {@code key}) to be granted, otherwise a {@code * SecurityException} will be thrown. - * </p> - * + * * @param key * the name of the security property. * @param datnum @@ -512,7 +475,6 @@ public final class Security { * @throws SecurityException * if a {@code SecurityManager} is installed and the caller does * not have permission to invoke this method. - * @since Android 1.0 */ public static void setProperty(String key, String datnum) { SecurityManager sm = System.getSecurityManager(); @@ -526,22 +488,27 @@ public final class Security { * Returns a {@code Set} of all registered algorithms for the specified * cryptographic service. {@code "Signature"}, {@code "Cipher"} and {@code * "KeyStore"} are examples for such kind of services. - * + * * @param serviceName * the case-insensitive name of the service. * @return a {@code Set} of all registered algorithms for the specified * cryptographic service, or an empty {@code Set} if {@code * serviceName} is {@code null} or if no registered provider * provides the requested service. - * @since Android 1.0 */ public static Set<String> getAlgorithms(String serviceName) { Set<String> result = new HashSet<String>(); + // BEGIN android-added + // compatibility with RI + if (serviceName == null) { + return result; + } + // END android-added Provider[] p = getProviders(); for (int i = 0; i < p.length; i++) { for (Iterator it = p[i].getServices().iterator(); it.hasNext();) { Provider.Service s = (Provider.Service) it.next(); - if (s.getType().equalsIgnoreCase(serviceName)) { + if (Util.equalsIgnoreCase(s.getType(),serviceName)) { result.add(s.getAlgorithm()); } } diff --git a/security/src/main/java/java/security/SecurityPermission.java b/security/src/main/java/java/security/SecurityPermission.java index 87f3aaa..599ec6f 100644 --- a/security/src/main/java/java/security/SecurityPermission.java +++ b/security/src/main/java/java/security/SecurityPermission.java @@ -15,18 +15,11 @@ * limitations under the License. */ -/** -* @author Alexey V. Varlamov -* @version $Revision$ -*/ - package java.security; /** * {@code SecurityPermission} objects guard access to the mechanisms which * implement security. Security permissions have names, but not actions. - * - * @since Android 1.0 */ public final class SecurityPermission extends BasicPermission { @@ -35,10 +28,9 @@ public final class SecurityPermission extends BasicPermission { /** * Constructs a new instance of {@code SecurityPermission} with the given * name. - * + * * @param name * the name of the permission. - * @since Android 1.0 */ public SecurityPermission(String name) { super(name); @@ -48,12 +40,11 @@ public final class SecurityPermission extends BasicPermission { * Constructs a new instance of {@code SecurityPermission} with the given * {@code name} and {@code action} list. The action list is ignored - it is * existing for compatibility reasons only. - * + * * @param name * the name of the permission. * @param action * ignored. - * @since Android 1.0 */ public SecurityPermission(String name, String action) { super(name, action); diff --git a/security/src/main/java/java/security/Signature.java b/security/src/main/java/java/security/Signature.java index e5d488e..4e3fe14 100644 --- a/security/src/main/java/java/security/Signature.java +++ b/security/src/main/java/java/security/Signature.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Boris V. Kuznetsov -* @version $Revision$ -*/ - package java.security; import java.nio.ByteBuffer; @@ -39,7 +34,6 @@ import org.apache.harmony.security.internal.nls.Messages; * registered with the {@link Security} class. * * @see SignatureSpi - * @since Android 1.0 */ public abstract class Signature extends SignatureSpi { @@ -58,24 +52,18 @@ public abstract class Signature extends SignatureSpi { /** * Constant that indicates that this {@code Signature} instance has not yet * been initialized. - * - * @since Android 1.0 */ protected static final int UNINITIALIZED = 0; /** * Constant that indicates that this {@code Signature} instance has been * initialized for signing. - * - * @since Android 1.0 */ protected static final int SIGN = 2; /** * Constant that indicates that this {@code Signature} instance has been * initialized for verification. - * - * @since Android 1.0 */ protected static final int VERIFY = 3; @@ -83,18 +71,15 @@ public abstract class Signature extends SignatureSpi { * Represents the current state of this {@code Signature}. The three * possible states are {@link #UNINITIALIZED}, {@link #SIGN} or * {@link #VERIFY}. - * - * @since Android 1.0 */ protected int state = UNINITIALIZED; /** * Constructs a new instance of {@code Signature} with the name of * the algorithm to use. - * + * * @param algorithm * the name of algorithm to use. - * @since Android 1.0 */ protected Signature(String algorithm) { this.algorithm = algorithm; @@ -103,7 +88,7 @@ public abstract class Signature extends SignatureSpi { /** * Returns a new instance of {@code Signature} that utilizes the specified * algorithm. - * + * * @param algorithm * the name of the algorithm to use. * @return a new instance of {@code Signature} that utilizes the specified @@ -112,7 +97,6 @@ public abstract class Signature extends SignatureSpi { * if the specified algorithm is not available. * @throws NullPointerException * if {@code algorithm} is {@code null}. - * @since Android 1.0 */ public static Signature getInstance(String algorithm) throws NoSuchAlgorithmException { @@ -137,7 +121,7 @@ public abstract class Signature extends SignatureSpi { /** * Returns a new instance of {@code Signature} that utilizes the specified * algorithm from the specified provider. - * + * * @param algorithm * the name of the algorithm to use. * @param provider @@ -150,7 +134,6 @@ public abstract class Signature extends SignatureSpi { * if the specified provider is not available. * @throws NullPointerException * if {@code algorithm} is {@code null}. - * @since Android 1.0 */ public static Signature getInstance(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException { @@ -171,7 +154,7 @@ public abstract class Signature extends SignatureSpi { /** * Returns a new instance of {@code Signature} that utilizes the specified * algorithm from the specified provider. - * + * * @param algorithm * the name of the algorithm to use. * @param provider @@ -182,7 +165,6 @@ public abstract class Signature extends SignatureSpi { * if the specified algorithm is not available. * @throws NullPointerException * if {@code algorithm} is {@code null}. - * @since Android 1.0 */ public static Signature getInstance(String algorithm, Provider provider) throws NoSuchAlgorithmException { @@ -214,9 +196,8 @@ public abstract class Signature extends SignatureSpi { /** * Returns the provider associated with this {@code Signature}. - * + * * @return the provider associated with this {@code Signature}. - * @since Android 1.0 */ public final Provider getProvider() { return provider; @@ -224,9 +205,8 @@ public abstract class Signature extends SignatureSpi { /** * Returns the name of the algorithm of this {@code Signature}. - * + * * @return the name of the algorithm of this {@code Signature}. - * @since Android 1.0 */ public final String getAlgorithm() { return algorithm; @@ -236,12 +216,11 @@ public abstract class Signature extends SignatureSpi { * Initializes this {@code Signature} instance for signature verification, * using the public key of the identity whose signature is going to be * verified. - * + * * @param publicKey * the public key. * @throws InvalidKeyException * if {@code publicKey} is not valid. - * @since Android 1.0 */ public final void initVerify(PublicKey publicKey) throws InvalidKeyException { @@ -257,14 +236,12 @@ public abstract class Signature extends SignatureSpi { * If the given certificate is an instance of {@link X509Certificate} and * has a key usage parameter that indicates, that this certificate is not to * be used for signing, an {@code InvalidKeyException} is thrown. - * </p> - * + * * @param certificate * the certificate used to verify a signature. * @throws InvalidKeyException * if the publicKey in the certificate is not valid or not to be * used for signing. - * @since Android 1.0 */ public final void initVerify(Certificate certificate) throws InvalidKeyException { @@ -302,12 +279,11 @@ public abstract class Signature extends SignatureSpi { /** * Initializes this {@code Signature} instance for signing, using the * private key of the identity whose signature is going to be generated. - * + * * @param privateKey * the private key. * @throws InvalidKeyException * if {@code privateKey} is not valid. - * @since Android 1.0 */ public final void initSign(PrivateKey privateKey) throws InvalidKeyException { @@ -319,14 +295,13 @@ public abstract class Signature extends SignatureSpi { * Initializes this {@code Signature} instance for signing, using the * private key of the identity whose signature is going to be generated and * the specified source of randomness. - * + * * @param privateKey * the private key. * @param random * the {@code SecureRandom} to use. * @throws InvalidKeyException * if {@code privateKey} is not valid. - * @since Android 1.0 */ public final void initSign(PrivateKey privateKey, SecureRandom random) throws InvalidKeyException { @@ -340,13 +315,11 @@ public abstract class Signature extends SignatureSpi { * This {@code Signature} instance is reset to the state of its last * initialization for signing and thus can be used for another signature * from the same identity. - * </p> - * + * * @return the signature of all updated data. * @throws SignatureException * if this {@code Signature} instance is not initialized * properly. - * @since Android 1.0 */ public final byte[] sign() throws SignatureException { if (state != SIGN) { @@ -363,8 +336,7 @@ public abstract class Signature extends SignatureSpi { * This {@code Signature} instance is reset to the state of its last * initialization for signing and thus can be used for another signature * from the same identity. - * </p> - * + * * @param outbuf * the buffer to store the signature. * @param offset @@ -378,7 +350,6 @@ public abstract class Signature extends SignatureSpi { * @throws IllegalArgumentException * if {@code offset} or {@code len} are not valid in respect to * {@code outbuf}. - * @since Android 1.0 */ public final int sign(byte[] outbuf, int offset, int len) throws SignatureException { @@ -401,8 +372,7 @@ public abstract class Signature extends SignatureSpi { * This {@code Signature} instance is reset to the state of its last * initialization for verifying and thus can be used to verify another * signature of the same signer. - * </p> - * + * * @param signature * the signature to verify. * @return {@code true} if the signature was verified, {@code false} @@ -410,7 +380,6 @@ public abstract class Signature extends SignatureSpi { * @throws SignatureException * if this {@code Signature} instance is not initialized * properly. - * @since Android 1.0 */ public final boolean verify(byte[] signature) throws SignatureException { if (state != VERIFY) { @@ -428,8 +397,7 @@ public abstract class Signature extends SignatureSpi { * This {@code Signature} instance is reset to the state of its last * initialization for verifying and thus can be used to verify another * signature of the same signer. - * </p> - * + * * @param signature * the {@code byte[]} containing the signature to verify. * @param offset @@ -444,7 +412,6 @@ public abstract class Signature extends SignatureSpi { * @throws IllegalArgumentException * if {@code offset} or {@code length} are not valid in respect * to {@code signature}. - * @since Android 1.0 */ public final boolean verify(byte[] signature, int offset, int length) throws SignatureException { @@ -463,13 +430,12 @@ public abstract class Signature extends SignatureSpi { /** * Updates the data to be verified or to be signed, using the specified * {@code byte}. - * + * * @param b * the byte to update with. * @throws SignatureException * if this {@code Signature} instance is not initialized * properly. - * @since Android 1.0 */ public final void update(byte b) throws SignatureException { if (state == UNINITIALIZED) { @@ -482,13 +448,12 @@ public abstract class Signature extends SignatureSpi { /** * Updates the data to be verified or to be signed, using the specified * {@code byte[]}. - * + * * @param data * the byte array to update with. * @throws SignatureException * if this {@code Signature} instance is not initialized * properly. - * @since Android 1.0 */ public final void update(byte[] data) throws SignatureException { if (state == UNINITIALIZED) { @@ -501,7 +466,7 @@ public abstract class Signature extends SignatureSpi { /** * Updates the data to be verified or to be signed, using the given {@code * byte[]}, starting form the specified index for the specified length. - * + * * @param data * the byte array to update with. * @param off @@ -511,7 +476,6 @@ public abstract class Signature extends SignatureSpi { * @throws SignatureException * if this {@code Signature} instance is not initialized * properly. - * @since Android 1.0 */ public final void update(byte[] data, int off, int len) throws SignatureException { @@ -530,13 +494,12 @@ public abstract class Signature extends SignatureSpi { /** * Updates the data to be verified or to be signed, using the specified * {@code ByteBuffer}. - * + * * @param data * the {@code ByteBuffer} to update with. * @throws SignatureException * if this {@code Signature} instance is not initialized * properly. - * @since Android 1.0 */ public final void update(ByteBuffer data) throws SignatureException { if (state == UNINITIALIZED) { @@ -549,10 +512,10 @@ public abstract class Signature extends SignatureSpi { /** * Returns a string containing a concise, human-readable description of this * {@code Signature} including its algorithm and its state. - * + * * @return a printable representation for this {@code Signature}. - * @since Android 1.0 */ + @Override public String toString() { return "SIGNATURE " + algorithm + " state: " + stateToString(state); //$NON-NLS-1$ //$NON-NLS-2$ } @@ -571,12 +534,9 @@ public abstract class Signature extends SignatureSpi { } } - // BEGIN android-note - // added Deprecated annotation - // END android-note /** * Sets the specified parameter to the given value. - * + * * @param param * the name of the parameter. * @param value @@ -585,7 +545,6 @@ public abstract class Signature extends SignatureSpi { * if the parameter is invalid, already set or is not allowed to * be changed. * @deprecated Use {@link #setParameter(AlgorithmParameterSpec)} - * @since Android 1.0 */ @Deprecated public final void setParameter(String param, Object value) @@ -595,13 +554,12 @@ public abstract class Signature extends SignatureSpi { /** * Sets the specified {@code AlgorithmParameterSpec}. - * + * * @param params * the parameter to set. * @throws InvalidAlgorithmParameterException * if the parameter is invalid, already set or is not allowed to * be changed. - * @since Android 1.0 */ public final void setParameter(AlgorithmParameterSpec params) throws InvalidAlgorithmParameterException { @@ -611,18 +569,14 @@ public abstract class Signature extends SignatureSpi { /** * Returns the {@code AlgorithmParameters} of this {@link Signature} * instance. - * + * * @return the {@code AlgorithmParameters} of this {@link Signature} * instance, maybe {@code null}. - * @since Android 1.0 */ public final AlgorithmParameters getParameters() { return engineGetParameters(); } - // BEGIN android-note - // added Deprecated annotation - // END android-note /** * Returns the value of the parameter with the specified name. * @@ -634,7 +588,6 @@ public abstract class Signature extends SignatureSpi { * if {@code param} is not a valid parameter for this {@code * Signature} or an other error occures. * @deprecated There is no generally accepted parameter naming convention. - * @since Android 1.0 */ @Deprecated public final Object getParameter(String param) @@ -642,12 +595,12 @@ public abstract class Signature extends SignatureSpi { return engineGetParameter(param); } + @Override public Object clone() throws CloneNotSupportedException { if (this instanceof Cloneable) { return super.clone(); - } else { - throw new CloneNotSupportedException(); } + throw new CloneNotSupportedException(); } /** @@ -668,58 +621,66 @@ public abstract class Signature extends SignatureSpi { } // engineSign() implementation + @Override protected byte[] engineSign() throws SignatureException { return spiImpl.engineSign(); } // engineUpdate() implementation + @Override protected void engineUpdate(byte arg0) throws SignatureException { spiImpl.engineUpdate(arg0); } // engineVerify() implementation + @Override protected boolean engineVerify(byte[] arg0) throws SignatureException { return spiImpl.engineVerify(arg0); } // engineUpdate() implementation + @Override protected void engineUpdate(byte[] arg0, int arg1, int arg2) throws SignatureException { spiImpl.engineUpdate(arg0, arg1, arg2); } // engineInitSign() implementation + @Override protected void engineInitSign(PrivateKey arg0) throws InvalidKeyException { spiImpl.engineInitSign(arg0); } // engineInitVerify() implementation + @Override protected void engineInitVerify(PublicKey arg0) throws InvalidKeyException { spiImpl.engineInitVerify(arg0); } // engineGetParameter() implementation + @Override protected Object engineGetParameter(String arg0) throws InvalidParameterException { return spiImpl.engineGetParameter(arg0); } // engineSetParameter() implementation + @Override protected void engineSetParameter(String arg0, Object arg1) throws InvalidParameterException { spiImpl.engineSetParameter(arg0, arg1); } // Returns a clone if the spiImpl is cloneable + @Override public Object clone() throws CloneNotSupportedException { if (spiImpl instanceof Cloneable) { SignatureSpi spi = (SignatureSpi) spiImpl.clone(); return new SignatureImpl(spi, getProvider(), getAlgorithm()); - } else { - throw new CloneNotSupportedException(); } + throw new CloneNotSupportedException(); } } } diff --git a/security/src/main/java/java/security/SignatureException.java b/security/src/main/java/java/security/SignatureException.java index f07c34b..f8909d1 100644 --- a/security/src/main/java/java/security/SignatureException.java +++ b/security/src/main/java/java/security/SignatureException.java @@ -15,18 +15,12 @@ * limitations under the License. */ -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - package java.security; /** *{@code SignatureException} is a general {@code Signature} exception. * * @see Signature - * @since Android 1.0 */ public class SignatureException extends GeneralSecurityException { @@ -35,10 +29,9 @@ public class SignatureException extends GeneralSecurityException { /** * Constructs a new instance of {@code SignatureException} with the * given message. - * + * * @param msg * the detail message for this exception. - * @since Android 1.0 */ public SignatureException(String msg) { super(msg); @@ -46,8 +39,6 @@ public class SignatureException extends GeneralSecurityException { /** * Constructs a new instance of {@code SignatureException}. - * - * @since Android 1.0 */ public SignatureException() { } @@ -55,12 +46,11 @@ public class SignatureException extends GeneralSecurityException { /** * Constructs a new instance of {@code SignatureException} 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 SignatureException(String message, Throwable cause) { super(message, cause); @@ -69,10 +59,9 @@ public class SignatureException extends GeneralSecurityException { /** * Constructs a new instance of {@code SignatureException} with the * cause. - * + * * @param cause * the exception which is the cause for this exception - * @since Android 1.0 */ public SignatureException(Throwable cause) { super(cause); diff --git a/security/src/main/java/java/security/SignatureSpi.java b/security/src/main/java/java/security/SignatureSpi.java index 738d489..93c9e8c 100644 --- a/security/src/main/java/java/security/SignatureSpi.java +++ b/security/src/main/java/java/security/SignatureSpi.java @@ -14,10 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** -* @author Boris V. Kuznetsov -* @version $Revision$ -*/ package java.security; @@ -31,14 +27,11 @@ import org.apache.harmony.security.internal.nls.Messages; * definition for {@link Signature}. * * @see Signature - * @since Android 1.0 */ public abstract class SignatureSpi { /** * Implementation specific source of randomness. - * - * @since Android 1.0 */ protected SecureRandom appRandom; @@ -46,12 +39,11 @@ public abstract class SignatureSpi { * Initializes this {@code SignatureSpi} instance for signature * verification, using the public key of the identity whose signature is * going to be verified. - * + * * @param publicKey * the public key. * @throws InvalidKeyException * if {@code publicKey} is not valid. - * @since Android 1.0 */ protected abstract void engineInitVerify(PublicKey publicKey) throws InvalidKeyException; @@ -59,12 +51,11 @@ public abstract class SignatureSpi { /** * Initializes this {@code SignatureSpi} instance for signing, using the * private key of the identity whose signature is going to be generated. - * + * * @param privateKey * the private key. * @throws InvalidKeyException * if {@code privateKey} is not valid. - * @since Android 1.0 */ protected abstract void engineInitSign(PrivateKey privateKey) throws InvalidKeyException; @@ -73,14 +64,13 @@ public abstract class SignatureSpi { * Initializes this {@code SignatureSpi} instance for signing, using the * private key of the identity whose signature is going to be generated and * the specified source of randomness. - * + * * @param privateKey * the private key. * @param random * the {@code SecureRandom} to use. * @throws InvalidKeyException * if {@code privateKey} is not valid. - * @since Android 1.0 */ protected void engineInitSign(PrivateKey privateKey, SecureRandom random) throws InvalidKeyException { @@ -91,20 +81,19 @@ public abstract class SignatureSpi { /** * Updates the data to be verified or to be signed, using the specified * {@code byte}. - * + * * @param b * the byte to update with. * @throws SignatureException * if this {@code SignatureSpi} instance is not initialized * properly. - * @since Android 1.0 */ protected abstract void engineUpdate(byte b) throws SignatureException; /** * Updates the data to be verified or to be signed, using the given {@code * byte[]}, starting form the specified index for the specified length. - * + * * @param b * the byte array to update with. * @param off @@ -114,7 +103,6 @@ public abstract class SignatureSpi { * @throws SignatureException * if this {@code SignatureSpi} instance is not initialized * properly. - * @since Android 1.0 */ protected abstract void engineUpdate(byte[] b, int off, int len) throws SignatureException; @@ -130,7 +118,6 @@ public abstract class SignatureSpi { * method it throws a {@code RuntimeException} if underlying * {@link #engineUpdate(byte[], int, int)} throws {@code * SignatureException}. - * @since Android 1.0 */ protected void engineUpdate(ByteBuffer input) { if (!input.hasRemaining()) { @@ -165,13 +152,11 @@ public abstract class SignatureSpi { * This {@code SignatureSpi} instance is reset to the state of its last * initialization for signing and thus can be used for another signature * from the same identity. - * </p> - * + * * @return the signature of all updated data. * @throws SignatureException * if this {@code SignatureSpi} instance is not initialized * properly. - * @since Android 1.0 */ protected abstract byte[] engineSign() throws SignatureException; @@ -182,8 +167,7 @@ public abstract class SignatureSpi { * This {@code SignatureSpi} instance is reset to the state of its last * initialization for signing and thus can be used for another signature * from the same identity. - * </p> - * + * * @param outbuf * the buffer to store the signature. * @param offset @@ -197,7 +181,6 @@ public abstract class SignatureSpi { * @throws IllegalArgumentException * if {@code offset} or {@code len} are not valid in respect to * {@code outbuf}. - * @since Android 1.0 */ protected int engineSign(byte[] outbuf, int offset, int len) throws SignatureException { @@ -225,8 +208,7 @@ public abstract class SignatureSpi { * This {@code SignatureSpi} instance is reset to the state of its last * initialization for verifying and thus can be used to verify another * signature of the same signer. - * </p> - * + * * @param sigBytes * the signature to verify. * @return {@code true} if the signature was verified, {@code false} @@ -234,7 +216,6 @@ public abstract class SignatureSpi { * @throws SignatureException * if this {@code SignatureSpi} instance is not initialized * properly. - * @since Android 1.0 */ protected abstract boolean engineVerify(byte[] sigBytes) throws SignatureException; @@ -247,8 +228,7 @@ public abstract class SignatureSpi { * This {@code SignatureSpi} instance is reset to the state of its last * initialization for verifying and thus can be used to verify another * signature of the same signer. - * </p> - * + * * @param sigBytes * the {@code byte[]} containing the signature to verify. * @param offset @@ -263,7 +243,6 @@ public abstract class SignatureSpi { * @throws IllegalArgumentException * if {@code offset} or {@code length} are not valid in respect * to {@code sigBytes}. - * @since Android 1.0 */ protected boolean engineVerify(byte[] sigBytes, int offset, int length) throws SignatureException { @@ -274,7 +253,7 @@ public abstract class SignatureSpi { /** * Sets the specified parameter to the given value. - * + * * @param param * the name of the parameter. * @param value @@ -283,7 +262,6 @@ public abstract class SignatureSpi { * if the parameter is invalid, already set or is not allowed to * be changed. * @deprecated Use {@link #engineSetParameter(AlgorithmParameterSpec)} - * @since Android 1.0 */ @Deprecated protected abstract void engineSetParameter(String param, Object value) @@ -291,13 +269,12 @@ public abstract class SignatureSpi { /** * Sets the specified {@code AlgorithmParameterSpec}. - * + * * @param params * the parameter to set. * @throws InvalidAlgorithmParameterException * if the parameter is invalid, already set or is not allowed to * be changed. - * @since Android 1.0 */ protected void engineSetParameter(AlgorithmParameterSpec params) throws InvalidAlgorithmParameterException { @@ -307,21 +284,17 @@ public abstract class SignatureSpi { /** * Returns the {@code AlgorithmParameters} of this {@link SignatureSpi} * instance. - * + * * @return the {@code AlgorithmParameters} of this {@link SignatureSpi} * instance, maybe {@code null}. - * @since Android 1.0 */ protected AlgorithmParameters engineGetParameters() { throw new UnsupportedOperationException(); } - // BEGIN android-note - // added Deprecated annotation - // END android-note /** * Returns the value of the parameter with the specified name. - * + * * @param param * the name of the requested parameter value. * @return the value of the parameter with the specified name, maybe {@code @@ -330,17 +303,16 @@ public abstract class SignatureSpi { * if {@code param} is not a valid parameter for this {@code * SignatureSpi} or an other error occurs. * @deprecated There is no generally accepted parameter naming convention. - * @since Android 1.0 */ @Deprecated protected abstract Object engineGetParameter(String param) throws InvalidParameterException; + @Override public Object clone() throws CloneNotSupportedException { if (this instanceof Cloneable) { return super.clone(); - } else { - throw new CloneNotSupportedException(); } + throw new CloneNotSupportedException(); } } diff --git a/security/src/main/java/java/security/SignedObject.java b/security/src/main/java/java/security/SignedObject.java index d2022c8..3347cf3 100644 --- a/security/src/main/java/java/security/SignedObject.java +++ b/security/src/main/java/java/security/SignedObject.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Boris V. Kuznetsov -* @version $Revision$ -*/ - package java.security; import java.io.ByteArrayInputStream; @@ -33,8 +28,6 @@ import java.io.Serializable; * A {@code SignedObject} instance acts as a container for another object. The * {@code SignedObject} contains the target in serialized form along with a * digital signature of the serialized data. - * - * @since Android 1.0 */ public final class SignedObject implements Serializable { @@ -75,7 +68,6 @@ public final class SignedObject implements Serializable { * if the private key is not valid. * @throws SignatureException * if signature generation failed. - * @since Android 1.0 */ public SignedObject(Serializable object, PrivateKey signingKey, Signature signingEngine) throws IOException, InvalidKeyException, @@ -106,7 +98,6 @@ public final class SignedObject implements Serializable { * if deserialization failed. * @throws ClassNotFoundException * if the class of the encapsulated object can not be found. - * @since Android 1.0 */ public Object getObject() throws IOException, ClassNotFoundException { // deserialize our object @@ -123,7 +114,6 @@ public final class SignedObject implements Serializable { * Returns the signature data of the encapsulated serialized object. * * @return the signature data of the encapsulated serialized object. - * @since Android 1.0 */ public byte[] getSignature() { byte[] sig = new byte[signature.length]; @@ -135,7 +125,6 @@ public final class SignedObject implements Serializable { * Returns the name of the algorithm of this {@code SignedObject}. * * @return the name of the algorithm of this {@code SignedObject}. - * @since Android 1.0 */ public String getAlgorithm() { return thealgorithm; @@ -155,7 +144,6 @@ public final class SignedObject implements Serializable { * if the public key is invalid. * @throws SignatureException * if signature verification failed. - * @since Android 1.0 */ public boolean verify(PublicKey verificationKey, Signature verificationEngine) throws InvalidKeyException, @@ -166,4 +154,4 @@ public final class SignedObject implements Serializable { return verificationEngine.verify(signature); } -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/Signer.java b/security/src/main/java/java/security/Signer.java index 9e48226..64996bf 100644 --- a/security/src/main/java/java/security/Signer.java +++ b/security/src/main/java/java/security/Signer.java @@ -15,16 +15,8 @@ * limitations under the License. */ -/** - * @author Aleksei Y. Semenov - * @version $Revision$ - */ - package java.security; -// BEGIN android-note -// added Deprecated annotation -// END android-note /** * {@link Signer} represents an identity (individual or corporation) that owns a * private key and the corresponding public key. @@ -32,7 +24,6 @@ package java.security; * @deprecated Replaced by behavior in {@link java.security.cert * java.security.cert} package and {@link java.security.Principal * Principal} - * @since Android 1.0 */ @Deprecated public abstract class Signer extends Identity { @@ -43,8 +34,6 @@ public abstract class Signer extends Identity { /** * Constructs a new instance of {@code Signer}. - * - * @since Android 1.0 */ protected Signer() { super(); @@ -52,10 +41,9 @@ public abstract class Signer extends Identity { /** * Constructs a new instance of {@code Signer} with the given name. - * + * * @param name * the name of the signer. - * @since Android 1.0 */ public Signer(String name) { super(name); @@ -64,7 +52,7 @@ public abstract class Signer extends Identity { /** * Constructs a new instance of {@code Signer} with the given name in the * given scope. - * + * * @param name * the name of the signer. * @param scope @@ -72,7 +60,6 @@ public abstract class Signer extends Identity { * @throws KeyManagementException * if a signer with the specified name already exists in the * provided scope. - * @since Android 1.0 */ public Signer(String name, IdentityScope scope) throws KeyManagementException { @@ -84,12 +71,11 @@ public abstract class Signer extends Identity { * SecurityManager} is installed, code calling this method needs the {@code * SecurityPermission} {@code "getSignerPrivateKey"} to be granted, otherwise * a {@code SecurityException} will be thrown. - * + * * @return the private key of this {@code Signer}. * @throws SecurityException * if a {@code SecurityManager} is installed and the caller does * not have permission to invoke this method. - * @since Android 1.0 */ public PrivateKey getPrivateKey() { SecurityManager sm = System.getSecurityManager(); @@ -105,7 +91,7 @@ public abstract class Signer extends Identity { * SecurityManager} is installed, code calling this method needs the {@code * SecurityPermission} {@code getSignerPrivateKey} to be granted, otherwise * a {@code SecurityException} will be thrown. - * + * * @param pair * the key pair to associate with this {@code Signer}. * @throws InvalidParameterException @@ -115,7 +101,6 @@ public abstract class Signer extends Identity { * @throws SecurityException * if a {@code SecurityManager} is installed and the caller does * not have permission to invoke this method. - * @since Android 1.0 */ public final void setKeyPair(KeyPair pair) throws InvalidParameterException, KeyException { @@ -148,10 +133,10 @@ public abstract class Signer extends Identity { /** * Returns a string containing a concise, human-readable description of this * {@code Signer} including its name and its scope if present. - * + * * @return a printable representation for this {@code Signer}. - * @since Android 1.0 */ + @Override public String toString() { String s = "[Signer]" + getName(); //$NON-NLS-1$ if (getScope() != null) { diff --git a/security/src/main/java/java/security/Timestamp.java b/security/src/main/java/java/security/Timestamp.java index 1d31e6f..5a2930a 100644 --- a/security/src/main/java/java/security/Timestamp.java +++ b/security/src/main/java/java/security/Timestamp.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Alexander V. Astapchuk -* @version $Revision$ -*/ - package java.security; import java.io.Serializable; @@ -31,8 +26,6 @@ import org.apache.harmony.security.internal.nls.Messages; /** * {@code Timestamp} represents a signed time stamp. {@code Timestamp} is * immutable. - * - * @since Android 1.0 */ public final class Timestamp implements Serializable { @@ -48,7 +41,7 @@ public final class Timestamp implements Serializable { /** * Constructs a new instance of {@code Timestamp} with the specified {@code * timestamp} and the given certificate path. - * + * * @param timestamp * date and time. * @param signerCertPath @@ -56,7 +49,6 @@ public final class Timestamp implements Serializable { * @throws NullPointerException * if {@code timestamp} is {@code null} or if {@code * signerCertPath} is {@code null}. - * @since Android 1.0 */ public Timestamp(Date timestamp, CertPath signerCertPath) { if (timestamp == null) { @@ -76,15 +68,15 @@ public final class Timestamp implements Serializable { * otherwise. The given object is equal to this {@code Timestamp}, if it is * an instance of {@code Timestamp}, the two timestamps have an equal date * and time and their certificate paths are equal. - * + * * @param obj * object to be compared for equality with this {@code * Timestamp}. * @return {@code true} if the specified object is equal to this {@code * Timestamp}, otherwise {@code false}. * @see #hashCode - * @since Android 1.0 */ + @Override public boolean equals(Object obj) { if (obj == this) { return true; @@ -99,9 +91,8 @@ public final class Timestamp implements Serializable { /** * Returns the certificate path of this {@code Timestamp}. - * + * * @return the certificate path of this {@code Timestamp}. - * @since Android 1.0 */ public CertPath getSignerCertPath() { return signerCertPath; @@ -109,15 +100,11 @@ public final class Timestamp implements Serializable { /** * Returns the date and time of this {@code Timestamp}. - * + * * @return the date and time of this {@code Timestamp}. - * @since Android 1.0 */ public Date getTimestamp() { - // BEGIN android-changed - // copied from a newer version of harmony return (Date) timestamp.clone(); - // END android-changed } /** @@ -128,8 +115,8 @@ public final class Timestamp implements Serializable { * @return the hash code value for this {@code Timestamp}. * @see Object#equals(Object) * @see Timestamp#equals(Object) - * @since Android 1.0 */ + @Override public int hashCode() { if (hash == 0) { hash = timestamp.hashCode() ^ signerCertPath.hashCode(); @@ -140,15 +127,15 @@ public final class Timestamp implements Serializable { /** * Returns a string containing a concise, human-readable description of this * {@code Timestamp}. - * + * * @return a printable representation for this {@code Timestamp}. - * @since Android 1.0 */ + @Override public String toString() { - StringBuffer buf = new StringBuffer(256); + StringBuilder buf = new StringBuilder(256); // Dump only the first certificate buf.append("Timestamp [").append(timestamp).append(" certPath="); //$NON-NLS-1$ //$NON-NLS-2$ buf.append(signerCertPath.getCertificates().get(0)).append("]"); //$NON-NLS-1$ return buf.toString(); } -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/UnrecoverableEntryException.java b/security/src/main/java/java/security/UnrecoverableEntryException.java index dc2981a..24ff54b 100644 --- a/security/src/main/java/java/security/UnrecoverableEntryException.java +++ b/security/src/main/java/java/security/UnrecoverableEntryException.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - package java.security; @@ -29,7 +24,6 @@ package java.security; * * @see KeyStore * @see KeyStore.Entry - * @since Android 1.0 */ public class UnrecoverableEntryException extends GeneralSecurityException { @@ -37,8 +31,6 @@ public class UnrecoverableEntryException extends GeneralSecurityException { /** * Constructs a new instance of {@code UnrecoverableEntryException}. - * - * @since Android 1.0 */ public UnrecoverableEntryException() { } @@ -46,12 +38,11 @@ public class UnrecoverableEntryException extends GeneralSecurityException { /** * Constructs a new instance of {@code UnrecoverableEntryException} with the * given message. - * + * * @param msg * the detail message for this exception. - * @since Android 1.0 */ public UnrecoverableEntryException(String msg) { super(msg); } -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/UnrecoverableKeyException.java b/security/src/main/java/java/security/UnrecoverableKeyException.java index e4b399b..3840e6b 100644 --- a/security/src/main/java/java/security/UnrecoverableKeyException.java +++ b/security/src/main/java/java/security/UnrecoverableKeyException.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - package java.security; /** @@ -27,7 +22,6 @@ package java.security; * from a {@code KeyStore}. * * @see KeyStore - * @since Android 1.0 */ public class UnrecoverableKeyException extends GeneralSecurityException { @@ -36,10 +30,9 @@ public class UnrecoverableKeyException extends GeneralSecurityException { /** * Constructs a new instance of {@code UnrecoverableKeyException} with the * given message. - * + * * @param msg * the detail message for this exception - * @since Android 1.0 */ public UnrecoverableKeyException(String msg) { super(msg); @@ -47,8 +40,6 @@ public class UnrecoverableKeyException extends GeneralSecurityException { /** * Constructs a new instance of {@code UnrecoverableKeyException}. - * - * @since Android 1.0 */ public UnrecoverableKeyException() { } diff --git a/security/src/main/java/java/security/UnresolvedPermission.java b/security/src/main/java/java/security/UnresolvedPermission.java index 6570de4..bf99a40 100644 --- a/security/src/main/java/java/security/UnresolvedPermission.java +++ b/security/src/main/java/java/security/UnresolvedPermission.java @@ -15,27 +15,18 @@ * limitations under the License. */ -/** -* @author Alexey V. Varlamov -* @version $Revision$ -*/ - package java.security; import java.io.ByteArrayInputStream; import java.io.IOException; -import java.io.InvalidObjectException; import java.io.NotSerializableException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import java.io.ObjectStreamField; import java.io.Serializable; import java.security.cert.Certificate; import java.security.cert.CertificateEncodingException; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; -import java.util.ArrayList; -import java.util.List; import org.apache.harmony.security.fortress.PolicyUtils; import org.apache.harmony.security.internal.nls.Messages; @@ -46,24 +37,17 @@ import org.apache.harmony.security.internal.nls.Messages; * Policy}. {@code UnresolvedPermission}s contain all information to be replaced * by a concrete typed {@code Permission} right before the access checks are * performed. - * - * @since Android 1.0 */ public final class UnresolvedPermission extends Permission implements Serializable { private static final long serialVersionUID = -4821973115467008846L; - private static final ObjectStreamField serialPersistentFields[] = { - new ObjectStreamField("type", String.class), //$NON-NLS-1$ - new ObjectStreamField("name", String.class), //$NON-NLS-1$ - new ObjectStreamField("actions", String.class), }; //$NON-NLS-1$ - - // Target name - private transient String targetName; - - //Target actions - private transient String targetActions; + private String type; + + private String name; + + private String actions; // The signer certificates private transient Certificate[] targetCerts; @@ -75,7 +59,7 @@ public final class UnresolvedPermission extends Permission * Constructs a new instance of {@code UnresolvedPermission}. The supplied * parameters are used when this instance is resolved to the concrete * {@code Permission}. - * + * * @param type * the fully qualified class name of the permission this class is * resolved to. @@ -90,26 +74,17 @@ public final class UnresolvedPermission extends Permission * maybe {@code null}. * @throws NullPointerException * if type is {@code null}. - * @since Android 1.0 */ public UnresolvedPermission(String type, String name, String actions, Certificate[] certs) { super(type); checkType(type); - targetName = name; - targetActions = actions; - if (certs != null && certs.length != 0) { - //TODO filter non-signer certificates ??? - List tmp = new ArrayList(); - for (int i = 0; i < certs.length; i++) { - if (certs[i] != null) { - tmp.add(certs[i]); - } - } - if (tmp.size() != 0) { - targetCerts = (Certificate[])tmp.toArray( - new Certificate[tmp.size()]); - } + this.type = type; + this.name = name; + this.actions = actions; + if (certs != null) { + this.targetCerts = new Certificate[certs.length]; + System.arraycopy(certs, 0, targetCerts, 0, certs.length); } hash = 0; } @@ -136,52 +111,105 @@ public final class UnresolvedPermission extends Permission * instance of {@code UnresolvedPermission}, the two {@code * UnresolvedPermission}s must refer to the same type and must have the same * name, the same actions and certificates. - * + * * @param obj * object to be compared for equality with this {@code * UnresolvedPermission}. * @return {@code true} if the specified object is equal to this {@code * UnresolvedPermission}, otherwise {@code false}. - * @since Android 1.0 */ + @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof UnresolvedPermission) { - UnresolvedPermission that = (UnresolvedPermission)obj; + UnresolvedPermission that = (UnresolvedPermission) obj; if (getName().equals(that.getName()) - && (targetName == null ? that.targetName == null - : targetName.equals(that.targetName)) - && (targetActions == null ? that.targetActions == null - : targetActions.equals(that.targetActions)) - && (PolicyUtils.matchSubset(targetCerts, that.targetCerts) - && PolicyUtils.matchSubset(that.targetCerts, targetCerts))) { + && (name == null ? that.name == null : name + .equals(that.name)) + && (actions == null ? that.actions == null : actions + .equals(that.actions)) + && equalsCertificates(this.targetCerts, that.targetCerts)) { return true; } } return false; } + /* + * check whether given array of certificates are equivalent + */ + private boolean equalsCertificates(Certificate[] certs1, + Certificate[] certs2) { + if (certs1 == null || certs2 == null) { + return certs1 == certs2; + } + + int length = certs1.length; + if (length != certs2.length) { + return false; + } + + if (length > 0) { + boolean found; + for (int i = 0; i < length; i++) { + // Skip the checking for null + if(certs1[i] == null){ + continue; + } + found = false; + for (int j = 0; j < length; j++) { + if (certs1[i].equals(certs2[j])) { + found = true; + break; + } + } + + if (!found) { + return false; + } + } + + for (int i = 0; i < length; i++) { + if(certs2[i] == null){ + continue; + } + found = false; + for (int j = 0; j < length; j++) { + if (certs2[i].equals(certs1[j])) { + found = true; + break; + } + } + + if (!found) { + return false; + } + } + } + return true; + } + /** * Returns the hash code value for this {@code UnresolvedPermission}. * Returns the same hash code for {@code UnresolvedPermission}s that are * equal to each other as required by the general contract of * {@link Object#hashCode}. - * + * * @return the hash code value for this {@code UnresolvedPermission}. * @see Object#equals(Object) * @see UnresolvedPermission#equals(Object) - * @since Android 1.0 */ + @Override public int hashCode() { if (hash == 0) { hash = getName().hashCode(); - if (targetName != null) { - hash ^= targetName.hashCode(); + if (name != null) { + hash ^= name.hashCode(); } - if (targetActions != null) { - hash ^= targetActions.hashCode(); + if (actions != null) { + hash ^= actions.hashCode(); } } return hash; @@ -191,10 +219,10 @@ public final class UnresolvedPermission extends Permission * Returns an empty string since there are no actions allowed for {@code * UnresolvedPermission}. The actions, specified in the constructor, are * used when the concrete permission is resolved and created. - * + * * @return an empty string, indicating that there are no actions. - * @since Android 1.0 */ + @Override public String getActions() { return ""; //$NON-NLS-1$ } @@ -202,34 +230,31 @@ public final class UnresolvedPermission extends Permission /** * Returns the name of the permission this {@code UnresolvedPermission} is * resolved to. - * + * * @return the name of the permission this {@code UnresolvedPermission} is * resolved to. - * @since Android 1.0 */ public String getUnresolvedName() { - return targetName; + return name; } /** * Returns the actions of the permission this {@code UnresolvedPermission} * is resolved to. - * + * * @return the actions of the permission this {@code UnresolvedPermission} * is resolved to. - * @since Android 1.0 */ public String getUnresolvedActions() { - return targetActions; + return actions; } /** * Returns the fully qualified class name of the permission this {@code * UnresolvedPermission} is resolved to. - * + * * @return the fully qualified class name of the permission this {@code * UnresolvedPermission} is resolved to. - * @since Android 1.0 */ public String getUnresolvedType() { return super.getName(); @@ -238,10 +263,9 @@ public final class UnresolvedPermission extends Permission /** * Returns the certificates of the permission this {@code * UnresolvedPermission} is resolved to. - * + * * @return the certificates of the permission this {@code * UnresolvedPermission} is resolved to. - * @since Android 1.0 */ public Certificate[] getUnresolvedCerts() { if (targetCerts != null) { @@ -261,13 +285,12 @@ public final class UnresolvedPermission extends Permission * UnresolvedPermissions (if any) against the passed instance. Successfully * resolved permissions (if any) are taken into account during further * processing. - * </p> - * + * * @param permission * the permission to check. * @return always {@code false} - * @since Android 1.0 */ + @Override public boolean implies(Permission permission) { return false; } @@ -276,23 +299,23 @@ public final class UnresolvedPermission extends Permission * Returns a string containing a concise, human-readable description of this * {@code UnresolvedPermission} including its target name and its target * actions. - * + * * @return a printable representation for this {@code UnresolvedPermission}. - * @since Android 1.0 */ + @Override public String toString() { - return "(unresolved " + getName() + " " + targetName + " " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - + targetActions + ")"; //$NON-NLS-1$ + return "(unresolved " + type + " " + name + " " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + + actions + ")"; //$NON-NLS-1$ } /** * Returns a new {@code PermissionCollection} for holding {@code * UnresolvedPermission} objects. - * + * * @return a new PermissionCollection for holding {@code * UnresolvedPermission} objects. - * @since Android 1.0 */ + @Override public PermissionCollection newPermissionCollection() { return new UnresolvedPermissionCollection(); } @@ -306,16 +329,12 @@ public final class UnresolvedPermission extends Permission * per {@code getUnresolvedCerts()}) among the passed collection of signers. * If it does, a zero, one, and/or two-argument constructor is tried to * instantiate a new permission, which is then returned. - * </p> * <p> * If an appropriate constructor is not available or the class is improperly * signed, {@code null} is returned. - * </p> - * + * * @param targetType * - a target class instance, must not be {@code null} - * @param signers - * - actual signers of the targetType * @return resolved permission or null */ Permission resolve(Class targetType) { @@ -323,8 +342,8 @@ public final class UnresolvedPermission extends Permission if (PolicyUtils.matchSubset(targetCerts, targetType.getSigners())) { try { return PolicyUtils.instantiatePermission(targetType, - targetName, - targetActions); + name, + actions); } catch (Exception ignore) { //TODO log warning? } @@ -333,8 +352,6 @@ public final class UnresolvedPermission extends Permission } /** - * @com.intel.drl.spec_ref - * * Outputs {@code type},{@code name},{@code actions} * fields via default mechanism; next manually writes certificates in the * following format: <br> @@ -353,11 +370,7 @@ public final class UnresolvedPermission extends Permission * @see <a href="http://java.sun.com/j2se/1.5.0/docs/api/serialized-form.html#java.security.UnresolvedPermission">Java Spec</a> */ private void writeObject(ObjectOutputStream out) throws IOException { - ObjectOutputStream.PutField fields = out.putFields(); - fields.put("type", getUnresolvedType()); //$NON-NLS-1$ - fields.put("name", getUnresolvedName()); //$NON-NLS-1$ - fields.put("actions", getUnresolvedActions()); //$NON-NLS-1$ - out.writeFields(); + out.defaultWriteObject(); if (targetCerts == null) { out.writeInt(0); } else { @@ -378,19 +391,12 @@ public final class UnresolvedPermission extends Permission } /** - * @com.intel.drl.spec_ref - * * Reads the object from stream and checks target type for validity. */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - checkType(getUnresolvedType()); - ObjectInputStream.GetField fields = in.readFields(); - if (!getUnresolvedType().equals(fields.get("type", null))) { //$NON-NLS-1$ - throw new InvalidObjectException(Messages.getString("security.31")); //$NON-NLS-1$ - } - targetName = (String)fields.get("name", null); //$NON-NLS-1$ - targetActions = (String)fields.get("actions", null); //$NON-NLS-1$ + in.defaultReadObject(); + checkType(getUnresolvedType()); int certNumber = in.readInt(); if (certNumber != 0) { targetCerts = new Certificate[certNumber]; diff --git a/security/src/main/java/java/security/UnresolvedPermissionCollection.java b/security/src/main/java/java/security/UnresolvedPermissionCollection.java index a43a54f..3a6ba92 100644 --- a/security/src/main/java/java/security/UnresolvedPermissionCollection.java +++ b/security/src/main/java/java/security/UnresolvedPermissionCollection.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Alexey V. Varlamov -* @version $Revision$ -*/ - package java.security; import java.io.IOException; @@ -66,7 +61,6 @@ final class UnresolvedPermissionCollection extends PermissionCollection { * @throws IllegalArgumentException * if {@code permission} is {@code null} or not an {@code * UnresolvedPermission}. - * @since Android 1.0 */ public void add(Permission permission) { if (isReadOnly()) { @@ -101,7 +95,6 @@ final class UnresolvedPermissionCollection extends PermissionCollection { * * @return always {@code false} * @see UnresolvedPermission#implies(Permission). - * @since Android 1.0 */ public boolean implies(Permission permission) { return false; @@ -159,15 +152,14 @@ final class UnresolvedPermissionCollection extends PermissionCollection { } /** - * @com.intel.drl.spec_ref - * * Output fields via default mechanism. */ private void writeObject(java.io.ObjectOutputStream out) throws IOException { Hashtable permissions = new Hashtable(); - for (Iterator iter = klasses.keySet().iterator(); iter.hasNext();) { - String key = (String)iter.next(); - permissions.put(key, new Vector(((Collection)klasses.get(key)))); + for (Iterator iter = klasses.entrySet().iterator(); iter.hasNext();) { + Map.Entry entry = (Map.Entry) iter.next(); + String key = (String) entry.getKey(); + permissions.put(key, new Vector(((Collection) entry.getValue()))); } ObjectOutputStream.PutField fields = out.putFields(); fields.put("permissions", permissions); //$NON-NLS-1$ @@ -175,8 +167,6 @@ final class UnresolvedPermissionCollection extends PermissionCollection { } /** - * @com.intel.drl.spec_ref - * * Reads the object from stream and checks elements grouping for validity. */ private void readObject(java.io.ObjectInputStream in) throws IOException, @@ -185,20 +175,23 @@ final class UnresolvedPermissionCollection extends PermissionCollection { Map permissions = (Map)fields.get("permissions", null); //$NON-NLS-1$ klasses = new HashMap(); synchronized (klasses) { - for (Iterator iter = permissions.keySet().iterator(); iter - .hasNext();) { - String key = (String)iter.next(); - Collection values = (Collection)permissions.get(key); - for (Iterator iterator = values.iterator(); iterator.hasNext();) { - UnresolvedPermission element = (UnresolvedPermission)iterator - .next(); - if (!element.getName().equals(key)) { - throw new InvalidObjectException( - Messages.getString("security.22")); //$NON-NLS-1$ - } - } - klasses.put(key, new HashSet(values)); - } + for (Iterator iter = permissions.entrySet().iterator(); iter + .hasNext();) { + Map.Entry entry = (Map.Entry) iter.next(); + String key = (String) entry.getKey(); + Collection values = (Collection) entry.getValue(); + + for (Iterator iterator = values.iterator(); iterator.hasNext();) { + UnresolvedPermission element = + (UnresolvedPermission) iterator.next(); + + if (!element.getName().equals(key)) { + throw new InvalidObjectException( + Messages.getString("security.22")); //$NON-NLS-1$ + } + } + klasses.put(key, new HashSet(values)); + } } } }
\ No newline at end of file diff --git a/security/src/main/java/java/security/acl/Acl.java b/security/src/main/java/java/security/acl/Acl.java index 35c92fc..88dd9f0 100644 --- a/security/src/main/java/java/security/acl/Acl.java +++ b/security/src/main/java/java/security/acl/Acl.java @@ -24,17 +24,15 @@ import java.util.Enumeration; * The <i>Access Control List</i> (<b>ACL</b>) interface definition. * <p> * An ACL is a set of {@link AclEntry} objects. - * </p> * <p> * An {@code AclEntry} is a list of {@link Permission}s that are granted * (<i>positive</i>) or denied * (<i>negative</i>) to a {@link Principal}. - * </p> * <p> - * An {@code Acl} has a list of owners ({@link Owner}) which are principals as well {@code - * Principal}. Only those principals which are the {@code Acl}'s owners are allowed to modify the {@code + * An {@code Acl} has a list of owners ({@link Owner}) which are principals as + * well {@code Principal}. Only those principals which are the {@code Acl}'s + * owners are allowed to modify the {@code * Acl}. - * </p> * <p> * The <i>ACL</i> has to conform to the following rules: * <ul> @@ -49,9 +47,6 @@ import java.util.Enumeration; * <li>If there is no {@code AclEntry} associated with a specific {@code * Principal}, then it is interpreted as an empty list of permissions.</li> * </ul> - * </p> - * - * @since Android 1.0 */ public interface Acl extends Owner { @@ -65,7 +60,6 @@ public interface Acl extends Owner { * @throws NotOwnerException * if the invoking {@code Principal} is not an owner of this * <i>ACL</i>. - * @since Android 1.0 */ void setName(Principal caller, String name) throws NotOwnerException; @@ -73,7 +67,6 @@ public interface Acl extends Owner { * Returns the name of this <i>ACL</i> instance. * * @return the name of this <i>ACL</i> instance. - * @since Android 1.0 */ String getName(); @@ -82,18 +75,16 @@ public interface Acl extends Owner { * <p> * If the <i>ACL</i> already has an {@code AclEntry} of the same type (<i> * positive</i> or <i>negative</i>) and principal, then the new entry is not added. - * </p> - * + * * @param caller * the invoking {@code Principal}. * @param entry * the ACL entry to add. - * @return {@code true} if the entry is added, {@code false} if there is already an entry of - * the same type for the same principal + * @return {@code true} if the entry is added, {@code false} if there is + * already an entry of the same type for the same principal * @throws NotOwnerException * if the invoking {@code Principal} is not an owner of this * <i>ACL</i>. - * @since Android 1.0 */ boolean addEntry(Principal caller, AclEntry entry) throws NotOwnerException; @@ -104,12 +95,11 @@ public interface Acl extends Owner { * the invoking {@code Principal}. * @param entry * the ACL entry to remove. - * @return {@code true} if the entry is removed, {@code false} if the entry is not in this - * <i>ACL</i>. + * @return {@code true} if the entry is removed, {@code false} if the entry + * is not in this <i>ACL</i>. * @throws NotOwnerException * if the invoking {@code Principal} is not an owner of this * <i>ACL</i>. - * @since Android 1.0 */ boolean removeEntry(Principal caller, AclEntry entry) throws NotOwnerException; @@ -120,7 +110,6 @@ public interface Acl extends Owner { * <p> * If the specified principal has no entry in this ACL, an empty set is * returned. - * </p> * <p> * The allowed permissions are collected according to the following rules: * <ul> @@ -136,12 +125,10 @@ public interface Acl extends Owner { * permissions override the group's negative permissions and the negative * individual permissions override the grpup's positive permissions.</li> * </ul> - * </p> - * + * * @param user * the principal to get the allowed permissions for. * @return the set of allowed permissions for the specified principal. - * @since Android 1.0 */ Enumeration<Permission> getPermissions(Principal user); @@ -151,7 +138,6 @@ public interface Acl extends Owner { * * @return an {@code Enumeration} of the {@code AclEntry} of this * <i>ACL</i>. - * @since Android 1.0 */ Enumeration<AclEntry> entries(); @@ -161,15 +147,14 @@ public interface Acl extends Owner { * <p> * The list of granted permissions is determined according to the rules * specified by {@code getPermissions}. - * </p> - * + * * @param principal * the principal the check the permissions for. * @param permission * the permission to check for the principal. - * @return {@code true} if the principal is granted the permission, otherwise {@code false}. + * @return {@code true} if the principal is granted the permission, + * otherwise {@code false}. * @see #getPermissions(Principal) - * @since Android 1.0 */ boolean checkPermission(Principal principal, Permission permission); @@ -177,7 +162,6 @@ public interface Acl extends Owner { * Returns the string representation of this ACL. * * @return the string representation of this ACL. - * @since Android 1.0 */ String toString(); } diff --git a/security/src/main/java/java/security/acl/AclEntry.java b/security/src/main/java/java/security/acl/AclEntry.java index 7a5b722..fe2fb3a 100644 --- a/security/src/main/java/java/security/acl/AclEntry.java +++ b/security/src/main/java/java/security/acl/AclEntry.java @@ -25,9 +25,6 @@ import java.util.Enumeration; * <p> * An {@code AclEntry} is a list of the {@link Permission}s that are * granted (<i>positive</i>) or denied (<i>negative</i>) to a {@link Principal}. - * </p> - * - * @since Android 1.0 */ public interface AclEntry extends Cloneable { @@ -35,13 +32,11 @@ public interface AclEntry extends Cloneable { * Set the principal for this ACL entry. * <p> * The principal for an ACL entry can only be set once. - * </p> - * + * * @param user * the principal for this ACL entry. * @return {@code true} on success, {@code false} if there is a principal already set for * this entry. - * @since Android 1.0 */ boolean setPrincipal(Principal user); @@ -49,7 +44,6 @@ public interface AclEntry extends Cloneable { * Returns the principal of this ACL entry. * * @return the principal of this ACL entry, or null if none is set. - * @since Android 1.0 */ Principal getPrincipal(); @@ -58,13 +52,9 @@ public interface AclEntry extends Cloneable { * <p> * The permissions in this ACL entry will be denied to the principal * associated with this entry. - * </p> * <p> * Note: An ACL entry is <i>positive</i> by default and can only become * <i>negative</i> by calling this method. - * </p> - * - * @since Android 1.0 */ void setNegativePermissions(); @@ -72,7 +62,6 @@ public interface AclEntry extends Cloneable { * Returns whether this ACL entry is <i>negative</i>. * * @return {@code true} if this ACL entry is negative, {@code false} if it's positive. - * @since Android 1.0 */ boolean isNegative(); @@ -83,7 +72,6 @@ public interface AclEntry extends Cloneable { * the permission to be added. * @return {@code true} if the specified permission is added, {@code false} if the * permission was already in this entry. - * @since Android 1.0 */ boolean addPermission(Permission permission); @@ -94,7 +82,6 @@ public interface AclEntry extends Cloneable { * the permission to be removed. * @return {@code true} if the permission is removed, {@code false} if the permission was * not in this entry. - * @since Android 1.0 */ boolean removePermission(Permission permission); @@ -104,7 +91,6 @@ public interface AclEntry extends Cloneable { * @param permission * the permission to check. * @return {@code true} if the permission is in this entry, otherwise {@code false}. - * @since Android 1.0 */ boolean checkPermission(Permission permission); @@ -112,7 +98,6 @@ public interface AclEntry extends Cloneable { * Returns the list of permissions of this ACL entry. * * @return the list of permissions of this ACL entry, - * @since Android 1.0 */ Enumeration<Permission> permissions(); @@ -120,7 +105,6 @@ public interface AclEntry extends Cloneable { * Returns the string representation of this ACL entry. * * @return the string representation of this ACL entry. - * @since Android 1.0 */ String toString(); @@ -128,7 +112,6 @@ public interface AclEntry extends Cloneable { * Clones this ACL entry instance. * * @return a copy of this entry. - * @since Android 1.0 */ Object clone(); diff --git a/security/src/main/java/java/security/acl/AclNotFoundException.java b/security/src/main/java/java/security/acl/AclNotFoundException.java index c8d4208..59b9045 100644 --- a/security/src/main/java/java/security/acl/AclNotFoundException.java +++ b/security/src/main/java/java/security/acl/AclNotFoundException.java @@ -20,18 +20,13 @@ package java.security.acl; /** * The exception, that is thrown when a reference to a non-existent <i>Access * Control List</i> (ACL) is made. - * - * @since Android 1.0 */ - public class AclNotFoundException extends Exception { private static final long serialVersionUID = 5684295034092681791L; /** * Creates a new {@code AclNotFoundException}. - * - * @since Android 1.0 */ public AclNotFoundException() { diff --git a/security/src/main/java/java/security/acl/Group.java b/security/src/main/java/java/security/acl/Group.java index 16898e6..7452181 100644 --- a/security/src/main/java/java/security/acl/Group.java +++ b/security/src/main/java/java/security/acl/Group.java @@ -24,8 +24,6 @@ import java.util.Enumeration; * A {@code Principal} that represents a group of principals. * * @see Principal - * - * @since Android 1.0 */ public interface Group extends Principal { @@ -35,7 +33,6 @@ public interface Group extends Principal { * @param user * the member to add. * @return {@code true} if the member was added, {@code false} if it was already a member. - * @since Android 1.0 */ boolean addMember(Principal user); @@ -45,7 +42,6 @@ public interface Group extends Principal { * @param user * the member to remove. * @return {@code true} if the member was removed, {@code false} if it was not a member. - * @since Android 1.0 */ boolean removeMember(Principal user); @@ -55,7 +51,6 @@ public interface Group extends Principal { * @param member * the principal to check. * @return {@code true} if the principal is a member, otherwise {@code false}. - * @since Android 1.0 */ boolean isMember(Principal member); @@ -63,7 +58,6 @@ public interface Group extends Principal { * Returns the members of this group. * * @return the members of this group. - * @since Android 1.0 */ Enumeration<? extends Principal> members(); diff --git a/security/src/main/java/java/security/acl/LastOwnerException.java b/security/src/main/java/java/security/acl/LastOwnerException.java index 11c235f..f947f22 100644 --- a/security/src/main/java/java/security/acl/LastOwnerException.java +++ b/security/src/main/java/java/security/acl/LastOwnerException.java @@ -18,12 +18,10 @@ package java.security.acl; /** - * The exception that is thrown when an attempt is made to remove the + * The exception that is thrown when an attempt is made to remove the * the last {@code Owner} from an {@code Owner}. - * + * * @see Owner - * - * @since Android 1.0 */ public class LastOwnerException extends Exception { @@ -31,9 +29,7 @@ public class LastOwnerException extends Exception { /** * Creates a new {@code LastOwnerException}. - * - * @since Android 1.0 */ public LastOwnerException() { } -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/acl/NotOwnerException.java b/security/src/main/java/java/security/acl/NotOwnerException.java index 081bdea..c7de8c9 100644 --- a/security/src/main/java/java/security/acl/NotOwnerException.java +++ b/security/src/main/java/java/security/acl/NotOwnerException.java @@ -19,13 +19,11 @@ package java.security.acl; /** * The exception that is thrown when an action that requires ownership is - * attempted by a principal that is not an owner of the object for which - * ownership is required. + * attempted by a principal that is not an owner of the object for which + * ownership is required. * * @see Acl * @see Owner - * - * @since Android 1.0 */ public class NotOwnerException extends Exception { @@ -33,9 +31,7 @@ public class NotOwnerException extends Exception { /** * Creates a new {@code NotOwnerException}. - * - * @since Android 1.0 */ public NotOwnerException() { } -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/acl/Owner.java b/security/src/main/java/java/security/acl/Owner.java index 335dc84..c392e2f 100644 --- a/security/src/main/java/java/security/acl/Owner.java +++ b/security/src/main/java/java/security/acl/Owner.java @@ -24,7 +24,6 @@ import java.security.Principal; * * @see Acl * @see Principal - * @since Android 1.0 */ public interface Owner { @@ -38,7 +37,6 @@ public interface Owner { * @return {@code true} if the owner was added, {@code false} if it was already an owner. * @throws NotOwnerException * if the invoking principal is not an owner. - * @since Android 1.0 */ boolean addOwner(Principal caller, Principal owner) throws NotOwnerException; @@ -56,7 +54,6 @@ public interface Owner { * @throws LastOwnerException * if the owner to be removed is the last owner and hence removing it * would make this object owner-less. - * @since Android 1.0 */ boolean deleteOwner(Principal caller, Principal owner) throws NotOwnerException, LastOwnerException; @@ -67,7 +64,6 @@ public interface Owner { * @param owner * the principal to check. * @return {@code true} if the specified principal is an owner, otherwise {@code false}. - * @since Android 1.0 */ boolean isOwner(Principal owner); } diff --git a/security/src/main/java/java/security/acl/Permission.java b/security/src/main/java/java/security/acl/Permission.java index 0d6e22c..f2ee251 100644 --- a/security/src/main/java/java/security/acl/Permission.java +++ b/security/src/main/java/java/security/acl/Permission.java @@ -22,9 +22,6 @@ package java.security.acl; * <p> * It can be granted or denied to a {@link java.security.Principal Principal} * using an {@link Acl}. - * </p> - * - * @since Android 1.0 */ public interface Permission { @@ -36,7 +33,6 @@ public interface Permission { * the permission object to compare to this permission. * @return true if the specified permission object is equal to this, false * if not. - * @since Android 1.0 */ boolean equals(Object another); @@ -44,7 +40,6 @@ public interface Permission { * Returns the string representation of this permission. * * @return the string representation of this permission. - * @since Android 1.0 */ String toString(); } diff --git a/security/src/main/java/java/security/cert/CRL.java b/security/src/main/java/java/security/cert/CRL.java index b0f3e30..8153853 100644 --- a/security/src/main/java/java/security/cert/CRL.java +++ b/security/src/main/java/java/security/cert/CRL.java @@ -23,7 +23,6 @@ package java.security.cert; * expired and consequently has become invalid. * * @see CertificateFactory - * @since Android 1.0 */ public abstract class CRL { // The CRL type @@ -31,10 +30,9 @@ public abstract class CRL { /** * Creates a new certificate revocation list of the specified type. - * + * * @param type * the type for the CRL. - * @since Android 1.0 */ protected CRL(String type) { this.type = type; @@ -42,9 +40,8 @@ public abstract class CRL { /** * Returns the type of this CRL. - * + * * @return the type of this CRL. - * @since Android 1.0 */ public final String getType() { return type; @@ -52,20 +49,18 @@ public abstract class CRL { /** * Returns whether the specified certificate is revoked by this CRL. - * + * * @param cert * the certificate to check. * @return {@code true} if the certificate is revoked by this CRL, otherwise * {@code false}. - * @since Android 1.0 */ public abstract boolean isRevoked(Certificate cert); /** * Returns the string representation of this instance. - * + * * @return the string representation of this instance. - * @since Android 1.0 */ public abstract String toString(); } diff --git a/security/src/main/java/java/security/cert/CRLException.java b/security/src/main/java/java/security/cert/CRLException.java index 625d7d3..01e2071 100644 --- a/security/src/main/java/java/security/cert/CRLException.java +++ b/security/src/main/java/java/security/cert/CRLException.java @@ -15,19 +15,12 @@ * limitations under the License. */ -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - package java.security.cert; import java.security.GeneralSecurityException; /** * The exception that is thrown if errors occur during handling of {@code CRL}s. - * - * @since Android 1.0 */ public class CRLException extends GeneralSecurityException { @@ -38,7 +31,6 @@ public class CRLException extends GeneralSecurityException { * * @param msg * the detail message for this exception. - * @since Android 1.0 */ public CRLException(String msg) { super(msg); @@ -46,8 +38,6 @@ public class CRLException extends GeneralSecurityException { /** * Creates a new {@code CRLException}. - * - * @since Android 1.0 */ public CRLException() { } @@ -59,7 +49,6 @@ public class CRLException extends GeneralSecurityException { * the detail message for this exception. * @param cause * the cause for this exception. - * @since Android 1.0 */ public CRLException(String message, Throwable cause) { super(message, cause); @@ -70,7 +59,6 @@ public class CRLException extends GeneralSecurityException { * * @param cause * the cause for this exception. - * @since Android 1.0 */ public CRLException(Throwable cause) { super(cause); diff --git a/security/src/main/java/java/security/cert/CRLSelector.java b/security/src/main/java/java/security/cert/CRLSelector.java index ee2d39e..5b14446 100644 --- a/security/src/main/java/java/security/cert/CRLSelector.java +++ b/security/src/main/java/java/security/cert/CRLSelector.java @@ -23,11 +23,9 @@ package java.security.cert; * <p> * The implementations of this interface are typically used to define the * criteria for selecting {@code CRL}s from a {@code CertStore}. - * </p> * * @see CertStore * @see CRL - * @since Android 1.0 */ public interface CRLSelector extends Cloneable { @@ -35,7 +33,6 @@ public interface CRLSelector extends Cloneable { * Clones this {@code CRLSelector} instance. * * @return the cloned instance. - * @since Android 1.0 */ public Object clone(); @@ -47,7 +44,6 @@ public interface CRLSelector extends Cloneable { * the CRL to be evaluated. * @return {@code true} if the CRL matches the criteria, {@code false} * otherwise. - * @since Android 1.0 */ public boolean match(CRL crl); -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/cert/CertPath.java b/security/src/main/java/java/security/cert/CertPath.java index 2874a4d..e9d049b 100644 --- a/security/src/main/java/java/security/cert/CertPath.java +++ b/security/src/main/java/java/security/cert/CertPath.java @@ -33,16 +33,12 @@ import org.apache.harmony.security.internal.nls.Messages; * <p> * A {@code CertPath} can be represented as a byte array in at least one * supported encoding scheme (i.e. PkiPath or PKCS7) when serialized. - * </p> * <p> * When a {@code List} of the certificates is obtained it must be immutable. - * </p> * <p> * A {@code CertPath} must be thread-safe without requiring coordinated access. - * </p> - * + * * @see Certificate - * @since Android 1.0 */ public abstract class CertPath implements Serializable { @@ -53,10 +49,9 @@ public abstract class CertPath implements Serializable { /** * Creates a new {@code CertPath} instance for the specified certificate * type. - * + * * @param type * the certificate type. - * @since Android 1.0 */ protected CertPath(String type) { this.type = type; @@ -64,9 +59,8 @@ public abstract class CertPath implements Serializable { /** * Returns the type of {@code Certificate} in this instance. - * + * * @return the certificate type. - * @since Android 1.0 */ public String getType() { return type; @@ -76,13 +70,11 @@ public abstract class CertPath implements Serializable { * Returns {@code true} if {@code Certificate}s in the list are the same * type and the lists are equal (and by implication the certificates * contained within are the same). - * + * * @param other * {@code CertPath} to be compared for equality. * @return {@code true} if the object are equal, {@code false} otherwise. - * @since Android 1.0 */ - @Override public boolean equals(Object other) { if (this == other) { return true; @@ -99,14 +91,14 @@ public abstract class CertPath implements Serializable { } /** - * Overrides {@code Object.hashCode()}. The function is defined as follows: <br> + * Overrides {@code Object.hashCode()}. The function is defined as follows: + * <pre> * {@code hashCode = 31 * path.getType().hashCode() + - * path.getCertificates().hashCode();}</br> </p> - * + * path.getCertificates().hashCode();} + * </pre> + * * @return the hash code for this instance. - * @since Android 1.0 */ - @Override public int hashCode() { int hash = getType().hashCode(); hash = hash*31 + getCertificates().hashCode(); @@ -115,13 +107,13 @@ public abstract class CertPath implements Serializable { /** * Returns a {@code String} representation of this {@code CertPath} - * instance. - * + * instance. It is the result of calling {@code toString} on all {@code + * Certificate}s in the {@code List}. + * * @return a string representation of this instance. - * @since Android 1.0 */ public String toString() { - StringBuffer sb = new StringBuffer(getType()); + StringBuilder sb = new StringBuilder(getType()); sb.append(" Cert Path, len="); //$NON-NLS-1$ sb.append(getCertificates().size()); sb.append(": [\n"); //$NON-NLS-1$ @@ -144,7 +136,6 @@ public abstract class CertPath implements Serializable { * in the {@code CertPath}. * * @return a list of {@code Certificate}s in the {@code CertPath}. - * @since Android 1.0 */ public abstract List<? extends Certificate> getCertificates(); @@ -154,7 +145,6 @@ public abstract class CertPath implements Serializable { * @return default encoding of the {@code CertPath}. * @throws CertificateEncodingException * if the encoding fails. - * @since Android 1.0 */ public abstract byte[] getEncoded() throws CertificateEncodingException; @@ -167,7 +157,6 @@ public abstract class CertPath implements Serializable { * @return default encoding of the {@code CertPath}. * @throws CertificateEncodingException * if the encoding fails. - * @since Android 1.0 */ public abstract byte[] getEncoded(String encoding) throws CertificateEncodingException; @@ -177,17 +166,15 @@ public abstract class CertPath implements Serializable { * representation of the certificate path. * * @return {@code Iterator} over supported encodings (as {@code String}s). - * @since Android 1.0 */ public abstract Iterator<String> getEncodings(); /** * Returns an alternate object to be serialized. - * + * * @return an alternate object to be serialized. * @throws ObjectStreamException * if the creation of the alternate object fails. - * @since Android 1.0 */ protected Object writeReplace() throws ObjectStreamException { try { @@ -201,8 +188,6 @@ public abstract class CertPath implements Serializable { /** * The alternate {@code Serializable} class to be used for serialization and * deserialization on {@code CertPath} objects. - * - * @since Android 1.0 */ protected static class CertPathRep implements Serializable { @@ -222,12 +207,11 @@ public abstract class CertPath implements Serializable { /** * Creates a new {@code CertPathRep} instance with the specified type * and encoded data. - * + * * @param type * the certificate type. * @param data * the encoded data. - * @since Android 1.0 */ protected CertPathRep(String type, byte[] data) { this.type = type; @@ -237,11 +221,10 @@ public abstract class CertPath implements Serializable { /** * Deserializes a {@code CertPath} from a serialized {@code CertPathRep} * object. - * + * * @return the deserialized {@code CertPath}. * @throws ObjectStreamException * if deserialization fails. - * @since Android 1.0 */ protected Object readResolve() throws ObjectStreamException { try { diff --git a/security/src/main/java/java/security/cert/CertPathBuilder.java b/security/src/main/java/java/security/cert/CertPathBuilder.java index 47eac13..8daa741 100644 --- a/security/src/main/java/java/security/cert/CertPathBuilder.java +++ b/security/src/main/java/java/security/cert/CertPathBuilder.java @@ -31,8 +31,6 @@ import org.apache.harmony.security.internal.nls.Messages; /** * This class implements the functionality of a builder for an unverified * <i>Certification Path</i>s from a specified certificate to a trust anchor. - * - * @since Android 1.0 */ public class CertPathBuilder { @@ -60,14 +58,13 @@ public class CertPathBuilder { /** * Creates a new {@code CertPathBuilder}. - * + * * @param builderSpi * the implementation delegate. * @param provider * the provider. * @param algorithm * the desired algorithm available at the provider. - * @since Android 1.0 */ protected CertPathBuilder(CertPathBuilderSpi builderSpi, Provider provider, String algorithm) { @@ -78,9 +75,8 @@ public class CertPathBuilder { /** * Returns the algorithm name of this instance. - * + * * @return the algorithm name of this instance. - * @since Android 1.0 */ public final String getAlgorithm() { return algorithm; @@ -88,9 +84,8 @@ public class CertPathBuilder { /** * Returns the provider of this instance. - * + * * @return the provider of this instance. - * @since Android 1.0 */ public final Provider getProvider() { return provider; @@ -107,7 +102,6 @@ public class CertPathBuilder { * if the algorithm is {@code null}. * @throws NoSuchAlgorithmException * if no installed provider can provide the algorithm. - * @since Android 1.0 */ public static CertPathBuilder getInstance(String algorithm) throws NoSuchAlgorithmException { @@ -138,7 +132,6 @@ public class CertPathBuilder { * if algorithm is {@code null}. * @throws IllegalArgumentException * if provider is {@code null} or empty. - * @since Android 1.0 */ public static CertPathBuilder getInstance(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException { @@ -168,7 +161,6 @@ public class CertPathBuilder { * if provider is {@code null}. * @throws NullPointerException * if algorithm is {@code null}. - * @since Android 1.0 */ public static CertPathBuilder getInstance(String algorithm, Provider provider) throws NoSuchAlgorithmException { @@ -187,7 +179,7 @@ public class CertPathBuilder { /** * Builds a certification path with the specified algorithm parameters. - * + * * @param params * the algorithm parameters. * @return the built certification path. @@ -197,7 +189,6 @@ public class CertPathBuilder { * if the specified parameters cannot be used to build with this * builder. * @see CertPathBuilderResult - * @since Android 1.0 */ public final CertPathBuilderResult build(CertPathParameters params) throws CertPathBuilderException, InvalidAlgorithmParameterException { @@ -207,11 +198,10 @@ public class CertPathBuilder { /** * Returns the default {@code CertPathBuilder} type from the <i>Security * Properties</i>. - * + * * @return the default {@code CertPathBuilder} type from the <i>Security * Properties</i>, or the string "{@code PKIX}" if it cannot be * determined. - * @since Android 1.0 */ public static final String getDefaultType() { String defaultType = AccessController @@ -222,4 +212,4 @@ public class CertPathBuilder { }); return (defaultType != null ? defaultType : DEFAULTPROPERTY); } -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/cert/CertPathBuilderException.java b/security/src/main/java/java/security/cert/CertPathBuilderException.java index b957291..58a4a60 100644 --- a/security/src/main/java/java/security/cert/CertPathBuilderException.java +++ b/security/src/main/java/java/security/cert/CertPathBuilderException.java @@ -21,8 +21,6 @@ import java.security.GeneralSecurityException; /** * The exception that is thrown when a {@code CertPathBuilder} method fails. - * - * @since Android 1.0 */ public class CertPathBuilderException extends GeneralSecurityException { @@ -36,7 +34,6 @@ public class CertPathBuilderException extends GeneralSecurityException { * the detail message for the exception * @param cause * why the building of the certification path failed. - * @since Android 1.0 */ public CertPathBuilderException(String msg, Throwable cause) { super(msg, cause); @@ -47,7 +44,6 @@ public class CertPathBuilderException extends GeneralSecurityException { * * @param cause * why the building of the certification path failed. - * @since Android 1.0 */ public CertPathBuilderException(Throwable cause) { super(cause); @@ -59,7 +55,6 @@ public class CertPathBuilderException extends GeneralSecurityException { * * @param msg * the detail message for the exception. - * @since Android 1.0 */ public CertPathBuilderException(String msg) { super(msg); @@ -67,9 +62,7 @@ public class CertPathBuilderException extends GeneralSecurityException { /** * Creates a new {@code CertPathBuilderException}. - * - * @since Android 1.0 */ public CertPathBuilderException() { } -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/cert/CertPathBuilderResult.java b/security/src/main/java/java/security/cert/CertPathBuilderResult.java index e56c4a0..36d99a1 100644 --- a/security/src/main/java/java/security/cert/CertPathBuilderResult.java +++ b/security/src/main/java/java/security/cert/CertPathBuilderResult.java @@ -20,8 +20,6 @@ package java.security.cert; /** * The interface for results generated by * {@link CertPathBuilder#build(CertPathParameters)}. - * - * @since Android 1.0 */ public interface CertPathBuilderResult extends Cloneable { @@ -29,7 +27,6 @@ public interface CertPathBuilderResult extends Cloneable { * Clones this {@code CertPathBuilderResult} instance. * * @return the copy of this instance. - * @since Android 1.0 */ public Object clone(); @@ -37,7 +34,6 @@ public interface CertPathBuilderResult extends Cloneable { * Returns the built {@code CertPath} instance. Never returns {@code null}. * * @return the built certificate path instance. - * @since Android 1.0 */ public CertPath getCertPath(); -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/cert/CertPathBuilderSpi.java b/security/src/main/java/java/security/cert/CertPathBuilderSpi.java index 952f387..80ee0ef 100644 --- a/security/src/main/java/java/security/cert/CertPathBuilderSpi.java +++ b/security/src/main/java/java/security/cert/CertPathBuilderSpi.java @@ -22,15 +22,11 @@ import java.security.InvalidAlgorithmParameterException; /** * The <i>Service Provider Interface</i> (<b>SPI</b>) for the {@code * CertPathBuilder} class to be implemented by security providers. - * - * @since Android 1.0 */ public abstract class CertPathBuilderSpi { /** * Creates a new {@code CertPathBuilderSpi} instance. - * - * @since Android 1.0 */ public CertPathBuilderSpi() { } @@ -46,7 +42,6 @@ public abstract class CertPathBuilderSpi { * @throws InvalidAlgorithmParameterException * if the specified parameters cannot be used to build the path * with this builder. - * @since Android 1.0 */ public abstract CertPathBuilderResult engineBuild(CertPathParameters params) throws CertPathBuilderException, InvalidAlgorithmParameterException; diff --git a/security/src/main/java/java/security/cert/CertPathParameters.java b/security/src/main/java/java/security/cert/CertPathParameters.java index c99826f..e2cee18 100644 --- a/security/src/main/java/java/security/cert/CertPathParameters.java +++ b/security/src/main/java/java/security/cert/CertPathParameters.java @@ -22,8 +22,6 @@ package java.security.cert; * <p> * This interface is for grouping purposes of {@code CertPath} parameter * implementations. - * </p> - * @since Android 1.0 */ public interface CertPathParameters extends Cloneable { @@ -31,7 +29,6 @@ public interface CertPathParameters extends Cloneable { * Clones this {@code CertPathParameters} instance. * * @return the cloned instance. - * @since Android 1.0 */ public Object clone(); -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/cert/CertPathValidator.java b/security/src/main/java/java/security/cert/CertPathValidator.java index f95bd03..0d73280 100644 --- a/security/src/main/java/java/security/cert/CertPathValidator.java +++ b/security/src/main/java/java/security/cert/CertPathValidator.java @@ -32,8 +32,6 @@ import org.apache.harmony.security.internal.nls.Messages; * This class provides the functionality for validating certification paths * (certificate chains) establishing a trust chain from a certificate to a trust * anchor. - * - * @since Android 1.0 */ public class CertPathValidator { // Store CertPathValidator implementation service name @@ -60,14 +58,13 @@ public class CertPathValidator { /** * Creates a new {@code CertPathValidator} instance. - * + * * @param validatorSpi * the implementation delegate. * @param provider * the security provider. * @param algorithm * the name of the algorithm. - * @since Android 1.0 */ protected CertPathValidator(CertPathValidatorSpi validatorSpi, Provider provider, String algorithm) { @@ -78,9 +75,8 @@ public class CertPathValidator { /** * Returns the certification path algorithm name. - * + * * @return the certification path algorithm name. - * @since Android 1.0 */ public final String getAlgorithm() { return algorithm; @@ -88,9 +84,8 @@ public class CertPathValidator { /** * Returns the security provider. - * + * * @return the provider. - * @since Android 1.0 */ public final Provider getProvider() { return provider; @@ -106,7 +101,6 @@ public class CertPathValidator { * if no installed provider provides the specified algorithm. * @throws NullPointerException * if algorithm is {@code null}. - * @since Android 1.0 */ public static CertPathValidator getInstance(String algorithm) throws NoSuchAlgorithmException { @@ -138,7 +132,6 @@ public class CertPathValidator { * if algorithm is {@code null}. * @throws IllegalArgumentException * if provider is {@code null} or empty. - * @since Android 1.0 */ public static CertPathValidator getInstance(String algorithm, String provider) throws NoSuchAlgorithmException, @@ -169,7 +162,6 @@ public class CertPathValidator { * if provider is {@code null}. * @throws NullPointerException * if algorithm is {@code null}. - * @since Android 1.0 */ public static CertPathValidator getInstance(String algorithm, Provider provider) throws NoSuchAlgorithmException { @@ -203,7 +195,6 @@ public class CertPathValidator { * if the specified algorithm parameters cannot be used with * this algorithm. * @see CertPathValidatorResult - * @since Android 1.0 */ public final CertPathValidatorResult validate(CertPath certPath, CertPathParameters params) throws CertPathValidatorException, @@ -214,11 +205,10 @@ public class CertPathValidator { /** * Returns the default {@code CertPathValidator} type from the <i>Security * Properties</i>. - * + * * @return the default {@code CertPathValidator} type from the <i>Security * Properties</i>, or the string {@code "PKIX"} if it cannot be * determined. - * @since Android 1.0 */ public static final String getDefaultType() { String defaultType = AccessController @@ -229,4 +219,4 @@ public class CertPathValidator { }); return (defaultType != null ? defaultType : DEFAULTPROPERTY); } -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/cert/CertPathValidatorException.java b/security/src/main/java/java/security/cert/CertPathValidatorException.java index 072785c..4d2b69f 100644 --- a/security/src/main/java/java/security/cert/CertPathValidatorException.java +++ b/security/src/main/java/java/security/cert/CertPathValidatorException.java @@ -28,9 +28,6 @@ import org.apache.harmony.security.internal.nls.Messages; * A {@code CertPathValidatorException} may optionally include the certification * path instance that failed the validation and the index of the failed * certificate. - * </p> - * - * @since Android 1.0 */ public class CertPathValidatorException extends GeneralSecurityException { @@ -65,7 +62,6 @@ public class CertPathValidatorException extends GeneralSecurityException { * @throws IndexOutOfBoundsException * if {@code certPath} is not {@code null} and index is not * referencing an certificate in the certification path. - * @since Android 1.0 */ public CertPathValidatorException(String msg, Throwable cause, CertPath certPath, int index) { @@ -91,7 +87,6 @@ public class CertPathValidatorException extends GeneralSecurityException { * the detail message for this exception. * @param cause * the cause why the path could not be validated. - * @since Android 1.0 */ public CertPathValidatorException(String msg, Throwable cause) { super(msg, cause); @@ -103,7 +98,6 @@ public class CertPathValidatorException extends GeneralSecurityException { * * @param cause * the cause why the path could not be validated. - * @since Android 1.0 */ public CertPathValidatorException(Throwable cause) { super(cause); @@ -115,7 +109,6 @@ public class CertPathValidatorException extends GeneralSecurityException { * * @param msg * the detail message for this exception. - * @since Android 1.0 */ public CertPathValidatorException(String msg) { super(msg); @@ -123,8 +116,6 @@ public class CertPathValidatorException extends GeneralSecurityException { /** * Creates a new {@code CertPathValidatorException}. - * - * @since Android 1.0 */ public CertPathValidatorException() { } @@ -134,7 +125,6 @@ public class CertPathValidatorException extends GeneralSecurityException { * * @return the certification path that failed validation, or {@code null} if * none was specified. - * @since Android 1.0 */ public CertPath getCertPath() { return certPath; @@ -145,9 +135,8 @@ public class CertPathValidatorException extends GeneralSecurityException { * * @return the index of the failed certificate in the certification path, or * {@code -1} if none was specified. - * @since Android 1.0 */ public int getIndex() { return index; } -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/cert/CertPathValidatorResult.java b/security/src/main/java/java/security/cert/CertPathValidatorResult.java index 42540e4..7fab21a 100644 --- a/security/src/main/java/java/security/cert/CertPathValidatorResult.java +++ b/security/src/main/java/java/security/cert/CertPathValidatorResult.java @@ -21,8 +21,6 @@ package java.security.cert; * The interface specification for certification path validation results. * <p> * This interface is for grouping purposes of validation result implementations. - * </p> - * @since Android 1.0 */ public interface CertPathValidatorResult extends Cloneable { @@ -30,7 +28,6 @@ public interface CertPathValidatorResult extends Cloneable { * Clones this {@code CertPathValidatorResult} instance. * * @return the cloned instance. - * @since Android 1.0 */ public Object clone(); -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/cert/CertPathValidatorSpi.java b/security/src/main/java/java/security/cert/CertPathValidatorSpi.java index 5573679..e14e8dd 100644 --- a/security/src/main/java/java/security/cert/CertPathValidatorSpi.java +++ b/security/src/main/java/java/security/cert/CertPathValidatorSpi.java @@ -22,15 +22,11 @@ import java.security.InvalidAlgorithmParameterException; /** * The <i>Service Provider Interface</i> (<b>SPI</b>) for the {@code * CertPathValidator} class to be implemented by security providers. - * - * @since Android 1.0 */ public abstract class CertPathValidatorSpi { /** * Creates a new {@code CertPathValidatorSpi} instance. - * - * @since Android 1.0 */ public CertPathValidatorSpi() { } @@ -38,7 +34,7 @@ public abstract class CertPathValidatorSpi { /** * Validates the {@code CertPath} with the algorithm of this {@code * CertPathValidator} using the specified algorithm parameters. - * + * * @param certPath * the certification path to be validated. * @param params @@ -51,10 +47,9 @@ public abstract class CertPathValidatorSpi { * @throws InvalidAlgorithmParameterException * if the specified algorithm parameters cannot be used with * this algorithm. - * @since Android 1.0 */ public abstract CertPathValidatorResult engineValidate(CertPath certPath, CertPathParameters params) throws CertPathValidatorException, InvalidAlgorithmParameterException; -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/cert/CertSelector.java b/security/src/main/java/java/security/cert/CertSelector.java index 0316ad3..c490b22 100644 --- a/security/src/main/java/java/security/cert/CertSelector.java +++ b/security/src/main/java/java/security/cert/CertSelector.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - package java.security.cert; /** @@ -28,11 +23,9 @@ package java.security.cert; * <p> * The implementations of this interface are typically used to define the * criteria for selecting {@code Certificate}s from a {@code CertStore}. - * </p> * * @see CertStore * @see Certificate - * @since Android 1.0 */ public interface CertSelector extends Cloneable { @@ -40,7 +33,6 @@ public interface CertSelector extends Cloneable { * Clones this {@code CertSelector} instance. * * @return the cloned instance. - * @since Android 1.0 */ public Object clone(); @@ -52,7 +44,6 @@ public interface CertSelector extends Cloneable { * the certificate to be evaluated. * @return {@code true} if the certificate matches the criteria, {@code * false} otherwise. - * @since Android 1.0 */ public boolean match(Certificate cert); -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/cert/CertStore.java b/security/src/main/java/java/security/cert/CertStore.java index a5c8260..d0b7600 100644 --- a/security/src/main/java/java/security/cert/CertStore.java +++ b/security/src/main/java/java/security/cert/CertStore.java @@ -33,8 +33,6 @@ import org.apache.harmony.security.internal.nls.Messages; * This class provides the functionality to retrieve {@code Certificate}s and * {@code CRL}s from a read-only repository. This repository may be very large * and may store trusted as well as untrusted certificates. - * - * @since Android 1.0 */ public class CertStore { @@ -65,7 +63,7 @@ public class CertStore { /** * Creates a new {@code CertStore} instance. - * + * * @param storeSpi * the implementation delegate. * @param provider @@ -74,7 +72,6 @@ public class CertStore { * the certificate store type. * @param params * the certificate store parameters (may be {@code null}. - * @since Android 1.0 */ protected CertStore(CertStoreSpi storeSpi, Provider provider, String type, CertStoreParameters params) { @@ -101,7 +98,6 @@ public class CertStore { * certificate store instance. * @throws NullPointerException * if the {@code type} is {@code null}. - * @since Android 1.0 */ public static CertStore getInstance(String type, CertStoreParameters params) throws InvalidAlgorithmParameterException, NoSuchAlgorithmException { @@ -147,7 +143,6 @@ public class CertStore { * if provider is null of empty. * @throws NullPointerException * if {@code type} is {@code null}. - * @since Android 1.0 */ public static CertStore getInstance(String type, CertStoreParameters params, String provider) @@ -183,7 +178,6 @@ public class CertStore { * if provider is {@code null}. * @throws NullPointerException * if {@code type} is {@code null}. - * @since Android 1.0 */ public static CertStore getInstance(String type, CertStoreParameters params, Provider provider) @@ -212,9 +206,8 @@ public class CertStore { /** * Returns the certificate store type. - * + * * @return the certificate store type. - * @since Android 1.0 */ public final String getType() { return type; @@ -222,9 +215,8 @@ public class CertStore { /** * Returns the security provider. - * + * * @return the security provider. - * @since Android 1.0 */ public final Provider getProvider() { return provider; @@ -233,10 +225,9 @@ public class CertStore { /** * Returns a copy of the certificate store parameters that were used to * initialize this instance. - * + * * @return a copy of the certificate store parameters or {@code null} if * none were specified. - * @since Android 1.0 */ public final CertStoreParameters getCertStoreParameters() { if (certStoreParams == null) { @@ -249,7 +240,7 @@ public class CertStore { /** * Returns the list of {@code Certificate}s for the specified {@code * CertSelector} from this certificate store. - * + * * @param selector * the selector containing the criteria to search for * certificates in this certificate store. @@ -257,7 +248,6 @@ public class CertStore { * specified selector. * @throws CertStoreException * if error(s) occur. - * @since Android 1.0 */ public final Collection<? extends Certificate> getCertificates(CertSelector selector) throws CertStoreException { @@ -267,7 +257,7 @@ public class CertStore { /** * Returns the list of {@code CRL}s for the specified {@code CRLSelector} * from this certificate store. - * + * * @param selector * the selector containing the criteria to search for certificate * revocation lists in this store. @@ -275,7 +265,6 @@ public class CertStore { * selector * @throws CertStoreException * if error(s) occur. - * @since Android 1.0 */ public final Collection<? extends CRL> getCRLs(CRLSelector selector) throws CertStoreException { @@ -285,12 +274,11 @@ public class CertStore { /** * Returns the default {@code CertStore} type from the <i>Security * Properties</i>. - * + * * @return the default {@code CertStore} type from the <i>Security * Properties</i>, or the string {@code "LDAP"} if it cannot be * determined. - * @since Android 1.0 - */ + */ public static final String getDefaultType() { String defaultType = AccessController .doPrivileged(new java.security.PrivilegedAction<String>() { diff --git a/security/src/main/java/java/security/cert/CertStoreException.java b/security/src/main/java/java/security/cert/CertStoreException.java index 8351605..7f356b2 100644 --- a/security/src/main/java/java/security/cert/CertStoreException.java +++ b/security/src/main/java/java/security/cert/CertStoreException.java @@ -21,8 +21,6 @@ import java.security.GeneralSecurityException; /** * The exception that is thrown when an access to a {@code CertStore} fails. - * - * @since Android 1.0 */ public class CertStoreException extends GeneralSecurityException { @@ -36,7 +34,6 @@ public class CertStoreException extends GeneralSecurityException { * the detail message for this exception. * @param cause * the cause why the access to the certificate store failed. - * @since Android 1.0 */ public CertStoreException(String msg, Throwable cause) { super(msg, cause); @@ -47,7 +44,6 @@ public class CertStoreException extends GeneralSecurityException { * * @param cause * the cause why the access to the certificate store failed. - * @since Android 1.0 */ public CertStoreException(Throwable cause) { super(cause); @@ -58,7 +54,6 @@ public class CertStoreException extends GeneralSecurityException { * * @param msg * the detail message for this exception. - * @since Android 1.0 */ public CertStoreException(String msg) { super(msg); @@ -66,9 +61,7 @@ public class CertStoreException extends GeneralSecurityException { /** * Creates a new {@code CertStoreException}. - * - * @since Android 1.0 */ public CertStoreException() { } -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/cert/CertStoreParameters.java b/security/src/main/java/java/security/cert/CertStoreParameters.java index 566b2e2..06a1976 100644 --- a/security/src/main/java/java/security/cert/CertStoreParameters.java +++ b/security/src/main/java/java/security/cert/CertStoreParameters.java @@ -20,8 +20,6 @@ package java.security.cert; /** * The marker interface specifying the parameters used to initialize a {@code * CertStore} instance. - * - * @since Android 1.0 */ public interface CertStoreParameters extends Cloneable { @@ -29,7 +27,6 @@ public interface CertStoreParameters extends Cloneable { * Clones this {@code CertStoreParameters} instance. * * @return the cloned instance. - * @since Android 1.0 */ public Object clone(); -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/cert/CertStoreSpi.java b/security/src/main/java/java/security/cert/CertStoreSpi.java index be680a7..cb38a31 100644 --- a/security/src/main/java/java/security/cert/CertStoreSpi.java +++ b/security/src/main/java/java/security/cert/CertStoreSpi.java @@ -23,8 +23,6 @@ import java.util.Collection; /** * The <i>Service Provider Interface</i> (<b>SPI</b>) definition for the {@code * CertStore} class to be implemented by security providers. - * - * @since Android 1.0 */ public abstract class CertStoreSpi { @@ -36,7 +34,6 @@ public abstract class CertStoreSpi { * @throws InvalidAlgorithmParameterException * if the specified initialization parameters cannot be used to * initialize this instance. - * @since Android 1.0 */ public CertStoreSpi(CertStoreParameters params) throws InvalidAlgorithmParameterException { @@ -53,7 +50,6 @@ public abstract class CertStoreSpi { * specified selector. * @throws CertStoreException * if error(s) occur. - * @since Android 1.0 */ public abstract Collection<? extends Certificate> engineGetCertificates(CertSelector selector) throws CertStoreException; @@ -69,7 +65,6 @@ public abstract class CertStoreSpi { * selector * @throws CertStoreException * if error(s) occur. - * @since Android 1.0 */ public abstract Collection<? extends CRL> engineGetCRLs(CRLSelector selector) throws CertStoreException; diff --git a/security/src/main/java/java/security/cert/Certificate.java b/security/src/main/java/java/security/cert/Certificate.java index 0543329..22cbe9c 100644 --- a/security/src/main/java/java/security/cert/Certificate.java +++ b/security/src/main/java/java/security/cert/Certificate.java @@ -35,8 +35,6 @@ import org.apache.harmony.security.internal.nls.Messages; * Abstract class to represent identity certificates. It represents a way to * verify the binding of a Principal and its public key. Examples are X.509, * PGP, and SDSI. - * - * @since Android 1.0 */ public abstract class Certificate implements Serializable { @@ -47,10 +45,9 @@ public abstract class Certificate implements Serializable { /** * Creates a new {@code Certificate} with the specified type. - * + * * @param type * the certificate type. - * @since Android 1.0 */ protected Certificate(String type) { this.type = type; @@ -58,9 +55,8 @@ public abstract class Certificate implements Serializable { /** * Returns the certificate type. - * + * * @return the certificate type. - * @since Android 1.0 */ public final String getType() { return type; @@ -71,13 +67,12 @@ public abstract class Certificate implements Serializable { * represent the <em>same</em> object using a class specific comparison. The * implementation in Object returns {@code true} only if the argument is the * exact same object as the callee (==). - * + * * @param other * the object to compare with this object. * @return {@code true} if the object is the same as this object, {@code * false} if it is different from this object. * @see #hashCode - * @since Android 1.0 */ public boolean equals(Object other) { // obj equal to itself @@ -100,10 +95,9 @@ public abstract class Certificate implements Serializable { * Returns an integer hash code for the certificate. Any two objects which * return {@code true} when passed to {@code equals} must return the same * value for this method. - * + * * @return the certificate's hash * @see #equals - * @since Android 1.0 */ public int hashCode() { try { @@ -120,17 +114,16 @@ public abstract class Certificate implements Serializable { /** * Returns the encoded representation for this certificate. - * + * * @return the encoded representation for this certificate. * @throws CertificateEncodingException * if the encoding fails. - * @since Android 1.0 */ public abstract byte[] getEncoded() throws CertificateEncodingException; /** * Verifies that this certificate was signed with the given public key. - * + * * @param key * PublicKey public key for which verification should be * performed. @@ -144,7 +137,6 @@ public abstract class Certificate implements Serializable { * if there is no default provider. * @throws SignatureException * if signature errors are detected. - * @since Android 1.0 */ public abstract void verify(PublicKey key) throws CertificateException, @@ -156,7 +148,7 @@ public abstract class Certificate implements Serializable { /** * Verifies that this certificate was signed with the given public key. It * Uses the signature algorithm given by the provider. - * + * * @param key * PublicKey public key for which verification should be * performed. @@ -172,7 +164,6 @@ public abstract class Certificate implements Serializable { * if the specified provider does not exists. * @exception SignatureException * if signature errors are detected. - * @since Android 1.0 */ public abstract void verify(PublicKey key, String sigProvider) throws CertificateException, @@ -184,27 +175,24 @@ public abstract class Certificate implements Serializable { /** * Returns a string containing a concise, human-readable description of the * certificate. - * + * * @return a printable representation for the certificate. - * @since Android 1.0 */ public abstract String toString(); /** * Returns the public key corresponding to this certificate. - * + * * @return the public key corresponding to this certificate. - * @since Android 1.0 */ public abstract PublicKey getPublicKey(); /** * Returns an alternate object to be serialized. - * + * * @return the object to serialize. * @throws ObjectStreamException * if the creation of the alternate object fails. - * @since Android 1.0 */ protected Object writeReplace() throws ObjectStreamException { try { @@ -217,9 +205,7 @@ public abstract class Certificate implements Serializable { /** * The alternate {@code Serializable} class to be used for serialization and - * deserialization of {@code Certificate} objects. - * - * @since Android 1.0 + * deserialization of {@code Certificate} objects. */ protected static class CertificateRep implements Serializable { @@ -239,12 +225,11 @@ public abstract class Certificate implements Serializable { /** * Creates a new {@code CertificateRep} instance with the specified * certificate type and encoded data. - * + * * @param type * the certificate type. * @param data * the encoded data. - * @since Android 1.0 */ protected CertificateRep(String type, byte[] data) { this.type = type; @@ -254,11 +239,10 @@ public abstract class Certificate implements Serializable { /** * Deserializes a {@code Certificate} from a serialized {@code * CertificateRep} object. - * + * * @return the deserialized {@code Certificate}. * @throws ObjectStreamException * if deserialization fails. - * @since Android 1.0 */ protected Object readResolve() throws ObjectStreamException { try { diff --git a/security/src/main/java/java/security/cert/CertificateEncodingException.java b/security/src/main/java/java/security/cert/CertificateEncodingException.java index 188d084..c5532b9 100644 --- a/security/src/main/java/java/security/cert/CertificateEncodingException.java +++ b/security/src/main/java/java/security/cert/CertificateEncodingException.java @@ -20,8 +20,6 @@ package java.security.cert; /** * The exception that is thrown when an error occurs while a {@code Certificate} * is being encoded. - * - * @since Android 1.0 */ public class CertificateEncodingException extends CertificateException { @@ -33,7 +31,6 @@ public class CertificateEncodingException extends CertificateException { * * @param msg * The detail message for the exception. - * @since Android 1.0 */ public CertificateEncodingException(String msg) { super(msg); @@ -41,8 +38,6 @@ public class CertificateEncodingException extends CertificateException { /** * Creates a new {@code CertificateEncodingException}. - * - * @since Android 1.0 */ public CertificateEncodingException() { } @@ -55,7 +50,6 @@ public class CertificateEncodingException extends CertificateException { * the detail message for the exception. * @param cause * the cause. - * @since Android 1.0 */ public CertificateEncodingException(String message, Throwable cause) { super(message, cause); @@ -67,7 +61,6 @@ public class CertificateEncodingException extends CertificateException { * * @param cause * the cause. - * @since Android 1.0 */ public CertificateEncodingException(Throwable cause) { super(cause); diff --git a/security/src/main/java/java/security/cert/CertificateException.java b/security/src/main/java/java/security/cert/CertificateException.java index 674d617..8b1c4d3 100644 --- a/security/src/main/java/java/security/cert/CertificateException.java +++ b/security/src/main/java/java/security/cert/CertificateException.java @@ -21,8 +21,6 @@ import java.security.GeneralSecurityException; /** * The base class for all {@code Certificate} related exceptions. - * - * @since Android 1.0 */ public class CertificateException extends GeneralSecurityException { @@ -33,7 +31,6 @@ public class CertificateException extends GeneralSecurityException { * * @param msg * the detail message for the exception. - * @since Android 1.0 */ public CertificateException(String msg) { super(msg); @@ -41,8 +38,6 @@ public class CertificateException extends GeneralSecurityException { /** * Creates a new {@code CertificateException}. - * - * @since Android 1.0 */ public CertificateException() { } @@ -55,7 +50,6 @@ public class CertificateException extends GeneralSecurityException { * the detail message for the exception. * @param cause * the cause. - * @since Android 1.0 */ public CertificateException(String message, Throwable cause) { super(message, cause); @@ -66,7 +60,6 @@ public class CertificateException extends GeneralSecurityException { * * @param cause * the cause - * @since Android 1.0 */ public CertificateException(Throwable cause) { super(cause); diff --git a/security/src/main/java/java/security/cert/CertificateExpiredException.java b/security/src/main/java/java/security/cert/CertificateExpiredException.java index fe3fc1f..e15bf98 100644 --- a/security/src/main/java/java/security/cert/CertificateExpiredException.java +++ b/security/src/main/java/java/security/cert/CertificateExpiredException.java @@ -19,8 +19,6 @@ package java.security.cert; /** * The exception that is thrown when a {@code Certificate} has expired. - * - * @since Android 1.0 */ public class CertificateExpiredException extends CertificateException { @@ -32,7 +30,6 @@ public class CertificateExpiredException extends CertificateException { * * @param msg * the detail message for this exception - * @since Android 1.0 */ public CertificateExpiredException(String msg) { super(msg); @@ -40,8 +37,6 @@ public class CertificateExpiredException extends CertificateException { /** * Creates a new {@code CertificateExpiredException}. - * - * @since Android 1.0 */ public CertificateExpiredException() { } diff --git a/security/src/main/java/java/security/cert/CertificateFactory.java b/security/src/main/java/java/security/cert/CertificateFactory.java index b4213d4..cb2636a 100644 --- a/security/src/main/java/java/security/cert/CertificateFactory.java +++ b/security/src/main/java/java/security/cert/CertificateFactory.java @@ -36,9 +36,6 @@ import org.apache.harmony.security.internal.nls.Messages; * <p> * It defines methods for parsing certificate chains (certificate paths) and * <i>Certificate Revocation Lists</i> (CRLs). - * </p> - * - * @since Android 1.0 */ public class CertificateFactory { @@ -59,14 +56,13 @@ public class CertificateFactory { /** * Creates a new {@code CertificateFactory} instance. - * + * * @param certFacSpi * the implementation delegate. * @param provider * the associated provider. * @param type * the certificate type. - * @since Android 1.0 */ protected CertificateFactory(CertificateFactorySpi certFacSpi, Provider provider, String type) { @@ -87,7 +83,6 @@ public class CertificateFactory { * installed provider. * @throws NullPointerException * if {@code type} is {@code null}. - * @since Android 1.0 */ public static final CertificateFactory getInstance(String type) throws CertificateException { @@ -124,7 +119,6 @@ public class CertificateFactory { * if the specified provider name is {@code null} or empty. * @throws NullPointerException * it {@code type} is {@code null}. - * @since Android 1.0 */ public static final CertificateFactory getInstance(String type, String provider) throws CertificateException, @@ -156,7 +150,6 @@ public class CertificateFactory { * if the specified provider is {@code null}. * @throws NullPointerException * is {@code type} is {@code null}. - * @since Android 1.0 */ public static final CertificateFactory getInstance(String type, Provider provider) throws CertificateException { @@ -182,7 +175,6 @@ public class CertificateFactory { * the certificate. * * @return the provider of this certificate factory. - * @since Android 1.0 */ public final Provider getProvider() { return provider; @@ -192,7 +184,6 @@ public class CertificateFactory { * Returns the Certificate type. * * @return type of certificate being used. - * @since Android 1.0 */ public final String getType() { return type; @@ -208,7 +199,6 @@ public class CertificateFactory { * @return an initialized Certificate. * @throws CertificateException * if parsing problems are detected. - * @since Android 1.0 */ public final Certificate generateCertificate(InputStream inStream) throws CertificateException { @@ -221,7 +211,6 @@ public class CertificateFactory { * * @return an iterator over supported {@link CertPath} encodings (as * Strings). - * @since Android 1.0 */ public final Iterator<String> getCertPathEncodings() { return spiImpl.engineGetCertPathEncodings(); @@ -236,7 +225,6 @@ public class CertificateFactory { * @return a {@code CertPath} initialized from the provided data. * @throws CertificateException * if parsing problems are detected. - * @since Android 1.0 */ public final CertPath generateCertPath(InputStream inStream) throws CertificateException { @@ -261,7 +249,6 @@ public class CertificateFactory { * if parsing problems are detected. * @throws UnsupportedOperationException * if the provider does not implement this method. - * @since Android 1.0 */ public final CertPath generateCertPath(InputStream inStream, String encoding) throws CertificateException { @@ -280,7 +267,6 @@ public class CertificateFactory { * if parsing problems are detected. * @throws UnsupportedOperationException * if the provider does not implement this method. - * @since Android 1.0 */ public final CertPath generateCertPath(List<? extends Certificate> certificates) throws CertificateException { @@ -297,7 +283,6 @@ public class CertificateFactory { * @return an initialized collection of certificates. * @throws CertificateException * if parsing problems are detected. - * @since Android 1.0 */ public final Collection<? extends Certificate> generateCertificates(InputStream inStream) throws CertificateException { @@ -313,7 +298,6 @@ public class CertificateFactory { * @return an initialized CRL. * @exception CRLException * if parsing problems are detected. - * @since Android 1.0 */ public final CRL generateCRL(InputStream inStream) throws CRLException { return spiImpl.engineGenerateCRL(inStream); @@ -328,7 +312,6 @@ public class CertificateFactory { * @return an initialized collection of CRLs. * @exception CRLException * if parsing problems are detected. - * @since Android 1.0 */ public final Collection<? extends CRL> generateCRLs(InputStream inStream) throws CRLException { diff --git a/security/src/main/java/java/security/cert/CertificateFactorySpi.java b/security/src/main/java/java/security/cert/CertificateFactorySpi.java index ed6ffed..d9f2044 100644 --- a/security/src/main/java/java/security/cert/CertificateFactorySpi.java +++ b/security/src/main/java/java/security/cert/CertificateFactorySpi.java @@ -28,16 +28,12 @@ import org.apache.harmony.security.internal.nls.Messages; * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) for the * {@code CertificateFactory} class. This SPI must be implemented for each * certificate type a security provider wishes to support. - * - * @since Android 1.0 */ public abstract class CertificateFactorySpi { /** * Constructs a new instance of this class. - * - * @since Android 1.0 */ public CertificateFactorySpi() { } @@ -52,7 +48,6 @@ public abstract class CertificateFactorySpi { * @return an initialized certificate. * @exception CertificateException * if parsing problems are detected. - * @since Android 1.0 */ public abstract Certificate engineGenerateCertificate(InputStream inStream) throws CertificateException; @@ -66,7 +61,6 @@ public abstract class CertificateFactorySpi { * @return a collection of certificates. * @exception CertificateException * if parsing problems are detected. - * @since Android 1.0 */ public abstract Collection<? extends Certificate> engineGenerateCertificates(InputStream inStream) throws CertificateException; @@ -80,7 +74,6 @@ public abstract class CertificateFactorySpi { * @return an CRL instance. * @exception CRLException * if parsing problems are detected. - * @since Android 1.0 */ public abstract CRL engineGenerateCRL(InputStream inStream) throws CRLException; @@ -94,7 +87,6 @@ public abstract class CertificateFactorySpi { * @return a collection of CRLs. * @exception CRLException * if parsing problems are detected. - * @since Android 1.0 */ public abstract Collection<? extends CRL> engineGenerateCRLs(InputStream inStream) throws CRLException; @@ -108,7 +100,6 @@ public abstract class CertificateFactorySpi { * @return a {@code CertPath} initialized from the provided data. * @throws CertificateException * if parsing problems are detected. - * @since Android 1.0 */ public CertPath engineGenerateCertPath(InputStream inStream) throws CertificateException { @@ -130,7 +121,6 @@ public abstract class CertificateFactorySpi { * if parsing problems are detected. * @throws UnsupportedOperationException * if the provider does not implement this method. - * @since Android 1.0 */ public CertPath engineGenerateCertPath(InputStream inStream, String encoding) throws CertificateException { @@ -150,7 +140,6 @@ public abstract class CertificateFactorySpi { * if parsing problems are detected. * @throws UnsupportedOperationException * if the provider does not implement this method. - * @since Android 1.0 */ public CertPath engineGenerateCertPath(List<? extends Certificate> certificates) throws CertificateException { @@ -164,7 +153,6 @@ public abstract class CertificateFactorySpi { * * @return an iterator over supported {@code CertPath} encodings (as * Strings). - * @since Android 1.0 */ public Iterator<String> engineGetCertPathEncodings() { throw new UnsupportedOperationException( diff --git a/security/src/main/java/java/security/cert/CertificateNotYetValidException.java b/security/src/main/java/java/security/cert/CertificateNotYetValidException.java index 221b22a..dd26bf8 100644 --- a/security/src/main/java/java/security/cert/CertificateNotYetValidException.java +++ b/security/src/main/java/java/security/cert/CertificateNotYetValidException.java @@ -20,8 +20,6 @@ package java.security.cert; /** * The exception that is thrown when a {@code Certificate} is not yet valid or * will not yet be valid on a specified date. - * - * @since Android 1.0 */ public class CertificateNotYetValidException extends CertificateException { @@ -33,7 +31,6 @@ public class CertificateNotYetValidException extends CertificateException { * * @param msg * the detail message for the exception. - * @since Android 1.0 */ public CertificateNotYetValidException(String msg) { super(msg); @@ -41,8 +38,6 @@ public class CertificateNotYetValidException extends CertificateException { /** * Creates a new {@code CertificateNotYetValidException}. - * - * @since Android 1.0 */ public CertificateNotYetValidException() { } diff --git a/security/src/main/java/java/security/cert/CertificateParsingException.java b/security/src/main/java/java/security/cert/CertificateParsingException.java index 2c75d20..4efd159 100644 --- a/security/src/main/java/java/security/cert/CertificateParsingException.java +++ b/security/src/main/java/java/security/cert/CertificateParsingException.java @@ -19,8 +19,6 @@ package java.security.cert; /** * The exception that is thrown when a {@code Certificate} can not be parsed. - * - * @since Android 1.0 */ public class CertificateParsingException extends CertificateException { @@ -29,10 +27,9 @@ public class CertificateParsingException extends CertificateException { /** * Creates a new {@code CertificateParsingException} with the specified * message. - * + * * @param msg * the detail message for the exception. - * @since Android 1.0 */ public CertificateParsingException(String msg) { super(msg); @@ -40,8 +37,6 @@ public class CertificateParsingException extends CertificateException { /** * Creates a new {@code CertificateParsingException}. - * - * @since Android 1.0 */ public CertificateParsingException() { } @@ -49,12 +44,11 @@ public class CertificateParsingException extends CertificateException { /** * Creates a new {@code CertificateParsingException} with the specified * message and cause. - * + * * @param message * the detail message for the exception. * @param cause * the exception's source. - * @since Android 1.0 */ public CertificateParsingException(String message, Throwable cause) { super(message, cause); @@ -63,10 +57,9 @@ public class CertificateParsingException extends CertificateException { /** * Creates a new {@code CertificateParsingException} with the specified * cause. - * + * * @param cause * the exception's source. - * @since Android 1.0 */ public CertificateParsingException(Throwable cause) { super(cause); diff --git a/security/src/main/java/java/security/cert/CollectionCertStoreParameters.java b/security/src/main/java/java/security/cert/CollectionCertStoreParameters.java index 23d8884..3c2fe1c 100644 --- a/security/src/main/java/java/security/cert/CollectionCertStoreParameters.java +++ b/security/src/main/java/java/security/cert/CollectionCertStoreParameters.java @@ -24,13 +24,9 @@ import java.util.Collections; * The parameters to initialize a <i>Collection</i> type {@code CertStore} instance. * <p> * It is used to specify the {@code Collection} where the {@code CertStore} will - * retrieve the certificates and CRLs from. - * </p> - * - * @since Android 1.0 + * retrieve the certificates and CRLs from. */ public class CollectionCertStoreParameters implements CertStoreParameters { - // BEGIN android-changed // Default empty and immutable collection. // Used if <code>CollectionCertStoreParameters</code>instance // created by the no arg constructor @@ -38,14 +34,11 @@ public class CollectionCertStoreParameters implements CertStoreParameters { // A <code>Collection</code> of <code>Certificate</code>s // and <code>CRL</code>s private final Collection<?> collection; - // END android-changed /** * Creates a new {@code CollectionCertStoreParameters} without a collection. * <p> * The default collection is an empty and unmodifiable {@code Collection}. - * </p> - * @since Android 1.0 */ public CollectionCertStoreParameters() { this.collection = defaultCollection; @@ -57,14 +50,12 @@ public class CollectionCertStoreParameters implements CertStoreParameters { * <p> * The specified collection is not copied and therefore may be modified at * any time. - * </p> - * + * * @param collection * the collection where the {@code Certificate}s and {@code CRL}s * will be retrieved from. * @throws NullPointerException * if {@code collection is null}. - * @since Android 1.0 */ public CollectionCertStoreParameters(Collection<?> collection) { this.collection = collection; @@ -76,21 +67,23 @@ public class CollectionCertStoreParameters implements CertStoreParameters { /** * Clones this {@code CollectionCertStoreParameters} instance, but not the * underlying collection. - * + * * @return the cloned instance. - * @since Android 1.0 */ public Object clone() { - return new CollectionCertStoreParameters(collection); + try { + return super.clone(); + } catch (CloneNotSupportedException e) { + return null; + } } /** * Returns the collection where the {@code Certificate}s and {@code CRL}s * are retrieved from. - * + * * @return the collection where the {@code Certificate}s and {@code CRL}s * will be retrieved from. - * @since Android 1.0 */ public Collection<?> getCollection() { return collection; @@ -98,13 +91,12 @@ public class CollectionCertStoreParameters implements CertStoreParameters { /** * Returns the string representation of this instance. - * + * * @return the string representation of this instance. - * @since Android 1.0 */ public String toString() { - StringBuffer sb = - new StringBuffer("CollectionCertStoreParameters: [\ncollection: "); //$NON-NLS-1$ + StringBuilder sb = + new StringBuilder("CollectionCertStoreParameters: [\ncollection: "); //$NON-NLS-1$ sb.append(getCollection().toString()); sb.append("\n]"); //$NON-NLS-1$ return sb.toString(); diff --git a/security/src/main/java/java/security/cert/LDAPCertStoreParameters.java b/security/src/main/java/java/security/cert/LDAPCertStoreParameters.java index 9145848..1d6542f 100644 --- a/security/src/main/java/java/security/cert/LDAPCertStoreParameters.java +++ b/security/src/main/java/java/security/cert/LDAPCertStoreParameters.java @@ -19,8 +19,6 @@ package java.security.cert; /** * The parameters to initialize a LDAP {@code CertStore} instance. - * - * @since Android 1.0 */ public class LDAPCertStoreParameters implements CertStoreParameters { // Default LDAP server name @@ -36,14 +34,13 @@ public class LDAPCertStoreParameters implements CertStoreParameters { /** * Creates a new {@code LDAPCertStoreParameters} instance with the specified * server name and port. - * + * * @param serverName * the LDAP server name. * @param port * the port. * @throws NullPointerException * is {@code serverName} is {@code null}. - * @since Android 1.0 */ public LDAPCertStoreParameters(String serverName, int port) { this.port = port; @@ -58,9 +55,6 @@ public class LDAPCertStoreParameters implements CertStoreParameters { * parameters. * <p> * The default parameters are server name "localhost" and port 389. - * </p> - * - * @since Android 1.0 */ public LDAPCertStoreParameters() { this.serverName = DEFAULT_LDAP_SERVER_NAME; @@ -70,12 +64,11 @@ public class LDAPCertStoreParameters implements CertStoreParameters { /** * Creates a new {@code LDAPCertStoreParameters} instance with the specified * server name and default port 389. - * + * * @param serverName * the LDAP server name. * @throws NullPointerException * if {@code serverName} is {@code null}. - * @since Android 1.0 */ public LDAPCertStoreParameters(String serverName) { this.port = DEFAULT_LDAP_PORT; @@ -87,19 +80,21 @@ public class LDAPCertStoreParameters implements CertStoreParameters { /** * Clones this {@code LDAPCertStoreParameters} instance. - * + * * @return the cloned instance. - * @since Android 1.0 */ public Object clone() { - return new LDAPCertStoreParameters(serverName, port); + try { + return super.clone(); + } catch (CloneNotSupportedException e) { + return null; + } } /** * Returns the LDAP server port. - * + * * @return the LDAP server port. - * @since Android 1.0 */ public int getPort() { return port; @@ -107,9 +102,8 @@ public class LDAPCertStoreParameters implements CertStoreParameters { /** * Returns the LDAP server name. - * + * * @return the LDAP server name. - * @since Android 1.0 */ public String getServerName() { return serverName; @@ -118,14 +112,13 @@ public class LDAPCertStoreParameters implements CertStoreParameters { /** * Returns the string representation of this {@code LDAPCertStoreParameters} * instance. - * + * * @return the string representation of this {@code LDAPCertStoreParameters} * instance. - * @since Android 1.0 */ public String toString() { - StringBuffer sb = - new StringBuffer("LDAPCertStoreParameters: [\n serverName: "); //$NON-NLS-1$ + StringBuilder sb = + new StringBuilder("LDAPCertStoreParameters: [\n serverName: "); //$NON-NLS-1$ sb.append(getServerName()); sb.append("\n port: "); //$NON-NLS-1$ sb.append(getPort()); diff --git a/security/src/main/java/java/security/cert/PKIXBuilderParameters.java b/security/src/main/java/java/security/cert/PKIXBuilderParameters.java index a047a80..1a75063 100644 --- a/security/src/main/java/java/security/cert/PKIXBuilderParameters.java +++ b/security/src/main/java/java/security/cert/PKIXBuilderParameters.java @@ -32,11 +32,9 @@ import org.apache.harmony.security.internal.nls.Messages; * <p> * The parameters must be created with <i>trusted</i> certificate authorities * and constraints for the target certificates. - * </p> - * + * * @see CertPathBuilder * @see CertPathParameters - * @since Android 1.0 */ public class PKIXBuilderParameters extends PKIXParameters { // Maximum certificate path length (5 by default) @@ -55,7 +53,6 @@ public class PKIXBuilderParameters extends PKIXParameters { * @throws ClassCastException * if one of the items in {@code trustAnchors} is not an * instance of {@code java.security.cert.TrustAnchor}. - * @since Android 1.0 */ public PKIXBuilderParameters(Set<TrustAnchor> trustAnchors, CertSelector targetConstraints) @@ -77,7 +74,6 @@ public class PKIXBuilderParameters extends PKIXParameters { * @throws InvalidAlgorithmParameterException * if {@code keyStore} does not contained any trusted * certificate entry. - * @since Android 1.0 */ public PKIXBuilderParameters(KeyStore keyStore, CertSelector targetConstraints) @@ -92,11 +88,9 @@ public class PKIXBuilderParameters extends PKIXParameters { * <p> * This is the maximum number of non-self-signed certificates in a * certification path. - * </p> - * + * * @return the maximum length of a certification path, or {@code -1} if it * is unlimited. - * @since Android 1.0 */ public int getMaxPathLength() { return maxPathLength; @@ -107,13 +101,11 @@ public class PKIXBuilderParameters extends PKIXParameters { * <p> * This is the maximum number of non-self-signed certificates in a * certification path. - * </p> * * @param maxPathLength * the maximum length of a certification path. * @throws InvalidParameterException * if {@code maxPathLength} is less than {@code -1}. - * @since Android 1.0 */ public void setMaxPathLength(int maxPathLength) { if (maxPathLength < -1) { @@ -129,10 +121,9 @@ public class PKIXBuilderParameters extends PKIXParameters { * * @return a string representation of this {@code PKIXBuilderParameters} * instance. - * @since Android 1.0 */ public String toString() { - StringBuffer sb = new StringBuffer("[\n"); //$NON-NLS-1$ + StringBuilder sb = new StringBuilder("[\n"); //$NON-NLS-1$ sb.append(super.toString()); sb.append(" Max Path Length: "); //$NON-NLS-1$ sb.append(maxPathLength); diff --git a/security/src/main/java/java/security/cert/PKIXCertPathBuilderResult.java b/security/src/main/java/java/security/cert/PKIXCertPathBuilderResult.java index 6064194..5a9fb2d 100644 --- a/security/src/main/java/java/security/cert/PKIXCertPathBuilderResult.java +++ b/security/src/main/java/java/security/cert/PKIXCertPathBuilderResult.java @@ -25,8 +25,6 @@ import org.apache.harmony.security.internal.nls.Messages; /** * The result of the PKIX certification path builder, returned by * {@link CertPathBuilder#build(CertPathParameters)}. - * - * @since Android 1.0 */ public class PKIXCertPathBuilderResult extends PKIXCertPathValidatorResult implements CertPathBuilderResult { @@ -49,7 +47,6 @@ public class PKIXCertPathBuilderResult extends PKIXCertPathValidatorResult * @throws NullPointerException * if the {@code cerPath}, {@code trustAnchor} or {@code * subjectPolicyKey} is {@code null}. - * @since Android 1.0 */ public PKIXCertPathBuilderResult(CertPath certPath, TrustAnchor trustAnchor, PolicyNode policyTree, PublicKey subjectPublicKey) { @@ -64,7 +61,6 @@ public class PKIXCertPathBuilderResult extends PKIXCertPathValidatorResult * Returns the validated certification path. * * @return the validated certification path. - * @since Android 1.0 */ public CertPath getCertPath() { return certPath; @@ -76,10 +72,9 @@ public class PKIXCertPathBuilderResult extends PKIXCertPathValidatorResult * * @return a string representation of this {@code PKIXCertPathBuilderResult} * instance. - * @since Android 1.0 */ public String toString() { - StringBuffer sb = new StringBuffer(super.toString()); + StringBuilder sb = new StringBuilder(super.toString()); sb.append("\n Certification Path: "); //$NON-NLS-1$ sb.append(certPath.toString()); sb.append("\n]"); //$NON-NLS-1$ diff --git a/security/src/main/java/java/security/cert/PKIXCertPathChecker.java b/security/src/main/java/java/security/cert/PKIXCertPathChecker.java index 5614878..710ac11 100644 --- a/security/src/main/java/java/security/cert/PKIXCertPathChecker.java +++ b/security/src/main/java/java/security/cert/PKIXCertPathChecker.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Vladimir N. Molotkov -* @version $Revision$ -*/ - package java.security.cert; import java.util.Collection; @@ -38,22 +33,16 @@ import java.util.Set; * {@link #check(Certificate, Collection) check} method will be called for each * certificate processed by a {@code CertPathBuilder} of {@code * CertPathValidator}. - * </p> * <p> * A {@code PKIXCertPathChecker} implementation <u>must</u> support reverse * checking (from trusted CA to target) and <u>may</u> support forward checking * (from target to trusted CA). The return value of {@code * isForwardCheckingSupported} indicates whether forward checking is supported. - * </p> - * - * @since Android 1.0 */ public abstract class PKIXCertPathChecker implements Cloneable { /** * Creates a new {@code PKIXCertPathChecker} instance. - * - * @since Android 1.0 */ protected PKIXCertPathChecker() {} @@ -61,7 +50,6 @@ public abstract class PKIXCertPathChecker implements Cloneable { * Clones this {@code PKIXCertPathChecker} instance. * * @return the cloned instance. - * @since Android 1.0 */ public Object clone() { try { @@ -84,7 +72,6 @@ public abstract class PKIXCertPathChecker implements Cloneable { * if initialization of this {@code PKIXCertPathChecker} * instance fails, or if it cannot process certificates in the * specified order. - * @since Android 1.0 */ public abstract void init(boolean forward) throws CertPathValidatorException; @@ -95,7 +82,6 @@ public abstract class PKIXCertPathChecker implements Cloneable { * * @return {@code true} if this {@code PKIXCertPathChecker} instance * supports forward checking, otherwise {@code false}. - * @since Android 1.0 */ public abstract boolean isForwardCheckingSupported(); @@ -106,7 +92,6 @@ public abstract class PKIXCertPathChecker implements Cloneable { * @return the list of extensions of X.509 certificates that this {@code * PKIXCertPathChecker} is able to process, or {@code null} if there * are none. - * @since Android 1.0 */ public abstract Set<String> getSupportedExtensions(); @@ -120,7 +105,6 @@ public abstract class PKIXCertPathChecker implements Cloneable { * the list of critical X.509 extension OID strings. * @throws CertPathValidatorException * if check(s) fail on the specified certificate. - * @since Android 1.0 */ public abstract void check(Certificate cert, Collection<String> unresolvedCritExts) throws CertPathValidatorException; diff --git a/security/src/main/java/java/security/cert/PKIXCertPathValidatorResult.java b/security/src/main/java/java/security/cert/PKIXCertPathValidatorResult.java index 21f90c9..7d80ae5 100644 --- a/security/src/main/java/java/security/cert/PKIXCertPathValidatorResult.java +++ b/security/src/main/java/java/security/cert/PKIXCertPathValidatorResult.java @@ -26,7 +26,6 @@ import org.apache.harmony.security.internal.nls.Messages; * * @see CertPathValidator * @see CertPathValidator#validate(CertPath, CertPathParameters) - * @since Android 1.0 */ public class PKIXCertPathValidatorResult implements CertPathValidatorResult { // A trust anchor used during validation of certification path @@ -48,7 +47,6 @@ public class PKIXCertPathValidatorResult implements CertPathValidatorResult { * the valid policy tree from the validation. * @param subjectPublicKey * the subject public key from the validation. - * @since Android 1.0 */ public PKIXCertPathValidatorResult(TrustAnchor trustAnchor, PolicyNode policyTree, PublicKey subjectPublicKey) { @@ -68,7 +66,6 @@ public class PKIXCertPathValidatorResult implements CertPathValidatorResult { * Returns the valid policy tree from the validation. * * @return the valid policy tree from the validation. - * @since Android 1.0 */ public PolicyNode getPolicyTree() { return policyTree; @@ -78,7 +75,6 @@ public class PKIXCertPathValidatorResult implements CertPathValidatorResult { * Returns the subject public key from the validation. * * @return the subject public key from the validation. - * @since Android 1.0 */ public PublicKey getPublicKey() { return subjectPublicKey; @@ -89,7 +85,6 @@ public class PKIXCertPathValidatorResult implements CertPathValidatorResult { * served as trust anchor for this certification path. * * @return the trust anchor. - * @since Android 1.0 */ public TrustAnchor getTrustAnchor() { return trustAnchor; @@ -99,7 +94,6 @@ public class PKIXCertPathValidatorResult implements CertPathValidatorResult { * Clones this {@code PKIXCertPathValidatorResult} instance. * * @return the cloned instance. - * @since Android 1.0 */ public Object clone() { try { @@ -116,10 +110,9 @@ public class PKIXCertPathValidatorResult implements CertPathValidatorResult { * * @return a string representation for this {@code * PKIXCertPathValidatorResult} instance. - * @since Android 1.0 */ public String toString() { - StringBuffer sb = new StringBuffer(super.toString()); + StringBuilder sb = new StringBuilder(super.toString()); sb.append(": [\n Trust Anchor: "); //$NON-NLS-1$ sb.append(trustAnchor.toString()); sb.append("\n Policy Tree: "); //$NON-NLS-1$ diff --git a/security/src/main/java/java/security/cert/PKIXParameters.java b/security/src/main/java/java/security/cert/PKIXParameters.java index 16b0686..4034d21 100644 --- a/security/src/main/java/java/security/cert/PKIXParameters.java +++ b/security/src/main/java/java/security/cert/PKIXParameters.java @@ -36,11 +36,9 @@ import org.apache.harmony.security.internal.nls.Messages; * <p> * The parameters must be created with <i>trusted</i> certificate authorities * (trust anchors). - * </p> - * + * * @see CertPathValidator * @see CertPathParameters - * @since Android 1.0 */ public class PKIXParameters implements CertPathParameters { // Set of trust anchors - most trusted CAs @@ -79,7 +77,6 @@ public class PKIXParameters implements CertPathParameters { * the trusted CAs. * @throws InvalidAlgorithmParameterException * if {@code trustAnchors} is empty. - * @since Android 1.0 */ public PKIXParameters(Set<TrustAnchor> trustAnchors) throws InvalidAlgorithmParameterException { @@ -101,7 +98,6 @@ public class PKIXParameters implements CertPathParameters { * @throws InvalidAlgorithmParameterException * if {@code keyStore} does not contained any trusted * certificate entry. - * @since Android 1.0 */ public PKIXParameters(KeyStore keyStore) throws KeyStoreException, @@ -137,7 +133,6 @@ public class PKIXParameters implements CertPathParameters { * Returns a unmodifiable set of the <i>trusted</i> certificate authorities. * * @return a unmodifiable set of the <i>trusted</i> certificate authorities. - * @since Android 1.0 */ public Set<TrustAnchor> getTrustAnchors() { return Collections.unmodifiableSet(trustAnchors); @@ -150,7 +145,6 @@ public class PKIXParameters implements CertPathParameters { * the set of <i>trusted</i> certificate authorities. * @throws InvalidAlgorithmParameterException * if {@code trustAnchors} is empty. - * @since Android 1.0 */ public void setTrustAnchors(Set<TrustAnchor> trustAnchors) throws InvalidAlgorithmParameterException { @@ -169,7 +163,6 @@ public class PKIXParameters implements CertPathParameters { * * @return {@code true} if the <i>any policy OID</i> will be inhibited, * otherwise {@code false}. - * @since Android 1.0 */ public boolean isAnyPolicyInhibited() { return anyPolicyInhibited; @@ -182,7 +175,6 @@ public class PKIXParameters implements CertPathParameters { * @param anyPolicyInhibited * {@code true} if the <i>any policy OID</i> should be inhibited, * otherwise {@code false}. - * @since Android 1.0 */ public void setAnyPolicyInhibited(boolean anyPolicyInhibited) { this.anyPolicyInhibited = anyPolicyInhibited; @@ -192,10 +184,8 @@ public class PKIXParameters implements CertPathParameters { * Returns the list of checkers for the certification path. * <p> * The list is unmodifiable and the entries in the list are cloned. - * </p> - * + * * @return the list of checkers for the certification path. - * @since Android 1.0 */ public List<PKIXCertPathChecker> getCertPathCheckers() { if (certPathCheckers == null) { @@ -222,12 +212,10 @@ public class PKIXParameters implements CertPathParameters { * Sets the list of checkers for the certification path. * <p> * The list is copied and the entries are cloned. - * </p> * * @param certPathCheckers * the list of checkers for the certification path, or {@code * null} to clear the checkers. - * @since Android 1.0 */ public void setCertPathCheckers(List<PKIXCertPathChecker> certPathCheckers) { if (certPathCheckers == null || certPathCheckers.isEmpty()) { @@ -254,7 +242,6 @@ public class PKIXParameters implements CertPathParameters { * @param checker * the {@code PKIXCertPathChecker} to add, if {@code null}, it * will be ignored. - * @since Android 1.0 */ public void addCertPathChecker(PKIXCertPathChecker checker) { if (checker == null) { @@ -274,7 +261,6 @@ public class PKIXParameters implements CertPathParameters { * and CRLs. * * @return an immutable list of certificate stores. - * @since Android 1.0 */ public List<CertStore> getCertStores() { if (certStores == null) { @@ -298,7 +284,6 @@ public class PKIXParameters implements CertPathParameters { * CRLs. * * @param certStores the list of certificate stores. - * @since Android 1.0 */ public void setCertStores(List<CertStore> certStores) { if (certStores == null || certStores.isEmpty()) { @@ -325,7 +310,6 @@ public class PKIXParameters implements CertPathParameters { * * @param store * the store to add, if {@code null}, it will be ignored. - * @since Android 1.0 */ public void addCertStore(CertStore store) { if (store == null) { @@ -346,7 +330,6 @@ public class PKIXParameters implements CertPathParameters { * * @return the time for the validation, or {@code null} for the current * time. - * @since Android 1.0 */ public Date getDate() { return date == null ? null : (Date)date.clone(); @@ -359,7 +342,6 @@ public class PKIXParameters implements CertPathParameters { * @param date * the time for the validation, or {@code null} for the current * time. - * @since Android 1.0 */ public void setDate(Date date) { this.date = (date == null ? null : new Date(date.getTime())); @@ -371,7 +353,6 @@ public class PKIXParameters implements CertPathParameters { * * @return {@code true} if an explicit policy is required, otherwise {@code * false}. - * @since Android 1.0 */ public boolean isExplicitPolicyRequired() { return explicitPolicyRequired; @@ -384,7 +365,6 @@ public class PKIXParameters implements CertPathParameters { * @param explicitPolicyRequired * {@code true} if an explicit policy is required, otherwise * {@code false}. - * @since Android 1.0 */ public void setExplicitPolicyRequired(boolean explicitPolicyRequired) { this.explicitPolicyRequired = explicitPolicyRequired; @@ -396,7 +376,6 @@ public class PKIXParameters implements CertPathParameters { * * @return the unmodifiable list of policies, or an empty set if any policy * is acceptable. - * @since Android 1.0 */ public Set<String> getInitialPolicies() { if (initialPolicies == null) { @@ -421,7 +400,6 @@ public class PKIXParameters implements CertPathParameters { * @param initialPolicies * the list of policies, or an empty set or {@code null} if any * policy is acceptable. - * @since Android 1.0 */ public void setInitialPolicies(Set<String> initialPolicies) { if (initialPolicies == null || initialPolicies.isEmpty()) { @@ -448,7 +426,6 @@ public class PKIXParameters implements CertPathParameters { * * @return {@code true} if policy mapping is inhibited, otherwise {@code * false}. - * @since Android 1.0 */ public boolean isPolicyMappingInhibited() { return policyMappingInhibited; @@ -460,7 +437,6 @@ public class PKIXParameters implements CertPathParameters { * @param policyMappingInhibited * {@code true} if policy mapping is to be inhibited, otherwise * {@code false}. - * @since Android 1.0 */ public void setPolicyMappingInhibited(boolean policyMappingInhibited) { this.policyMappingInhibited = policyMappingInhibited; @@ -472,7 +448,6 @@ public class PKIXParameters implements CertPathParameters { * * @return {@code true} if the certificates should be rejected, otherwise * {@code false}. - * @since Android 1.0 */ public boolean getPolicyQualifiersRejected() { return policyQualifiersRejected; @@ -485,7 +460,6 @@ public class PKIXParameters implements CertPathParameters { * @param policyQualifiersRejected * {@code true} if the certificates should be rejected, otherwise * {@code false}. - * @since Android 1.0 */ public void setPolicyQualifiersRejected(boolean policyQualifiersRejected) { this.policyQualifiersRejected = policyQualifiersRejected; @@ -497,7 +471,6 @@ public class PKIXParameters implements CertPathParameters { * * @return {@code true} if the default revocation checking mechanism is * used, otherwise {@code false}. - * @since Android 1.0 */ public boolean isRevocationEnabled() { return revocationEnabled; @@ -510,7 +483,6 @@ public class PKIXParameters implements CertPathParameters { * @param revocationEnabled * {@code true} id the default revocation checking mechanism * should be used, otherwise {@code false}. - * @since Android 1.0 */ public void setRevocationEnabled(boolean revocationEnabled) { this.revocationEnabled = revocationEnabled; @@ -521,7 +493,6 @@ public class PKIXParameters implements CertPathParameters { * * @return the name of the signature provider, or {@code null} if none is * set. - * @since Android 1.0 */ public String getSigProvider() { return sigProvider; @@ -537,7 +508,6 @@ public class PKIXParameters implements CertPathParameters { * @param sigProvider * the name of the preferred signature provider, or {@code null} * if none is preferred. - * @since Android 1.0 */ public void setSigProvider(String sigProvider) { this.sigProvider = sigProvider; @@ -548,7 +518,6 @@ public class PKIXParameters implements CertPathParameters { * * @return the constraints for the target certificate, or {@code null} if * none are set. - * @since Android 1.0 */ public CertSelector getTargetCertConstraints() { return (targetCertConstraints == null ? null @@ -561,7 +530,6 @@ public class PKIXParameters implements CertPathParameters { * @param targetCertConstraints * the constraints for the target certificate, or {@code null} if * none should be used. - * @since Android 1.0 */ public void setTargetCertConstraints(CertSelector targetCertConstraints) { this.targetCertConstraints = (targetCertConstraints == null ? null @@ -572,7 +540,6 @@ public class PKIXParameters implements CertPathParameters { * Clones this {@code PKIXParameters} instance. * * @return the cloned instance. - * @since Android 1.0 */ public Object clone() { try { @@ -595,11 +562,10 @@ public class PKIXParameters implements CertPathParameters { * Returns a string representation of this {@code PKIXParameters} instance. * * @return a string representation of this {@code PKIXParameters} instance. - * @since Android 1.0 */ public String toString() { - StringBuffer sb = - new StringBuffer("[\n Trust Anchors: "); //$NON-NLS-1$ + StringBuilder sb = + new StringBuilder("[\n Trust Anchors: "); //$NON-NLS-1$ sb.append(trustAnchors); sb.append("\n Revocation Enabled: "); //$NON-NLS-1$ sb.append(revocationEnabled); diff --git a/security/src/main/java/java/security/cert/PolicyNode.java b/security/src/main/java/java/security/cert/PolicyNode.java index c112a8a..c485b69 100644 --- a/security/src/main/java/java/security/cert/PolicyNode.java +++ b/security/src/main/java/java/security/cert/PolicyNode.java @@ -26,9 +26,6 @@ import java.util.Set; * <p> * Instances of this class are one of the outputs of the PKIX certification path * validation algorithm. - * </p> - * - * @since Android 1.0 */ public interface PolicyNode { @@ -36,7 +33,6 @@ public interface PolicyNode { * Returns the list of children of this node as an {@code Iterator}. * * @return the list of children of this node as an {@code Iterator}. - * @since Android 1.0 */ public Iterator<? extends PolicyNode> getChildren(); @@ -44,10 +40,8 @@ public interface PolicyNode { * Returns the depth of this node in the policy tree. * <p> * the depth is zero based. - * </p> * * @return the depth of this node in the policy tree. - * @since Android 1.0 */ public int getDepth(); @@ -55,7 +49,6 @@ public interface PolicyNode { * Returns the expected policies for the next certificate to be valid. * * @return the expected policies. - * @since Android 1.0 */ public Set<String> getExpectedPolicies(); @@ -63,7 +56,6 @@ public interface PolicyNode { * Returns the parent policy node. * * @return the parent policy node. - * @since Android 1.0 */ public PolicyNode getParent(); @@ -71,7 +63,6 @@ public interface PolicyNode { * Returns the policy qualifiers associated with the policy of this node. * * @return the policy qualifiers associated with the policy of this node. - * @since Android 1.0 */ public Set<? extends PolicyQualifierInfo> getPolicyQualifiers(); @@ -79,7 +70,6 @@ public interface PolicyNode { * Returns the valid policy of this node. * * @return the valid policy of this node. - * @since Android 1.0 */ public String getValidPolicy(); @@ -89,7 +79,6 @@ public interface PolicyNode { * * @return {@code true} if the extension is marked as critical, otherwise * {@code false}. - * @since Android 1.0 */ public boolean isCritical(); } diff --git a/security/src/main/java/java/security/cert/PolicyQualifierInfo.java b/security/src/main/java/java/security/cert/PolicyQualifierInfo.java index 5a63d51..903a6e9 100644 --- a/security/src/main/java/java/security/cert/PolicyQualifierInfo.java +++ b/security/src/main/java/java/security/cert/PolicyQualifierInfo.java @@ -27,8 +27,6 @@ import org.apache.harmony.security.utils.Array; /** * This class implements a policy qualifier as defined by the ASN.1 * {@code PolicyQualifierInfo} structure. - * - * @since Android 1.0 */ public class PolicyQualifierInfo { // This PolicyQualifierInfo DER encoding @@ -48,7 +46,6 @@ public class PolicyQualifierInfo { * the DER encoded policy qualifier. * @throws IOException * the policy qualifier cannot be decoded. - * @since Android 1.0 */ public PolicyQualifierInfo(byte[] encoded) throws IOException { if (encoded == null) { @@ -71,7 +68,6 @@ public class PolicyQualifierInfo { * Returns a ASN.1 DER encoded copy of policy qualifier info. * * @return a ASN.1 DER encoded copy of policy qualifier info. - * @since Android 1.0 */ public final byte[] getEncoded() { byte[] ret = new byte[encoded.length]; @@ -83,7 +79,6 @@ public class PolicyQualifierInfo { * Returns the identifier (an OID) of this policy qualifier info. * * @return the identifier of this policy qualifier info. - * @since Android 1.0 */ public final String getPolicyQualifierId() { return policyQualifierId; @@ -95,7 +90,6 @@ public class PolicyQualifierInfo { * * @return a ASN.1 DER encoded copy of the qualifier of this policy * qualifier info. - * @since Android 1.0 */ public final byte[] getPolicyQualifier() { if (policyQualifier == null) { @@ -112,11 +106,10 @@ public class PolicyQualifierInfo { * * @return a string representation of this {@code PolicyQualifierInfo} * instance. - * @since Android 1.0 */ public String toString() { - StringBuffer sb = - new StringBuffer("PolicyQualifierInfo: [\npolicyQualifierId: "); //$NON-NLS-1$ + StringBuilder sb = + new StringBuilder("PolicyQualifierInfo: [\npolicyQualifierId: "); //$NON-NLS-1$ sb.append(policyQualifierId); sb.append("\npolicyQualifier: \n"); //$NON-NLS-1$ sb.append(Array.toString(policyQualifier, " ")); //$NON-NLS-1$ diff --git a/security/src/main/java/java/security/cert/TrustAnchor.java b/security/src/main/java/java/security/cert/TrustAnchor.java index 9dc2025..eae38d6 100644 --- a/security/src/main/java/java/security/cert/TrustAnchor.java +++ b/security/src/main/java/java/security/cert/TrustAnchor.java @@ -36,9 +36,6 @@ import org.apache.harmony.security.x509.NameConstraints; * of the CA, the CA's name and the constraints for the validation of * certification paths. The constructor also allows to specify a binary * representation of a so called "Name Constraints" extension as a byte array. - * </p> - * - * @since Android 1.0 */ public class TrustAnchor { // Most trusted CA as a X500Principal @@ -58,8 +55,7 @@ public class TrustAnchor { * <p> * The name constraints will be used as additional constraints during the * validation of certification paths. - * </p> - * + * * @param trustedCert * the trusted certificate * @param nameConstraints @@ -67,7 +63,6 @@ public class TrustAnchor { * null} if none. * @throws IllegalArgumentException * if the decoding of the name constraints fail. - * @since Android 1.0 */ public TrustAnchor(X509Certificate trustedCert, byte[] nameConstraints) { if (trustedCert == null) { @@ -94,8 +89,7 @@ public class TrustAnchor { * <p> * The name constraints will be used as additional constraints during the * validation of certification paths. - * </p> - * + * * @param caName * the X.500 name of the certificate authority in RFC 2253 * {@code String} format. @@ -107,7 +101,6 @@ public class TrustAnchor { * @throws IllegalArgumentException * if the {@code caName} is empty or if decoding of the name * constraints fail. - * @since Android 1.0 */ public TrustAnchor(String caName, PublicKey caPublicKey, byte[] nameConstraints) { @@ -146,7 +139,6 @@ public class TrustAnchor { * <p> * The name constraints will be used as additional constraints during the * validation of certification paths. - * </p> * * @param caPrincipal * the name of the certificate authority as X500 principal. @@ -157,7 +149,6 @@ public class TrustAnchor { * null} if none. * @throws IllegalArgumentException * if decoding of the name constraints fail. - * @since Android 1.0 */ public TrustAnchor(X500Principal caPrincipal, PublicKey caPublicKey, byte[] nameConstraints) { @@ -187,7 +178,6 @@ public class TrustAnchor { * Returns a copy of the name constraints in ASN.1 DER encoded form. * * @return a copy of the name constraints in ASN.1 DER encoded form. - * @since Android 1.0 */ public final byte[] getNameConstraints() { if (nameConstraints == null) { @@ -204,7 +194,6 @@ public class TrustAnchor { * * @return the certificate of this CA or {@code null}, if the trust anchor * of this instance was not created with a certificate. - * @since Android 1.0 */ public final X509Certificate getTrustedCert() { return trustedCert; @@ -216,7 +205,6 @@ public class TrustAnchor { * @return the name of the certificate authority or {@code null} if the * trust anchor of this instance was not created with a {@code * X500Principal}. - * @since Android 1.0 */ public final X500Principal getCA() { return caPrincipal; @@ -229,7 +217,6 @@ public class TrustAnchor { * @return the name of the certificate authority as {@code String} in RFC * 2253 format or {@code null} if the trust anchor of this instance * was not created with a CA name. - * @since Android 1.0 */ public final String getCAName() { return caName; @@ -241,7 +228,6 @@ public class TrustAnchor { * @return the public key of the certificate authority or {@code null} if * the trust anchor if this instance was not created with a public * key. - * @since Android 1.0 */ public final PublicKey getCAPublicKey() { return caPublicKey; @@ -251,10 +237,9 @@ public class TrustAnchor { * Returns a string representation of this {@code TrustAnchor} instance. * * @return a string representation of this {@code TrustAnchor} instance. - * @since Android 1.0 */ public String toString() { - StringBuffer sb = new StringBuffer("TrustAnchor: [\n"); //$NON-NLS-1$ + StringBuilder sb = new StringBuilder("TrustAnchor: [\n"); //$NON-NLS-1$ if (trustedCert != null) { sb.append("Trusted CA certificate: "); //$NON-NLS-1$ sb.append(trustedCert); diff --git a/security/src/main/java/java/security/cert/X509CRL.java b/security/src/main/java/java/security/cert/X509CRL.java index eabdb68..cb99843 100644 --- a/security/src/main/java/java/security/cert/X509CRL.java +++ b/security/src/main/java/java/security/cert/X509CRL.java @@ -44,16 +44,11 @@ import org.apache.harmony.security.internal.nls.Messages; * href * ="http://www.ietf.org/rfc/rfc2459.txt">http://www.ietf.org/rfc/rfc2459.txt * </a>. - * </p> - * - * @since Android 1.0 */ public abstract class X509CRL extends CRL implements X509Extension { /** * Creates a new {@code X509CRL} instance. - * - * @since Android 1.0 */ protected X509CRL() { super("X.509"); //$NON-NLS-1$ @@ -66,7 +61,6 @@ public abstract class X509CRL extends CRL implements X509Extension { * the object to compare. * @return {@code true} if the specified object is equal to this, otherwise * {@code false}. - * @since Android 1.0 */ public boolean equals(Object other) { if (other == this) { @@ -87,7 +81,6 @@ public abstract class X509CRL extends CRL implements X509Extension { * Returns the hashcode of this CRL instance. * * @return the hashcode. - * @since Android 1.0 */ public int hashCode() { try { @@ -108,7 +101,6 @@ public abstract class X509CRL extends CRL implements X509Extension { * @return this CRL in ASN.1 DER encoded form. * @throws CRLException * if encoding fails. - * @since Android 1.0 */ public abstract byte[] getEncoded() throws CRLException; @@ -129,7 +121,6 @@ public abstract class X509CRL extends CRL implements X509Extension { * if no provider can be found. * @throws SignatureException * if errors occur on signatures. - * @since Android 1.0 */ public abstract void verify(PublicKey key) throws CRLException, NoSuchAlgorithmException, @@ -155,7 +146,6 @@ public abstract class X509CRL extends CRL implements X509Extension { * if the specified provider cannot be found. * @throws SignatureException * if errors occur on signatures. - * @since Android 1.0 */ public abstract void verify(PublicKey key, String sigProvider) throws CRLException, NoSuchAlgorithmException, @@ -166,7 +156,6 @@ public abstract class X509CRL extends CRL implements X509Extension { * Returns the version number of this CRL. * * @return the version number of this CRL. - * @since Android 1.0 */ public abstract int getVersion(); @@ -175,7 +164,6 @@ public abstract class X509CRL extends CRL implements X509Extension { * the issuer as an implementation specific Principal object. * * @return the issuer distinguished name. - * @since Android 1.0 */ public abstract Principal getIssuerDN(); @@ -183,7 +171,6 @@ public abstract class X509CRL extends CRL implements X509Extension { * Returns the issuer distinguished name of this CRL. * * @return the issuer distinguished name of this CRL. - * @since Android 1.0 */ public X500Principal getIssuerX500Principal() { try { @@ -206,7 +193,6 @@ public abstract class X509CRL extends CRL implements X509Extension { * Returns the {@code thisUpdate} value of this CRL. * * @return the {@code thisUpdate} value of this CRL. - * @since Android 1.0 */ public abstract Date getThisUpdate(); @@ -215,7 +201,6 @@ public abstract class X509CRL extends CRL implements X509Extension { * * @return the {@code nextUpdate} value of this CRL, or {@code null} if none * is present. - * @since Android 1.0 */ public abstract Date getNextUpdate(); @@ -226,7 +211,6 @@ public abstract class X509CRL extends CRL implements X509Extension { * the certificate serial number to search for a CRL entry. * @return the entry for the specified certificate serial number, or {@code * null} if not found. - * @since Android 1.0 */ public abstract X509CRLEntry getRevokedCertificate(BigInteger serialNumber); @@ -237,7 +221,6 @@ public abstract class X509CRL extends CRL implements X509Extension { * the certificate to search a CRL entry for. * @return the entry for the specified certificate, or {@code null} if not * found. - * @since Android 1.0 */ public X509CRLEntry getRevokedCertificate(X509Certificate certificate) { if (certificate == null) { @@ -251,7 +234,6 @@ public abstract class X509CRL extends CRL implements X509Extension { * * @return the set of revoked certificates, or {@code null} if no revoked * certificates are in this CRL. - * @since Android 1.0 */ public abstract Set<? extends X509CRLEntry> getRevokedCertificates(); @@ -262,7 +244,6 @@ public abstract class X509CRL extends CRL implements X509Extension { * @return the CRL information in DER encoded form. * @throws CRLException * if encoding fails. - * @since Android 1.0 */ public abstract byte[] getTBSCertList() throws CRLException; @@ -270,7 +251,6 @@ public abstract class X509CRL extends CRL implements X509Extension { * Returns the signature bytes of this CRL. * * @return the signature bytes of this CRL. - * @since Android 1.0 */ public abstract byte[] getSignature(); @@ -278,7 +258,6 @@ public abstract class X509CRL extends CRL implements X509Extension { * Returns the name of the signature algorithm. * * @return the name of the signature algorithm. - * @since Android 1.0 */ public abstract String getSigAlgName(); @@ -286,7 +265,6 @@ public abstract class X509CRL extends CRL implements X509Extension { * Returns the OID of the signature algorithm. * * @return the OID of the signature algorithm. - * @since Android 1.0 */ public abstract String getSigAlgOID(); @@ -295,7 +273,6 @@ public abstract class X509CRL extends CRL implements X509Extension { * * @return the parameters of the signature algorithm in DER encoded form, or * {@code null} if not present. - * @since Android 1.0 */ public abstract byte[] getSigAlgParams(); } diff --git a/security/src/main/java/java/security/cert/X509CRLEntry.java b/security/src/main/java/java/security/cert/X509CRLEntry.java index 35fb78b..ccdaf2f 100644 --- a/security/src/main/java/java/security/cert/X509CRLEntry.java +++ b/security/src/main/java/java/security/cert/X509CRLEntry.java @@ -29,14 +29,11 @@ import javax.security.auth.x500.X500Principal; * Abstract base class for entries in a certificate revocation list (CRL). * * @see X509CRL - * @since Android 1.0 */ public abstract class X509CRLEntry implements X509Extension { /** * Creates a new {@code X509CRLEntry} instance. - * - * @since Android 1.0 */ public X509CRLEntry() {} @@ -47,7 +44,6 @@ public abstract class X509CRLEntry implements X509Extension { * the object to compare. * @return {@code true} if the specified object equals to this instance, * otherwise {@code false}. - * @since Android 1.0 */ public boolean equals(Object other) { if (other == this) { @@ -68,7 +64,6 @@ public abstract class X509CRLEntry implements X509Extension { * Returns the hashcode of this instance. * * @return the hashcode of this instance. - * @since Android 1.0 */ public int hashCode() { int res = 0; @@ -88,7 +83,6 @@ public abstract class X509CRLEntry implements X509Extension { * @return the encoded form of this entry. * @throws CRLException * if encoding fails. - * @since Android 1.0 */ public abstract byte[] getEncoded() throws CRLException; @@ -96,7 +90,6 @@ public abstract class X509CRLEntry implements X509Extension { * Returns the serial number of the revoked certificate. * * @return the serial number of the revoked certificate. - * @since Android 1.0 */ public abstract BigInteger getSerialNumber(); @@ -105,7 +98,6 @@ public abstract class X509CRLEntry implements X509Extension { * * @return the issuer of the revoked certificate, or {@code null} if the * issuer is equal to the CRL issuer. - * @since Android 1.0 */ public X500Principal getCertificateIssuer() { return null; @@ -115,7 +107,6 @@ public abstract class X509CRLEntry implements X509Extension { * Returns the date when the certificate is revoked. * * @return the date when the certificate is revoked. - * @since Android 1.0 */ public abstract Date getRevocationDate(); @@ -124,7 +115,6 @@ public abstract class X509CRLEntry implements X509Extension { * * @return {@code true} is this CRL entry has extensions, otherwise {@code * false}. - * @since Android 1.0 */ public abstract boolean hasExtensions(); @@ -132,7 +122,6 @@ public abstract class X509CRLEntry implements X509Extension { * Returns a string representation of this instance. * * @return a string representation of this instance. - * @since Android 1.0 */ public abstract String toString(); } diff --git a/security/src/main/java/java/security/cert/X509CRLSelector.java b/security/src/main/java/java/security/cert/X509CRLSelector.java index c1b5f45..0edddf4 100644 --- a/security/src/main/java/java/security/cert/X509CRLSelector.java +++ b/security/src/main/java/java/security/cert/X509CRLSelector.java @@ -36,10 +36,7 @@ import org.apache.harmony.security.x501.Name; * X509CRL}s that match the specified criteria. * <p> * When constructed, all criteria are set to default values that will match any - * {@code X509CRL}. - * </p> - * - * @since Android 1.0 + * {@code X509CRL}. */ public class X509CRLSelector implements CRLSelector { @@ -60,8 +57,6 @@ public class X509CRLSelector implements CRLSelector { /** * Creates a new {@code X509CertSelector}. - * - * @since Android 1.0 */ public X509CRLSelector() { } @@ -70,12 +65,10 @@ public class X509CRLSelector implements CRLSelector { * <p> * The CRL issuer must match at least one of the specified distinguished * names. - * </p> - * + * * @param issuers * the list of issuer distinguished names to match, or {@code * null} if any issuer distinguished name will do. - * @since Android 1.0 */ public void setIssuers(Collection<X500Principal> issuers) { if (issuers == null) { @@ -97,20 +90,17 @@ public class X509CRLSelector implements CRLSelector { * <p> * The CRL issuer must match at least one of the specified distinguished * names. - * </p> * <p> * The specified parameter {@code names} is a collection with an entry for * each name to be included in the criterion. The name is specified as a * {@code String} or a byte array specifying the name (in RFC 2253 or ASN.1 * DER encoded form) - * </p> - * + * * @param names * the list of issuer distinguished names to match, or {@code * null} if any issuer distinguished name will do. * @throws IOException * if parsing fails. - * @since Android 1.0 */ public void setIssuerNames(Collection<?> names) throws IOException { if (names == null) { @@ -143,11 +133,9 @@ public class X509CRLSelector implements CRLSelector { * <p> * The CRL issuer must match at least one of the specified distinguished * names. - * </p> - * + * * @param issuer * the issuer to add to the criterion - * @since Android 1.0 */ public void addIssuer(X500Principal issuer) { if (issuer == null) { @@ -178,13 +166,11 @@ public class X509CRLSelector implements CRLSelector { * <p> * Adds an issuer to the criterion for the issuer distinguished names. The * CRK issuer must match at least one of the specified distinguished names. - * </p> - * + * * @param iss_name * the RFC 2253 encoded name. * @throws IOException * if parsing fails. - * @since Android 1.0 */ public void addIssuerName(String iss_name) throws IOException { if (issuerNames == null) { @@ -206,13 +192,11 @@ public class X509CRLSelector implements CRLSelector { * <p> * The CRL issuer must match at least one of the specified distinguished * names. - * </p> - * + * * @param iss_name * the issuer to add to the criterion in ASN.1 DER encoded form. * @throws IOException * if parsing fails. - * @since Android 1.0 */ public void addIssuerName(byte[] iss_name) throws IOException { if (iss_name == null) { @@ -232,12 +216,10 @@ public class X509CRLSelector implements CRLSelector { * <p> * The CRL must have a number extension with a value greater than or equal * to the specified parameter. - * </p> - * + * * @param minCRL * the minimum CRL number or null to not check the minimum CRL * number - * @since Android 1.0 */ public void setMinCRLNumber(BigInteger minCRL) { this.minCRL = minCRL; @@ -248,12 +230,10 @@ public class X509CRLSelector implements CRLSelector { * <p> * The CRL must have a number extension with a value less than or equal to * the specified parameter. - * </p> - * + * * @param maxCRL * the maximum CRL number or null to not check the maximum CRL * number. - * @since Android 1.0 */ public void setMaxCRLNumber(BigInteger maxCRL) { this.maxCRL = maxCRL; @@ -264,12 +244,10 @@ public class X509CRLSelector implements CRLSelector { * <p> * The CRL's {@code thisUpdate} value must be equal or before the specified * date and the {@code nextUpdate} value must be after the specified date. - * </p> - * + * * @param dateAndTime * the date to search for valid CRL's or {@code null} to not * check the date. - * @since Android 1.0 */ public void setDateAndTime(Date dateAndTime) { if (dateAndTime == null) { @@ -282,10 +260,9 @@ public class X509CRLSelector implements CRLSelector { /** * Sets a certificate hint to find CRLs. It's not a criterion but may help * finding relevant CRLs. - * + * * @param cert * the certificate hint or {@code null}. - * @since Android 1.0 */ public void setCertificateChecking(X509Certificate cert) { this.certificateChecking = cert; @@ -295,11 +272,9 @@ public class X509CRLSelector implements CRLSelector { * Returns the criterion for the issuer distinguished names. * <p> * The CRL issuer must match at least one of the distinguished names. - * </p> - * + * * @return the unmodifiable list of issuer distinguished names to match, or * {@code null} if any issuer distinguished name will do. - * @since Android 1.0 */ public Collection<X500Principal> getIssuers() { if (issuerNames == null) { @@ -320,11 +295,9 @@ public class X509CRLSelector implements CRLSelector { * Returns the criterion for the issuer distinguished names. * <p> * The CRL issuer must match at least one of the distinguished names. - * </p> - * + * * @return a copy of the list of issuer distinguished names to match, or * {@code null} if any issuer distinguished name will do. - * @since Android 1.0 */ public Collection<Object> getIssuerNames() { if (issuerNames == null) { @@ -338,11 +311,9 @@ public class X509CRLSelector implements CRLSelector { * <p> * The CRL must have a number extension with a value greater than or equal * to the returned value. - * </p> - * + * * @return the minimum CRL number or {@code null} if the minimum CRL number * is not to be checked. - * @since Android 1.0 */ public BigInteger getMinCRL() { return minCRL; @@ -353,11 +324,9 @@ public class X509CRLSelector implements CRLSelector { * <p> * The CRL must have a number extension with a value less than or equal to * the returned value. - * </p> - * + * * @return the maximum CRL number or null if the maximum CRL number is not * checked. - * @since Android 1.0 */ public BigInteger getMaxCRL() { return maxCRL; @@ -368,11 +337,9 @@ public class X509CRLSelector implements CRLSelector { * <p> * The CRL's {@code thisUpdate} value must be equal or before the returned * date and the {@code nextUpdate} value must be after the returned date. - * </p> - * + * * @return the date to search for valid CRL's or {@code null} if the date is * not checked. - * @since Android 1.0 */ public Date getDateAndTime() { if (dateAndTime == -1) { @@ -384,9 +351,8 @@ public class X509CRLSelector implements CRLSelector { /** * Returns the certificate hint to find CRLs. It's not a criterion but may * help finding relevant CRLs. - * + * * @return the certificate hint or {@code null} if none set. - * @since Android 1.0 */ public X509Certificate getCertificateChecking() { return certificateChecking; @@ -394,12 +360,11 @@ public class X509CRLSelector implements CRLSelector { /** * Returns a string representation of this {@code X509CRLSelector} instance. - * + * * @return a string representation of this {@code X509CRLSelector} instance. - * @since Android 1.0 */ public String toString() { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); result.append("X509CRLSelector:\n["); //$NON-NLS-1$ if (issuerNames != null) { result.append("\n IssuerNames:\n ["); //$NON-NLS-1$ @@ -429,12 +394,11 @@ public class X509CRLSelector implements CRLSelector { /** * Returns whether the specified CRL matches all the criteria collected in * this instance. - * + * * @param crl * the CRL to check. * @return {@code true} if the CRL matches all the criteria, otherwise * {@code false}. - * @since Android 1.0 */ public boolean match(CRL crl) { if (!(crl instanceof X509CRL)) { @@ -482,19 +446,20 @@ public class X509CRLSelector implements CRLSelector { /** * Clones this {@code X509CRL} instance. - * + * * @return the cloned instance. - * @since Android 1.0 */ public Object clone() { - X509CRLSelector result = new X509CRLSelector(); - if (issuerNames != null) { - result.issuerNames = new ArrayList<String>(issuerNames); - } - result.minCRL = minCRL; - result.maxCRL = maxCRL; - result.dateAndTime = dateAndTime; - result.certificateChecking = certificateChecking; + X509CRLSelector result; + + try { + result = (X509CRLSelector) super.clone(); + if (issuerNames != null) { + result.issuerNames = new ArrayList<String>(issuerNames); + } + } catch (CloneNotSupportedException e) { + result = null; + } return result; } } diff --git a/security/src/main/java/java/security/cert/X509CertSelector.java b/security/src/main/java/java/security/cert/X509CertSelector.java index c6d2e98..e2de95b 100644 --- a/security/src/main/java/java/security/cert/X509CertSelector.java +++ b/security/src/main/java/java/security/cert/X509CertSelector.java @@ -49,8 +49,6 @@ import org.apache.harmony.security.x509.SubjectPublicKeyInfo; /** * A certificate selector ({@code CertSelector} for selecting {@code * X509Certificate}s that match the specified criteria. - * - * @since Android 1.0 */ public class X509CertSelector implements CertSelector { @@ -81,17 +79,14 @@ public class X509CertSelector implements CertSelector { /** * Creates a new {@code X509CertSelector}. - * - * @since Android 1.0 */ public X509CertSelector() {} /** * Sets the certificate that a matching certificate must be equal to. - * + * * @param certificate * the certificate to match, or null to not check this criteria. - * @since Android 1.0 */ public void setCertificate(X509Certificate certificate) { certificateEquals = certificate; @@ -99,10 +94,9 @@ public class X509CertSelector implements CertSelector { /** * Returns the certificate that a matching certificate must be equal to. - * + * * @return the certificate to match, or null if this criteria is not * checked. - * @since Android 1.0 */ public X509Certificate getCertificate() { return certificateEquals; @@ -110,11 +104,10 @@ public class X509CertSelector implements CertSelector { /** * Sets the serial number that a certificate must match. - * + * * @param serialNumber * the serial number to match, or {@code null} to not check the * serial number. - * @since Android 1.0 */ public void setSerialNumber(BigInteger serialNumber) { this.serialNumber = serialNumber; @@ -122,10 +115,9 @@ public class X509CertSelector implements CertSelector { /** * Returns the serial number that a certificate must match. - * + * * @return the serial number to match, or {@code null} if the serial number * is not to be checked. - * @since Android 1.0 */ public BigInteger getSerialNumber() { return serialNumber; @@ -133,11 +125,10 @@ public class X509CertSelector implements CertSelector { /** * Sets the issuer that a certificate must match. - * + * * @param issuer * the issuer to match, or {@code null} if the issuer is not to * be checked. - * @since Android 1.0 */ public void setIssuer(X500Principal issuer) { this.issuer = issuer; @@ -147,10 +138,9 @@ public class X509CertSelector implements CertSelector { /** * Returns the issuer that a certificate must match. - * + * * @return the issuer that a certificate must match, or {@code null} if the * issuer is not to be checked. - * @since Android 1.0 */ public X500Principal getIssuer() { return issuer; @@ -160,13 +150,12 @@ public class X509CertSelector implements CertSelector { * <b>Do not use</b>, use {@link #getIssuer()} or * {@link #getIssuerAsBytes()} instead. Sets the issuer that a certificate * must match. - * + * * @param issuerName * the issuer in a RFC 2253 format string, or {@code null} to not * check the issuer. * @throws IOException * if parsing the issuer fails. - * @since Android 1.0 */ public void setIssuer(String issuerName) throws IOException { if (issuerName == null) { @@ -188,10 +177,9 @@ public class X509CertSelector implements CertSelector { * <b>Do not use</b>, use {@link #getIssuer()} or * {@link #getIssuerAsBytes()} instead. Returns the issuer that a * certificate must match in a RFC 2253 format string. - * + * * @return the issuer in a RFC 2253 format string, or {@code null} if the * issuer is not to be checked. - * @since Android 1.0 */ public String getIssuerAsString() { if (issuer == null) { @@ -205,13 +193,12 @@ public class X509CertSelector implements CertSelector { /** * Sets the issuer that a certificate must match. - * + * * @param issuerDN * the distinguished issuer name in ASN.1 DER encoded format, or * {@code null} to not check the issuer. * @throws IOException * if decoding the issuer fail. - * @since Android 1.0 */ public void setIssuer(byte[] issuerDN) throws IOException { if (issuerDN == null) { @@ -230,12 +217,11 @@ public class X509CertSelector implements CertSelector { /** * Returns the issuer that a certificate must match. - * + * * @return the distinguished issuer name in ASN.1 DER encoded format, or * {@code null} if the issuer is not to be checked. * @throws IOException * if encoding the issuer fails. - * @since Android 1.0 */ public byte[] getIssuerAsBytes() throws IOException { if (issuer == null) { @@ -251,11 +237,10 @@ public class X509CertSelector implements CertSelector { /** * Set the subject that a certificate must match. - * + * * @param subject * the subject distinguished name or {@code null} to not check * the subject. - * @since Android 1.0 */ public void setSubject(X500Principal subject) { this.subject = subject; @@ -263,10 +248,9 @@ public class X509CertSelector implements CertSelector { /** * Returns the subject that a certificate must match. - * + * * @return the subject distinguished name, or null if the subject is not to * be checked. - * @since Android 1.0 */ public X500Principal getSubject() { return subject; @@ -276,13 +260,12 @@ public class X509CertSelector implements CertSelector { * <b>Do not use</b>, use {@link #setSubject(byte[])} or * {@link #setSubject(X500Principal)} instead. Returns the subject that a * certificate must match. - * + * * @param subjectDN * the subject distinguished name in RFC 2253 format or {@code * null} to not check the subject. * @throws IOException * if decoding the subject fails. - * @since Android 1.0 */ public void setSubject(String subjectDN) throws IOException { if (subjectDN == null) { @@ -300,10 +283,9 @@ public class X509CertSelector implements CertSelector { * <b>Do not use</b>, use {@link #getSubject()} or * {@link #getSubjectAsBytes()} instead. Returns the subject that a * certificate must match. - * + * * @return the subject distinguished name in RFC 2253 format, or {@code * null} if the subject is not to be checked. - * @since Android 1.0 */ public String getSubjectAsString() { if (subject == null) { @@ -314,13 +296,12 @@ public class X509CertSelector implements CertSelector { /** * Sets the subject that a certificate must match. - * + * * @param subjectDN * the subject distinguished name in ASN.1 DER format, or {@code * null} to not check the subject. * @throws IOException * if decoding the subject fails. - * @since Android 1.0 */ public void setSubject(byte[] subjectDN) throws IOException { if (subjectDN == null) { @@ -336,12 +317,11 @@ public class X509CertSelector implements CertSelector { /** * Returns the subject that a certificate must match. - * + * * @return the subject distinguished name in ASN.1 DER format, or {@code * null} if the subject is not to be checked. * @throws IOException * if encoding the subject fails. - * @since Android 1.0 */ public byte[] getSubjectAsBytes() throws IOException { if (subject == null) { @@ -354,12 +334,10 @@ public class X509CertSelector implements CertSelector { * Sets the criterion for the {@literal SubjectKeyIdentifier} extension. * <p> * The {@code subjectKeyIdentifier} should be a single DER encoded value. - * </p> - * + * * @param subjectKeyIdentifier * the subject key identifier or {@code null} to disable this * check. - * @since Android 1.0 */ public void setSubjectKeyIdentifier(byte[] subjectKeyIdentifier) { if (subjectKeyIdentifier == null) { @@ -373,10 +351,9 @@ public class X509CertSelector implements CertSelector { /** * Returns the criterion for the {@literal SubjectKeyIdentifier} extension. - * + * * @return the subject key identifier or {@code null} if it is not to be * checked. - * @since Android 1.0 */ public byte[] getSubjectKeyIdentifier() { if (subjectKeyIdentifier == null) { @@ -389,11 +366,10 @@ public class X509CertSelector implements CertSelector { /** * Sets the criterion for the {@literal AuthorityKeyIdentifier} extension. - * + * * @param authorityKeyIdentifier * the authority key identifier, or {@code null} to disable this * check. - * @since Android 1.0 */ public void setAuthorityKeyIdentifier(byte[] authorityKeyIdentifier) { if (authorityKeyIdentifier == null) { @@ -409,10 +385,9 @@ public class X509CertSelector implements CertSelector { /** * Returns the criterion for the {@literal AuthorityKeyIdentifier} * extension. - * + * * @return the authority key identifier, or {@code null} if it is not to be * checked. - * @since Android 1.0 */ public byte[] getAuthorityKeyIdentifier() { if (authorityKeyIdentifier == null) { @@ -427,10 +402,8 @@ public class X509CertSelector implements CertSelector { * Sets the criterion for the validity date of the certificate. * <p> * The certificate must be valid at the specified date. - * </p> * @param certificateValid * the validity date or {@code null} to not check the date. - * @since Android 1.0 */ public void setCertificateValid(Date certificateValid) { this.certificateValid = (certificateValid == null) @@ -440,10 +413,9 @@ public class X509CertSelector implements CertSelector { /** * Returns the criterion for the validity date of the certificate. - * + * * @return the validity date or {@code null} if the date is not to be * checked. - * @since Android 1.0 */ public Date getCertificateValid() { return (certificateValid == null) @@ -455,11 +427,9 @@ public class X509CertSelector implements CertSelector { * Sets the criterion for the validity date of the private key. * <p> * The private key must be valid at the specified date. - * </p> - * + * * @param privateKeyValid * the validity date or {@code null} to not check the date. - * @since Android 1.0 */ public void setPrivateKeyValid(Date privateKeyValid) { if (privateKeyValid == null) { @@ -473,11 +443,9 @@ public class X509CertSelector implements CertSelector { * Returns the criterion for the validity date of the private key. * <p> * The private key must be valid at the specified date. - * </p> - * + * * @return the validity date or {@code null} if the date is not to be * checked. - * @since Android 1.0 */ public Date getPrivateKeyValid() { if (privateKeyValid != null) { @@ -512,14 +480,12 @@ public class X509CertSelector implements CertSelector { * <p> * The certificate must contain a subject public key with the algorithm * specified. - * </p> - * + * * @param oid * the OID (object identifier) of the signature algorithm or * {@code null} to not check the OID. * @throws IOException * if the specified object identifier is invalid. - * @since Android 1.0 */ public void setSubjectPublicKeyAlgID(String oid) throws IOException { if (oid == null) { @@ -532,10 +498,9 @@ public class X509CertSelector implements CertSelector { /** * Returns the criterion for the subject public key signature algorithm. - * + * * @return the OID (object identifier) or the signature algorithm or {@code * null} if it's not to be checked. - * @since Android 1.0 */ public String getSubjectPublicKeyAlgID() { return subjectPublicKeyAlgID; @@ -543,10 +508,9 @@ public class X509CertSelector implements CertSelector { /** * Sets the criterion for the subject public key. - * + * * @param key * the subject public key or {@code null} to not check the key. - * @since Android 1.0 */ public void setSubjectPublicKey(PublicKey key) { subjectPublicKey = (key == null) ? null : key.getEncoded(); @@ -555,13 +519,12 @@ public class X509CertSelector implements CertSelector { /** * Sets the criterion for the subject public key. - * + * * @param key * the subject public key in ASN.1 DER encoded format or {@code null} to * not check the key. * @throws IOException * if decoding the the public key fails. - * @since Android 1.0 */ public void setSubjectPublicKey(byte[] key) throws IOException { if (key == null) { @@ -578,10 +541,9 @@ public class X509CertSelector implements CertSelector { /** * Returns the criterion for the subject public key. - * + * * @return the subject public key or {@code null} if the key is not to be * checked. - * @since Android 1.0 */ public PublicKey getSubjectPublicKey() { return subjectPublicKeyImpl; @@ -589,12 +551,11 @@ public class X509CertSelector implements CertSelector { /** * Sets the criterion for the {@literal KeyUsage} extension. - * + * * @param keyUsage * the boolean array in the format as returned by * {@link X509Certificate#getKeyUsage()}, or {@code null} to not * check the key usage. - * @since Android 1.0 */ public void setKeyUsage(boolean[] keyUsage) { if (keyUsage == null) { @@ -607,11 +568,10 @@ public class X509CertSelector implements CertSelector { /** * Returns the criterion for the {@literal KeyUsage} extension. - * + * * @return the boolean array in the format as returned by * {@link X509Certificate#getKeyUsage()}, or {@code null} if the key * usage is not to be checked. - * @since Android 1.0 */ public boolean[] getKeyUsage() { if (keyUsage == null) { @@ -624,12 +584,11 @@ public class X509CertSelector implements CertSelector { /** * Sets the criterion for the {@literal ExtendedKeyUsage} extension. - * + * * @param keyUsage * the set of key usage OIDs, or {@code null} to not check it. * @throws IOException * if one of the OIDs is invalid. - * @since Android 1.0 */ public void setExtendedKeyUsage(Set<String> keyUsage) throws IOException { @@ -649,10 +608,9 @@ public class X509CertSelector implements CertSelector { /** * Returns the criterion for the {@literal ExtendedKeyUsage} extension. - * + * * @return the set of key usage OIDs, or {@code null} if it's not to be * checked. - * @since Android 1.0 */ public Set<String> getExtendedKeyUsage() { return extendedKeyUsage; @@ -662,15 +620,12 @@ public class X509CertSelector implements CertSelector { * Sets the flag for the matching behavior for subject alternative names. * <p> * The flag indicates whether a certificate must contain all or at least one - * of the subject alternative names specified by - * {@link #setSubjectAlternativeNames} or {@link #addSubjectAlternativeName} - * . - * </p> - * + * of the subject alternative names specified by {@link + * #setSubjectAlternativeNames} or {@link #addSubjectAlternativeName}. + * * @param matchAllNames * {@code true} if a certificate must contain all of the * specified subject alternative names, otherwise {@code false}. - * @since Android 1.0 */ public void setMatchAllSubjectAltNames(boolean matchAllNames) { this.matchAllNames = matchAllNames; @@ -680,14 +635,11 @@ public class X509CertSelector implements CertSelector { * Returns the flag for the matching behavior for subject alternative names. * <p> * The flag indicates whether a certificate must contain all or at least one - * of the subject alternative names specified by - * {@link #setSubjectAlternativeNames} or {@link #addSubjectAlternativeName} - * . - * </p> - * + * of the subject alternative names specified by {@link + * #setSubjectAlternativeNames} or {@link #addSubjectAlternativeName}. + * * @return {@code true} if a certificate must contain all of the specified * subject alternative names, otherwise {@code false}. - * @since Android 1.0 */ public boolean getMatchAllSubjectAltNames() { return matchAllNames; @@ -699,20 +651,17 @@ public class X509CertSelector implements CertSelector { * the certificate must contain all or at least one of the specified subject * alternative names. The behavior is specified by * {@link #getMatchAllSubjectAltNames}. - * </p> * <p> * The specified parameter {@code names} is a collection with an entry for * each name to be included in the criterion. The name is specified as a * {@code List}, the first entry must be an {@code Integer} specifying the * name type (0-8), the second entry must be a {@code String} or a byte * array specifying the name (in string or ASN.1 DER encoded form) - * </p> - * + * * @param names * the names collection or {@code null} to not perform this check. * @throws IOException * if the decoding of a name fails. - * @since Android 1.0 */ public void setSubjectAlternativeNames(Collection<List<?>> names) throws IOException { @@ -737,14 +686,13 @@ public class X509CertSelector implements CertSelector { /** * Adds a subject alternative name to the respective criterion. - * + * * @param tag * the type of the name * @param name * the name in string format. * @throws IOException * if parsing the name fails. - * @since Android 1.0 */ public void addSubjectAlternativeName(int tag, String name) throws IOException { @@ -761,14 +709,13 @@ public class X509CertSelector implements CertSelector { /** * Adds a subject alternative name to the respective criterion. - * + * * @param tag * the type of the name. * @param name * the name in ASN.1 DER encoded form. * @throws IOException * if the decoding of the name fails. - * @since Android 1.0 */ public void addSubjectAlternativeName(int tag, byte[] name) throws IOException { @@ -789,16 +736,13 @@ public class X509CertSelector implements CertSelector { * the certificate must contain all or at least one of the specified subject * alternative names. The behavior is specified by * {@link #getMatchAllSubjectAltNames}. - * </p> * <p> * The subject alternative names is a collection with an entry for each name * included in the criterion. The name is specified as a {@code List}, the * first entry is an {@code Integer} specifying the name type (0-8), the * second entry is byte array specifying the name in ASN.1 DER encoded form) - * </p> - * + * * @return the names collection or {@code null} if none specified. - * @since Android 1.0 */ public Collection<List<?>> getSubjectAlternativeNames() { if (subjectAltNames == null) { @@ -830,24 +774,23 @@ public class X509CertSelector implements CertSelector { * <p> * The certificate must constraint subject and subject alternative names * that match the specified name constraints. - * </p> * <p> * The name constraints in ASN.1: - * + * * <pre> * NameConstraints ::= SEQUENCE { * permittedSubtrees [0] GeneralSubtrees OPTIONAL, * excludedSubtrees [1] GeneralSubtrees OPTIONAL } - * + * * GeneralSubtrees ::= SEQUENCE SIZE (1..MAX) OF GeneralSubtree - * + * * GeneralSubtree ::= SEQUENCE { * base GeneralName, * minimum [0] BaseDistance DEFAULT 0, * maximum [1] BaseDistance OPTIONAL } - * + * * BaseDistance ::= INTEGER (0..MAX) - * + * * GeneralName ::= CHOICE { * otherName [0] OtherName, * rfc822Name [1] IA5String, @@ -858,17 +801,14 @@ public class X509CertSelector implements CertSelector { * uniformResourceIdentifier [6] IA5String, * iPAddress [7] OCTET STRING, * registeredID [8] OBJECT IDENTIFIER} - * + * * </pre> - * - * </p> - * + * * @param bytes * the name constraints in ASN.1 DER encoded format, or null to * not check any constraints. * @throws IOException * if decoding the name constraints fail. - * @since Android 1.0 */ public void setNameConstraints(byte[] bytes) throws IOException { this.nameConstraints = (bytes == null) @@ -878,10 +818,9 @@ public class X509CertSelector implements CertSelector { /** * Returns the criterion for the name constraints. - * + * * @return the name constraints or {@code null} if none specified. * @see #setNameConstraints - * @since Android 1.0 */ public byte[] getNameConstraints() { return (nameConstraints == null) @@ -896,11 +835,9 @@ public class X509CertSelector implements CertSelector { * include a basic constraints extension with a path length of a least that * value. A value of {@code -2} indicates that only end-entity certificates * are accepted. A value of {@code -1} indicates that no check is done. - * </p> - * + * * @param pathLen * the value specifying the criterion. - * @since Android 1.0 * @throws IllegalArgumentException * if {@code pathLen} is less than {@code -2}. */ @@ -918,10 +855,8 @@ public class X509CertSelector implements CertSelector { * include a basic constraints extension with a path length of a least that * value. A value of {@code -2} indicates that only end-entity certificates * are accepted. A value of {@code -1} indicates that no check is done. - * </p> - * + * * @return the value of the criterion. - * @since Android 1.0 */ public int getBasicConstraints() { return pathLen; @@ -933,14 +868,12 @@ public class X509CertSelector implements CertSelector { * The certificate must have at least one of the specified certificate * policy extensions. For an empty set the certificate must have at least * some policies in its policy extension. - * </p> - * + * * @param policies * the certificate policy OIDs, an empty set, or {@code null} to * not perform this check. * @throws IOException * if parsing the specified OIDs fails. - * @since Android 1.0 */ public void setPolicy(Set<String> policies) throws IOException { if (policies == null) { @@ -963,11 +896,9 @@ public class X509CertSelector implements CertSelector { * The certificate must have at least one of the certificate policy * extensions. For an empty set the certificate must have at least some * policies in its policy extension. - * </p> - * + * * @return the certificate policy OIDs, an empty set, or {@code null} if not * to be checked. - * @since Android 1.0 */ public Set<String> getPolicy() { return policies; @@ -978,21 +909,18 @@ public class X509CertSelector implements CertSelector { * <p> * This allows to specify the complete set of names, a certificate's name * constraints must permit. - * </p> * <p> * The specified parameter {@code names} is a collection with an entry for * each name to be included in the criterion. The name is specified as a * {@code List}, the first entry must be an {@code Integer} specifying the * name type (0-8), the second entry must be a {@code String} or a byte * array specifying the name (in string or ASN.1 DER encoded form) - * </p> - * + * * @param names * the names collection or {@code null} to not perform this * check. * @throws IOException * if decoding fails. - * @since Android 1.0 */ public void setPathToNames(Collection<List<?>> names) throws IOException { @@ -1017,7 +945,7 @@ public class X509CertSelector implements CertSelector { /** * Adds a {@literal "pathToName"} to the respective criterion. - * + * * @param type * the type of the name. * @param name @@ -1025,7 +953,6 @@ public class X509CertSelector implements CertSelector { * @throws IOException * if parsing fails. * @see #setPathToNames - * @since Android 1.0 */ public void addPathToName(int type, String name) throws IOException { GeneralName path_name = new GeneralName(type, name); @@ -1038,7 +965,7 @@ public class X509CertSelector implements CertSelector { /** * Adds a {@literal "pathToName"} to the respective criterion. - * + * * @param type * the type of the name * @param name @@ -1046,7 +973,6 @@ public class X509CertSelector implements CertSelector { * @throws IOException * if decoding fails. * @see #setPathToNames - * @since Android 1.0 */ public void addPathToName(int type, byte[] name) throws IOException { GeneralName path_name= new GeneralName(type, name); @@ -1064,10 +990,8 @@ public class X509CertSelector implements CertSelector { * in the criterion. The name is specified as a {@code List}, the first * entry is an {@code Integer} specifying the name type (0-8), the second * entry is a byte array specifying the name in ASN.1 DER encoded form. - * </p> - * + * * @return the pathToNames constraint or {@code null} if none specified. - * @since Android 1.0 */ public Collection<List<?>> getPathToNames() { if (pathToNames == null) { @@ -1085,17 +1009,16 @@ public class X509CertSelector implements CertSelector { /** * Returns a string representation of this {@code X509CertSelector} * instance. - * + * * @return a string representation of this {@code X509CertSelector} * instance. - * @since Android 1.0 */ public String toString() { // For convenient reading of the string representation // all of the fields named according to the rfc 3280 // (http://www.ietf.org/rfc/rfc3280.txt). - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); result.append("X509CertSelector: \n["); //$NON-NLS-1$ if (this.certificateEquals != null) { result.append("\n certificateEquals: " + certificateEquals); //$NON-NLS-1$ @@ -1210,12 +1133,11 @@ public class X509CertSelector implements CertSelector { /** * Returns whether the specified certificate matches all the criteria * collected in this instance. - * + * * @param certificate * the certificate to check. * @return {@code true} if the certificate matches all the criteria, * otherwise {@code false}. - * @since Android 1.0 */ public boolean match(Certificate certificate) { if (! (certificate instanceof X509Certificate)) { @@ -1452,16 +1374,18 @@ public class X509CertSelector implements CertSelector { /** * Clones this {@code X509CertSelector} instance. - * + * * @return the cloned instance. - * @since Android 1.0 */ public Object clone() { - X509CertSelector result = new X509CertSelector(); - result.certificateEquals = this.certificateEquals; - result.serialNumber = this.serialNumber; - result.issuer = this.issuer; - result.subject = this.subject; + X509CertSelector result; + + try { + result = (X509CertSelector) super.clone(); + } catch (CloneNotSupportedException e) { + return null; + } + if (this.subjectKeyIdentifier != null) { result.subjectKeyIdentifier = new byte[this.subjectKeyIdentifier.length]; @@ -1476,9 +1400,6 @@ public class X509CertSelector implements CertSelector { result.authorityKeyIdentifier, 0, this.authorityKeyIdentifier.length); } - result.certificateValid = this.certificateValid; - result.subjectPublicKeyAlgID = this.subjectPublicKeyAlgID; - result.privateKeyValid = this.privateKeyValid; if (this.subjectPublicKey != null) { result.subjectPublicKey = new byte[this.subjectPublicKey.length]; System.arraycopy(this.subjectPublicKey, 0, result.subjectPublicKey, @@ -1492,8 +1413,6 @@ public class X509CertSelector implements CertSelector { result.extendedKeyUsage = (this.extendedKeyUsage == null) ? null : new HashSet(this.extendedKeyUsage); - result.matchAllNames = this.matchAllNames; - result.pathLen = this.pathLen; if (this.subjectAltNames != null) { result.subjectAltNames = new ArrayList[9]; for (int i=0; i<9; i++) { @@ -1503,15 +1422,12 @@ public class X509CertSelector implements CertSelector { } } } - result.nameConstraints = this.nameConstraints; result.policies = (this.policies == null) ? null : new HashSet(this.policies); result.pathToNames = (this.pathToNames == null) ? null : new ArrayList(this.pathToNames); - result.subjectPublicKeyImpl = this.subjectPublicKeyImpl; - return result; } } diff --git a/security/src/main/java/java/security/cert/X509Certificate.java b/security/src/main/java/java/security/cert/X509Certificate.java index 9e10077..e49901c 100644 --- a/security/src/main/java/java/security/cert/X509Certificate.java +++ b/security/src/main/java/java/security/cert/X509Certificate.java @@ -33,7 +33,6 @@ import org.apache.harmony.security.internal.nls.Messages; * <p> * This represents a standard way for accessing the attributes of X.509 * certificates. - * </p> * <p> * The basic X.509 v3 format described in ASN.1: * @@ -59,16 +58,12 @@ import org.apache.harmony.security.internal.nls.Messages; * -- If present, version must be v3 * } * </pre> - * </p> * <p> * For more information consult RFC 2459 * "Internet X.509 Public Key Infrastructure Certificate and CRL Profile" at <a * href * ="http://www.ietf.org/rfc/rfc2459.txt">http://www.ietf.org/rfc/rfc2459.txt * </a> . - * </p> - * - * @since Android 1.0 */ public abstract class X509Certificate extends Certificate implements X509Extension { @@ -77,8 +72,6 @@ public abstract class X509Certificate /** * Creates a new {@code X509Certificate}. - * - * @since Android 1.0 */ protected X509Certificate() { super("X.509"); //$NON-NLS-1$ @@ -101,13 +94,10 @@ public abstract class X509Certificate * generalTime GeneralizedTime } * </pre> * - * </p> - * * @throws CertificateExpiredException * if the certificate has expired. * @throws CertificateNotYetValidException * if the certificate is not yet valid. - * @since Android 1.0 */ public abstract void checkValidity() throws CertificateExpiredException, CertificateNotYetValidException; @@ -122,7 +112,6 @@ public abstract class X509Certificate * @throws CertificateNotYetValidException * if the certificate is not yet valid. * @see #checkValidity() - * @since Android 1.0 */ public abstract void checkValidity(Date date) throws CertificateExpiredException, CertificateNotYetValidException; @@ -136,10 +125,7 @@ public abstract class X509Certificate * Version ::= INTEGER { v1(0), v2(1), v3(2) } * </pre> * - * </p> - * * @return the version number. - * @since Android 1.0 */ public abstract int getVersion(); @@ -152,10 +138,7 @@ public abstract class X509Certificate * CertificateSerialNumber ::= INTEGER * </pre> * - * </p> - * * @return the serial number. - * @since Android 1.0 */ public abstract BigInteger getSerialNumber(); @@ -184,12 +167,10 @@ public abstract class X509Certificate * AttributeValue ::= ANY DEFINED BY AttributeType * </pre> * - * </p> * <b>replaced by:</b> {@link #getIssuerX500Principal()}. * * @return the {@code issuer} as an implementation specific {@code * Principal}. - * @since Android 1.0 */ public abstract Principal getIssuerDN() ; @@ -198,7 +179,6 @@ public abstract class X509Certificate * X500Principal}. * * @return the {@code issuer} (issuer distinguished name). - * @since Android 1.0 */ public X500Principal getIssuerX500Principal() { @@ -243,13 +223,10 @@ public abstract class X509Certificate * AttributeValue ::= ANY DEFINED BY AttributeType * </pre> * - * </p> * <p> * <b>replaced by:</b> {@link #getSubjectX500Principal()}. - * </p> - * + * * @return the {@code subject} (subject distinguished name). - * @since Android 1.0 */ public abstract Principal getSubjectDN(); @@ -258,7 +235,6 @@ public abstract class X509Certificate * X500Principal}. * * @return the {@code subject} (subject distinguished name) - * @since Android 1.0 */ public X500Principal getSubjectX500Principal() { @@ -283,7 +259,6 @@ public abstract class X509Certificate * certificate. * * @return the start of the validity period. - * @since Android 1.0 */ public abstract Date getNotBefore(); @@ -292,7 +267,6 @@ public abstract class X509Certificate * certificate. * * @return the end of the validity period. - * @since Android 1.0 */ public abstract Date getNotAfter(); @@ -303,7 +277,6 @@ public abstract class X509Certificate * @return the DER-encoded certificate information. * @throws CertificateEncodingException * if an error occurs in encoding - * @since Android 1.0 */ public abstract byte[] getTBSCertificate() throws CertificateEncodingException; @@ -312,7 +285,6 @@ public abstract class X509Certificate * Returns the raw signature bits from the certificate. * * @return the raw signature bits from the certificate. - * @since Android 1.0 */ public abstract byte[] getSignature(); @@ -320,7 +292,6 @@ public abstract class X509Certificate * Returns the name of the algorithm for the certificate signature. * * @return the signature algorithm name. - * @since Android 1.0 */ public abstract String getSigAlgName(); @@ -328,7 +299,6 @@ public abstract class X509Certificate * Returns the OID of the signature algorithm from the certificate. * * @return the OID of the signature algorithm. - * @since Android 1.0 */ public abstract String getSigAlgOID(); @@ -337,7 +307,6 @@ public abstract class X509Certificate * * @return the parameters of the signature algorithm, or {@code null} if * none are used. - * @since Android 1.0 */ public abstract byte[] getSigAlgParams(); @@ -346,7 +315,6 @@ public abstract class X509Certificate * * @return the {@code issuerUniqueID} or {@code null} if there's none in the * certificate. - * @since Android 1.0 */ public abstract boolean[] getIssuerUniqueID(); @@ -355,7 +323,6 @@ public abstract class X509Certificate * * @return the {@code subjectUniqueID} or null if there's none in the * certificate. - * @since Android 1.0 */ public abstract boolean[] getSubjectUniqueID(); @@ -378,11 +345,8 @@ public abstract class X509Certificate * * </pre> * - * </p> - * * @return the {@code KeyUsage} extension or {@code null} if there's none in * the certificate. - * @since Android 1.0 */ public abstract boolean[] getKeyUsage(); @@ -394,7 +358,6 @@ public abstract class X509Certificate * in the certificate. * @throws CertificateParsingException * if the extension decoding fails. - * @since Android 1.0 */ public List<String> getExtendedKeyUsage() throws CertificateParsingException { @@ -408,7 +371,6 @@ public abstract class X509Certificate * @return the path length of the certificate constraints if the extension * is present or {@code -1} if the extension is not present. {@code * Integer.MAX_VALUE} if there's not limit. - * @since Android 1.0 */ public abstract int getBasicConstraints(); @@ -436,13 +398,10 @@ public abstract class X509Certificate * * </pre> * - * </p> - * * @return the subject alternative names or {@code null} if there are none * in the certificate. * @throws CertificateParsingException * if decoding of the extension fails. - * @since Android 1.0 */ public Collection<List<?>> getSubjectAlternativeNames() throws CertificateParsingException { @@ -473,13 +432,10 @@ public abstract class X509Certificate * * </pre> * - * </p> - * * @return the issuer alternative names of {@code null} if there are none in * the certificate. * @throws CertificateParsingException * if decoding of the extension fails. - * @since Android 1.0 */ public Collection<List<?>> getIssuerAlternativeNames() throws CertificateParsingException { diff --git a/security/src/main/java/java/security/cert/X509Extension.java b/security/src/main/java/java/security/cert/X509Extension.java index cc8648b..1543f3d 100644 --- a/security/src/main/java/java/security/cert/X509Extension.java +++ b/security/src/main/java/java/security/cert/X509Extension.java @@ -21,8 +21,6 @@ import java.util.Set; /** * The interface specifying an X.509 Certificate or CRL extension. - * - * @since Android 1.0 */ public interface X509Extension { @@ -33,7 +31,6 @@ public interface X509Extension { * @return the set of extension OIDs marked as CRITIAL, an empty set if none * are marked as CRITICAL, or {@code null} if no extensions are * present. - * @since Android 1.0 */ public Set<String> getCriticalExtensionOIDs(); @@ -45,7 +42,6 @@ public interface X509Extension { * the object identifier to get the extension value for. * @return the extension value as DER-encoded OCTET string, or {@code null} * if no extension for the specified OID can be found. - * @since Android 1.0 */ public byte[] getExtensionValue(String oid); @@ -56,7 +52,6 @@ public interface X509Extension { * @return the set of extension OIDs marked as NON-CRITIAL, an empty set if * none are marked as NON-.CRITICAL, or {@code null} if no * extensions are present. - * @since Android 1.0 */ public Set<String> getNonCriticalExtensionOIDs(); @@ -66,7 +61,6 @@ public interface X509Extension { * * @return {@code true} if an unsupported CRITICAL extension is present, * {@code false} otherwise. - * @since Android 1.0 */ public boolean hasUnsupportedCriticalExtension(); } diff --git a/security/src/main/java/java/security/interfaces/DSAKey.java b/security/src/main/java/java/security/interfaces/DSAKey.java index 1362bff..ac9aade 100644 --- a/security/src/main/java/java/security/interfaces/DSAKey.java +++ b/security/src/main/java/java/security/interfaces/DSAKey.java @@ -21,8 +21,6 @@ package java.security.interfaces; /** * The base interface for Digital Signature Algorithm (DSA) public or private * keys. - * - * @since Android 1.0 */ public interface DSAKey { @@ -30,8 +28,7 @@ public interface DSAKey { * Returns the DSA key parameters. * * @return the DSA key parameters. - * @since Android 1.0 */ public DSAParams getParams(); -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/interfaces/DSAKeyPairGenerator.java b/security/src/main/java/java/security/interfaces/DSAKeyPairGenerator.java index 4b89c6a..b7b5480 100644 --- a/security/src/main/java/java/security/interfaces/DSAKeyPairGenerator.java +++ b/security/src/main/java/java/security/interfaces/DSAKeyPairGenerator.java @@ -22,8 +22,6 @@ import java.security.SecureRandom; /** * The interface for key generators that can generate DSA key pairs. - * - * @since Android 1.0 */ public interface DSAKeyPairGenerator { @@ -38,7 +36,6 @@ public interface DSAKeyPairGenerator { * @throws InvalidParameterException * if the specified parameter values are {@code null} or * invalid. - * @since Android 1.0 */ public void initialize(DSAParams params, SecureRandom random) throws InvalidParameterException; @@ -53,7 +50,6 @@ public interface DSAKeyPairGenerator { * it will use the pre-calculated values for the specified modulus * length. Default parameters are available for modulus lengths of 512 and 1024 * bits. - * </p> * * @param modlen * the length of the modulus in bits. @@ -65,8 +61,7 @@ public interface DSAKeyPairGenerator { * if the specified modulus length is not valid, or if there are * no pre-calculated values and {@code genParams} is {@code * false}. - * @since Android 1.0 */ public void initialize(int modlen, boolean genParams, SecureRandom random) throws InvalidParameterException; -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/interfaces/DSAParams.java b/security/src/main/java/java/security/interfaces/DSAParams.java index 0483da2..62f2d00 100644 --- a/security/src/main/java/java/security/interfaces/DSAParams.java +++ b/security/src/main/java/java/security/interfaces/DSAParams.java @@ -21,8 +21,6 @@ import java.math.BigInteger; /** * The interface for Digital Signature Algorithm (DSA) specific parameters. - * - * @since Android 1.0 */ public interface DSAParams { @@ -30,7 +28,6 @@ public interface DSAParams { * Returns the base ({@code g}) value. * * @return the base ({@code g}) value. - * @since Android 1.0 */ public BigInteger getG(); @@ -38,7 +35,6 @@ public interface DSAParams { * Returns the prime ({@code p}) value. * * @return the prime ({@code p}) value. - * @since Android 1.0 */ public BigInteger getP(); @@ -46,7 +42,6 @@ public interface DSAParams { * Returns the subprime ({@code q} value. * * @return the subprime ({@code q} value. - * @since Android 1.0 */ public BigInteger getQ(); diff --git a/security/src/main/java/java/security/interfaces/DSAPrivateKey.java b/security/src/main/java/java/security/interfaces/DSAPrivateKey.java index e2592ca..6419440 100644 --- a/security/src/main/java/java/security/interfaces/DSAPrivateKey.java +++ b/security/src/main/java/java/security/interfaces/DSAPrivateKey.java @@ -22,15 +22,11 @@ import java.security.PrivateKey; /** * The interface for a Digital Signature Algorithm (DSA) private key. - * - * @since Android 1.0 */ public interface DSAPrivateKey extends DSAKey, PrivateKey { /** * The serial version identifier. - * - * @since Android 1.0 */ public static final long serialVersionUID = 7776497482533790279L; @@ -38,8 +34,7 @@ public interface DSAPrivateKey extends DSAKey, PrivateKey { * Returns the private key value {@code x}. * * @return the private key value {@code x}. - * @since Android 1.0 */ public BigInteger getX(); -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/interfaces/DSAPublicKey.java b/security/src/main/java/java/security/interfaces/DSAPublicKey.java index ccb985e..9642bf1 100644 --- a/security/src/main/java/java/security/interfaces/DSAPublicKey.java +++ b/security/src/main/java/java/security/interfaces/DSAPublicKey.java @@ -22,15 +22,11 @@ import java.security.PublicKey; /** * The interface for a Digital Signature Algorithm (DSA) public key. - * - * @since Android 1.0 */ public interface DSAPublicKey extends DSAKey, PublicKey { /** * The serial version identifier. - * - * @since Android 1.0 */ public static final long serialVersionUID = 1234526332779022332L; @@ -38,8 +34,7 @@ public interface DSAPublicKey extends DSAKey, PublicKey { * Returns the public key value {@code y}. * * @return the public key value {@code y}. - * @since Android 1.0 */ public BigInteger getY(); -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/interfaces/ECKey.java b/security/src/main/java/java/security/interfaces/ECKey.java index 9f5d254..5469392 100644 --- a/security/src/main/java/java/security/interfaces/ECKey.java +++ b/security/src/main/java/java/security/interfaces/ECKey.java @@ -21,8 +21,6 @@ import java.security.spec.ECParameterSpec; /** * The base interface for Elliptic Curve (EC) public or private keys. - * - * @since Android 1.0 */ public interface ECKey { @@ -30,7 +28,6 @@ public interface ECKey { * Returns the EC key parameters. * * @return the EC key parameters. - * @since Android 1.0 */ public ECParameterSpec getParams(); -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/interfaces/ECPrivateKey.java b/security/src/main/java/java/security/interfaces/ECPrivateKey.java index 74ef4c2..254d2a6 100644 --- a/security/src/main/java/java/security/interfaces/ECPrivateKey.java +++ b/security/src/main/java/java/security/interfaces/ECPrivateKey.java @@ -22,15 +22,11 @@ import java.security.PrivateKey; /** * The interface for an Elliptic Curve (EC) private key. - * - * @since Android 1.0 */ public interface ECPrivateKey extends PrivateKey, ECKey { /** * The serial version identifier. - * - * @since Android 1.0 */ public static final long serialVersionUID = -7896394956925609184L; @@ -38,7 +34,6 @@ public interface ECPrivateKey extends PrivateKey, ECKey { * Returns the private value {@code S}. * * @return the private value {@code S}. - * @since Android 1.0 */ public BigInteger getS(); -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/interfaces/ECPublicKey.java b/security/src/main/java/java/security/interfaces/ECPublicKey.java index 063dfe9..8ad97fc 100644 --- a/security/src/main/java/java/security/interfaces/ECPublicKey.java +++ b/security/src/main/java/java/security/interfaces/ECPublicKey.java @@ -22,15 +22,11 @@ import java.security.PublicKey; /** * The interface for an Elliptic Curve (EC) public key. - * - * @since Android 1.0 */ public interface ECPublicKey extends PublicKey, ECKey { /** * The serial version identifier. - * - * @since Android 1.0 */ public static final long serialVersionUID = -3314988629879632826L; @@ -38,7 +34,6 @@ public interface ECPublicKey extends PublicKey, ECKey { * Returns the public point {@code W} on an elliptic curve (EC). * * @return the public point {@code W} on an elliptic curve (EC). - * @since Android 1.0 */ public ECPoint getW(); -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/interfaces/RSAKey.java b/security/src/main/java/java/security/interfaces/RSAKey.java index bc0877e..2c9e6c1 100644 --- a/security/src/main/java/java/security/interfaces/RSAKey.java +++ b/security/src/main/java/java/security/interfaces/RSAKey.java @@ -21,8 +21,6 @@ import java.math.BigInteger; /** * The base interface for PKCS#1 RSA public and private keys. - * - * @since Android 1.0 */ public interface RSAKey { @@ -30,7 +28,6 @@ public interface RSAKey { * Returns the modulus. * * @return the modulus. - * @since Android 1.0 */ public BigInteger getModulus(); -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/interfaces/RSAMultiPrimePrivateCrtKey.java b/security/src/main/java/java/security/interfaces/RSAMultiPrimePrivateCrtKey.java index c5e86c3..d8aa1bf 100644 --- a/security/src/main/java/java/security/interfaces/RSAMultiPrimePrivateCrtKey.java +++ b/security/src/main/java/java/security/interfaces/RSAMultiPrimePrivateCrtKey.java @@ -24,15 +24,11 @@ import java.security.spec.RSAOtherPrimeInfo; * The interface for a Multi-Prime RSA private key. Specified by <a * href="http://www.rsa.com/rsalabs/node.asp?id=2125">PKCS #1 v2.0 Amendment 1: * Multi-Prime RSA</a>. - * - * @since Android 1.0 */ public interface RSAMultiPrimePrivateCrtKey extends RSAPrivateKey { /** * the serial version identifier. - * - * @since Android 1.0 */ public static final long serialVersionUID = 618058533534628008L; @@ -40,7 +36,6 @@ public interface RSAMultiPrimePrivateCrtKey extends RSAPrivateKey { * Returns the CRT coefficient, {@code q^-1 mod p}. * * @return the CRT coefficient. - * @since Android 1.0 */ public BigInteger getCrtCoefficient(); @@ -49,7 +44,6 @@ public interface RSAMultiPrimePrivateCrtKey extends RSAPrivateKey { * * @return the information for the additional primes, or {@code null} if * there are only the two primes ({@code p, q}), - * @since Android 1.0 */ public RSAOtherPrimeInfo[] getOtherPrimeInfo(); @@ -57,7 +51,6 @@ public interface RSAMultiPrimePrivateCrtKey extends RSAPrivateKey { * Returns the prime factor {@code p} of {@code n}. * * @return the prime factor {@code p} of {@code n}. - * @since Android 1.0 */ public BigInteger getPrimeP(); @@ -65,7 +58,6 @@ public interface RSAMultiPrimePrivateCrtKey extends RSAPrivateKey { * Returns the prime factor {@code q} of {@code n}. * * @return the prime factor {@code q} of {@code n}. - * @since Android 1.0 */ public BigInteger getPrimeQ(); @@ -73,7 +65,6 @@ public interface RSAMultiPrimePrivateCrtKey extends RSAPrivateKey { * Returns the CRT exponent of the prime {@code p}. * * @return the CRT exponent of the prime {@code p}. - * @since Android 1.0 */ public BigInteger getPrimeExponentP(); @@ -81,7 +72,6 @@ public interface RSAMultiPrimePrivateCrtKey extends RSAPrivateKey { * Returns the CRT exponent of the prime {@code q}. * * @return the CRT exponent of the prime {@code q}. - * @since Android 1.0 */ public BigInteger getPrimeExponentQ(); @@ -89,7 +79,6 @@ public interface RSAMultiPrimePrivateCrtKey extends RSAPrivateKey { * Returns the public exponent {@code e}. * * @return the public exponent {@code e}. - * @since Android 1.0 */ public BigInteger getPublicExponent(); -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/interfaces/RSAPrivateCrtKey.java b/security/src/main/java/java/security/interfaces/RSAPrivateCrtKey.java index 48d70ce..a670491 100644 --- a/security/src/main/java/java/security/interfaces/RSAPrivateCrtKey.java +++ b/security/src/main/java/java/security/interfaces/RSAPrivateCrtKey.java @@ -21,15 +21,11 @@ import java.math.BigInteger; /** * The interface for a PKCS#1 RSA private key using CRT information values. - * - * @since Android 1.0 */ public interface RSAPrivateCrtKey extends RSAPrivateKey { /** * The serial version identifier. - * - * @since Android 1.0 */ public static final long serialVersionUID = -5682214253527700368L; @@ -37,7 +33,6 @@ public interface RSAPrivateCrtKey extends RSAPrivateKey { * Returns the CRT coefficient, {@code q^-1 mod p}. * * @return the CRT coefficient. - * @since Android 1.0 */ public BigInteger getCrtCoefficient(); @@ -45,7 +40,6 @@ public interface RSAPrivateCrtKey extends RSAPrivateKey { * Returns the prime factor {@code p} of {@code n}. * * @return the prime factor {@code p} of {@code n}. - * @since Android 1.0 */ public BigInteger getPrimeP(); @@ -53,7 +47,6 @@ public interface RSAPrivateCrtKey extends RSAPrivateKey { * Returns the prime factor {@code q} of {@code n}. * * @return the prime factor {@code q} of {@code n}. - * @since Android 1.0 */ public BigInteger getPrimeQ(); @@ -61,7 +54,6 @@ public interface RSAPrivateCrtKey extends RSAPrivateKey { * Returns the CRT exponent of the primet {@code p}. * * @return the CRT exponent of the prime {@code p}. - * @since Android 1.0 */ public BigInteger getPrimeExponentP(); @@ -69,7 +61,6 @@ public interface RSAPrivateCrtKey extends RSAPrivateKey { * Returns the CRT exponent of the prime {@code q}. * * @return the CRT exponent of the prime {@code q}. - * @since Android 1.0 */ public BigInteger getPrimeExponentQ(); @@ -77,7 +68,6 @@ public interface RSAPrivateCrtKey extends RSAPrivateKey { * Returns the public exponent {@code e}. * * @return the public exponent {@code e}. - * @since Android 1.0 */ public BigInteger getPublicExponent(); -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/interfaces/RSAPrivateKey.java b/security/src/main/java/java/security/interfaces/RSAPrivateKey.java index 041a1e3..0da15e9 100644 --- a/security/src/main/java/java/security/interfaces/RSAPrivateKey.java +++ b/security/src/main/java/java/security/interfaces/RSAPrivateKey.java @@ -22,15 +22,11 @@ import java.security.PrivateKey; /** * The interface for an PKCS#1 RSA private key. - * - * @since Android 1.0 */ public interface RSAPrivateKey extends PrivateKey, RSAKey { /** * The serial version identifier. - * - * @since Android 1.0 */ public static final long serialVersionUID = 5187144804936595022L; @@ -38,7 +34,6 @@ public interface RSAPrivateKey extends PrivateKey, RSAKey { * Returns the private exponent {@code d}. * * @return the private exponent {@code d}. - * @since Android 1.0 */ public BigInteger getPrivateExponent(); -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/interfaces/RSAPublicKey.java b/security/src/main/java/java/security/interfaces/RSAPublicKey.java index b13b1aa..379351f 100644 --- a/security/src/main/java/java/security/interfaces/RSAPublicKey.java +++ b/security/src/main/java/java/security/interfaces/RSAPublicKey.java @@ -22,15 +22,11 @@ import java.security.PublicKey; /** * The interface for a PKCS#1 RSA public key. - * - * @since Android 1.0 */ public interface RSAPublicKey extends PublicKey, RSAKey { /** * The serial version identifier. - * - * @since Android 1.0 */ public static final long serialVersionUID = -8727434096241101194L; @@ -38,8 +34,7 @@ public interface RSAPublicKey extends PublicKey, RSAKey { * Returns the public exponent {@code e}. * * @return the public exponent {@code e}. - * @since Android 1.0 */ public BigInteger getPublicExponent(); -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/spec/AlgorithmParameterSpec.java b/security/src/main/java/java/security/spec/AlgorithmParameterSpec.java index 32c7a3a..0cbba76 100644 --- a/security/src/main/java/java/security/spec/AlgorithmParameterSpec.java +++ b/security/src/main/java/java/security/spec/AlgorithmParameterSpec.java @@ -20,8 +20,6 @@ package java.security.spec; /** * The marker interface for algorithm parameter specifications. The purpose is * to group parameter specifications for algorithms. - * - * @since Android 1.0 */ public interface AlgorithmParameterSpec { -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/spec/DSAParameterSpec.java b/security/src/main/java/java/security/spec/DSAParameterSpec.java index 5465b5b..e23a682 100644 --- a/security/src/main/java/java/security/spec/DSAParameterSpec.java +++ b/security/src/main/java/java/security/spec/DSAParameterSpec.java @@ -22,8 +22,6 @@ import java.security.interfaces.DSAParams; /** * The parameter specification used with the Digital Signature Algorithm (DSA). - * - * @since Android 1.0 */ public class DSAParameterSpec implements AlgorithmParameterSpec, DSAParams { // Prime @@ -43,7 +41,6 @@ public class DSAParameterSpec implements AlgorithmParameterSpec, DSAParams { * the sub-prime {@code q}. * @param g * the base {@code g}; - * @since Android 1.0 */ public DSAParameterSpec(BigInteger p, BigInteger q, BigInteger g) { this.p = p; @@ -55,7 +52,6 @@ public class DSAParameterSpec implements AlgorithmParameterSpec, DSAParams { * Returns the base {@code g}. * * @return the base {@code g}. - * @since Android 1.0 */ public BigInteger getG() { return g; @@ -65,7 +61,6 @@ public class DSAParameterSpec implements AlgorithmParameterSpec, DSAParams { * Returns the prime {@code p}. * * @return the prime {@code p}. - * @since Android 1.0 */ public BigInteger getP() { return p; @@ -73,8 +68,8 @@ public class DSAParameterSpec implements AlgorithmParameterSpec, DSAParams { /** * Returns the sub-prime {@code q}. + * * @return the sub-prime {@code q}. - * @since Android 1.0 */ public BigInteger getQ() { return q; diff --git a/security/src/main/java/java/security/spec/DSAPrivateKeySpec.java b/security/src/main/java/java/security/spec/DSAPrivateKeySpec.java index 3b692c8..6dc12c8 100644 --- a/security/src/main/java/java/security/spec/DSAPrivateKeySpec.java +++ b/security/src/main/java/java/security/spec/DSAPrivateKeySpec.java @@ -21,8 +21,6 @@ import java.math.BigInteger; /** * The parameters specifying a DSA private key. - * - * @since Android 1.0 */ public class DSAPrivateKeySpec implements KeySpec { // Private key @@ -46,7 +44,6 @@ public class DSAPrivateKeySpec implements KeySpec { * the sub-prime {@code q}. * @param g * the base {@code g}. - * @since Android 1.0 */ public DSAPrivateKeySpec(BigInteger x, BigInteger p, BigInteger q, BigInteger g) { @@ -60,7 +57,6 @@ public class DSAPrivateKeySpec implements KeySpec { * Returns the base {@code g}. * * @return the base {@code g}. - * @since Android 1.0 */ public BigInteger getG() { return g; @@ -70,7 +66,6 @@ public class DSAPrivateKeySpec implements KeySpec { * Returns the prime {@code p}. * * @return the prime {@code p}. - * @since Android 1.0 */ public BigInteger getP() { return p; @@ -80,7 +75,6 @@ public class DSAPrivateKeySpec implements KeySpec { * Returns the sub-prime {@code q}. * * @return the sub-prime {@code q}. - * @since Android 1.0 */ public BigInteger getQ() { return q; @@ -90,7 +84,6 @@ public class DSAPrivateKeySpec implements KeySpec { * Returns the private key {@code x}. * * @return the private key {@code x}. - * @since Android 1.0 */ public BigInteger getX() { return x; diff --git a/security/src/main/java/java/security/spec/DSAPublicKeySpec.java b/security/src/main/java/java/security/spec/DSAPublicKeySpec.java index 95d1141..af90919 100644 --- a/security/src/main/java/java/security/spec/DSAPublicKeySpec.java +++ b/security/src/main/java/java/security/spec/DSAPublicKeySpec.java @@ -21,8 +21,6 @@ import java.math.BigInteger; /** * The parameters specifying a DSA public key. - * - * @since Android 1.0 */ public class DSAPublicKeySpec implements KeySpec { // Public key @@ -46,7 +44,6 @@ public class DSAPublicKeySpec implements KeySpec { * the sub-prime {@code q}. * @param g * the base {@code g}. - * @since Android 1.0 */ public DSAPublicKeySpec(BigInteger y, BigInteger p, BigInteger q, BigInteger g) { @@ -60,7 +57,6 @@ public class DSAPublicKeySpec implements KeySpec { * Returns the base {@code g}. * * @return the base {@code g}. - * @since Android 1.0 */ public BigInteger getG() { return g; @@ -70,7 +66,6 @@ public class DSAPublicKeySpec implements KeySpec { * Returns the prime {@code p}. * * @return the prime {@code p}. - * @since Android 1.0 */ public BigInteger getP() { return p; @@ -80,7 +75,6 @@ public class DSAPublicKeySpec implements KeySpec { * Returns the sub-prime {@code q}. * * @return the sub-prime {@code q}. - * @since Android 1.0 */ public BigInteger getQ() { return q; @@ -90,7 +84,6 @@ public class DSAPublicKeySpec implements KeySpec { * Returns the public key value {@code y}. * * @return the public key value {@code y}. - * @since Android 1.0 */ public BigInteger getY() { return y; diff --git a/security/src/main/java/java/security/spec/ECField.java b/security/src/main/java/java/security/spec/ECField.java index 74a5eb8..b4c6be2 100644 --- a/security/src/main/java/java/security/spec/ECField.java +++ b/security/src/main/java/java/security/spec/ECField.java @@ -19,8 +19,6 @@ package java.security.spec; /** * The base interface for a Finite Field of an Elliptic Curve. - * - * @since Android 1.0 */ public interface ECField { @@ -28,7 +26,6 @@ public interface ECField { * Returns the size of the field (in bits). * * @return the size of the field (in bits). - * @since Android 1.0 */ int getFieldSize(); } diff --git a/security/src/main/java/java/security/spec/ECFieldF2m.java b/security/src/main/java/java/security/spec/ECFieldF2m.java index d68378b..e5a636a 100644 --- a/security/src/main/java/java/security/spec/ECFieldF2m.java +++ b/security/src/main/java/java/security/spec/ECFieldF2m.java @@ -25,8 +25,6 @@ import org.apache.harmony.security.internal.nls.Messages; /** * The parameters specifying a <i>characteristic 2 finite field</i> of an * elliptic curve. - * - * @since Android 1.0 */ public class ECFieldF2m implements ECField { // Mid terms array length for trinomial basis @@ -52,7 +50,6 @@ public class ECFieldF2m implements ECField { * the exponent {@code m} for the number of elements. * @throws IllegalArgumentException * if {@code m <= zero}. - * @since Android 1.0 */ public ECFieldF2m(int m) { this.m = m; @@ -69,8 +66,7 @@ public class ECFieldF2m implements ECField { * <p> * The reduction polynomial must be either <i>trinomial</i> or * <i>pentanomial</i>. - * </p> - * + * * @param m * the exponent {@code m} for the number of elements. * @param rp @@ -79,7 +75,6 @@ public class ECFieldF2m implements ECField { * polynomial. * @throws IllegalArgumentException * if {@code m <= zero} or the {@code rp} is invalid. - * @since Android 1.0 */ public ECFieldF2m(int m, BigInteger rp) { this.m = m; @@ -117,7 +112,6 @@ public class ECFieldF2m implements ECField { * <p> * The reduction polynomial must be either <i>trinomial</i> or * <i>pentanomial</i>. - * </p> * * @param m * the exponent {@code m} for the number of elements. @@ -127,7 +121,6 @@ public class ECFieldF2m implements ECField { * @throws IllegalArgumentException * if {@code m <= zero} or the reduction polynomial is not * valid. - * @since Android 1.0 */ public ECFieldF2m(int m, int[] ks) { this.m = m; @@ -182,7 +175,6 @@ public class ECFieldF2m implements ECField { * the object to compare to this finite field. * @return {@code true} if the specified object is equal to this finite field, * otherwise {@code false}. - * @since Android 1.0 */ public boolean equals(Object obj) { // object equals to itself @@ -214,7 +206,6 @@ public class ECFieldF2m implements ECField { * Returns the size of this finite field (in bits). * * @return the size of this finite field (in bits). - * @since Android 1.0 */ public int getFieldSize() { return m; @@ -225,7 +216,6 @@ public class ECFieldF2m implements ECField { * the number of elements. * * @return the exponent {@code m} for this finite field - * @since Android 1.0 */ public int getM() { return m; @@ -238,7 +228,6 @@ public class ECFieldF2m implements ECField { * @return a copy of the integer array containing the order of the middle * term(s) of the reduction polynomial for a polynomial basis or * {@code null} for a normal basis. - * @since Android 1.0 */ public int[] getMidTermsOfReductionPolynomial() { // Defensively copies private array @@ -261,7 +250,6 @@ public class ECFieldF2m implements ECField { * @return the base of the reduction polynomial with the n-th bit * corresponding to the n-th coefficient of the reduction polynomial * for a polynomial basis or {@code null} for a normal basis. - * @since Android 1.0 */ public BigInteger getReductionPolynomial() { return rp; @@ -271,7 +259,6 @@ public class ECFieldF2m implements ECField { * Returns the hashcode value for this finite field. * * @return the hashcode value for this finite field. - * @since Android 1.0 */ public int hashCode() { return rp == null ? m : m + rp.hashCode(); diff --git a/security/src/main/java/java/security/spec/ECFieldFp.java b/security/src/main/java/java/security/spec/ECFieldFp.java index d3f4ee6..b68238d 100644 --- a/security/src/main/java/java/security/spec/ECFieldFp.java +++ b/security/src/main/java/java/security/spec/ECFieldFp.java @@ -24,8 +24,6 @@ import org.apache.harmony.security.internal.nls.Messages; /** * The parameters specifying a <i>prime finite field</i> of an * elliptic curve. - * - * @since Android 1.0 */ public class ECFieldFp implements ECField { // Prime @@ -39,7 +37,6 @@ public class ECFieldFp implements ECField { * the prime value {@code p}. * @throws IllegalArgumentException * if {@code p <= zero}. - * @since Android 1.0 */ public ECFieldFp(BigInteger p) { this.p = p; @@ -56,7 +53,6 @@ public class ECFieldFp implements ECField { * Returns the size of the finite field (in bits). * * @return the size of the finite field (in bits). - * @since Android 1.0 */ public int getFieldSize() { return p.bitLength(); @@ -66,7 +62,6 @@ public class ECFieldFp implements ECField { * Returns the prime value {@code p} for this finite field. * * @return the prime value {@code p} for this finite field. - * @since Android 1.0 */ public BigInteger getP() { return p; @@ -79,7 +74,6 @@ public class ECFieldFp implements ECField { * the object to compare to this finite field. * @return {@code true} if the specified object is equal to this finite field, * otherwise {@code false}. - * @since Android 1.0 */ public boolean equals(Object obj) { // object equals itself @@ -96,7 +90,6 @@ public class ECFieldFp implements ECField { * Returns the hashcode value for this finite field. * * @return the hashcode value for this finite field. - * @since Android 1.0 */ public int hashCode() { return p.hashCode(); diff --git a/security/src/main/java/java/security/spec/ECGenParameterSpec.java b/security/src/main/java/java/security/spec/ECGenParameterSpec.java index 210b315..de4cd04 100644 --- a/security/src/main/java/java/security/spec/ECGenParameterSpec.java +++ b/security/src/main/java/java/security/spec/ECGenParameterSpec.java @@ -21,8 +21,6 @@ import org.apache.harmony.security.internal.nls.Messages; /** * The parameter specification used to generate elliptic curve domain parameters. - * - * @since Android 1.0 */ public class ECGenParameterSpec implements AlgorithmParameterSpec { // Standard (or predefined) name for EC domain @@ -35,7 +33,6 @@ public class ECGenParameterSpec implements AlgorithmParameterSpec { * * @param name * the name of the elliptic curve domain parameter. - * @since Android 1.0 */ public ECGenParameterSpec(String name) { this.name = name; @@ -49,7 +46,6 @@ public class ECGenParameterSpec implements AlgorithmParameterSpec { * curve domain parameter. * * @return the name - * @since Android 1.0 */ public String getName() { return name; diff --git a/security/src/main/java/java/security/spec/ECParameterSpec.java b/security/src/main/java/java/security/spec/ECParameterSpec.java index e10757b..a1985db 100644 --- a/security/src/main/java/java/security/spec/ECParameterSpec.java +++ b/security/src/main/java/java/security/spec/ECParameterSpec.java @@ -23,8 +23,6 @@ import org.apache.harmony.security.internal.nls.Messages; /** * The parameter specification used with Elliptic Curve Cryptography (ECC). - * - * @since Android 1.0 */ public class ECParameterSpec implements AlgorithmParameterSpec { // Elliptic curve for which this is parameter @@ -51,7 +49,6 @@ public class ECParameterSpec implements AlgorithmParameterSpec { * the co-factor. * @throws IllegalArgumentException * if {@code order <= zero} or {@code cofactor <= zero}. - * @since Android 1.0 */ public ECParameterSpec(EllipticCurve curve, ECPoint generator, BigInteger order, int cofactor) { @@ -84,7 +81,6 @@ public class ECParameterSpec implements AlgorithmParameterSpec { * Returns the {@code cofactor}. * * @return the {@code cofactor}. - * @since Android 1.0 */ public int getCofactor() { return cofactor; @@ -94,7 +90,6 @@ public class ECParameterSpec implements AlgorithmParameterSpec { * Returns the elliptic curve. * * @return the elliptic curve. - * @since Android 1.0 */ public EllipticCurve getCurve() { return curve; @@ -104,7 +99,6 @@ public class ECParameterSpec implements AlgorithmParameterSpec { * Returns the generator (or base point). * * @return the generator (or base point). - * @since Android 1.0 */ public ECPoint getGenerator() { return generator; @@ -114,7 +108,6 @@ public class ECParameterSpec implements AlgorithmParameterSpec { * Returns the order of the generator. * * @return the order of the generator. - * @since Android 1.0 */ public BigInteger getOrder() { return order; diff --git a/security/src/main/java/java/security/spec/ECPoint.java b/security/src/main/java/java/security/spec/ECPoint.java index 3aba6c7..0751757 100644 --- a/security/src/main/java/java/security/spec/ECPoint.java +++ b/security/src/main/java/java/security/spec/ECPoint.java @@ -23,15 +23,11 @@ import org.apache.harmony.security.internal.nls.Messages; /** * A Point on an Elliptic Curve in barycentric (or affine) coordinates. - * - * @since Android 1.0 */ public class ECPoint { /** * The point on an Elliptic Curve at infinity. - * - * @since Android 1.0 */ public static final ECPoint POINT_INFINITY = new ECPoint(); // affine X coordinate of this point @@ -52,7 +48,6 @@ public class ECPoint { * the x-coordinate. * @param affineY * the y-coordinate. - * @since Android 1.0 */ public ECPoint(BigInteger affineX, BigInteger affineY) { this.affineX = affineX; @@ -69,7 +64,6 @@ public class ECPoint { * Returns the x-coordinate. * * @return the x-coordinate, or {@code null} for the infinite point. - * @since Android 1.0 */ public BigInteger getAffineX() { return affineX; @@ -79,7 +73,6 @@ public class ECPoint { * Returns the y-coordinate. * * @return the y-coordinate, or {@code null} fot the infinite point. - * @since Android 1.0 */ public BigInteger getAffineY() { return affineY; @@ -93,7 +86,6 @@ public class ECPoint { * the object to compare. * @return {@code true} if the specified object and this elliptic curve * point are equal, otherwise {@code false}. - * @since Android 1.0 */ public boolean equals(Object other) { if (this == other) { @@ -116,7 +108,6 @@ public class ECPoint { * Returns the hashcode of this elliptic curve point. * * @return the hashcode of this elliptic curve point. - * @since Android 1.0 */ public int hashCode() { if (this.affineX != null) { diff --git a/security/src/main/java/java/security/spec/ECPrivateKeySpec.java b/security/src/main/java/java/security/spec/ECPrivateKeySpec.java index de778fd..1ddfec3 100644 --- a/security/src/main/java/java/security/spec/ECPrivateKeySpec.java +++ b/security/src/main/java/java/security/spec/ECPrivateKeySpec.java @@ -23,8 +23,6 @@ import org.apache.harmony.security.internal.nls.Messages; /** * The parameters specifying an Elliptic Curve (EC) private key. - * - * @since Android 1.0 */ public class ECPrivateKeySpec implements KeySpec { // Private value associated with this key @@ -40,7 +38,6 @@ public class ECPrivateKeySpec implements KeySpec { * the private value {@code S}. * @param params * the domain parameter specification. - * @since Android 1.0 */ public ECPrivateKeySpec(BigInteger s, ECParameterSpec params) { this.s = s; @@ -58,7 +55,6 @@ public class ECPrivateKeySpec implements KeySpec { * Returns the domain parameter specification. * * @return the domain parameter specification. - * @since Android 1.0 */ public ECParameterSpec getParams() { return params; @@ -68,7 +64,6 @@ public class ECPrivateKeySpec implements KeySpec { * Returns the private value {@code S}. * * @return the private value {@code S}. - * @since Android 1.0 */ public BigInteger getS() { return s; diff --git a/security/src/main/java/java/security/spec/ECPublicKeySpec.java b/security/src/main/java/java/security/spec/ECPublicKeySpec.java index da182b5..0c88590 100644 --- a/security/src/main/java/java/security/spec/ECPublicKeySpec.java +++ b/security/src/main/java/java/security/spec/ECPublicKeySpec.java @@ -21,8 +21,6 @@ import org.apache.harmony.security.internal.nls.Messages; /** * The parameters specifying an Elliptic Curve (EC) public key. - * - * @since Android 1.0 */ public class ECPublicKeySpec implements KeySpec { // The public point @@ -40,7 +38,6 @@ public class ECPublicKeySpec implements KeySpec { * the domain parameter specification. * @throws IllegalArgumentException * if the specified point {@code W} is at infinity. - * @since Android 1.0 */ public ECPublicKeySpec(ECPoint w, ECParameterSpec params) { this.w = w; @@ -63,7 +60,6 @@ public class ECPublicKeySpec implements KeySpec { * Returns the domain parameter specification. * * @return the domain parameter specification. - * @since Android 1.0 */ public ECParameterSpec getParams() { return params; @@ -73,7 +69,6 @@ public class ECPublicKeySpec implements KeySpec { * Returns the public elliptic curve point {@code W}. * * @return the public elliptic curve point {@code W}. - * @since Android 1.0 */ public ECPoint getW() { return w; diff --git a/security/src/main/java/java/security/spec/EllipticCurve.java b/security/src/main/java/java/security/spec/EllipticCurve.java index 3ab2921..45ff042 100644 --- a/security/src/main/java/java/security/spec/EllipticCurve.java +++ b/security/src/main/java/java/security/spec/EllipticCurve.java @@ -24,8 +24,6 @@ import org.apache.harmony.security.internal.nls.Messages; /** * An Elliptic Curve with its necessary values. - * - * @since Android 1.0 */ public class EllipticCurve { @@ -59,7 +57,6 @@ public class EllipticCurve { * the seed used for the generation of the curve. * @throws IllegalArgumentException * if the specified coefficients are not in the specified field. - * @since Android 1.0 */ public EllipticCurve(ECField field, BigInteger a, BigInteger b, byte[] seed) { this.field = field; @@ -115,7 +112,6 @@ public class EllipticCurve { * the coefficient {@code b}. * @throws IllegalArgumentException * if the specified coefficients are not in the specified field. - * @since Android 1.0 */ public EllipticCurve(ECField field, BigInteger a, BigInteger b) { this(field, a, b, null); @@ -125,7 +121,6 @@ public class EllipticCurve { * Returns the coefficient {@code a} of this elliptic curve. * * @return the coefficient {@code a} of this elliptic curve. - * @since Android 1.0 */ public BigInteger getA() { return a; @@ -135,7 +130,6 @@ public class EllipticCurve { * Returns the coefficient {@code b} of this elliptic curve. * * @return the coefficient {@code b} of this elliptic curve. - * @since Android 1.0 */ public BigInteger getB() { return b; @@ -145,7 +139,6 @@ public class EllipticCurve { * Returns the finite field of this elliptic curve. * * @return the finite field of this elliptic curve. - * @since Android 1.0 */ public ECField getField() { return field; @@ -156,7 +149,6 @@ public class EllipticCurve { * * @return a copy of the seed that was used to generate this elliptic curve, * or {@code null} if none specified. - * @since Android 1.0 */ public byte[] getSeed() { if (seed == null) { @@ -176,7 +168,6 @@ public class EllipticCurve { * the object to compare. * @return {@code true} if the specified object is equal to this elliptic * curve, otherwise {@code false}. - * @since Android 1.0 */ public boolean equals(Object other) { if (this == other) { @@ -195,7 +186,6 @@ public class EllipticCurve { * Returns the hashcode of this elliptic curve. * * @return the hashcode of this elliptic curve. - * @since Android 1.0 */ public int hashCode() { // hash init is delayed diff --git a/security/src/main/java/java/security/spec/EncodedKeySpec.java b/security/src/main/java/java/security/spec/EncodedKeySpec.java index f199bca..d34794c 100644 --- a/security/src/main/java/java/security/spec/EncodedKeySpec.java +++ b/security/src/main/java/java/security/spec/EncodedKeySpec.java @@ -20,8 +20,6 @@ package java.security.spec; /** * The abstract key specification for a public or a private key in encoded * format. - * - * @since Android 1.0 */ public abstract class EncodedKeySpec implements KeySpec { // Encoded key @@ -32,7 +30,6 @@ public abstract class EncodedKeySpec implements KeySpec { * * @param encodedKey * the encoded key bytes. - * @since Android 1.0 */ public EncodedKeySpec(byte[] encodedKey) { // Defensively copies parameter @@ -46,7 +43,6 @@ public abstract class EncodedKeySpec implements KeySpec { * Returns the encoded key bytes. * * @return the encoded key bytes. - * @since Android 1.0 */ public byte[] getEncoded() { // Defensively copies private array @@ -62,7 +58,6 @@ public abstract class EncodedKeySpec implements KeySpec { * * @return the name of the encoding format of this encoded key * specification. - * @since Android 1.0 */ public abstract String getFormat(); } diff --git a/security/src/main/java/java/security/spec/InvalidKeySpecException.java b/security/src/main/java/java/security/spec/InvalidKeySpecException.java index a83e984..4ae5877 100644 --- a/security/src/main/java/java/security/spec/InvalidKeySpecException.java +++ b/security/src/main/java/java/security/spec/InvalidKeySpecException.java @@ -22,15 +22,11 @@ import java.security.GeneralSecurityException; /** * The exception that is thrown when an invalid key specification is * encountered. - * - * @since Android 1.0 */ public class InvalidKeySpecException extends GeneralSecurityException { /** * The serial version identifier. - * - * @since Android 1.0 */ private static final long serialVersionUID = 3546139293998810778L; @@ -39,7 +35,6 @@ public class InvalidKeySpecException extends GeneralSecurityException { * * @param msg * the detail message of this exception. - * @since Android 1.0 */ public InvalidKeySpecException(String msg) { super(msg); @@ -47,8 +42,6 @@ public class InvalidKeySpecException extends GeneralSecurityException { /** * Creates a new {@code InvalidKeySpecException}. - * - * @since Android 1.0 */ public InvalidKeySpecException() { } @@ -61,7 +54,6 @@ public class InvalidKeySpecException extends GeneralSecurityException { * the detail message of this exception. * @param cause * the cause of this exception. - * @since Android 1.0 */ public InvalidKeySpecException(String message, Throwable cause) { super(message, cause); @@ -72,7 +64,6 @@ public class InvalidKeySpecException extends GeneralSecurityException { * * @param cause * the cause of this exception. - * @since Android 1.0 */ public InvalidKeySpecException(Throwable cause) { super(cause); diff --git a/security/src/main/java/java/security/spec/InvalidParameterSpecException.java b/security/src/main/java/java/security/spec/InvalidParameterSpecException.java index 668fda5..e308dd8 100644 --- a/security/src/main/java/java/security/spec/InvalidParameterSpecException.java +++ b/security/src/main/java/java/security/spec/InvalidParameterSpecException.java @@ -22,15 +22,11 @@ import java.security.GeneralSecurityException; /** * The exception that is thrown when an invalid parameter specification is * encountered. - * - * @since Android 1.0 */ public class InvalidParameterSpecException extends GeneralSecurityException { /** * The serial version identifier. - * - * @since Android 1.0 */ private static final long serialVersionUID = -970468769593399342L; @@ -40,7 +36,6 @@ public class InvalidParameterSpecException extends GeneralSecurityException { * * @param msg * the detail message for this exception. - * @since Android 1.0 */ public InvalidParameterSpecException(String msg) { super(msg); @@ -48,9 +43,7 @@ public class InvalidParameterSpecException extends GeneralSecurityException { /** * Creates a new {@code InvalidParameterSpecException}. - * - * @since Android 1.0 */ public InvalidParameterSpecException() { } -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/spec/KeySpec.java b/security/src/main/java/java/security/spec/KeySpec.java index 350a7eb..fe8df1d 100644 --- a/security/src/main/java/java/security/spec/KeySpec.java +++ b/security/src/main/java/java/security/spec/KeySpec.java @@ -20,8 +20,6 @@ package java.security.spec; /** * The marker interface for key specifications. The purpose is * to group key specifications for cryptographic keys. - * - * @since Android 1.0 */ public interface KeySpec { -}
\ No newline at end of file +} diff --git a/security/src/main/java/java/security/spec/MGF1ParameterSpec.java b/security/src/main/java/java/security/spec/MGF1ParameterSpec.java index a40f0b3..6475d90 100644 --- a/security/src/main/java/java/security/spec/MGF1ParameterSpec.java +++ b/security/src/main/java/java/security/spec/MGF1ParameterSpec.java @@ -26,17 +26,12 @@ import org.apache.harmony.security.internal.nls.Messages; * Defined in the <a * href="http://www.rsa.com/rsalabs/pubs/PKCS/html/pkcs-1.html">PKCS #1 v2.1</a> * standard - * </p> - * - * @since Android 1.0 */ public class MGF1ParameterSpec implements AlgorithmParameterSpec { /** * The predefined MGF1 parameter specification with an "SHA-1" message * digest. - * - * @since Android 1.0 */ public static final MGF1ParameterSpec SHA1 = new MGF1ParameterSpec("SHA-1"); //$NON-NLS-1$ @@ -44,8 +39,6 @@ public class MGF1ParameterSpec implements AlgorithmParameterSpec { /** * The predefined MGF1 parameter specification with an "SHA-256" message * digest. - * - * @since Android 1.0 */ public static final MGF1ParameterSpec SHA256 = new MGF1ParameterSpec("SHA-256"); //$NON-NLS-1$ @@ -53,8 +46,6 @@ public class MGF1ParameterSpec implements AlgorithmParameterSpec { /** * The predefined MGF1 parameter specification with an "SHA-384" message * digest. - * - * @since Android 1.0 */ public static final MGF1ParameterSpec SHA384 = new MGF1ParameterSpec("SHA-384"); //$NON-NLS-1$ @@ -62,8 +53,6 @@ public class MGF1ParameterSpec implements AlgorithmParameterSpec { /** * The predefined MGF1 parameter specification with an "SHA-512" message * digest. - * - * @since Android 1.0 */ public static final MGF1ParameterSpec SHA512 = new MGF1ParameterSpec("SHA-512"); //$NON-NLS-1$ @@ -77,7 +66,6 @@ public class MGF1ParameterSpec implements AlgorithmParameterSpec { * * @param mdName * the name of the message digest algorithm. - * @since Android 1.0 */ public MGF1ParameterSpec(String mdName) { this.mdName = mdName; @@ -90,7 +78,6 @@ public class MGF1ParameterSpec implements AlgorithmParameterSpec { * Returns the name of the message digest algorithm. * * @return the name of the message digest algorithm. - * @since Android 1.0 */ public String getDigestAlgorithm() { return mdName; diff --git a/security/src/main/java/java/security/spec/PKCS8EncodedKeySpec.java b/security/src/main/java/java/security/spec/PKCS8EncodedKeySpec.java index 5cb67b8..6910789 100644 --- a/security/src/main/java/java/security/spec/PKCS8EncodedKeySpec.java +++ b/security/src/main/java/java/security/spec/PKCS8EncodedKeySpec.java @@ -20,8 +20,6 @@ package java.security.spec; /** * The key specification for an encoded private key in ASN.1 format as defined * in the PKCS#8 standard. - * - * @since Android 1.0 */ public class PKCS8EncodedKeySpec extends EncodedKeySpec { @@ -31,7 +29,6 @@ public class PKCS8EncodedKeySpec extends EncodedKeySpec { * * @param encodedKey * the encoded key bytes. - * @since Android 1.0 */ public PKCS8EncodedKeySpec(byte[] encodedKey) { // Super class' ctor makes defensive parameter copy @@ -42,7 +39,6 @@ public class PKCS8EncodedKeySpec extends EncodedKeySpec { * Returns a copy of the encoded key bytes. * * @return a copy of the encoded key bytes. - * @since Android 1.0 */ public byte[] getEncoded() { // Super class' getEncoded() always returns a new array @@ -54,7 +50,6 @@ public class PKCS8EncodedKeySpec extends EncodedKeySpec { * specification. * * @return the string "PKCS#8". - * @since Android 1.0 */ public final String getFormat() { return "PKCS#8"; //$NON-NLS-1$ diff --git a/security/src/main/java/java/security/spec/PSSParameterSpec.java b/security/src/main/java/java/security/spec/PSSParameterSpec.java index c6a5bc5..06c1d05 100644 --- a/security/src/main/java/java/security/spec/PSSParameterSpec.java +++ b/security/src/main/java/java/security/spec/PSSParameterSpec.java @@ -25,9 +25,6 @@ import org.apache.harmony.security.internal.nls.Messages; * Defined in the <a * href="http://www.rsa.com/rsalabs/pubs/PKCS/html/pkcs-1.html">PKCS #1 v2.1</a> * standard. - * </p> - * - * @since Android 1.0 */ public class PSSParameterSpec implements AlgorithmParameterSpec { @@ -40,8 +37,6 @@ public class PSSParameterSpec implements AlgorithmParameterSpec { * <li>salt length: {@code 20}</li> * <li>trailer field: {@code -1}</li> * </ul> - * - * @since Android 1.0 */ public static final PSSParameterSpec DEFAULT = new PSSParameterSpec(20); @@ -64,7 +59,6 @@ public class PSSParameterSpec implements AlgorithmParameterSpec { * the salt length (in bits). * @throws IllegalArgumentException * if {@code saltLen} is negative. - * @since Android 1.0 */ public PSSParameterSpec(int saltLen) { if (saltLen < 0) { @@ -94,7 +88,6 @@ public class PSSParameterSpec implements AlgorithmParameterSpec { * the trailer field value. * @throws IllegalArgumentException * if {@code saltLen} or {@code trailerField} is negative. - * @since Android 1.0 */ public PSSParameterSpec(String mdName, String mgfName, AlgorithmParameterSpec mgfSpec, int saltLen, int trailerField) { @@ -122,7 +115,6 @@ public class PSSParameterSpec implements AlgorithmParameterSpec { * Returns the length of the salt (in bits). * * @return the length of the salt (in bits). - * @since Android 1.0 */ public int getSaltLength() { return saltLen; @@ -132,7 +124,6 @@ public class PSSParameterSpec implements AlgorithmParameterSpec { * Returns the name of the message digest algorithm. * * @return the name of the message digest algorithm. - * @since Android 1.0 */ public String getDigestAlgorithm() { return mdName; @@ -142,7 +133,6 @@ public class PSSParameterSpec implements AlgorithmParameterSpec { * Returns the name of the mask generation function algorithm. * * @return the name of the mask generation function algorithm. - * @since Android 1.0 */ public String getMGFAlgorithm() { return mgfName; @@ -153,7 +143,6 @@ public class PSSParameterSpec implements AlgorithmParameterSpec { * * @return the parameter for the mask generation function algorithm, or * {@code null} if none specified. - * @since Android 1.0 */ public AlgorithmParameterSpec getMGFParameters() { return mgfSpec; @@ -163,7 +152,6 @@ public class PSSParameterSpec implements AlgorithmParameterSpec { * Returns the trailer field value. * * @return the trailer field value. - * @since Android 1.0 */ public int getTrailerField() { return trailerField; diff --git a/security/src/main/java/java/security/spec/RSAKeyGenParameterSpec.java b/security/src/main/java/java/security/spec/RSAKeyGenParameterSpec.java index 06f3498..2377c75 100644 --- a/security/src/main/java/java/security/spec/RSAKeyGenParameterSpec.java +++ b/security/src/main/java/java/security/spec/RSAKeyGenParameterSpec.java @@ -21,22 +21,16 @@ import java.math.BigInteger; /** * The parameter specification for generating an RSA key pair. - * - * @since Android 1.0 */ public class RSAKeyGenParameterSpec implements AlgorithmParameterSpec { /** * The value of the public exponent {@code F0} = 3. - * - * @since Android 1.0 */ public static final BigInteger F0 = BigInteger.valueOf(3L); /** * The value of the public exponent {@code F4} = 65537. - * - * @since Android 1.0 */ public static final BigInteger F4 = BigInteger.valueOf(65537L); @@ -53,7 +47,6 @@ public class RSAKeyGenParameterSpec implements AlgorithmParameterSpec { * the size of the modulus (number of bits). * @param publicExponent * the value of the public exponent. - * @since Android 1.0 */ public RSAKeyGenParameterSpec(int keysize, BigInteger publicExponent) { this.keysize = keysize; @@ -64,7 +57,6 @@ public class RSAKeyGenParameterSpec implements AlgorithmParameterSpec { * Returns the size of the modulus (number of bits). * * @return the size of the modulus (number of bits). - * @since Android 1.0 */ public int getKeysize() { return keysize; @@ -74,7 +66,6 @@ public class RSAKeyGenParameterSpec implements AlgorithmParameterSpec { * Returns the value of the public exponent. * * @return the value of the public exponent. - * @since Android 1.0 */ public BigInteger getPublicExponent() { return publicExponent; diff --git a/security/src/main/java/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java b/security/src/main/java/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java index 93e3193..28469d7 100644 --- a/security/src/main/java/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java +++ b/security/src/main/java/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java @@ -28,9 +28,6 @@ import org.apache.harmony.security.internal.nls.Messages; * Defined in the <a * href="http://www.rsa.com/rsalabs/pubs/PKCS/html/pkcs-1.html">PKCS #1 v2.1</a> * standard. - * </p> - * - * @since Android 1.0 */ public class RSAMultiPrimePrivateCrtKeySpec extends RSAPrivateKeySpec { // Public Exponent @@ -74,7 +71,6 @@ public class RSAMultiPrimePrivateCrtKeySpec extends RSAPrivateKeySpec { * there are only the two primes ({@code p, q}). * @throws IllegalArgumentException * if {@code otherPrimeInfo} is not null but empty. - * @since Android 1.0 */ public RSAMultiPrimePrivateCrtKeySpec( BigInteger modulus, @@ -139,7 +135,6 @@ public class RSAMultiPrimePrivateCrtKeySpec extends RSAPrivateKeySpec { * Returns the CRT coefficient, {@code q^-1 mod p}. * * @return the CRT coefficient, {@code q^-1 mod p}. - * @since Android 1.0 */ public BigInteger getCrtCoefficient() { return crtCoefficient; @@ -150,7 +145,6 @@ public class RSAMultiPrimePrivateCrtKeySpec extends RSAPrivateKeySpec { * * @return the information for the additional primes, or {@code null} if * there are only the two primes ({@code p, q}). - * @since Android 1.0 */ public RSAOtherPrimeInfo[] getOtherPrimeInfo() { // Clone array (if not null) to prevent subsequent modification @@ -168,7 +162,6 @@ public class RSAMultiPrimePrivateCrtKeySpec extends RSAPrivateKeySpec { * Returns the exponent of the prime {@code p}. * * @return the exponent of the prime {@code p}. - * @since Android 1.0 */ public BigInteger getPrimeExponentP() { return primeExponentP; @@ -178,7 +171,6 @@ public class RSAMultiPrimePrivateCrtKeySpec extends RSAPrivateKeySpec { * Returns the exponent of the prime {@code q}. * * @return the exponent of the prime {@code q}. - * @since Android 1.0 */ public BigInteger getPrimeExponentQ() { return primeExponentQ; @@ -188,7 +180,6 @@ public class RSAMultiPrimePrivateCrtKeySpec extends RSAPrivateKeySpec { * Returns the prime factor {@code p}. * * @return the prime factor {@code p}. - * @since Android 1.0 */ public BigInteger getPrimeP() { return primeP; @@ -198,7 +189,6 @@ public class RSAMultiPrimePrivateCrtKeySpec extends RSAPrivateKeySpec { * Returns the prime factor {@code q}. * * @return the prime factor {@code q}. - * @since Android 1.0 */ public BigInteger getPrimeQ() { return primeQ; @@ -208,7 +198,6 @@ public class RSAMultiPrimePrivateCrtKeySpec extends RSAPrivateKeySpec { * Returns the public exponent {@code e}. * * @return the public exponent {@code e}. - * @since Android 1.0 */ public BigInteger getPublicExponent() { return publicExponent; diff --git a/security/src/main/java/java/security/spec/RSAOtherPrimeInfo.java b/security/src/main/java/java/security/spec/RSAOtherPrimeInfo.java index 9b4828e..177ddf5 100644 --- a/security/src/main/java/java/security/spec/RSAOtherPrimeInfo.java +++ b/security/src/main/java/java/security/spec/RSAOtherPrimeInfo.java @@ -28,9 +28,6 @@ import org.apache.harmony.security.internal.nls.Messages; * Defined in the <a * href="http://www.rsa.com/rsalabs/pubs/PKCS/html/pkcs-1.html">PKCS #1 v2.1</a> * standard. - * </p> - * - * @since Android 1.0 */ public class RSAOtherPrimeInfo { // Prime @@ -50,7 +47,6 @@ public class RSAOtherPrimeInfo { * the prime exponent. * @param crtCoefficient * the CRT coefficient. - * @since Android 1.0 */ public RSAOtherPrimeInfo(BigInteger prime, BigInteger primeExponent, BigInteger crtCoefficient) { @@ -72,7 +68,6 @@ public class RSAOtherPrimeInfo { * Returns the CRT coefficient. * * @return the CRT coefficient. - * @since Android 1.0 */ public final BigInteger getCrtCoefficient() { return crtCoefficient; @@ -82,7 +77,6 @@ public class RSAOtherPrimeInfo { * Returns the prime factor. * * @return the prime factor. - * @since Android 1.0 */ public final BigInteger getPrime() { return prime; @@ -92,7 +86,6 @@ public class RSAOtherPrimeInfo { * Returns the exponent. * * @return the exponent. - * @since Android 1.0 */ public final BigInteger getExponent() { return primeExponent; diff --git a/security/src/main/java/java/security/spec/RSAPrivateCrtKeySpec.java b/security/src/main/java/java/security/spec/RSAPrivateCrtKeySpec.java index 1157099..e786e9e 100644 --- a/security/src/main/java/java/security/spec/RSAPrivateCrtKeySpec.java +++ b/security/src/main/java/java/security/spec/RSAPrivateCrtKeySpec.java @@ -26,9 +26,6 @@ import java.math.BigInteger; * Defined in the <a * href="http://www.rsa.com/rsalabs/pubs/PKCS/html/pkcs-1.html">PKCS #1 v2.1</a> * standard. - * </p> - * - * @since Android 1.0 */ public class RSAPrivateCrtKeySpec extends RSAPrivateKeySpec { // Public Exponent @@ -65,7 +62,6 @@ public class RSAPrivateCrtKeySpec extends RSAPrivateKeySpec { * the exponent of the prime {@code q}. * @param crtCoefficient * the CRT coefficient {@code q^-1 mod p}. - * @since Android 1.0 */ public RSAPrivateCrtKeySpec(BigInteger modulus, BigInteger publicExponent, @@ -90,7 +86,6 @@ public class RSAPrivateCrtKeySpec extends RSAPrivateKeySpec { * Returns the CRT coefficient, {@code q^-1 mod p}. * * @return the CRT coefficient, {@code q^-1 mod p}. - * @since Android 1.0 */ public BigInteger getCrtCoefficient() { return crtCoefficient; @@ -100,7 +95,6 @@ public class RSAPrivateCrtKeySpec extends RSAPrivateKeySpec { * Returns the exponent of the prime {@code p}. * * @return the exponent of the prime {@code p}. - * @since Android 1.0 */ public BigInteger getPrimeExponentP() { return primeExponentP; @@ -110,7 +104,6 @@ public class RSAPrivateCrtKeySpec extends RSAPrivateKeySpec { * Returns the exponent of the prime {@code q}. * * @return the exponent of the prime {@code q}. - * @since Android 1.0 */ public BigInteger getPrimeExponentQ() { return primeExponentQ; @@ -120,7 +113,6 @@ public class RSAPrivateCrtKeySpec extends RSAPrivateKeySpec { * Returns the prime factor {@code p}. * * @return the prime factor {@code p}. - * @since Android 1.0 */ public BigInteger getPrimeP() { return primeP; @@ -130,7 +122,6 @@ public class RSAPrivateCrtKeySpec extends RSAPrivateKeySpec { * Returns the prime factor {@code q}. * * @return the prime factor {@code q}. - * @since Android 1.0 */ public BigInteger getPrimeQ() { return primeQ; @@ -140,7 +131,6 @@ public class RSAPrivateCrtKeySpec extends RSAPrivateKeySpec { * Returns the public exponent {@code e}. * * @return the public exponent {@code e}. - * @since Android 1.0 */ public BigInteger getPublicExponent() { return publicExponent; diff --git a/security/src/main/java/java/security/spec/RSAPrivateKeySpec.java b/security/src/main/java/java/security/spec/RSAPrivateKeySpec.java index bd7d4e8..c94420e 100644 --- a/security/src/main/java/java/security/spec/RSAPrivateKeySpec.java +++ b/security/src/main/java/java/security/spec/RSAPrivateKeySpec.java @@ -25,9 +25,6 @@ import java.math.BigInteger; * Defined in the <a * href="http://www.rsa.com/rsalabs/pubs/PKCS/html/pkcs-1.html">PKCS #1 v2.1</a> * standard - * </p> - * - * @since Android 1.0 */ public class RSAPrivateKeySpec implements KeySpec { // Modulus @@ -43,7 +40,6 @@ public class RSAPrivateKeySpec implements KeySpec { * the modulus {@code n}. * @param privateExponent * the private exponent {@code e} - * @since Android 1.0 */ public RSAPrivateKeySpec(BigInteger modulus, BigInteger privateExponent) { this.modulus = modulus; @@ -54,7 +50,6 @@ public class RSAPrivateKeySpec implements KeySpec { * Returns the modulus {@code n}. * * @return the modulus {@code n}. - * @since Android 1.0 */ public BigInteger getModulus() { return modulus; @@ -64,7 +59,6 @@ public class RSAPrivateKeySpec implements KeySpec { * Returns the private exponent {@code e}. * * @return the private exponent {@code e}. - * @since Android 1.0 */ public BigInteger getPrivateExponent() { return privateExponent; diff --git a/security/src/main/java/java/security/spec/RSAPublicKeySpec.java b/security/src/main/java/java/security/spec/RSAPublicKeySpec.java index bd4c5b5..fe6de07 100644 --- a/security/src/main/java/java/security/spec/RSAPublicKeySpec.java +++ b/security/src/main/java/java/security/spec/RSAPublicKeySpec.java @@ -25,8 +25,6 @@ import java.math.BigInteger; * Defined in the <a * href="http://www.rsa.com/rsalabs/pubs/PKCS/html/pkcs-1.html">PKCS #1 v2.1</a> * standard. - * </p> - * @since Android 1.0 */ public class RSAPublicKeySpec implements KeySpec { // Modulus @@ -42,7 +40,6 @@ public class RSAPublicKeySpec implements KeySpec { * the modulus {@code n}. * @param publicExponent * the public exponent {@code d}. - * @since Android 1.0 */ public RSAPublicKeySpec(BigInteger modulus, BigInteger publicExponent) { this.modulus = modulus; @@ -53,7 +50,6 @@ public class RSAPublicKeySpec implements KeySpec { * Returns the modulus {@code n}. * * @return the modulus {@code n}. - * @since Android 1.0 */ public BigInteger getModulus() { return modulus; @@ -63,7 +59,6 @@ public class RSAPublicKeySpec implements KeySpec { * Returns the public exponent {@code d}. * * @return the public exponent {@code d}. - * @since Android 1.0 */ public BigInteger getPublicExponent() { return publicExponent; diff --git a/security/src/main/java/java/security/spec/X509EncodedKeySpec.java b/security/src/main/java/java/security/spec/X509EncodedKeySpec.java index 6cc6104..61f3475 100644 --- a/security/src/main/java/java/security/spec/X509EncodedKeySpec.java +++ b/security/src/main/java/java/security/spec/X509EncodedKeySpec.java @@ -19,8 +19,6 @@ package java.security.spec; /** * The key specification of an X.509 encoded key in ASN.1 format. - * - * @since Android 1.0 */ public class X509EncodedKeySpec extends EncodedKeySpec { @@ -30,7 +28,6 @@ public class X509EncodedKeySpec extends EncodedKeySpec { * * @param encodedKey * the encoded key bytes. - * @since Android 1.0 */ public X509EncodedKeySpec(byte[] encodedKey) { // Super class' ctor makes defensive parameter copy @@ -41,7 +38,6 @@ public class X509EncodedKeySpec extends EncodedKeySpec { * Returns the encoded key bytes. * * @return the encoded key bytes. - * @since Android 1.0 */ public byte[] getEncoded() { // Super class' getEncoded() always returns a new array @@ -53,7 +49,6 @@ public class X509EncodedKeySpec extends EncodedKeySpec { * specification. * * @return the string "X.509". - * @since Android 1.0 */ public final String getFormat() { return "X.509"; //$NON-NLS-1$ diff --git a/security/src/main/java/javax/security/cert/Certificate.java b/security/src/main/java/javax/security/cert/Certificate.java index fb00789..ef513a3 100644 --- a/security/src/main/java/javax/security/cert/Certificate.java +++ b/security/src/main/java/javax/security/cert/Certificate.java @@ -29,34 +29,30 @@ import javax.security.cert.CertificateException; /** * Abstract class to represent identity certificates. It represents a way to * verify the binding of a Principal and its public key. Examples are X.509, - * PGP, and SDSI. + * PGP, and SDSI. * <p> * Note: This package is provided only for compatibility reasons. * It contains a simplified version of the java.security.cert package that was * previously used by JSSE (Java SSL package). All applications that do not have * to be compatible with older versions of JSSE (that is before Java SDK 1.5) * should only use java.security.cert. - * </p> - * @since Android 1.0 */ public abstract class Certificate { /** * Creates a new {@code Certificate}. - * @since Android 1.0 */ public Certificate() {} /** * Compares the argument to this Certificate. If both have the same bytes * they are assumed to be equal. - * + * * @param obj * the {@code Certificate} to compare with this object * @return <code>true</code> if {@code obj} is the same as this * {@code Certificate}, <code>false</code> otherwise * @see #hashCode - * @since Android 1.0 */ public boolean equals(Object obj) { if (obj == this) { @@ -77,10 +73,9 @@ public abstract class Certificate { * Returns an integer hash code for the receiver. Any two objects which * return <code>true</code> when passed to <code>equals</code> must answer * the same value for this method. - * + * * @return the receiver's hash * @see #equals - * @since Android 1.0 */ public int hashCode() { int res = 0; @@ -96,18 +91,17 @@ public abstract class Certificate { /** * Returns the encoded representation for this certificate. - * + * * @return the encoded representation for this certificate. * @throws CertificateEncodingException * if encoding fails. - * @since Android 1.0 */ public abstract byte[] getEncoded() throws CertificateEncodingException; /** * Verifies that this certificate was signed with the given public key. - * + * * @param key * public key for which verification should be performed. * @throws CertificateException @@ -120,7 +114,6 @@ public abstract class Certificate { * if there is no default provider * @throws SignatureException * if signature errors are detected - * @since Android 1.0 */ public abstract void verify(PublicKey key) throws CertificateException, NoSuchAlgorithmException, @@ -130,7 +123,7 @@ public abstract class Certificate { /** * Verifies that this certificate was signed with the given public key. Uses * the signature algorithm given by the provider. - * + * * @param key * public key for which verification should be performed. * @param sigProvider @@ -145,7 +138,6 @@ public abstract class Certificate { * if the specified provider does not exists. * @exception SignatureException * if signature errors are detected - * @since Android 1.0 */ public abstract void verify(PublicKey key, String sigProvider) throws CertificateException, NoSuchAlgorithmException, @@ -155,17 +147,15 @@ public abstract class Certificate { /** * Returns a string containing a concise, human-readable description of the * receiver. - * + * * @return a printable representation for the receiver. - * @since Android 1.0 */ public abstract String toString(); /** * Returns the public key corresponding to this certificate. - * + * * @return the public key corresponding to this certificate. - * @since Android 1.0 */ public abstract PublicKey getPublicKey(); } diff --git a/security/src/main/java/javax/security/cert/CertificateEncodingException.java b/security/src/main/java/javax/security/cert/CertificateEncodingException.java index 4091695..780e43f 100644 --- a/security/src/main/java/javax/security/cert/CertificateEncodingException.java +++ b/security/src/main/java/javax/security/cert/CertificateEncodingException.java @@ -27,20 +27,20 @@ package javax.security.cert; * by JSSE (Java SSL package). All applications that do not have to be * compatible with older versions of JSSE (that is before Java SDK 1.5) should * only use java.security.cert. - * </p> - * @since Android 1.0 */ public class CertificateEncodingException extends CertificateException { + /** + * @serial + */ private static final long serialVersionUID = -8187642723048403470L; /** * Creates a new {@code CertificateEncodingException} with the specified * message. - * + * * @param msg * the detail message for the exception. - * @since Android 1.0 */ public CertificateEncodingException(String msg) { super(msg); @@ -48,9 +48,7 @@ public class CertificateEncodingException extends CertificateException { /** * Creates a new {@code CertificateEncodingException}. - * - * @since Android 1.0 */ public CertificateEncodingException() { } -}
\ No newline at end of file +} diff --git a/security/src/main/java/javax/security/cert/CertificateException.java b/security/src/main/java/javax/security/cert/CertificateException.java index f186e51..fd2a614 100644 --- a/security/src/main/java/javax/security/cert/CertificateException.java +++ b/security/src/main/java/javax/security/cert/CertificateException.java @@ -26,19 +26,19 @@ package javax.security.cert; * by JSSE (Java SSL package). All applications that do not have to be * compatible with older versions of JSSE (that is before Java SDK 1.5) should * only use java.security.cert. - * </p> - * @since Android 1.0 */ public class CertificateException extends Exception { + /** + * @serial + */ private static final long serialVersionUID = -5757213374030785290L; /** * Creates a new {@code CertificateException} with the specified message. - * + * * @param msg * the detail message for the exception. - * @since Android 1.0 */ public CertificateException(String msg) { super(msg); @@ -46,9 +46,7 @@ public class CertificateException extends Exception { /** * Creates a new {@code CertificateException}. - * - * @since Android 1.0 */ public CertificateException() { } -}
\ No newline at end of file +} diff --git a/security/src/main/java/javax/security/cert/CertificateExpiredException.java b/security/src/main/java/javax/security/cert/CertificateExpiredException.java index 62870a6..94e6558 100644 --- a/security/src/main/java/javax/security/cert/CertificateExpiredException.java +++ b/security/src/main/java/javax/security/cert/CertificateExpiredException.java @@ -25,20 +25,20 @@ package javax.security.cert; * by JSSE (Java SSL package). All applications that do not have to be * compatible with older versions of JSSE (that is before Java SDK 1.5) should * only use java.security.cert. - * </p> - * @since Android 1.0 */ public class CertificateExpiredException extends CertificateException { + /** + * @serial + */ private static final long serialVersionUID = 5091601212177261883L; /** * Creates a new {@code CertificateExpiredException} with the specified * message. - * + * * @param msg * the detail message for this exception - * @since Android 1.0 */ public CertificateExpiredException(String msg) { super(msg); @@ -46,9 +46,7 @@ public class CertificateExpiredException extends CertificateException { /** * Creates a new {@code CertificateExpiredException}. - * - * @since Android 1.0 */ public CertificateExpiredException() { } -}
\ No newline at end of file +} diff --git a/security/src/main/java/javax/security/cert/CertificateNotYetValidException.java b/security/src/main/java/javax/security/cert/CertificateNotYetValidException.java index 6f32945..8fe0a33 100644 --- a/security/src/main/java/javax/security/cert/CertificateNotYetValidException.java +++ b/security/src/main/java/javax/security/cert/CertificateNotYetValidException.java @@ -25,20 +25,20 @@ package javax.security.cert; * by JSSE (Java SSL package). All applications that do not have to be * compatible with older versions of JSSE (that is before Java SDK 1.5) should * only use java.security.cert. - * </p> - * @since Android 1.0 */ public class CertificateNotYetValidException extends CertificateException { + /** + * @serial + */ private static final long serialVersionUID = -8976172474266822818L; /** * Creates a new {@code CertificateNotYetValidException} with the specified * message. - * + * * @param msg * the detail message for the exception. - * @since Android 1.0 */ public CertificateNotYetValidException(String msg) { super(msg); @@ -46,9 +46,7 @@ public class CertificateNotYetValidException extends CertificateException { /** * Creates a new {@code CertificateNotYetValidException}. - * - * @since Android 1.0 */ public CertificateNotYetValidException() { } -}
\ No newline at end of file +} diff --git a/security/src/main/java/javax/security/cert/CertificateParsingException.java b/security/src/main/java/javax/security/cert/CertificateParsingException.java index 9b208e6..48986c0 100644 --- a/security/src/main/java/javax/security/cert/CertificateParsingException.java +++ b/security/src/main/java/javax/security/cert/CertificateParsingException.java @@ -25,20 +25,20 @@ package javax.security.cert; * by JSSE (Java SSL package). All applications that do not have to be * compatible with older versions of JSSE (that is before Java SDK 1.5) should * only use java.security.cert. - * </p> - * @since Android 1.0 */ public class CertificateParsingException extends CertificateException { + /** + * @serial + */ private static final long serialVersionUID = -8449352422951136229L; /** * Creates a new {@code CertificateParsingException} with the specified * message. - * + * * @param msg * the detail message for the exception. - * @since Android 1.0 */ public CertificateParsingException(String msg) { super(msg); @@ -46,9 +46,7 @@ public class CertificateParsingException extends CertificateException { /** * Creates a new {@code CertificateParsingException}. - * - * @since Android 1.0 */ public CertificateParsingException() { } -}
\ No newline at end of file +} diff --git a/security/src/main/java/javax/security/cert/X509Certificate.java b/security/src/main/java/javax/security/cert/X509Certificate.java index 77bffae..8877386 100644 --- a/security/src/main/java/javax/security/cert/X509Certificate.java +++ b/security/src/main/java/javax/security/cert/X509Certificate.java @@ -44,15 +44,12 @@ import org.apache.harmony.security.internal.nls.Messages; * <p> * This represents a standard way for accessing the attributes of X.509 v1 * certificates. - * </p> * <p> * Note: This package is provided only for compatibility reasons. * It contains a simplified version of the java.security.cert package that was * previously used by JSSE (Java SSL package). All applications that do not have * to be compatible with older versions of JSSE (that is before Java SDK 1.5) * should only use java.security.cert. - * </p> - * @since Android 1.0 */ public abstract class X509Certificate extends Certificate { @@ -76,8 +73,6 @@ public abstract class X509Certificate extends Certificate { /** * Creates a new {@code X509Certificate}. - * - * @since Android 1.0 */ public X509Certificate() { super(); @@ -86,13 +81,12 @@ public abstract class X509Certificate extends Certificate { /** * Creates a new {@code X509Certificate} and initializes it from the * specified input stream. - * + * * @param inStream * input stream containing data to initialize the certificate. * @return the certificate initialized from the specified input stream * @throws CertificateException * if the certificate cannot be created or initialized. - * @since Android 1.0 */ public static final X509Certificate getInstance(InputStream inStream) throws CertificateException { @@ -220,13 +214,12 @@ public abstract class X509Certificate extends Certificate { /** * Creates a new {@code X509Certificate} and initializes it from the * specified byte array. - * + * * @param certData * byte array containing data to initialize the certificate. * @return the certificate initialized from the specified byte array * @throws CertificateException * if the certificate cannot be created or initialized. - * @since Android 1.0 */ public static final X509Certificate getInstance(byte[] certData) throws CertificateException { @@ -241,26 +234,23 @@ public abstract class X509Certificate extends Certificate { * Checks whether the certificate is currently valid. * <p> * The validity defined in ASN.1: - * + * * <pre> * validity Validity - * - * Validity ::= SEQUENCE { - * notBefore CertificateValidityDate, + * + * Validity ::= SEQUENCE { + * notBefore CertificateValidityDate, * notAfter CertificateValidityDate } - * - * CertificateValidityDate ::= CHOICE { - * utcTime UTCTime, + * + * CertificateValidityDate ::= CHOICE { + * utcTime UTCTime, * generalTime GeneralizedTime } * </pre> - * - * </p> - * + * * @throws CertificateExpiredException * if the certificate has expired. * @throws CertificateNotYetValidException * if the certificate is not yet valid. - * @since Android 1.0 */ public abstract void checkValidity() throws CertificateExpiredException, CertificateNotYetValidException; @@ -268,7 +258,7 @@ public abstract class X509Certificate extends Certificate { /** * Checks whether the certificate is valid at the specified date. - * + * * @param date * the date to check the validity against. * @throws CertificateExpiredException @@ -276,7 +266,6 @@ public abstract class X509Certificate extends Certificate { * @throws CertificateNotYetValidException * if the certificate is not yet valid. * @see #checkValidity() - * @since Android 1.0 */ public abstract void checkValidity(Date date) throws CertificateExpiredException, CertificateNotYetValidException; @@ -285,15 +274,12 @@ public abstract class X509Certificate extends Certificate { * Returns the certificates {@code version} (version number). * <p> * The version defined is ASN.1: - * + * * <pre> * Version ::= INTEGER { v1(0), v2(1), v3(2) } * </pre> - * - * </p> - * + * * @return the version number. - * @since Android 1.0 */ public abstract int getVersion(); @@ -301,15 +287,12 @@ public abstract class X509Certificate extends Certificate { * Returns the {@code serialNumber} of the certificate. * <p> * The ASN.1 definition of {@code serialNumber}: - * + * * <pre> * CertificateSerialNumber ::= INTEGER * </pre> - * - * </p> - * + * * @return the serial number. - * @since Android 1.0 */ public abstract BigInteger getSerialNumber(); @@ -318,31 +301,28 @@ public abstract class X509Certificate extends Certificate { * implementation specific {@code Principal} object. * <p> * The ASN.1 definition of {@code issuer}: - * + * * <pre> * issuer Name - * + * * Name ::= CHOICE { * RDNSequence } - * + * * RDNSequence ::= SEQUENCE OF RelativeDistinguishedName - * + * * RelativeDistinguishedName ::= SET OF AttributeTypeAndValue - * + * * AttributeTypeAndValue ::= SEQUENCE { * type AttributeType, * value AttributeValue } - * + * * AttributeType ::= OBJECT IDENTIFIER - * + * * AttributeValue ::= ANY DEFINED BY AttributeType * </pre> - * - * </p> - * + * * @return the {@code issuer} as an implementation specific {@code * Principal}. - * @since Android 1.0 */ public abstract Principal getIssuerDN(); @@ -351,73 +331,65 @@ public abstract class X509Certificate extends Certificate { * implementation specific {@code Principal} object. * <p> * The ASN.1 definition of {@code subject}: - * + * * <pre> * subject Name - * + * * Name ::= CHOICE { * RDNSequence } - * + * * RDNSequence ::= SEQUENCE OF RelativeDistinguishedName - * + * * RelativeDistinguishedName ::= SET OF AttributeTypeAndValue - * + * * AttributeTypeAndValue ::= SEQUENCE { * type AttributeType, * value AttributeValue } - * + * * AttributeType ::= OBJECT IDENTIFIER - * + * * AttributeValue ::= ANY DEFINED BY AttributeType * </pre> - * - * </p> - * + * * @return the {@code subject} (subject distinguished name). - * @since Android 1.0 */ public abstract Principal getSubjectDN(); /** * Returns the {@code notBefore} date from the validity period of the * certificate. - * + * * @return the start of the validity period. - * @since Android 1.0 */ public abstract Date getNotBefore(); /** * Returns the {@code notAfter} date of the validity period of the * certificate. - * + * * @return the end of the validity period. - * @since Android 1.0 */ public abstract Date getNotAfter(); /** * Returns the name of the algorithm for the certificate signature. - * + * * @return the signature algorithm name. - * @since Android 1.0 */ public abstract String getSigAlgName(); /** * Returns the OID of the signature algorithm from the certificate. - * + * * @return the OID of the signature algorithm. - * @since Android 1.0 */ public abstract String getSigAlgOID(); /** * Returns the parameters of the signature algorithm in DER-encoded format. - * + * * @return the parameters of the signature algorithm, or null if none are * used. - * @since Android 1.0 */ public abstract byte[] getSigAlgParams(); } diff --git a/security/src/main/java/org/apache/harmony/security/DefaultPolicyScanner.java b/security/src/main/java/org/apache/harmony/security/DefaultPolicyScanner.java index ba3229b..afab96e 100644 --- a/security/src/main/java/org/apache/harmony/security/DefaultPolicyScanner.java +++ b/security/src/main/java/org/apache/harmony/security/DefaultPolicyScanner.java @@ -127,9 +127,9 @@ public class DefaultPolicyScanner { break parsing; case StreamTokenizer.TT_WORD: - if ("keystore".equalsIgnoreCase(st.sval)) { //$NON-NLS-1$ + if (Util.equalsIgnoreCase("keystore", st.sval)) { //$NON-NLS-1$ keystoreEntries.add(readKeystoreEntry(st)); - } else if ("grant".equalsIgnoreCase(st.sval)) { //$NON-NLS-1$ + } else if (Util.equalsIgnoreCase("grant", st.sval)) { //$NON-NLS-1$ grantEntries.add(readGrantEntry(st)); } else { handleUnexpectedToken(st, Messages.getString("security.89")); //$NON-NLS-1$ @@ -208,19 +208,19 @@ public class DefaultPolicyScanner { switch (st.nextToken()) { case StreamTokenizer.TT_WORD: - if ("signedby".equalsIgnoreCase(st.sval)) { //$NON-NLS-1$ + if (Util.equalsIgnoreCase("signedby", st.sval)) { //$NON-NLS-1$ if (st.nextToken() == '"') { ge.signers = st.sval; } else { handleUnexpectedToken(st, Messages.getString("security.8B")); //$NON-NLS-1$ } - } else if ("codebase".equalsIgnoreCase(st.sval)) { //$NON-NLS-1$ + } else if (Util.equalsIgnoreCase("codebase", st.sval)) { //$NON-NLS-1$ if (st.nextToken() == '"') { ge.codebase = st.sval; } else { handleUnexpectedToken(st, Messages.getString("security.8C")); //$NON-NLS-1$ } - } else if ("principal".equalsIgnoreCase(st.sval)) { //$NON-NLS-1$ + } else if (Util.equalsIgnoreCase("principal", st.sval)) { //$NON-NLS-1$ ge.addPrincipal(readPrincipalEntry(st)); } else { handleUnexpectedToken(st); @@ -308,7 +308,7 @@ public class DefaultPolicyScanner { switch (st.nextToken()) { case StreamTokenizer.TT_WORD: - if ("permission".equalsIgnoreCase(st.sval)) { //$NON-NLS-1$ + if (Util.equalsIgnoreCase("permission", st.sval)) { //$NON-NLS-1$ PermissionEntry pe = new PermissionEntry(); if (st.nextToken() == StreamTokenizer.TT_WORD) { pe.klass = st.sval; @@ -326,7 +326,7 @@ public class DefaultPolicyScanner { } } if (st.ttype == StreamTokenizer.TT_WORD - && "signedby".equalsIgnoreCase(st.sval)) { //$NON-NLS-1$ + && Util.equalsIgnoreCase("signedby", st.sval)) { //$NON-NLS-1$ if (st.nextToken() == '"') { pe.signers = st.sval; } else { diff --git a/security/src/main/java/org/apache/harmony/security/PolicyEntry.java b/security/src/main/java/org/apache/harmony/security/PolicyEntry.java index 4c7aa5b..0037ad6 100644 --- a/security/src/main/java/org/apache/harmony/security/PolicyEntry.java +++ b/security/src/main/java/org/apache/harmony/security/PolicyEntry.java @@ -22,6 +22,8 @@ package org.apache.harmony.security; +import java.net.URL; +import java.security.CodeSigner; import java.security.CodeSource; import java.security.Permission; import java.security.Principal; @@ -30,7 +32,6 @@ import java.util.Collections; import org.apache.harmony.security.fortress.PolicyUtils; - /** * This class represents an elementary block of a security policy. It associates * a CodeSource of an executable code, Principals allowed to execute the code, @@ -55,7 +56,7 @@ public class PolicyEntry { */ public PolicyEntry(CodeSource cs, Collection<? extends Principal> prs, Collection<? extends Permission> permissions) { - this.cs = cs; + this.cs = (cs != null) ? normalizeCodeSource(cs) : null; this.principals = (prs == null || prs.isEmpty()) ? null : (Principal[]) prs.toArray(new Principal[prs.size()]); this.permissions = (permissions == null || permissions.isEmpty()) ? null @@ -68,7 +69,31 @@ public class PolicyEntry { * imply() method. */ public boolean impliesCodeSource(CodeSource codeSource) { - return (cs == null) ? true : cs.implies(codeSource); + if (cs == null) { + return true; + } + + if (codeSource == null) { + return false; + } + return cs.implies(normalizeCodeSource(codeSource)); + } + + private CodeSource normalizeCodeSource(CodeSource codeSource) { + URL codeSourceURL = PolicyUtils.normalizeURL(codeSource.getLocation()); + CodeSource result = codeSource; + + if (codeSourceURL != codeSource.getLocation()) { + // URL was normalized - recreate codeSource with new URL + CodeSigner[] signers = codeSource.getCodeSigners(); + if (signers == null) { + result = new CodeSource(codeSourceURL, codeSource + .getCertificates()); + } else { + result = new CodeSource(codeSourceURL, signers); + } + } + return result; } /** diff --git a/security/src/main/java/org/apache/harmony/security/Util.java b/security/src/main/java/org/apache/harmony/security/Util.java new file mode 100644 index 0000000..e6e764f --- /dev/null +++ b/security/src/main/java/org/apache/harmony/security/Util.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.harmony.security; + +public class Util { + + public static String toUpperCase(String s) { + return org.apache.harmony.luni.util.Util.toASCIIUpperCase(s); + } + + public static boolean equalsIgnoreCase(String s1, String s2) { + s1 = org.apache.harmony.luni.util.Util.toASCIIUpperCase(s1); + s2 = org.apache.harmony.luni.util.Util.toASCIIUpperCase(s2); + return s1.equals(s2); + } +} diff --git a/security/src/main/java/org/apache/harmony/security/asn1/ASN1Choice.java b/security/src/main/java/org/apache/harmony/security/asn1/ASN1Choice.java index 1f5534d..e8db789 100644 --- a/security/src/main/java/org/apache/harmony/security/asn1/ASN1Choice.java +++ b/security/src/main/java/org/apache/harmony/security/asn1/ASN1Choice.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.math.BigInteger; import java.util.Arrays; import java.util.Iterator; +import java.util.Map; import java.util.TreeMap; import org.apache.harmony.security.internal.nls.Messages; @@ -269,12 +270,14 @@ public abstract class ASN1Choice extends ASN1Type { // fill identifiers array int size = map.size(); identifiers = new int[2][size]; - Iterator it = map.keySet().iterator(); + Iterator it = map.entrySet().iterator(); + for (int i = 0; i < size; i++) { - BigInteger identifier = (BigInteger) it.next(); + Map.Entry entry = (Map.Entry) it.next(); + BigInteger identifier = (BigInteger) entry.getKey(); identifiers[0][i] = identifier.intValue(); - identifiers[1][i] = ((BigInteger) map.get(identifier)).intValue(); + identifiers[1][i] = ((BigInteger) entry.getValue()).intValue(); } this.type = type; diff --git a/security/src/main/java/org/apache/harmony/security/asn1/ASN1GeneralizedTime.java b/security/src/main/java/org/apache/harmony/security/asn1/ASN1GeneralizedTime.java index 4ec103b..4908afb 100644 --- a/security/src/main/java/org/apache/harmony/security/asn1/ASN1GeneralizedTime.java +++ b/security/src/main/java/org/apache/harmony/security/asn1/ASN1GeneralizedTime.java @@ -23,6 +23,7 @@ package org.apache.harmony.security.asn1; import java.io.IOException; +import java.io.UnsupportedEncodingException; import java.text.SimpleDateFormat; import java.util.TimeZone; @@ -30,10 +31,7 @@ import java.util.TimeZone; /** * This class represents ASN.1 GeneralizedTime type. * - * According to X.680 specification this type is defined as follows: - * GeneralizedTime ::= [UNIVERSAL 24] IMPLICIT VisibleString - * - * @see <a href="http://asn1.elibel.tm.fr/en/standards/index.htm">ASN.1</a> + * @see http://asn1.elibel.tm.fr/en/standards/index.htm */ public class ASN1GeneralizedTime extends ASN1Time { @@ -114,7 +112,13 @@ public class ASN1GeneralizedTime extends ASN1Time { if (temp.charAt(currLength) == '.') { temp = temp.substring(0, currLength); } - out.content = (temp + "Z").getBytes(); //$NON-NLS-1$ + + try { + out.content = (temp + "Z").getBytes("UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$ + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e.getMessage()); + } + out.length = ((byte[]) out.content).length; } } diff --git a/security/src/main/java/org/apache/harmony/security/asn1/ASN1Oid.java b/security/src/main/java/org/apache/harmony/security/asn1/ASN1Oid.java index 6292870..960dc0f 100644 --- a/security/src/main/java/org/apache/harmony/security/asn1/ASN1Oid.java +++ b/security/src/main/java/org/apache/harmony/security/asn1/ASN1Oid.java @@ -154,7 +154,7 @@ public class ASN1Oid extends ASN1Primitive { public Object getDecodedObject(BerInputStream in) throws IOException { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); int element; diff --git a/security/src/main/java/org/apache/harmony/security/asn1/ASN1StringType.java b/security/src/main/java/org/apache/harmony/security/asn1/ASN1StringType.java index 55f48fa..0bc4b8a 100644 --- a/security/src/main/java/org/apache/harmony/security/asn1/ASN1StringType.java +++ b/security/src/main/java/org/apache/harmony/security/asn1/ASN1StringType.java @@ -118,7 +118,9 @@ public abstract class ASN1StringType extends ASN1Type { * @return java.land.String object */ public Object getDecodedObject(BerInputStream in) throws IOException { - return new String(in.buffer, in.contentOffset, in.length); + /* To ensure we get the correct encoding on non-ASCII platforms, specify + that we wish to convert from ASCII to the default platform encoding */ + return new String(in.buffer, in.contentOffset, in.length, "ISO-8859-1"); } // @@ -137,11 +139,15 @@ public abstract class ASN1StringType extends ASN1Type { } public void setEncodingContent(BerOutputStream out) { - - byte[] bytes = ((String) out.content).getBytes(); - - out.content = bytes; - out.length = bytes.length; + try { + byte[] bytes = ((String) out.content).getBytes("UTF-8"); //$NON-NLS-1$ + out.content = bytes; + out.length = bytes.length; + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e.getMessage()); + } } } + + diff --git a/security/src/main/java/org/apache/harmony/security/asn1/ASN1UTCTime.java b/security/src/main/java/org/apache/harmony/security/asn1/ASN1UTCTime.java index 0dd7ae4..3d2cb3e 100644 --- a/security/src/main/java/org/apache/harmony/security/asn1/ASN1UTCTime.java +++ b/security/src/main/java/org/apache/harmony/security/asn1/ASN1UTCTime.java @@ -23,6 +23,7 @@ package org.apache.harmony.security.asn1; import java.io.IOException; +import java.io.UnsupportedEncodingException; import java.text.SimpleDateFormat; import java.util.TimeZone; @@ -30,10 +31,7 @@ import java.util.TimeZone; /** * This class represents ASN.1 UTCTime type * - * According to X.680 specification this type is defined as follows: - * UTCTime ::= [UNIVERSAL 23] IMPLICIT VisibleString - * - * @see <a href="http://asn1.elibel.tm.fr/en/standards/index.htm">ASN.1</a> + * @see http://asn1.elibel.tm.fr/en/standards/index.htm */ public class ASN1UTCTime extends ASN1Time { @@ -118,7 +116,11 @@ public class ASN1UTCTime extends ASN1Time { public void setEncodingContent(BerOutputStream out) { SimpleDateFormat sdf = new SimpleDateFormat(UTC_PATTERN); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); //$NON-NLS-1$ - out.content = sdf.format(out.content).getBytes(); + try { + out.content = sdf.format(out.content).getBytes("UTF-8"); //$NON-NLS-1$ + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e.getMessage()); + } out.length = ((byte[]) out.content).length; } } diff --git a/security/src/main/java/org/apache/harmony/security/asn1/BerInputStream.java b/security/src/main/java/org/apache/harmony/security/asn1/BerInputStream.java index 68819b8..531d760 100644 --- a/security/src/main/java/org/apache/harmony/security/asn1/BerInputStream.java +++ b/security/src/main/java/org/apache/harmony/security/asn1/BerInputStream.java @@ -25,7 +25,6 @@ package org.apache.harmony.security.asn1; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; -import java.util.Calendar; import org.apache.harmony.security.internal.nls.Messages; @@ -132,8 +131,8 @@ public class BerInputStream { if (length != INDEFINIT_LENGTH) { // input stream has definite length encoding // check allocated length to avoid further reallocations - if (buffer.length < length) { - byte[] newBuffer = new byte[length]; + if (buffer.length < (length + offset)) { + byte[] newBuffer = new byte[length + offset]; System.arraycopy(buffer, 0, newBuffer, 0, offset); buffer = newBuffer; } @@ -916,9 +915,22 @@ public class BerInputStream { if (in == null) { offset += length; } else { - if (in.read(buffer, offset, length) != length) { - throw new ASN1Exception(Messages.getString("security.13C")); //$NON-NLS-1$ + int bytesRead = in.read(buffer, offset, length); + + if (bytesRead != length) { + // if input stream didn't return all data at once + // try to read it in several blocks + int c = bytesRead; + do { + if (c < 1 || bytesRead > length) { + throw new ASN1Exception(Messages + .getString("security.13C")); //$NON-NLS-1$ + } + c = in.read(buffer, offset + bytesRead, length - bytesRead); + bytesRead += c; + } while (bytesRead != length); } + offset += length; } } diff --git a/security/src/main/java/org/apache/harmony/security/asn1/InformationObjectSet.java b/security/src/main/java/org/apache/harmony/security/asn1/InformationObjectSet.java index 2a267e5..06ada53 100644 --- a/security/src/main/java/org/apache/harmony/security/asn1/InformationObjectSet.java +++ b/security/src/main/java/org/apache/harmony/security/asn1/InformationObjectSet.java @@ -95,7 +95,7 @@ public class InformationObjectSet { return intHash & 0x7FFFFFFF; // only positive } - private class Entry { + private static class Entry { public int[] oid; public Object object; diff --git a/security/src/main/java/org/apache/harmony/security/asn1/ObjectIdentifier.java b/security/src/main/java/org/apache/harmony/security/asn1/ObjectIdentifier.java index 0e7269a..0d3a77a 100644 --- a/security/src/main/java/org/apache/harmony/security/asn1/ObjectIdentifier.java +++ b/security/src/main/java/org/apache/harmony/security/asn1/ObjectIdentifier.java @@ -243,7 +243,7 @@ public final class ObjectIdentifier { * @return oid string representation */ public static String toString(int[] oid) { - StringBuffer sb = new StringBuffer(3 * oid.length); + StringBuilder sb = new StringBuilder(3 * oid.length); for (int i = 0; i < oid.length - 1; ++i) { sb.append(oid[i]); diff --git a/security/src/main/java/org/apache/harmony/security/fortress/DefaultPolicy.java b/security/src/main/java/org/apache/harmony/security/fortress/DefaultPolicy.java index 2aa474e..df425a4 100644 --- a/security/src/main/java/org/apache/harmony/security/fortress/DefaultPolicy.java +++ b/security/src/main/java/org/apache/harmony/security/fortress/DefaultPolicy.java @@ -163,7 +163,7 @@ public class DefaultPolicy extends Policy { // A flag indicating brand new instance which needs to be loaded // on the first appeal to it's data. - private boolean initiailized; + private boolean initialized; /** * Default constructor, equivalent to @@ -180,7 +180,7 @@ public class DefaultPolicy extends Policy { */ public DefaultPolicy(DefaultPolicyParser dpr) { parser = dpr; - initiailized = false; + initialized = false; refresh(); } @@ -191,9 +191,9 @@ public class DefaultPolicy extends Policy { * to be <code>null</code> if the domain is <code>null</code>. */ public PermissionCollection getPermissions(ProtectionDomain pd) { - if (!initiailized) { + if (!initialized) { synchronized (this) { - if (!initiailized) { + if (!initialized) { refresh(); } } @@ -230,9 +230,9 @@ public class DefaultPolicy extends Policy { * The evaluation assumes that current principals are undefined. */ public PermissionCollection getPermissions(CodeSource cs) { - if (!initiailized) { + if (!initialized) { synchronized (this) { - if (!initiailized) { + if (!initialized) { refresh(); } } @@ -306,6 +306,6 @@ public class DefaultPolicy extends Policy { cache.clear(); } - initiailized = true; + initialized = true; } } diff --git a/security/src/main/java/org/apache/harmony/security/fortress/DefaultPolicyParser.java b/security/src/main/java/org/apache/harmony/security/fortress/DefaultPolicyParser.java index fafa66c..c809fe4 100644 --- a/security/src/main/java/org/apache/harmony/security/fortress/DefaultPolicyParser.java +++ b/security/src/main/java/org/apache/harmony/security/fortress/DefaultPolicyParser.java @@ -25,7 +25,6 @@ package org.apache.harmony.security.fortress; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.File; import java.io.Reader; import java.net.URL; import java.security.cert.Certificate; @@ -62,8 +61,7 @@ import org.apache.harmony.security.internal.nls.Messages; * a pluggable scanner and converts received tokens to a set of * {@link org.apache.harmony.security.PolicyEntry PolicyEntries}. * For details of policy format, see the - * {@link org.apache.harmony.security.fortress.DefaultPolicy default policy - * description}. + * {@link org.apache.harmony.security.DefaultPolicy default policy description}. * <br> * For ordinary uses, this class has just one public method <code>parse()</code>, * which performs the main task. @@ -73,7 +71,7 @@ import org.apache.harmony.security.internal.nls.Messages; * This implementation is effectively thread-safe, as it has no field references * to data being processed (that is, passes all the data as method parameters). * - * @see org.apache.harmony.security.fortress.DefaultPolicy + * @see org.apache.harmony.security.DefaultPolicy * @see org.apache.harmony.security.DefaultPolicyScanner * @see org.apache.harmony.security.PolicyEntry */ @@ -188,7 +186,7 @@ public class DefaultPolicyParser { * of the GrantEntry * @see DefaultPolicyScanner.PrincipalEntry * @see DefaultPolicyScanner.PermissionEntry - * @see org.apache.harmony.security.fortress.PolicyUtils + * @see org.apache.harmony.security.PolicyUtils */ protected PolicyEntry resolveGrant(DefaultPolicyScanner.GrantEntry ge, KeyStore ks, Properties system, boolean resolve) throws Exception { @@ -200,14 +198,6 @@ public class DefaultPolicyParser { if (ge.codebase != null) { codebase = new URL(resolve ? PolicyUtils.expandURL(ge.codebase, system) : ge.codebase); - //Fix HARMONY-1963 - if ("file".equals(codebase.getProtocol())) { //$NON-NLS-1$ - File codeFile = new File(codebase.getFile()); - if (codeFile.isAbsolute()) { - codebase = new URL("file://" + //$NON-NLS-1$ - codeFile.getAbsolutePath()); - } - } } if (ge.signers != null) { if (resolve) { @@ -342,7 +332,7 @@ public class DefaultPolicyParser { if ("self".equals(protocol)) { //$NON-NLS-1$ //need expanding to list of principals in grant clause if (ge.principals != null && ge.principals.size() != 0) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (Iterator<PrincipalEntry> iter = ge.principals.iterator(); iter .hasNext();) { DefaultPolicyScanner.PrincipalEntry pr = iter @@ -385,7 +375,7 @@ public class DefaultPolicyParser { private String pc2str(Principal pc) { String klass = pc.getClass().getName(); String name = pc.getName(); - StringBuffer sb = new StringBuffer(klass.length() + name.length() + StringBuilder sb = new StringBuilder(klass.length() + name.length() + 5); return sb.append(klass).append(" \"").append(name).append("\"") //$NON-NLS-1$ //$NON-NLS-2$ .toString(); diff --git a/security/src/main/java/org/apache/harmony/security/fortress/Engine.java b/security/src/main/java/org/apache/harmony/security/fortress/Engine.java index 3b6f5d5..19fed41 100644 --- a/security/src/main/java/org/apache/harmony/security/fortress/Engine.java +++ b/security/src/main/java/org/apache/harmony/security/fortress/Engine.java @@ -25,6 +25,7 @@ package org.apache.harmony.security.fortress; import java.security.NoSuchAlgorithmException; import java.security.Provider; +import org.apache.harmony.security.Util; import org.apache.harmony.security.internal.nls.Messages; @@ -89,7 +90,7 @@ public class Engine { } Services.refresh(); if (returnedService != null - && algorithm.equalsIgnoreCase(lastAlgorithm) + && Util.equalsIgnoreCase(algorithm, lastAlgorithm) && refreshNumber == Services.refreshNumber) { serv = returnedService; } else { @@ -97,9 +98,9 @@ public class Engine { throw new NoSuchAlgorithmException(Messages.getString("security.14A", //$NON-NLS-1$ serviceName, algorithm)); } - serv = Services.getService(new StringBuffer(128) + serv = Services.getService(new StringBuilder(128) .append(serviceName).append(".").append( //$NON-NLS-1$ - algorithm.toUpperCase()).toString()); + Util.toUpperCase(algorithm)).toString()); if (serv == null) { throw new NoSuchAlgorithmException(Messages.getString("security.14A", //$NON-NLS-1$ serviceName, algorithm)); diff --git a/security/src/main/java/org/apache/harmony/security/fortress/PolicyUtils.java b/security/src/main/java/org/apache/harmony/security/fortress/PolicyUtils.java index eda7327..b4e0e6a 100644 --- a/security/src/main/java/org/apache/harmony/security/fortress/PolicyUtils.java +++ b/security/src/main/java/org/apache/harmony/security/fortress/PolicyUtils.java @@ -25,6 +25,8 @@ package org.apache.harmony.security.fortress; import java.io.File; import java.io.InputStream; import java.lang.reflect.Constructor; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.security.AccessController; import java.security.Permission; @@ -39,6 +41,7 @@ import java.util.Iterator; import java.util.List; import java.util.Properties; +import org.apache.harmony.security.Util; import org.apache.harmony.security.internal.nls.Messages; /** @@ -282,6 +285,56 @@ public class PolicyUtils { throws ExpansionFailedException { return expand(str, properties).replace(File.separatorChar, '/'); } + + /** + * Normalizes URLs to standard ones, eliminating pathname symbols. + * + * @param codebase - + * the original URL. + * @return - the normalized URL. + */ + public static URL normalizeURL(URL codebase) { + if (codebase != null && "file".equals(codebase.getProtocol())) { //$NON-NLS-1$ + try { + if (codebase.getHost().length() == 0) { + String path = codebase.getFile(); + + if (path.length() == 0) { + // codebase is "file:" + path = "*"; + } + return filePathToURI(new File(path) + .getAbsolutePath()).normalize().toURL(); + } else { + // codebase is "file://<smth>" + return codebase.toURI().normalize().toURL(); + } + } catch (Exception e) { + // Ignore + } + } + return codebase; + } + + /** + * Converts a file path to URI without accessing file system + * (like {File#toURI()} does). + * + * @param path - + * file path. + * @return - the resulting URI. + * @throw URISyntaxException + */ + public static URI filePathToURI(String path) throws URISyntaxException { + path = path.replace(File.separatorChar, '/'); + + if (!path.startsWith("/")) { //$NON-NLS-1$ + return new URI("file", null, //$NON-NLS-1$ + new StringBuilder(path.length() + 1).append('/') + .append(path).toString(), null, null); + } + return new URI("file", null, path, null, null); //$NON-NLS-1$ + } /** * Instances of this interface are intended for resolving @@ -371,7 +424,7 @@ public class PolicyUtils { * @see #expand(String, Properties) */ public static boolean canExpandProperties() { - return !FALSE.equalsIgnoreCase(AccessController + return !Util.equalsIgnoreCase(FALSE,AccessController .doPrivileged(new SecurityPropertyAccessor(POLICY_EXPAND))); } @@ -417,7 +470,7 @@ public class PolicyUtils { URL dynamicURL = null; //first check if policy is set via system properties - if (!FALSE.equalsIgnoreCase(AccessController + if (!Util.equalsIgnoreCase(FALSE, AccessController .doPrivileged(security.key(POLICY_ALLOW_DYNAMIC)))) { String location = system.getProperty(systemUrlKey); if (location != null) { diff --git a/security/src/main/java/org/apache/harmony/security/fortress/Services.java b/security/src/main/java/org/apache/harmony/security/fortress/Services.java index 300854a..60d9edd 100644 --- a/security/src/main/java/org/apache/harmony/security/fortress/Services.java +++ b/security/src/main/java/org/apache/harmony/security/fortress/Services.java @@ -33,6 +33,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.apache.harmony.security.Util; + /** * This class contains information about all registered providers and preferred @@ -56,7 +58,7 @@ public class Services { /** * Refresh number */ - public static int refreshNumber = 1; + static int refreshNumber = 1; // Registered providers private static final List<Provider> providers = new ArrayList<Provider>(20); @@ -89,8 +91,10 @@ public class Services { providers.add(p); providersNames.put(p.getName(), p); initServiceInfo(p); - } catch (Exception e) { // ignore - } + } catch (ClassNotFoundException e) { // ignore Exceptions + } catch (IllegalAccessException e) { + } catch (InstantiationException e) { + } } Engine.door.renumProviders(); } @@ -166,21 +170,21 @@ public class Services { String key; String type; String alias; - StringBuffer sb = new StringBuffer(128); + StringBuilder sb = new StringBuilder(128); for (Iterator<Provider.Service> it1 = p.getServices().iterator(); it1.hasNext();) { serv = it1.next(); type = serv.getType(); sb.delete(0, sb.length()); key = sb.append(type).append(".").append( //$NON-NLS-1$ - serv.getAlgorithm().toUpperCase()).toString(); + Util.toUpperCase(serv.getAlgorithm())).toString(); if (!services.containsKey(key)) { services.put(key, serv); } for (Iterator<String> it2 = Engine.door.getAliases(serv); it2.hasNext();) { alias = it2.next(); sb.delete(0, sb.length()); - key = sb.append(type).append(".").append(alias.toUpperCase()) //$NON-NLS-1$ + key = sb.append(type).append(".").append(Util.toUpperCase(alias)) //$NON-NLS-1$ .toString(); if (!services.containsKey(key)) { services.put(key, serv); diff --git a/security/src/main/java/org/apache/harmony/security/pkcs10/CertificationRequestInfo.java b/security/src/main/java/org/apache/harmony/security/pkcs10/CertificationRequestInfo.java index 7c57e93..2f31131 100644 --- a/security/src/main/java/org/apache/harmony/security/pkcs10/CertificationRequestInfo.java +++ b/security/src/main/java/org/apache/harmony/security/pkcs10/CertificationRequestInfo.java @@ -115,7 +115,7 @@ public class CertificationRequestInfo { public String toString() { - StringBuffer res = new StringBuffer(); + StringBuilder res = new StringBuilder(); res.append("-- CertificationRequestInfo:"); //$NON-NLS-1$ res.append("\n version: "); //$NON-NLS-1$ res.append(version); diff --git a/security/src/main/java/org/apache/harmony/security/pkcs7/ContentInfo.java b/security/src/main/java/org/apache/harmony/security/pkcs7/ContentInfo.java index 0249055..2c129e2 100644 --- a/security/src/main/java/org/apache/harmony/security/pkcs7/ContentInfo.java +++ b/security/src/main/java/org/apache/harmony/security/pkcs7/ContentInfo.java @@ -93,7 +93,7 @@ public class ContentInfo { } public String toString() { - StringBuffer res = new StringBuffer(); + StringBuilder res = new StringBuilder(); res.append("==== ContentInfo:"); //$NON-NLS-1$ res.append("\n== ContentType (OID): "); //$NON-NLS-1$ for (int i = 0; i< oid.length; i++) { diff --git a/security/src/main/java/org/apache/harmony/security/pkcs7/SignedData.java b/security/src/main/java/org/apache/harmony/security/pkcs7/SignedData.java index 718d3d3..2f9e99d 100644 --- a/security/src/main/java/org/apache/harmony/security/pkcs7/SignedData.java +++ b/security/src/main/java/org/apache/harmony/security/pkcs7/SignedData.java @@ -105,7 +105,7 @@ public class SignedData { } public String toString() { - StringBuffer res = new StringBuffer(); + StringBuilder res = new StringBuilder(); res.append("---- SignedData:"); //$NON-NLS-1$ res.append("\nversion: "); //$NON-NLS-1$ res.append(version); diff --git a/security/src/main/java/org/apache/harmony/security/pkcs7/SignerInfo.java b/security/src/main/java/org/apache/harmony/security/pkcs7/SignerInfo.java index 05a0c7a..9235577 100644 --- a/security/src/main/java/org/apache/harmony/security/pkcs7/SignerInfo.java +++ b/security/src/main/java/org/apache/harmony/security/pkcs7/SignerInfo.java @@ -130,7 +130,7 @@ public class SignerInfo { public String toString() { - StringBuffer res = new StringBuffer(); + StringBuilder res = new StringBuilder(); res.append("-- SignerInfo:"); //$NON-NLS-1$ res.append("\n version : "); //$NON-NLS-1$ res.append(version); diff --git a/security/src/main/java/org/apache/harmony/security/provider/cert/X509CRLImpl.java b/security/src/main/java/org/apache/harmony/security/provider/cert/X509CRLImpl.java index d53eb8a..7414e75 100644 --- a/security/src/main/java/org/apache/harmony/security/provider/cert/X509CRLImpl.java +++ b/security/src/main/java/org/apache/harmony/security/provider/cert/X509CRLImpl.java @@ -201,7 +201,7 @@ public class X509CRLImpl extends X509CRL { * from the TBSCertList structure and converts them to the * X509CRLEntryImpl objects */ - private void retirieveEntries() { + private void retrieveEntries() { entriesRetrieved = true; List rcerts = tbsCertList.getRevokedCertificates(); if (rcerts == null) { @@ -243,7 +243,7 @@ public class X509CRLImpl extends X509CRL { throw new NullPointerException(); } if (!entriesRetrieved) { - retirieveEntries(); + retrieveEntries(); } if (entries == null) { return null; @@ -295,7 +295,7 @@ public class X509CRLImpl extends X509CRL { */ public X509CRLEntry getRevokedCertificate(BigInteger serialNumber) { if (!entriesRetrieved) { - retirieveEntries(); + retrieveEntries(); } if (entries == null) { return null; @@ -315,7 +315,7 @@ public class X509CRLImpl extends X509CRL { */ public Set<? extends X509CRLEntry> getRevokedCertificates() { if (!entriesRetrieved) { - retirieveEntries(); + retrieveEntries(); } if (entries == null) { return null; diff --git a/security/src/main/java/org/apache/harmony/security/provider/cert/X509CertFactoryImpl.java b/security/src/main/java/org/apache/harmony/security/provider/cert/X509CertFactoryImpl.java index 17fd6f7..f0e47d9 100644 --- a/security/src/main/java/org/apache/harmony/security/provider/cert/X509CertFactoryImpl.java +++ b/security/src/main/java/org/apache/harmony/security/provider/cert/X509CertFactoryImpl.java @@ -25,6 +25,7 @@ package org.apache.harmony.security.provider.cert; import java.io.IOException; import java.io.InputStream; +import java.io.UnsupportedEncodingException; import java.security.cert.CRL; import java.security.cert.CRLException; import java.security.cert.CertPath; @@ -446,8 +447,8 @@ public class X509CertFactoryImpl extends CertificateFactorySpi { // ------------------------ Staff methods ------------------------------ // --------------------------------------------------------------------- - private static byte[] pemBegin = "-----BEGIN".getBytes(); //$NON-NLS-1$ - private static byte[] pemClose = "-----END".getBytes(); //$NON-NLS-1$ + private static byte[] pemBegin; + private static byte[] pemClose; /** * Code describing free format for PEM boundary suffix: * "^-----BEGIN.*\n" at the beginning, and<br> @@ -459,8 +460,18 @@ public class X509CertFactoryImpl extends CertificateFactorySpi { * "^-----BEGIN CERTIFICATE-----\n" at the beginning, and<br> * "\n-----END CERTIFICATE-----" at the end. */ - private static byte[] CERT_BOUND_SUFFIX = - " CERTIFICATE-----".getBytes(); //$NON-NLS-1$ + private static byte[] CERT_BOUND_SUFFIX; + + static { + // Initialise statics + try { + pemBegin = "-----BEGIN".getBytes("UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$ + pemClose = "-----END".getBytes("UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$ + CERT_BOUND_SUFFIX = " CERTIFICATE-----".getBytes("UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$ + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e.getMessage()); + } + } /** * Method retrieves the PEM encoded data from the stream @@ -515,9 +526,7 @@ public class X509CertFactoryImpl extends CertificateFactorySpi { if (boundary_suffix[i] != inStream.read()) { throw new IOException( Messages.getString("security.15B", //$NON-NLS-1$ - ((boundary_suffix == null) - ? "" - : new String(boundary_suffix)))); //$NON-NLS-1$ + new String(boundary_suffix))); //$NON-NLS-1$ } } // read new line characters @@ -574,9 +583,7 @@ public class X509CertFactoryImpl extends CertificateFactorySpi { if (boundary_suffix[i] != inStream.read()) { throw new IOException( Messages.getString("security.15B1", //$NON-NLS-1$ - ((boundary_suffix == null) - ? "" - : new String(boundary_suffix)))); //$NON-NLS-1$ + new String(boundary_suffix))); //$NON-NLS-1$ } } } @@ -933,3 +940,5 @@ public class X509CertFactoryImpl extends CertificateFactorySpi { } } + + diff --git a/security/src/main/java/org/apache/harmony/security/provider/cert/X509CertPathImpl.java b/security/src/main/java/org/apache/harmony/security/provider/cert/X509CertPathImpl.java index 2234ce4..83b9944 100644 --- a/security/src/main/java/org/apache/harmony/security/provider/cert/X509CertPathImpl.java +++ b/security/src/main/java/org/apache/harmony/security/provider/cert/X509CertPathImpl.java @@ -313,7 +313,7 @@ public class X509CertPathImpl extends CertPath { /** * ASN.1 DER Encoder/Decoder for PkiPath structure. */ - public static ASN1SequenceOf ASN1 = + public static final ASN1SequenceOf ASN1 = new ASN1SequenceOf(ASN1Any.getInstance()) { /** diff --git a/security/src/main/java/org/apache/harmony/security/provider/crypto/DSAKeyFactoryImpl.java b/security/src/main/java/org/apache/harmony/security/provider/crypto/DSAKeyFactoryImpl.java index af314ef..42d3043 100644 --- a/security/src/main/java/org/apache/harmony/security/provider/crypto/DSAKeyFactoryImpl.java +++ b/security/src/main/java/org/apache/harmony/security/provider/crypto/DSAKeyFactoryImpl.java @@ -38,7 +38,7 @@ import org.apache.harmony.security.internal.nls.Messages; public class DSAKeyFactoryImpl extends KeyFactorySpi { /** - * The method generates a DSAPrivateKey object from the provided key specification. + * This method generates a DSAPrivateKey object from the provided key specification. * * @param * keySpec - the specification (key material) for the DSAPrivateKey. @@ -66,7 +66,7 @@ public class DSAKeyFactoryImpl extends KeyFactorySpi { } /** - * The method generates a DSAPublicKey object from the provided key specification. + * This method generates a DSAPublicKey object from the provided key specification. * * @param * keySpec - the specification (key material) for the DSAPublicKey. @@ -92,28 +92,23 @@ public class DSAKeyFactoryImpl extends KeyFactorySpi { } throw new InvalidKeySpecException(Messages.getString("security.19D")); //$NON-NLS-1$ } - + /** - * The method returns a specification (key material) of the given key object. - * 'keySpec' identifies the specification class - * in which the key material should be returned. - * - * If it is DSAPublicKeySpec.class, the key material should be returned - * in an instance of the DSAPublicKeySpec class; - * if it is DSAPrivateKeySpec.class, the key material should be returned - * in an instance of the DSAPrivateKeySpec class. - * - * @param - * key - either DSAPrivateKey or DSAPublicKey - * @param - * keySpec - either DSAPublicKeySpec.class or DSAPublicKeySpec.class - * - * @return - * either DSAPublicKeySpec object or DSAPublicKeySpec object - * + * This method returns a specification for the supplied key. + * + * The specification will be returned in the form of an object of the type + * specified by keySpec. + * + * @param key - + * either DSAPrivateKey or DSAPublicKey + * @param keySpec - + * either DSAPrivateKeySpec.class or DSAPublicKeySpec.class + * + * @return either a DSAPrivateKeySpec or a DSAPublicKeySpec + * * @throws InvalidKeySpecException - * if "keySpec" is not s specification for DSAPublicKey or DSAPrivateKey - * + * if "keySpec" is not a specification for DSAPublicKey or + * DSAPrivateKey */ protected <T extends KeySpec> T engineGetKeySpec(Key key, Class<T> keySpec) throws InvalidKeySpecException { diff --git a/security/src/main/java/org/apache/harmony/security/provider/crypto/DSAPrivateKeyImpl.java b/security/src/main/java/org/apache/harmony/security/provider/crypto/DSAPrivateKeyImpl.java index 17af038..291d69e 100644 --- a/security/src/main/java/org/apache/harmony/security/provider/crypto/DSAPrivateKeyImpl.java +++ b/security/src/main/java/org/apache/harmony/security/provider/crypto/DSAPrivateKeyImpl.java @@ -27,6 +27,7 @@ package org.apache.harmony.security.provider.crypto; import java.io.IOException; +import java.io.NotActiveException; import java.math.BigInteger; import java.security.interfaces.DSAParams; import java.security.interfaces.DSAPrivateKey; @@ -53,9 +54,9 @@ public class DSAPrivateKeyImpl extends PrivateKeyImpl implements DSAPrivateKey { */ private static final long serialVersionUID = -4716227614104950081L; - private BigInteger x; + private BigInteger x, g, p, q; - private DSAParams params; + private transient DSAParams params; /** * Creates object from DSAPrivateKeySpec. @@ -68,9 +69,9 @@ public class DSAPrivateKeyImpl extends PrivateKeyImpl implements DSAPrivateKey { PrivateKeyInfo pki; - BigInteger g = keySpec.getG(); - BigInteger p = keySpec.getP(); - BigInteger q = keySpec.getQ(); + g = keySpec.getG(); + p = keySpec.getP(); + q = keySpec.getQ(); ThreeIntegerSequence threeInts = new ThreeIntegerSequence(p .toByteArray(), q.toByteArray(), g.toByteArray()); @@ -133,9 +134,10 @@ public class DSAPrivateKeyImpl extends PrivateKeyImpl implements DSAPrivateKey { throw new InvalidKeySpecException(Messages.getString( "security.19B", e)); //$NON-NLS-1$ } - params = new DSAParameterSpec(new BigInteger(threeInts.p), - new BigInteger(threeInts.q), new BigInteger(threeInts.g)); - + p = new BigInteger(threeInts.p); + q = new BigInteger(threeInts.q); + g = new BigInteger(threeInts.g); + params = new DSAParameterSpec(p, q, g); setEncoding(encoding); /* @@ -153,5 +155,10 @@ public class DSAPrivateKeyImpl extends PrivateKeyImpl implements DSAPrivateKey { public DSAParams getParams() { return params; } + + private void readObject(java.io.ObjectInputStream in) throws NotActiveException, IOException, ClassNotFoundException { + in.defaultReadObject(); + params = new DSAParameterSpec(p, q, g); + } } diff --git a/security/src/main/java/org/apache/harmony/security/provider/crypto/DSAPublicKeyImpl.java b/security/src/main/java/org/apache/harmony/security/provider/crypto/DSAPublicKeyImpl.java index bd1efdd..f4bb13d 100644 --- a/security/src/main/java/org/apache/harmony/security/provider/crypto/DSAPublicKeyImpl.java +++ b/security/src/main/java/org/apache/harmony/security/provider/crypto/DSAPublicKeyImpl.java @@ -29,6 +29,7 @@ package org.apache.harmony.security.provider.crypto; import java.io.IOException; +import java.io.NotActiveException; import java.math.BigInteger; @@ -45,12 +46,6 @@ import org.apache.harmony.security.x509.AlgorithmIdentifier; import org.apache.harmony.security.x509.SubjectPublicKeyInfo; import org.apache.harmony.security.asn1.ASN1Integer; -//import org.apache.harmony.security.asn1.ASN1Sequence; -//import org.apache.harmony.security.asn1.ASN1Type; -//import org.apache.harmony.security.asn1.BerInputStream; -//import org.apache.harmony.security.asn1.ASN1BitString; -//import org.apache.harmony.security.asn1.BitString; -//import org.apache.harmony.security.asn1.ASN1OctetString; import org.apache.harmony.security.internal.nls.Messages; @@ -67,9 +62,9 @@ public class DSAPublicKeyImpl extends PublicKeyImpl implements DSAPublicKey { */ private static final long serialVersionUID = -2279672131310978336L; - private BigInteger y; + private BigInteger y, g, p, q; - private DSAParams params; + private transient DSAParams params; /** * Creates object from DSAPublicKeySpec. @@ -82,9 +77,9 @@ public class DSAPublicKeyImpl extends PublicKeyImpl implements DSAPublicKey { SubjectPublicKeyInfo spki; - BigInteger p = keySpec.getP(); - BigInteger q = keySpec.getQ(); - BigInteger g = keySpec.getG(); + p = keySpec.getP(); + q = keySpec.getQ(); + g = keySpec.getG(); ThreeIntegerSequence threeInts = new ThreeIntegerSequence(p .toByteArray(), q.toByteArray(), g.toByteArray()); @@ -148,8 +143,10 @@ public class DSAPublicKeyImpl extends PublicKeyImpl implements DSAPublicKey { throw new InvalidKeySpecException(Messages.getString( "security.19B", e)); //$NON-NLS-1$ } - params = (DSAParams) (new DSAParameterSpec(new BigInteger(threeInts.p), - new BigInteger(threeInts.q), new BigInteger(threeInts.g))); + p = new BigInteger(threeInts.p); + q = new BigInteger(threeInts.q); + g = new BigInteger(threeInts.g); + params = (DSAParams) (new DSAParameterSpec(p, q, g)); setEncoding(encoding); @@ -176,5 +173,10 @@ public class DSAPublicKeyImpl extends PublicKeyImpl implements DSAPublicKey { public DSAParams getParams() { return params; } + + private void readObject(java.io.ObjectInputStream in) throws NotActiveException, IOException, ClassNotFoundException { + in.defaultReadObject(); + params = new DSAParameterSpec(p, q, g); + } } diff --git a/security/src/main/java/org/apache/harmony/security/provider/crypto/RandomBitsSupplier.java b/security/src/main/java/org/apache/harmony/security/provider/crypto/RandomBitsSupplier.java index 14db652..e3fde7f 100644 --- a/security/src/main/java/org/apache/harmony/security/provider/crypto/RandomBitsSupplier.java +++ b/security/src/main/java/org/apache/harmony/security/provider/crypto/RandomBitsSupplier.java @@ -35,7 +35,7 @@ import org.apache.harmony.security.internal.nls.Messages; * The static class providing access on Linux platform * to system means for generating true random bits. <BR> * - * The source for true random bits is one of Linux's devices "/dev/urandom/" or + * The source for true random bits is one of Linux's devices "/dev/urandom" or * "/dev/random" depends on which one is available; if both the first is used. <BR> * * If no device available the service is not available, @@ -69,7 +69,7 @@ public class RandomBitsSupplier implements SHA1_Data { /** * value of field is "true" only if a device is available */ - private static boolean serviceAvailable; + private static boolean serviceAvailable = false; static { @@ -86,16 +86,26 @@ public class RandomBitsSupplier implements SHA1_Data { bis = new FileInputStream(file); // END android-modified randomFile = file; + serviceAvailable = true; return null; } } catch (FileNotFoundException e) { } } + + // BEGIN android-removed +// // If we have come out of the above loop, then we have been unable to +// // access /dev/*random, so try to fall back to using the system random() API +// try { +// System.loadLibrary(LIBRARY_NAME); +// serviceAvailable = true; +// } catch (UnsatisfiedLinkError e) { +// serviceAvailable = false; +// } return null; } } ); - serviceAvailable = (bis != null); } @@ -108,12 +118,12 @@ public class RandomBitsSupplier implements SHA1_Data { /** - * On the Linux platform with "random" devices available, + * On platforms with "random" devices available, * the method reads random bytes from the device. <BR> * * In case of any runtime failure ProviderException gets thrown. */ - private static synchronized byte[] getLinuxRandomBits(int numBytes) { + private static synchronized byte[] getUnixDeviceRandom(int numBytes) { byte[] bytes = new byte[numBytes]; @@ -128,7 +138,6 @@ public class RandomBitsSupplier implements SHA1_Data { // the below case should not occur because /dev/random or /dev/urandom is a special file // hence, if it is happened there is some internal problem - // if ( bytesRead == -1 ) { throw new ProviderException( Messages.getString("security.193") ); //$NON-NLS-1$ @@ -146,7 +155,6 @@ public class RandomBitsSupplier implements SHA1_Data { // actually there should be no IOException because device is a special file; // hence, there is either some internal problem or, for instance, // device was removed in runtime, or something else - // throw new ProviderException( Messages.getString("security.194"), e ); //$NON-NLS-1$ } @@ -154,6 +162,17 @@ public class RandomBitsSupplier implements SHA1_Data { } + // BEGIN android-removed +// /** +// * On platforms with no "random" devices available, this native +// * method uses system API calls to generate random numbers<BR> +// * +// * In case of any runtime failure ProviderException gets thrown. +// */ +// private static native synchronized boolean getUnixSystemRandom(byte[] randomBits, int numBytes); + // END android-removed + + /** * The method returns byte array of requested length provided service is available. * ProviderException gets thrown otherwise. @@ -171,12 +190,15 @@ public class RandomBitsSupplier implements SHA1_Data { throw new IllegalArgumentException(Messages.getString("security.195", numBytes)); //$NON-NLS-1$ } + // We have been unable to get a random device or fall back to the + // native security module code - throw an exception. if ( !serviceAvailable ) { throw new ProviderException( Messages.getString("security.196")); //$NON-NLS-1$ } - return getLinuxRandomBits(numBytes); + // BEGIN android-changed + return getUnixDeviceRandom(numBytes); + // END android-changed } - } diff --git a/security/src/main/java/org/apache/harmony/security/provider/crypto/SHA1_Data.java b/security/src/main/java/org/apache/harmony/security/provider/crypto/SHA1_Data.java index 6e9ecb8..7294361 100644 --- a/security/src/main/java/org/apache/harmony/security/provider/crypto/SHA1_Data.java +++ b/security/src/main/java/org/apache/harmony/security/provider/crypto/SHA1_Data.java @@ -82,10 +82,12 @@ public interface SHA1_Data { static final int DIGEST_LENGTH = 20; - /** - * name of native library to use on Windows platform - */ - static final String LIBRARY_NAME = "hysecurity"; //$NON-NLS-1$ + // BEGIN android-removed +// /** +// * name of native library to use on Windows platform +// */ +// static final String LIBRARY_NAME = "hysecurity"; //$NON-NLS-1$ + // END android-removed /** diff --git a/security/src/main/java/org/apache/harmony/security/provider/crypto/SHA1withDSA_SignatureImpl.java b/security/src/main/java/org/apache/harmony/security/provider/crypto/SHA1withDSA_SignatureImpl.java index 576ac76..b7b9c98 100644 --- a/security/src/main/java/org/apache/harmony/security/provider/crypto/SHA1withDSA_SignatureImpl.java +++ b/security/src/main/java/org/apache/harmony/security/provider/crypto/SHA1withDSA_SignatureImpl.java @@ -83,7 +83,7 @@ public class SHA1withDSA_SignatureImpl extends Signature { DSAParams params; // parameters and private key - BigInteger p, q, g, x; + BigInteger p, q, x; int n; @@ -95,7 +95,6 @@ public class SHA1withDSA_SignatureImpl extends Signature { params = ((DSAPrivateKey) privateKey).getParams(); p = params.getP(); q = params.getQ(); - g = params.getG(); x = ((DSAPrivateKey) privateKey).getX(); // checks described in DSA standard @@ -129,7 +128,7 @@ public class SHA1withDSA_SignatureImpl extends Signature { throws InvalidKeyException { // parameters and public key - BigInteger p, q, g, y; + BigInteger p, q, y; int n1; @@ -141,7 +140,6 @@ public class SHA1withDSA_SignatureImpl extends Signature { DSAParams params = ((DSAPublicKey) publicKey).getParams(); p = params.getP(); q = params.getQ(); - g = params.getG(); y = ((DSAPublicKey) publicKey).getY(); // checks described in DSA standard @@ -207,7 +205,6 @@ public class SHA1withDSA_SignatureImpl extends Signature { // various byte array being used in computing signature byte randomBytes[]; - byte digest[]; byte rBytes[], sBytes[], signature[]; int n, n1, n2; diff --git a/security/src/main/java/org/apache/harmony/security/utils/AlgNameMapper.java b/security/src/main/java/org/apache/harmony/security/utils/AlgNameMapper.java index f1f5bce..bc84c01 100644 --- a/security/src/main/java/org/apache/harmony/security/utils/AlgNameMapper.java +++ b/security/src/main/java/org/apache/harmony/security/utils/AlgNameMapper.java @@ -29,43 +29,13 @@ import java.util.Map; import java.util.Set; import java.util.Map.Entry; +import org.apache.harmony.security.Util; import org.apache.harmony.security.asn1.ObjectIdentifier; /** - * Provides Algorithm Name to OID - * and OID to Algorithm Name mappings. - * Some known mappings are hardcoded. - * Tries to obtain additional mappings - * from installed providers during initialization. - * - * Hardcoded mappings - * (source: http://asn1.elibel.tm.fr): - * - * 1.2.840.10040.4.1 -> DSA - * - * 1.2.840.113549.1.1.1 -> RSA - * - * 1.2.840.113549.1.3.1 -> DiffieHellman - * - * 1.2.840.113549.1.5.3 -> PBEWithMD5AndDES - * - * 1.2.840.113549.1.12.1.3 -> pbeWithSHAAnd3-KeyTripleDES-CBC - * 1.2.840.113549.1.12.1.3 -> PBEWithSHA1AndDESede - * 1.2.840.113549.1.12.1.3 -> PBEWithSHA1AndTripleDES - * - * 1.2.840.113549.1.12.1.6 -> pbeWithSHAAnd40BitRC2-CBC - * 1.2.840.113549.1.12.1.6 -> PBEWithSHA1AndRC2_40 - * - * 1.2.840.113549.3.2 -> RC2-CBC - * 1.2.840.113549.3.3 -> RC2-EBC - * 1.2.840.113549.3.4 -> RC4 - * 1.2.840.113549.3.5 -> RC4WithMAC - * 1.2.840.113549.3.6 -> DESx-CBC - * 1.2.840.113549.3.7 -> TripleDES-CBC - * 1.2.840.113549.3.8 -> rc5CBC - * 1.2.840.113549.3.9 -> RC5-CBC - * 1.2.840.113549.3.10 -> DESCDMF (CDMFCBCPad) - * + * Provides Algorithm Name to OID and OID to Algorithm Name mappings. Some known + * mappings are hardcoded. Tries to obtain additional mappings from installed + * providers during initialization. */ public class AlgNameMapper { @@ -114,7 +84,7 @@ public class AlgNameMapper { static { for (String[] element : knownAlgMappings) { - String algUC = element[1].toUpperCase(); + String algUC = Util.toUpperCase(element[1]); alg2OidMap.put(algUC, element[0]); oid2AlgMap.put(element[0], algUC); // map upper case alg name to its original name @@ -144,7 +114,7 @@ public class AlgNameMapper { */ public static String map2OID(String algName) { // alg2OidMap map contains upper case keys - return alg2OidMap.get(algName.toUpperCase()); + return alg2OidMap.get(Util.toUpperCase(algName)); } /** @@ -167,7 +137,7 @@ public class AlgNameMapper { * @return algorithm name */ public static String getStandardName(String algName) { - return algAliasesMap.get(algName.toUpperCase()); + return algAliasesMap.get(Util.toUpperCase(algName)); } // Searches given provider for mappings like @@ -184,7 +154,7 @@ public class AlgNameMapper { if (key.startsWith(keyPrfix2find)) { String alias = key.substring(keyPrfix2find.length()); String alg = (String)me.getValue(); - String algUC = alg.toUpperCase(); + String algUC = Util.toUpperCase(alg); if (isOID(alias)) { if (alias.startsWith("OID.")) { //$NON-NLS-1$ alias = alias.substring(4); @@ -203,8 +173,8 @@ public class AlgNameMapper { algAliasesMap.put(algUC, alg); } // Do not override known standard names - } else if (!algAliasesMap.containsKey(alias.toUpperCase())) { - algAliasesMap.put(alias.toUpperCase(), alg); + } else if (!algAliasesMap.containsKey(Util.toUpperCase(alias))) { + algAliasesMap.put(Util.toUpperCase(alias), alg); } } } @@ -240,7 +210,7 @@ public class AlgNameMapper { * @return Internal maps String representation */ public static String dump() { - StringBuffer sb = new StringBuffer("alg2OidMap: "); //$NON-NLS-1$ + StringBuilder sb = new StringBuilder("alg2OidMap: "); //$NON-NLS-1$ sb.append(alg2OidMap); sb.append("\noid2AlgMap: "); //$NON-NLS-1$ sb.append(oid2AlgMap); diff --git a/security/src/main/java/org/apache/harmony/security/utils/ObjectIdentifier.java b/security/src/main/java/org/apache/harmony/security/utils/ObjectIdentifier.java index 517e096..2a19656 100644 --- a/security/src/main/java/org/apache/harmony/security/utils/ObjectIdentifier.java +++ b/security/src/main/java/org/apache/harmony/security/utils/ObjectIdentifier.java @@ -158,7 +158,7 @@ public final class ObjectIdentifier { */ public String toString() { if (soid == null) { - StringBuffer sb = new StringBuffer(4 * oid.length); + StringBuilder sb = new StringBuilder(4 * oid.length); for (int i = 0; i < oid.length - 1; ++i) { sb.append(oid[i]); diff --git a/security/src/main/java/org/apache/harmony/security/x501/AttributeTypeAndValue.java b/security/src/main/java/org/apache/harmony/security/x501/AttributeTypeAndValue.java index 34337eb..63434893 100644 --- a/security/src/main/java/org/apache/harmony/security/x501/AttributeTypeAndValue.java +++ b/security/src/main/java/org/apache/harmony/security/x501/AttributeTypeAndValue.java @@ -28,6 +28,7 @@ import java.util.HashMap; import java.util.Iterator; import javax.security.auth.x500.X500Principal; +import java.io.UnsupportedEncodingException; import org.apache.harmony.security.asn1.ASN1Constants; import org.apache.harmony.security.asn1.ASN1Oid; @@ -38,6 +39,7 @@ import org.apache.harmony.security.asn1.BerInputStream; import org.apache.harmony.security.asn1.BerOutputStream; import org.apache.harmony.security.internal.nls.Messages; import org.apache.harmony.security.utils.ObjectIdentifier; +import org.apache.harmony.security.Util; /** @@ -284,7 +286,7 @@ public class AttributeTypeAndValue { this.oid = thisOid; } else { - this.oid = (ObjectIdentifier) KNOWN_NAMES.get(sOid.toUpperCase()); + this.oid = (ObjectIdentifier) KNOWN_NAMES.get(Util.toUpperCase(sOid)); if (this.oid == null) { throw new IOException(Messages.getString("security.178", sOid)); //$NON-NLS-1$ } @@ -301,7 +303,7 @@ public class AttributeTypeAndValue { public void appendName(String attrFormat, StringBuffer buf) { boolean hexFormat = false; - if (attrFormat == X500Principal.RFC1779) { + if (X500Principal.RFC1779.equals(attrFormat)) { if (RFC1779_NAMES == oid.getGroup()) { buf.append(oid.getName()); } else { @@ -311,7 +313,7 @@ public class AttributeTypeAndValue { buf.append('='); if (value.escapedString == value.getHexString()) { //FIXME all chars in upper case - buf.append(value.getHexString().toUpperCase()); + buf.append(Util.toUpperCase(value.getHexString())); } else if (value.escapedString.length() != value.rawString.length()) { // was escaped value.appendQEString(buf); @@ -324,7 +326,7 @@ public class AttributeTypeAndValue { if (RFC1779_NAMES == group || RFC2253_NAMES == group) { buf.append(oid.getName()); - if (attrFormat == X500Principal.CANONICAL) { + if (X500Principal.CANONICAL.equals(attrFormat)) { // only PrintableString and UTF8String in string format // all others are output in hex format // BEGIN android-changed @@ -348,7 +350,7 @@ public class AttributeTypeAndValue { if (hexFormat) { buf.append(value.getHexString()); } else { - if (attrFormat == X500Principal.CANONICAL) { + if (X500Principal.CANONICAL.equals(attrFormat)) { buf.append(value.makeCanonical()); } else { buf.append(value.escapedString); @@ -387,7 +389,7 @@ public class AttributeTypeAndValue { * */ - public static ASN1Type AttributeValue = new ASN1Type( + public static final ASN1Type attributeValue = new ASN1Type( ASN1Constants.TAG_PRINTABLESTRING) { public boolean checkTag(int tag) { @@ -452,7 +454,11 @@ public class AttributeTypeAndValue { av.bytes = (byte[]) out.content; out.content = av; } else { - av.bytes = av.rawString.getBytes(); + try { + av.bytes = av.rawString.getBytes("UTF-8"); //$NON-NLS-1$ + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e.getMessage()); + } out.length = av.bytes.length; } } @@ -476,7 +482,7 @@ public class AttributeTypeAndValue { }; public static final ASN1Sequence ASN1 = new ASN1Sequence(new ASN1Type[] { - ASN1Oid.getInstance(), AttributeValue }) { + ASN1Oid.getInstance(), attributeValue }) { protected Object getDecodedObject(BerInputStream in) throws IOException { Object[] values = (Object[]) in.content; @@ -541,4 +547,4 @@ public class AttributeTypeAndValue { } return intHash & 0x7FFFFFFF; // only positive } -}
\ No newline at end of file +} diff --git a/security/src/main/java/org/apache/harmony/security/x501/AttributeTypeAndValueComparator.java b/security/src/main/java/org/apache/harmony/security/x501/AttributeTypeAndValueComparator.java index 8844035..30d71e7 100644 --- a/security/src/main/java/org/apache/harmony/security/x501/AttributeTypeAndValueComparator.java +++ b/security/src/main/java/org/apache/harmony/security/x501/AttributeTypeAndValueComparator.java @@ -22,6 +22,7 @@ package org.apache.harmony.security.x501; +import java.io.Serializable; import java.util.Comparator; import org.apache.harmony.security.utils.ObjectIdentifier; @@ -30,9 +31,11 @@ import org.apache.harmony.security.utils.ObjectIdentifier; * AttributeTypeAndValue comparator * */ -public class AttributeTypeAndValueComparator implements Comparator { +public class AttributeTypeAndValueComparator implements Comparator, Serializable { - /** + private static final long serialVersionUID = -1286471842007103132L; + + /** * compares two AttributeTypeAndValues * * @param obj1 @@ -63,14 +66,7 @@ public class AttributeTypeAndValueComparator implements Comparator { return compateOids(atav1.getType(), atav2.getType()); } - - /** - * @return false - */ - public boolean equals(Object obj) { - return false; - } - + /** * compares two Object identifiers * diff --git a/security/src/main/java/org/apache/harmony/security/x501/AttributeValue.java b/security/src/main/java/org/apache/harmony/security/x501/AttributeValue.java index 51f9725..0844c5e 100644 --- a/security/src/main/java/org/apache/harmony/security/x501/AttributeValue.java +++ b/security/src/main/java/org/apache/harmony/security/x501/AttributeValue.java @@ -126,7 +126,7 @@ public class AttributeValue { } } - StringBuffer buf = new StringBuffer(encoded.length * 2 + 1); + StringBuilder buf = new StringBuilder(encoded.length * 2 + 1); buf.append('#'); for (int i = 0, c; i < encoded.length; i++) { @@ -180,7 +180,7 @@ public class AttributeValue { if (length == 0) { return name; } - StringBuffer buf = new StringBuffer(length * 2); + StringBuilder buf = new StringBuilder(length * 2); for (int index = 0; index < length; index++) { @@ -223,7 +223,7 @@ public class AttributeValue { if (length == 0) { return rawString; } - StringBuffer buf = new StringBuffer(length * 2); + StringBuilder buf = new StringBuilder(length * 2); int index = 0; if (rawString.charAt(0) == '#') { diff --git a/security/src/main/java/org/apache/harmony/security/x501/Name.java b/security/src/main/java/org/apache/harmony/security/x501/Name.java index 836342e..ae08671 100644 --- a/security/src/main/java/org/apache/harmony/security/x501/Name.java +++ b/security/src/main/java/org/apache/harmony/security/x501/Name.java @@ -118,21 +118,21 @@ public class Name { // // check X500Principal constants first // - if (format == X500Principal.RFC1779) { + if (X500Principal.RFC1779.equals(format)) { if (rfc1779String == null) { rfc1779String = getName0(format); } return rfc1779String; - } else if (format == X500Principal.RFC2253) { + } else if (X500Principal.RFC2253.equals(format)) { if (rfc2253String == null) { rfc2253String = getName0(format); } return rfc2253String; - } else if (format == X500Principal.CANONICAL) { + } else if (X500Principal.CANONICAL.equals(format)) { if (canonicalString == null) { canonicalString = getName0(format); @@ -217,7 +217,7 @@ public class Name { } String sName = name.toString(); - if (format == X500Principal.CANONICAL) { + if (X500Principal.CANONICAL.equals(format)) { sName = sName.toLowerCase(Locale.US); } return sName; diff --git a/security/src/main/java/org/apache/harmony/security/x509/AccessDescription.java b/security/src/main/java/org/apache/harmony/security/x509/AccessDescription.java index bc8fd28..69b9258 100644 --- a/security/src/main/java/org/apache/harmony/security/x509/AccessDescription.java +++ b/security/src/main/java/org/apache/harmony/security/x509/AccessDescription.java @@ -70,7 +70,7 @@ public class AccessDescription { } public String toString() { - StringBuffer res = new StringBuffer(); + StringBuilder res = new StringBuilder(); res.append("\n-- AccessDescription:"); //$NON-NLS-1$ res.append("\naccessMethod: "); //$NON-NLS-1$ res.append(accessMethod); diff --git a/security/src/main/java/org/apache/harmony/security/x509/AlgorithmIdentifier.java b/security/src/main/java/org/apache/harmony/security/x509/AlgorithmIdentifier.java index 70dba99..728fd6a 100644 --- a/security/src/main/java/org/apache/harmony/security/x509/AlgorithmIdentifier.java +++ b/security/src/main/java/org/apache/harmony/security/x509/AlgorithmIdentifier.java @@ -143,6 +143,11 @@ public class AlgorithmIdentifier { : Arrays.equals(parameters, algid.parameters)); } + public int hashCode() { + return algorithm.hashCode() * 37 + + (parameters != null ? parameters.hashCode() : 0); + } + /** * Places the string representation into the StringBuffer object. */ diff --git a/security/src/main/java/org/apache/harmony/security/x509/AuthorityKeyIdentifier.java b/security/src/main/java/org/apache/harmony/security/x509/AuthorityKeyIdentifier.java index 1cf9c3e..3de59fb 100644 --- a/security/src/main/java/org/apache/harmony/security/x509/AuthorityKeyIdentifier.java +++ b/security/src/main/java/org/apache/harmony/security/x509/AuthorityKeyIdentifier.java @@ -103,7 +103,7 @@ public class AuthorityKeyIdentifier extends ExtensionValue { buffer.append(prefix).append("]\n"); //$NON-NLS-1$ } - public static ASN1Type ASN1 = new ASN1Sequence( + public static final ASN1Type ASN1 = new ASN1Sequence( new ASN1Type[] { new ASN1Implicit(0, ASN1OctetString.getInstance()), new ASN1Implicit(1, GeneralNames.ASN1), diff --git a/security/src/main/java/org/apache/harmony/security/x509/BasicConstraints.java b/security/src/main/java/org/apache/harmony/security/x509/BasicConstraints.java index 10b3156..edbf13e 100644 --- a/security/src/main/java/org/apache/harmony/security/x509/BasicConstraints.java +++ b/security/src/main/java/org/apache/harmony/security/x509/BasicConstraints.java @@ -105,7 +105,7 @@ public class BasicConstraints extends ExtensionValue { /** * ASN.1 Encoder/Decoder. */ - public static ASN1Type ASN1 = new ASN1Sequence(new ASN1Type[] { + public static final ASN1Type ASN1 = new ASN1Sequence(new ASN1Type[] { ASN1Boolean.getInstance(), ASN1Integer.getInstance() }) { { setDefault(Boolean.FALSE, 0); diff --git a/security/src/main/java/org/apache/harmony/security/x509/CRLNumber.java b/security/src/main/java/org/apache/harmony/security/x509/CRLNumber.java index 85cbea0..db2480e 100644 --- a/security/src/main/java/org/apache/harmony/security/x509/CRLNumber.java +++ b/security/src/main/java/org/apache/harmony/security/x509/CRLNumber.java @@ -84,5 +84,5 @@ public class CRLNumber extends ExtensionValue { /** * ASN.1 Encoder/Decoder. */ - public static ASN1Type ASN1 = ASN1Integer.getInstance(); + public static final ASN1Type ASN1 = ASN1Integer.getInstance(); } diff --git a/security/src/main/java/org/apache/harmony/security/x509/CertificateIssuer.java b/security/src/main/java/org/apache/harmony/security/x509/CertificateIssuer.java index 3a31734..d6ab760 100644 --- a/security/src/main/java/org/apache/harmony/security/x509/CertificateIssuer.java +++ b/security/src/main/java/org/apache/harmony/security/x509/CertificateIssuer.java @@ -87,7 +87,7 @@ public class CertificateIssuer extends ExtensionValue { /** * ASN.1 Encoder/Decoder. */ - public static ASN1Type ASN1 = new ASN1Sequence(new ASN1Type[] { + public static final ASN1Type ASN1 = new ASN1Sequence(new ASN1Type[] { GeneralName.ASN1 }) { public Object getDecodedObject(BerInputStream in) { diff --git a/security/src/main/java/org/apache/harmony/security/x509/DNParser.java b/security/src/main/java/org/apache/harmony/security/x509/DNParser.java index 730f7df..5870bcd 100644 --- a/security/src/main/java/org/apache/harmony/security/x509/DNParser.java +++ b/security/src/main/java/org/apache/harmony/security/x509/DNParser.java @@ -293,6 +293,9 @@ public class DNParser { case '#': case ';': case ' ': + case '*': + case '%': + case '_': //FIXME: escaping is allowed only for leading or trailing space char return chars[pos]; default: diff --git a/security/src/main/java/org/apache/harmony/security/x509/ExtendedKeyUsage.java b/security/src/main/java/org/apache/harmony/security/x509/ExtendedKeyUsage.java index 69e9cee..4eacbd5 100644 --- a/security/src/main/java/org/apache/harmony/security/x509/ExtendedKeyUsage.java +++ b/security/src/main/java/org/apache/harmony/security/x509/ExtendedKeyUsage.java @@ -109,7 +109,7 @@ public class ExtendedKeyUsage extends ExtensionValue { /** * ASN.1 Encoder/Decoder. */ - public static ASN1Type ASN1 = + public static final ASN1Type ASN1 = new ASN1SequenceOf(new ASN1Oid() { public Object getDecodedObject(BerInputStream in) diff --git a/security/src/main/java/org/apache/harmony/security/x509/Extension.java b/security/src/main/java/org/apache/harmony/security/x509/Extension.java index 833f2fe..86e7a45 100644 --- a/security/src/main/java/org/apache/harmony/security/x509/Extension.java +++ b/security/src/main/java/org/apache/harmony/security/x509/Extension.java @@ -58,34 +58,34 @@ public class Extension { // constants: the extension OIDs // certificate extensions: - public static final int[] SUBJ_DIRECTORY_ATTRS = {2, 5, 29, 9}; - public static final int[] SUBJ_KEY_ID = {2, 5, 29, 14}; - public static final int[] KEY_USAGE = {2, 5, 29, 15}; - public static final int[] PRIVATE_KEY_USAGE_PERIOD = {2, 5, 29, 16}; - public static final int[] SUBJECT_ALT_NAME = {2, 5, 29, 17}; - public static final int[] ISSUER_ALTERNATIVE_NAME = {2, 5, 29, 18}; - public static final int[] BASIC_CONSTRAINTS = {2, 5, 29, 19}; - public static final int[] NAME_CONSTRAINTS = {2, 5, 29, 30}; - public static final int[] CRL_DISTR_POINTS = {2, 5, 29, 31}; - public static final int[] CERTIFICATE_POLICIES = {2, 5, 29, 32}; - public static final int[] POLICY_MAPPINGS = {2, 5, 29, 33}; - public static final int[] AUTH_KEY_ID = {2, 5, 29, 35}; - public static final int[] POLICY_CONSTRAINTS = {2, 5, 29, 36}; - public static final int[] EXTENDED_KEY_USAGE = {2, 5, 29, 37}; - public static final int[] FRESHEST_CRL = {2, 5, 29, 46}; - public static final int[] INHIBIT_ANY_POLICY = {2, 5, 29, 54}; - public static final int[] AUTHORITY_INFO_ACCESS = + static final int[] SUBJ_DIRECTORY_ATTRS = {2, 5, 29, 9}; + static final int[] SUBJ_KEY_ID = {2, 5, 29, 14}; + static final int[] KEY_USAGE = {2, 5, 29, 15}; + static final int[] PRIVATE_KEY_USAGE_PERIOD = {2, 5, 29, 16}; + static final int[] SUBJECT_ALT_NAME = {2, 5, 29, 17}; + static final int[] ISSUER_ALTERNATIVE_NAME = {2, 5, 29, 18}; + static final int[] BASIC_CONSTRAINTS = {2, 5, 29, 19}; + static final int[] NAME_CONSTRAINTS = {2, 5, 29, 30}; + static final int[] CRL_DISTR_POINTS = {2, 5, 29, 31}; + static final int[] CERTIFICATE_POLICIES = {2, 5, 29, 32}; + static final int[] POLICY_MAPPINGS = {2, 5, 29, 33}; + static final int[] AUTH_KEY_ID = {2, 5, 29, 35}; + static final int[] POLICY_CONSTRAINTS = {2, 5, 29, 36}; + static final int[] EXTENDED_KEY_USAGE = {2, 5, 29, 37}; + static final int[] FRESHEST_CRL = {2, 5, 29, 46}; + static final int[] INHIBIT_ANY_POLICY = {2, 5, 29, 54}; + static final int[] AUTHORITY_INFO_ACCESS = {1, 3, 6, 1, 5, 5, 7, 1, 1}; - public static final int[] SUBJECT_INFO_ACCESS = + static final int[] SUBJECT_INFO_ACCESS = {1, 3, 6, 1, 5, 5, 7, 1, 11}; // crl extensions: - public static final int[] ISSUING_DISTR_POINT = {2, 5, 29, 28}; + static final int[] ISSUING_DISTR_POINT = {2, 5, 29, 28}; // crl entry extensions: - public static final int[] CRL_NUMBER = {2, 5, 29, 20}; - public static final int[] CERTIFICATE_ISSUER = {2, 5, 29, 29}; - public static final int[] INVALIDITY_DATE = {2, 5, 29, 24}; - public static final int[] REASON_CODE = {2, 5, 29, 21}; - public static final int[] ISSUING_DISTR_POINTS = {2, 5, 29, 28}; + static final int[] CRL_NUMBER = {2, 5, 29, 20}; + static final int[] CERTIFICATE_ISSUER = {2, 5, 29, 29}; + static final int[] INVALIDITY_DATE = {2, 5, 29, 24}; + static final int[] REASON_CODE = {2, 5, 29, 21}; + static final int[] ISSUING_DISTR_POINTS = {2, 5, 29, 28}; // the value of extnID field of the structure private final int[] extnID; @@ -238,6 +238,10 @@ public class Extension { && (critical == extn.critical) && Arrays.equals(extnValue, extn.extnValue); } + + public int hashCode() { + return (extnID.hashCode() * 37 + (critical ? 1 : 0)) * 37 + extnValue.hashCode(); + } public ExtensionValue getDecodedExtensionValue() throws IOException { if (!valueDecoded) { diff --git a/security/src/main/java/org/apache/harmony/security/x509/Extensions.java b/security/src/main/java/org/apache/harmony/security/x509/Extensions.java index e98a116..1fee6c0 100644 --- a/security/src/main/java/org/apache/harmony/security/x509/Extensions.java +++ b/security/src/main/java/org/apache/harmony/security/x509/Extensions.java @@ -386,6 +386,14 @@ public class Extensions { ); } + public int hashCode() { + int hashcode = 0; + if (extensions != null) { + hashcode = extensions.hashCode(); + } + return hashcode; + } + /** * Places the string representation into the StringBuffer object. */ diff --git a/security/src/main/java/org/apache/harmony/security/x509/GeneralName.java b/security/src/main/java/org/apache/harmony/security/x509/GeneralName.java index db4daaa..3b291a1 100644 --- a/security/src/main/java/org/apache/harmony/security/x509/GeneralName.java +++ b/security/src/main/java/org/apache/harmony/security/x509/GeneralName.java @@ -328,6 +328,24 @@ public class GeneralName { return false; } + public int hashCode() { + switch(tag) { + case RFC822_NAME: + case DNS_NAME: + case UR_ID: + case REG_ID: + case IP_ADDR: + return name.hashCode(); + case DIR_NAME: + case X400_ADDR: + case OTHER_NAME: + case EDIP_NAME: + return getEncoded().hashCode(); + default: + return super.hashCode(); + } + } + /** * Checks if the other general name is acceptable by this object. * The name is acceptable if it has the same type name and its @@ -562,16 +580,21 @@ public class GeneralName { /** * Checks the correctness of the string representation of DNS name. - * The correctness is checked as specified in RFC 1034 p. 10. + * The correctness is checked as specified in RFC 1034 p. 10, and modified + * by RFC 1123 (section 2.1). */ public static void checkDNS(String dns) throws IOException { - byte[] bytes = dns.toLowerCase().getBytes(); + byte[] bytes = dns.toLowerCase().getBytes("UTF-8"); //$NON-NLS-1$ // indicates if it is a first letter of the label boolean first_letter = true; for (int i=0; i<bytes.length; i++) { byte ch = bytes[i]; if (first_letter) { - if (ch > 'z' || ch < 'a') { + if ((bytes.length > 2) && (ch == '*') && (bytes[1] == '.')) { + first_letter = false; + continue; + } + if ((ch > 'z' || ch < 'a') && (ch < '0' || ch > '9')) { throw new IOException(Messages.getString("security.184", //$NON-NLS-1$ (char)ch, dns)); } @@ -585,7 +608,7 @@ public class GeneralName { if (ch == '.') { // check the end of the previous label, it should not // be '-' sign - if (bytes[i-i] == '-') { + if (bytes[i-1] == '-') { throw new IOException( Messages.getString("security.186", dns)); //$NON-NLS-1$ } @@ -619,7 +642,7 @@ public class GeneralName { * Converts OID into array of bytes. */ public static int[] oidStrToInts(String oid) throws IOException { - byte[] bytes = oid.getBytes(); + byte[] bytes = oid.getBytes("UTF-8"); //$NON-NLS-1$ if (bytes[bytes.length-1] == '.') { throw new IOException(Messages.getString("security.56", oid)); //$NON-NLS-1$ } @@ -673,7 +696,7 @@ public class GeneralName { } // the resulting array byte[] result = new byte[num_components]; - byte[] ip_bytes = ip.getBytes(); + byte[] ip_bytes = ip.getBytes("UTF-8"); //$NON-NLS-1$ // number of address component to be read int component = 0; // if it is reading the second bound of a range diff --git a/security/src/main/java/org/apache/harmony/security/x509/InfoAccessSyntax.java b/security/src/main/java/org/apache/harmony/security/x509/InfoAccessSyntax.java index 7323124..ce5404e 100644 --- a/security/src/main/java/org/apache/harmony/security/x509/InfoAccessSyntax.java +++ b/security/src/main/java/org/apache/harmony/security/x509/InfoAccessSyntax.java @@ -86,7 +86,7 @@ public class InfoAccessSyntax extends ExtensionValue { } public String toString() { - StringBuffer res = new StringBuffer(); + StringBuilder res = new StringBuilder(); res.append("\n---- InfoAccessSyntax:"); //$NON-NLS-1$ if (accessDescriptions != null) { for (Iterator it = accessDescriptions.iterator(); it.hasNext();) { diff --git a/security/src/main/java/org/apache/harmony/security/x509/InvalidityDate.java b/security/src/main/java/org/apache/harmony/security/x509/InvalidityDate.java index bc04caf..b01fa45 100644 --- a/security/src/main/java/org/apache/harmony/security/x509/InvalidityDate.java +++ b/security/src/main/java/org/apache/harmony/security/x509/InvalidityDate.java @@ -82,6 +82,6 @@ public class InvalidityDate extends ExtensionValue { /** * ASN.1 Encoder/Decoder. */ - public static ASN1Type ASN1 = ASN1GeneralizedTime.getInstance(); + public static final ASN1Type ASN1 = ASN1GeneralizedTime.getInstance(); } diff --git a/security/src/main/java/org/apache/harmony/security/x509/IssuingDistributionPoint.java b/security/src/main/java/org/apache/harmony/security/x509/IssuingDistributionPoint.java index aec57c3..102fe05 100644 --- a/security/src/main/java/org/apache/harmony/security/x509/IssuingDistributionPoint.java +++ b/security/src/main/java/org/apache/harmony/security/x509/IssuingDistributionPoint.java @@ -180,7 +180,7 @@ public class IssuingDistributionPoint extends ExtensionValue { /** * ASN.1 Encoder/Decoder. */ - public static ASN1Type ASN1 = new ASN1Sequence( + public static final ASN1Type ASN1 = new ASN1Sequence( new ASN1Type[] { // ASN.1 prohibits implicitly tagged CHOICE new ASN1Explicit(0, DistributionPointName.ASN1), diff --git a/security/src/main/java/org/apache/harmony/security/x509/ReasonCode.java b/security/src/main/java/org/apache/harmony/security/x509/ReasonCode.java index 26b4acc..de3505d 100644 --- a/security/src/main/java/org/apache/harmony/security/x509/ReasonCode.java +++ b/security/src/main/java/org/apache/harmony/security/x509/ReasonCode.java @@ -128,6 +128,6 @@ public class ReasonCode extends ExtensionValue { /** * ASN.1 Encoder/Decoder. */ - public static ASN1Type ASN1 = ASN1Enumerated.getInstance(); + public static final ASN1Type ASN1 = ASN1Enumerated.getInstance(); } diff --git a/security/src/main/java/org/apache/harmony/security/x509/ReasonFlags.java b/security/src/main/java/org/apache/harmony/security/x509/ReasonFlags.java index 6f72dc7..842784f 100644 --- a/security/src/main/java/org/apache/harmony/security/x509/ReasonFlags.java +++ b/security/src/main/java/org/apache/harmony/security/x509/ReasonFlags.java @@ -55,7 +55,7 @@ public class ReasonFlags { /** * The names of the reasons. */ - public static final String[] REASONS = { + static final String[] REASONS = { "unused", //$NON-NLS-1$ "keyCompromise", //$NON-NLS-1$ "cACompromise", //$NON-NLS-1$ @@ -97,7 +97,7 @@ public class ReasonFlags { /** * ASN.1 Encoder/Decoder. */ - public static ASN1BitString ASN1 = + public static final ASN1BitString ASN1 = new ASN1BitString.ASN1NamedBitList(REASONS.length) { public Object getDecodedObject(BerInputStream in) throws IOException { return new ReasonFlags((boolean[]) super.getDecodedObject(in)); diff --git a/security/src/main/java/org/apache/harmony/security/x509/TBSCertList.java b/security/src/main/java/org/apache/harmony/security/x509/TBSCertList.java index 597ca59..6b04d55 100644 --- a/security/src/main/java/org/apache/harmony/security/x509/TBSCertList.java +++ b/security/src/main/java/org/apache/harmony/security/x509/TBSCertList.java @@ -153,6 +153,11 @@ public class TBSCertList { ? rcert.crlEntryExtensions == null : crlEntryExtensions.equals(rcert.crlEntryExtensions)); } + + public int hashCode() { + return userCertificate.hashCode() * 37 + (int)revocationDate.getTime() / 1000 + + (crlEntryExtensions == null ? 0 : crlEntryExtensions.hashCode()); + } /** * Places the string representation of extension value @@ -171,7 +176,7 @@ public class TBSCertList { } } - public static ASN1Sequence ASN1 = new ASN1Sequence( + public static final ASN1Sequence ASN1 = new ASN1Sequence( new ASN1Type[] {ASN1Integer.getInstance(), Time.ASN1, Extensions.ASN1}) { { @@ -358,6 +363,12 @@ public class TBSCertList { ? tbscert.crlExtensions == null : crlExtensions.equals(tbscert.crlExtensions)); } + + public int hashCode() { + return ((version * 37 + signature.hashCode()) * 37 + + issuer.getEncoded().hashCode()) * 37 + + (int)thisUpdate.getTime() / 1000; + } /** * Places the string representation of extension value diff --git a/security/src/main/java/org/apache/harmony/security/x509/tsp/PKIStatusInfo.java b/security/src/main/java/org/apache/harmony/security/x509/tsp/PKIStatusInfo.java index 336a60d..b0b75a6 100644 --- a/security/src/main/java/org/apache/harmony/security/x509/tsp/PKIStatusInfo.java +++ b/security/src/main/java/org/apache/harmony/security/x509/tsp/PKIStatusInfo.java @@ -59,7 +59,7 @@ public class PKIStatusInfo { } public String toString(){ - StringBuffer res = new StringBuffer(); + StringBuilder res = new StringBuilder(); res.append("-- PKIStatusInfo:"); res.append("\nPKIStatus : "); res.append(status); @@ -122,8 +122,7 @@ public class PKIStatusInfo { int failInfoValue = -1; if (values[2] != null) { - boolean[] failInfoBoolArray = (values[2] == null) ? null - : ((BitString) values[2]).toBooleanArray(); + boolean[] failInfoBoolArray = ((BitString) values[2]).toBooleanArray(); for (int i = 0; i < failInfoBoolArray.length; i++) { if (failInfoBoolArray[i]) { failInfoValue = i; diff --git a/security/src/main/java/org/apache/harmony/security/x509/tsp/TSTInfo.java b/security/src/main/java/org/apache/harmony/security/x509/tsp/TSTInfo.java index 4c9454e..f2aa0ee 100644 --- a/security/src/main/java/org/apache/harmony/security/x509/tsp/TSTInfo.java +++ b/security/src/main/java/org/apache/harmony/security/x509/tsp/TSTInfo.java @@ -102,7 +102,7 @@ public class TSTInfo { } public String toString() { - StringBuffer res = new StringBuffer(); + StringBuilder res = new StringBuilder(); res.append("-- TSTInfo:"); res.append("\nversion: "); res.append(version); diff --git a/security/src/main/java/org/apache/harmony/security/x509/tsp/TimeStampReq.java b/security/src/main/java/org/apache/harmony/security/x509/tsp/TimeStampReq.java index 117ae27..5e4e6ff 100644 --- a/security/src/main/java/org/apache/harmony/security/x509/tsp/TimeStampReq.java +++ b/security/src/main/java/org/apache/harmony/security/x509/tsp/TimeStampReq.java @@ -82,7 +82,7 @@ public class TimeStampReq { } public String toString() { - StringBuffer res = new StringBuffer(); + StringBuilder res = new StringBuilder(); res.append("-- TimeStampReq:"); res.append("\nversion : "); res.append(version); diff --git a/security/src/main/java/org/apache/harmony/security/x509/tsp/TimeStampResp.java b/security/src/main/java/org/apache/harmony/security/x509/tsp/TimeStampResp.java index ea50a2d..af03ea5 100644 --- a/security/src/main/java/org/apache/harmony/security/x509/tsp/TimeStampResp.java +++ b/security/src/main/java/org/apache/harmony/security/x509/tsp/TimeStampResp.java @@ -46,7 +46,7 @@ public class TimeStampResp { } public String toString(){ - StringBuffer res = new StringBuffer(); + StringBuilder res = new StringBuilder(); res.append("-- TimeStampResp:"); res.append("\nstatus: "); res.append(status); diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/AlgorithmParametersTest.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/AlgorithmParametersTest.java index bbbe861..13ac904 100644 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/AlgorithmParametersTest.java +++ b/security/src/test/java/org/apache/harmony/security/tests/java/security/AlgorithmParametersTest.java @@ -709,8 +709,7 @@ public class AlgorithmParametersTest extends TestCase { params = AlgorithmParameters.getInstance("DSA"); try { params.init(enc, "DOUGLASMAWSON"); - params.init(enc, "DOUGLASMAWSON"); - fail("IOException exception expected"); + fail("unsupported format should have raised IOException"); } catch (IOException e) { // expected } diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/AllTests.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/AllTests.java index 2803251..089a7db 100644 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/AllTests.java +++ b/security/src/test/java/org/apache/harmony/security/tests/java/security/AllTests.java @@ -47,33 +47,26 @@ public class AllTests { suite.addTestSuite(CodeSignerTest.class); suite.addTestSuite(CodeSource2Test.class); suite.addTestSuite(CodeSourceTest.class); - suite.addTestSuite(DigestException2Test.class); suite.addTestSuite(DigestExceptionTest.class); suite.addTestSuite(DigestInputStream2Test.class); suite.addTestSuite(DigestInputStreamTest.class); suite.addTestSuite(DigestOutputStreamTest.class); - suite.addTestSuite(GeneralSecurityException2Test.class); suite.addTestSuite(GeneralSecurityExceptionTest.class); suite.addTestSuite(GuardedObjectTest.class); suite.addTestSuite(Identity2Test.class); suite.addTestSuite(IdentityScope2Test.class); suite.addTestSuite(IdentityScopeTest.class); - suite.addTestSuite(InvalidAlgorithmParameterException2Test.class); suite.addTestSuite(InvalidAlgorithmParameterExceptionTest.class); - suite.addTestSuite(InvalidKeyException2Test.class); suite.addTestSuite(InvalidKeyExceptionTest.class); - suite.addTestSuite(InvalidParameterException2Test.class); suite.addTestSuite(InvalidParameterExceptionTest.class); suite.addTestSuite(KSCallbackHandlerProtectionTest.class); suite.addTestSuite(KSPasswordProtectionTest.class); suite.addTestSuite(KSPrivateKeyEntryTest.class); suite.addTestSuite(KSSecretKeyEntryTest.class); suite.addTestSuite(KSTrustedCertificateEntryTest.class); - suite.addTestSuite(KeyException2Test.class); suite.addTestSuite(KeyExceptionTest.class); suite.addTestSuite(KeyFactory2Test.class); suite.addTestSuite(KeyFactorySpiTest.class); - suite.addTestSuite(KeyManagementException2Test.class); suite.addTestSuite(KeyManagementExceptionTest.class); suite.addTestSuite(KeyPairGenerator1Test.class); suite.addTestSuite(KeyPairGenerator2Test.class); @@ -86,7 +79,6 @@ public class AllTests { suite.addTestSuite(KeyStore2Test.class); suite.addTestSuite(KeyStore3Test.class); suite.addTestSuite(KeyStoreBuilderTest.class); - suite.addTestSuite(KeyStoreException2Test.class); suite.addTestSuite(KeyStoreExceptionTest.class); suite.addTestSuite(KeyStoreSpiTest.class); suite.addTestSuite(KeyStoreTest.class); @@ -94,9 +86,7 @@ public class AllTests { suite.addTestSuite(MessageDigest1Test.class); suite.addTestSuite(MessageDigest2Test.class); suite.addTestSuite(MessageDigestSpiTest.class); - suite.addTestSuite(NoSuchAlgorithmException2Test.class); suite.addTestSuite(NoSuchAlgorithmExceptionTest.class); - suite.addTestSuite(NoSuchProviderException2Test.class); suite.addTestSuite(NoSuchProviderExceptionTest.class); suite.addTestSuite(Permission2Test.class); suite.addTestSuite(PermissionCollectionTest.class); @@ -109,7 +99,6 @@ public class AllTests { suite.addTestSuite(PrivilegedActionExceptionTest.class); suite.addTestSuite(ProtectionDomainTest.class); suite.addTestSuite(Provider2Test.class); - suite.addTestSuite(ProviderException2Test.class); suite.addTestSuite(ProviderExceptionTest.class); suite.addTestSuite(ProviderServiceTest.class); suite.addTestSuite(ProviderTest.class); @@ -121,7 +110,6 @@ public class AllTests { suite.addTestSuite(SecurityPermissionTest.class); suite.addTestSuite(SecurityTest.class); suite.addTestSuite(Signature2Test.class); - suite.addTestSuite(SignatureException2Test.class); suite.addTestSuite(SignatureExceptionTest.class); suite.addTestSuite(SignatureSpiTest.class); suite.addTestSuite(SignatureTest.class); @@ -129,7 +117,6 @@ public class AllTests { suite.addTestSuite(SignerTest.class); suite.addTestSuite(TimestampTest.class); suite.addTestSuite(UnrecoverableEntryExceptionTest.class); - suite.addTestSuite(UnrecoverableKeyException2Test.class); suite.addTestSuite(UnrecoverableKeyExceptionTest.class); suite.addTestSuite(UnresolvedPermissionTest.class); diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/CodeSource2Test.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/CodeSource2Test.java index c70bc57..fa94fbf 100644 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/CodeSource2Test.java +++ b/security/src/test/java/org/apache/harmony/security/tests/java/security/CodeSource2Test.java @@ -128,7 +128,7 @@ public class CodeSource2Test extends junit.framework.TestCase { public void test_hashCode() throws Exception { URL url = new java.net.URL("file:///test"); CodeSource cs = new CodeSource(url, (Certificate[]) null); - assertTrue("Did not get expected hashCode!", cs.hashCode() == url + assertEquals("Did not get expected hashCode!", cs.hashCode(), url .hashCode()); } @@ -163,6 +163,7 @@ public class CodeSource2Test extends junit.framework.TestCase { (Certificate[]) null); assertEquals("Did not get expected location!", "file:/test", cs .getLocation().toString()); + assertNotNull("Host should not be null", cs.getLocation().getHost()); } /** @@ -187,7 +188,7 @@ public class CodeSource2Test extends junit.framework.TestCase { (Certificate[]) null); cs2 = new CodeSource(new URL("file:/d:/somedir/"), (Certificate[]) null); assertTrue("null host should imply host", cs1.implies(cs2)); - assertTrue("host should not imply null host", !cs2.implies(cs1)); - } + assertFalse("host should not imply null host", cs2.implies(cs1)); + } -}
\ No newline at end of file +} diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/DigestException2Test.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/DigestException2Test.java deleted file mode 100644 index 544e618..0000000 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/DigestException2Test.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.security.tests.java.security; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.security.DigestException; - -@TestTargetClass(DigestException.class) -public class DigestException2Test extends junit.framework.TestCase { - - /** - * @tests java.security.DigestException#DigestException() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "DigestException", - args = {} - ) - public void test_Constructor() { - // Test for method java.security.DigestException() - DigestException de = new DigestException(); - assertNull("Exception with no message should yield null message.", de - .getMessage()); - } - - /** - * @tests java.security.DigestException#DigestException(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Different variants of string parameter (empty, null, etc.) weren't checked", - method = "DigestException", - args = {java.lang.String.class} - ) - public void test_ConstructorLjava_lang_String() { - // Test for method java.security.DigestException(java.lang.String) - DigestException de = new DigestException("Test message"); - assertEquals("Exception message is incorrect", "Test message", de - .getMessage()); - } -}
\ No newline at end of file diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/DigestInputStream2Test.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/DigestInputStream2Test.java index 69a73a3..93ffe77 100644 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/DigestInputStream2Test.java +++ b/security/src/test/java/org/apache/harmony/security/tests/java/security/DigestInputStream2Test.java @@ -19,6 +19,7 @@ package org.apache.harmony.security.tests.java.security; import java.io.ByteArrayInputStream; import java.io.IOException; +import java.io.UnsupportedEncodingException; import java.security.DigestInputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -280,4 +281,4 @@ public class DigestInputStream2Test extends junit.framework.TestCase { fail("Unable to find SHA-1 algorithm"); } } -}
\ No newline at end of file +} diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/DigestOutputStreamTest.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/DigestOutputStreamTest.java index 8309c87..ca80f19 100644 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/DigestOutputStreamTest.java +++ b/security/src/test/java/org/apache/harmony/security/tests/java/security/DigestOutputStreamTest.java @@ -651,32 +651,28 @@ public class DigestOutputStreamTest extends TestCase { method = "on", args = {boolean.class} ) - public void test_onZ() { + public void test_onZ() throws Exception { // Test for method void java.security.DigestOutputStream.on(boolean) - try { - DigestOutputStream dos = new DigestOutputStream( - new ByteArrayOutputStream(), MessageDigest - .getInstance("SHA")); - dos.on(false); - byte digestArray[] = { 23, 43, 44 }; - dos.write(digestArray, 1, 1); - byte digestResult[] = dos.getMessageDigest().digest(); - byte expected[] = { -38, 57, -93, -18, 94, 107, 75, 13, 50, 85, - -65, -17, -107, 96, 24, -112, -81, -40, 7, 9 }; - assertTrue("Digest did not return expected result.", - java.util.Arrays.equals(digestResult, expected)); - // now turn on processing and re-run - dos.on(true); - dos.write(digestArray, 1, 1); - digestResult = dos.getMessageDigest().digest(); - byte expected1[] = { -87, 121, -17, 16, -52, 111, 106, 54, -33, - 107, -118, 50, 51, 7, -18, 59, -78, -30, -37, -100 }; - - assertTrue("Digest did not return expected result.", - java.util.Arrays.equals(digestResult, expected1)); - } catch (Exception e) { - fail("Caught exception : " + e); - } + DigestOutputStream dos = new DigestOutputStream( + new ByteArrayOutputStream(), MessageDigest + .getInstance("SHA")); + dos.on(false); + byte digestArray[] = { 23, 43, 44 }; + dos.write(digestArray, 1, 1); + byte digestResult[] = dos.getMessageDigest().digest(); + byte expected[] = { -38, 57, -93, -18, 94, 107, 75, 13, 50, 85, + -65, -17, -107, 96, 24, -112, -81, -40, 7, 9 }; + assertTrue("Digest did not return expected result.", + java.util.Arrays.equals(digestResult, expected)); + // now turn on processing and re-run + dos.on(true); + dos.write(digestArray, 1, 1); + digestResult = dos.getMessageDigest().digest(); + byte expected1[] = { -87, 121, -17, 16, -52, 111, 106, 54, -33, + 107, -118, 50, 51, 7, -18, 59, -78, -30, -37, -100 }; + + assertTrue("Digest did not return expected result.", + java.util.Arrays.equals(digestResult, expected1)); } /** diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/GeneralSecurityException2Test.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/GeneralSecurityException2Test.java deleted file mode 100644 index 3647115..0000000 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/GeneralSecurityException2Test.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.security.tests.java.security; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.security.GeneralSecurityException; - -@TestTargetClass(GeneralSecurityException.class) -public class GeneralSecurityException2Test extends junit.framework.TestCase { - - /** - * @tests java.security.GeneralSecurityException#GeneralSecurityException() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "GeneralSecurityException", - args = {} - ) - public void test_Constructor() { - // Test for method java.security.GeneralSecurityException() - GeneralSecurityException e = new GeneralSecurityException(); - assertNotNull("Constructor returned null instance", e); - assertEquals("Failed toString test for constructed instance", "java.security.GeneralSecurityException", e - .toString()); - } - - /** - * @tests java.security.GeneralSecurityException#GeneralSecurityException(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Verifies non null parameter only", - method = "GeneralSecurityException", - args = {java.lang.String.class} - ) - public void test_ConstructorLjava_lang_String() { - // Test for method - // java.security.GeneralSecurityException(java.lang.String) - GeneralSecurityException e = new GeneralSecurityException( - "test message"); - assertNotNull("Constructor returned null instance", e); - assertEquals("Failed toString test for constructed instance", - "java.security.GeneralSecurityException: test message", e - .toString()); - } -}
\ No newline at end of file diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/Identity2Test.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/Identity2Test.java index 55e2fd2..865bbea 100644 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/Identity2Test.java +++ b/security/src/test/java/org/apache/harmony/security/tests/java/security/Identity2Test.java @@ -20,6 +20,7 @@ package org.apache.harmony.security.tests.java.security; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.OutputStream; +import java.io.UnsupportedEncodingException; import java.security.Certificate; import java.security.Identity; import java.security.IdentityScope; diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/InvalidAlgorithmParameterException2Test.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/InvalidAlgorithmParameterException2Test.java deleted file mode 100644 index dafdb38..0000000 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/InvalidAlgorithmParameterException2Test.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.security.tests.java.security; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.security.InvalidAlgorithmParameterException; - -@TestTargetClass(InvalidAlgorithmParameterException.class) -public class InvalidAlgorithmParameterException2Test extends - junit.framework.TestCase { - - /** - * @tests java.security.InvalidAlgorithmParameterException#InvalidAlgorithmParameterException() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "InvalidAlgorithmParameterException", - args = {} - ) - public void test_Constructor() { - // Test for method java.security.InvalidAlgorithmParameterException() - InvalidAlgorithmParameterException e = new InvalidAlgorithmParameterException(); - assertNotNull("Constructor returned null instance", e); - assertEquals("Failed toString test for constructed instance", - "java.security.InvalidAlgorithmParameterException", e - .toString()); - } - - /** - * @tests java.security.InvalidAlgorithmParameterException#InvalidAlgorithmParameterException(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Verifies constructor with one string parameter", - method = "InvalidAlgorithmParameterException", - args = {java.lang.String.class} - ) - public void test_ConstructorLjava_lang_String() { - // Test for method - // java.security.InvalidAlgorithmParameterException(java.lang.String) - InvalidAlgorithmParameterException e = new InvalidAlgorithmParameterException( - "test message"); - assertNotNull("Constructor returned null instance", e); - assertEquals( - "Failed toString test for constructed instance", - "java.security.InvalidAlgorithmParameterException: test message", - e.toString()); - } -}
\ No newline at end of file diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/InvalidKeyException2Test.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/InvalidKeyException2Test.java deleted file mode 100644 index bbe9e08..0000000 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/InvalidKeyException2Test.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.security.tests.java.security; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.security.InvalidKeyException; - -@TestTargetClass(InvalidKeyException.class) -public class InvalidKeyException2Test extends junit.framework.TestCase { - - /** - * @tests java.security.InvalidKeyException#InvalidKeyException() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "InvalidKeyException", - args = {} - ) - public void test_Constructor() { - // Test for method java.security.InvalidKeyException() - InvalidKeyException e = new InvalidKeyException(); - assertNotNull("Constructor returned a null", e); - assertEquals("Failed toString test for constructed instance", "java.security.InvalidKeyException", e - .toString()); - } - - /** - * @tests java.security.InvalidKeyException#InvalidKeyException(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Verifies constructor with one string parameter", - method = "InvalidKeyException", - args = {java.lang.String.class} - ) - public void test_ConstructorLjava_lang_String() { - // Test for method java.security.InvalidKeyException(java.lang.String) - InvalidKeyException e = new InvalidKeyException("test message"); - assertNotNull("Constructor returned a null", e); - assertEquals("Failed toString test for constructed instance", - "java.security.InvalidKeyException: test message", e - .toString()); - } -}
\ No newline at end of file diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/InvalidParameterException2Test.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/InvalidParameterException2Test.java deleted file mode 100644 index 4830731..0000000 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/InvalidParameterException2Test.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.security.tests.java.security; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.security.InvalidParameterException; - -@TestTargetClass(InvalidParameterException.class) -public class InvalidParameterException2Test extends junit.framework.TestCase { - - /** - * @tests java.security.InvalidParameterException#InvalidParameterException() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "InvalidParameterException", - args = {} - ) - public void test_Constructor() { - // Test for method java.security.InvalidParameterException() - InvalidParameterException e = new InvalidParameterException(); - assertEquals("Failed toString test for constructed instance", "java.security.InvalidParameterException", e - .toString()); - } - - /** - * @tests java.security.InvalidParameterException#InvalidParameterException(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Verifies constructor with one variant of string parameter", - method = "InvalidParameterException", - args = {java.lang.String.class} - ) - public void test_ConstructorLjava_lang_String() { - // Test for method - // java.security.InvalidParameterException(java.lang.String) - InvalidParameterException e = new InvalidParameterException( - "test message"); - assertEquals("Failed toString test for constructed instance", - - "java.security.InvalidParameterException: test message", e - .toString() - ); - } -}
\ No newline at end of file diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyException2Test.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyException2Test.java deleted file mode 100644 index 1c7b71f..0000000 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyException2Test.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.security.tests.java.security; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.security.KeyException; - -@TestTargetClass(KeyException.class) -public class KeyException2Test extends junit.framework.TestCase { - - /** - * @tests java.security.KeyException#KeyException() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "KeyException", - args = {} - ) - public void test_Constructor() { - // Test for method java.security.KeyException() - KeyException e = new KeyException(); - assertEquals("Failed toString test for constructed instance", "java.security.KeyException", e - .toString()); - } - - /** - * @tests java.security.KeyException#KeyException(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Verifies constructor with one variant of string parameter", - method = "KeyException", - args = {java.lang.String.class} - ) - public void test_ConstructorLjava_lang_String() { - // Test for method java.security.KeyException(java.lang.String) - KeyException e = new KeyException("test message"); - assertEquals("Failed toString test for constructed instance", "java.security.KeyException: test message", e - .toString()); - } -}
\ No newline at end of file diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyManagementException2Test.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyManagementException2Test.java deleted file mode 100644 index c30370a..0000000 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyManagementException2Test.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.security.tests.java.security; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.security.KeyManagementException; - -@TestTargetClass(KeyManagementException.class) -public class KeyManagementException2Test extends junit.framework.TestCase { - - /** - * @tests java.security.KeyManagementException#KeyManagementException() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "KeyManagementException", - args = {} - ) - public void test_Constructor() { - // Test for method java.security.KeyManagementException() - KeyManagementException e = new KeyManagementException(); - assertEquals("Failed toString test for constructed instance", - "java.security.KeyManagementException", e.toString()); - } - - /** - * @tests java.security.KeyManagementException#KeyManagementException(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Checking with null and empty string parameter missed", - method = "KeyManagementException", - args = {java.lang.String.class} - ) - public void test_ConstructorLjava_lang_String() { - // Test for method - // java.security.KeyManagementException(java.lang.String) - KeyManagementException e = new KeyManagementException("test message"); - assertEquals("Failed toString test for constructed instance", - "java.security.KeyManagementException: test message", - e.toString()); - } -}
\ No newline at end of file diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStore2Test.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStore2Test.java index 817de35..059cef4 100644 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStore2Test.java +++ b/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStore2Test.java @@ -1372,4 +1372,4 @@ public class KeyStore2Test extends junit.framework.TestCase { } } -}
\ No newline at end of file +} diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStoreException2Test.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStoreException2Test.java deleted file mode 100644 index b3c9583..0000000 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStoreException2Test.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.security.tests.java.security; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.security.KeyStoreException; - -@TestTargetClass(KeyStoreException.class) -public class KeyStoreException2Test extends junit.framework.TestCase { - - /** - * @tests java.security.KeyStoreException#KeyStoreException() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "KeyStoreException", - args = {} - ) - public void test_Constructor() { - // Test for method java.security.KeyStoreException() - KeyStoreException e = new KeyStoreException(); - assertEquals("Failed toString test for constructed instance", "java.security.KeyStoreException", e - .toString()); - } - - /** - * @tests java.security.KeyStoreException#KeyStoreException(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Verifies constructor with one variant of string parameter", - method = "KeyStoreException", - args = {java.lang.String.class} - ) - public void test_ConstructorLjava_lang_String() { - // Test for method java.security.KeyStoreException(java.lang.String) - KeyStoreException e = new KeyStoreException("test message"); - assertEquals("Failed toString test for constructed instance", - "java.security.KeyStoreException: test message", e - .toString()); - } -}
\ No newline at end of file diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStorePrivateKeyEntryTest.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStorePrivateKeyEntryTest.java new file mode 100644 index 0000000..42feeec --- /dev/null +++ b/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStorePrivateKeyEntryTest.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.harmony.security.tests.java.security; + +import java.io.ByteArrayInputStream; +import java.io.UnsupportedEncodingException; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.KeyStore; +import java.security.PrivateKey; +import java.security.cert.Certificate; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; + +import junit.framework.TestCase; + +public class KeyStorePrivateKeyEntryTest extends TestCase { + + public void testGetCertificateChain() throws Exception { + + String certificateData = "-----BEGIN CERTIFICATE-----\n" + + "MIICZTCCAdICBQL3AAC2MA0GCSqGSIb3DQEBAgUAMF8xCzAJBgNVBAYTAlVTMSAw\n" + + "HgYDVQQKExdSU0EgRGF0YSBTZWN1cml0eSwgSW5jLjEuMCwGA1UECxMlU2VjdXJl\n" + + "IFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05NzAyMjAwMDAwMDBa\n" + + "Fw05ODAyMjAyMzU5NTlaMIGWMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZv\n" + + "cm5pYTESMBAGA1UEBxMJUGFsbyBBbHRvMR8wHQYDVQQKExZTdW4gTWljcm9zeXN0\n" + + "ZW1zLCBJbmMuMSEwHwYDVQQLExhUZXN0IGFuZCBFdmFsdWF0aW9uIE9ubHkxGjAY\n" + + "BgNVBAMTEWFyZ29uLmVuZy5zdW4uY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB\n" + + "iQKBgQCofmdY+PiUWN01FOzEewf+GaG+lFf132UpzATmYJkA4AEA/juW7jSi+LJk\n" + + "wJKi5GO4RyZoyimAL/5yIWDV6l1KlvxyKslr0REhMBaD/3Z3EsLTTEf5gVrQS6sT\n" + + "WMoSZAyzB39kFfsB6oUXNtV8+UKKxSxKbxvhQn267PeCz5VX2QIDAQABMA0GCSqG\n" + + "SIb3DQEBAgUAA34AXl3at6luiV/7I9MN5CXYoPJYI8Bcdc1hBagJvTMcmlqL2uOZ\n" + + "H9T5hNMEL9Tk6aI7yZPXcw/xI2K6pOR/FrMp0UwJmdxX7ljV6ZtUZf7pY492UqwC\n" + + "1777XQ9UEZyrKJvF5ntleeO0ayBqLGVKCWzWZX9YsXCpv47FNLZbupE=\n" + + "-----END CERTIFICATE-----\n"; + + ByteArrayInputStream certArray; + { + try{ + certArray = new ByteArrayInputStream( + certificateData.getBytes("UTF-8")); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e.getMessage()); + } + } + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + Certificate certificate = cf.generateCertificate(certArray); + assertTrue(certificate instanceof X509Certificate); + + String algorithm = certificate.getPublicKey().getAlgorithm(); + KeyPairGenerator keyPairGenerator = KeyPairGenerator + .getInstance(algorithm); + KeyPair keyPair = keyPairGenerator.generateKeyPair(); + PrivateKey privateKey = keyPair.getPrivate(); + + // If all the certificate in the chain is X509Certificate, + // KeyStore.PrivateKeyEntry will return a X509Certificate array. + KeyStore.PrivateKeyEntry privateKeyEntry = new KeyStore.PrivateKeyEntry( + privateKey, new Certificate[] { certificate }); + Certificate[] chain = privateKeyEntry.getCertificateChain(); + assertTrue(chain instanceof X509Certificate[]); + + } +} diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStoreTest.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStoreTest.java index d7ae43f..210116e 100644 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStoreTest.java +++ b/security/src/test/java/org/apache/harmony/security/tests/java/security/KeyStoreTest.java @@ -47,6 +47,8 @@ import java.security.cert.X509Certificate; import java.util.Date; import java.util.Set; import java.math.BigInteger; +import javax.crypto.KeyGenerator; +import javax.crypto.SecretKey; import org.apache.harmony.security.tests.support.KeyStoreTestSupport; import org.apache.harmony.security.tests.support.MyLoadStoreParams; @@ -277,6 +279,35 @@ public class KeyStoreTest extends TestCase { } + + /* + * @tests java.security.KeyStoreSpi.engineEntryInstanceOf(String, Class<? extends Entry>) + */ + public void testEngineEntryInstanceOf() throws Exception { + //Regression for HARMONY-615 + + // create a KeyStore + KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); + keyStore.load(null, "pwd".toCharArray()); + + // generate a key + KeyGenerator keyGen = KeyGenerator.getInstance("DES"); + keyGen.init(56); + SecretKey secretKey = keyGen.generateKey(); + + // put the key into keystore + String alias = "alias"; + keyStore.setKeyEntry(alias, secretKey, "pwd".toCharArray(), null); + + // check if it is a secret key + assertTrue(keyStore.entryInstanceOf(alias, + KeyStore.SecretKeyEntry.class)); + + // check if it is NOT a private key + assertFalse(keyStore.entryInstanceOf(alias, + KeyStore.PrivateKeyEntry.class)); + } + /** * @tests java.security.KeyStore.TrustedCertificateEntry.toString() */ diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/MessageDigest2Test.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/MessageDigest2Test.java index c26708d..9eca936 100644 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/MessageDigest2Test.java +++ b/security/src/test/java/org/apache/harmony/security/tests/java/security/MessageDigest2Test.java @@ -25,6 +25,7 @@ import dalvik.annotation.TestTargetNew; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; +import java.io.UnsupportedEncodingException; import java.security.DigestException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -676,4 +677,4 @@ public class MessageDigest2Test extends junit.framework.TestCase { } } -}
\ No newline at end of file +} diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/MessageDigestSpiTest.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/MessageDigestSpiTest.java index b7c11e5..8bcb392 100644 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/MessageDigestSpiTest.java +++ b/security/src/test/java/org/apache/harmony/security/tests/java/security/MessageDigestSpiTest.java @@ -109,29 +109,29 @@ public class MessageDigestSpiTest extends TestCase { ) public void test_engineDigestLB$LILI() throws Exception { - final int DIGEST_LENGHT = 2; + final int DIGEST_LENGTH = 2; MyMessageDigest md = new MyMessageDigest() { public int engineGetDigestLength() { - return DIGEST_LENGHT; + return DIGEST_LENGTH; } public byte[] engineDigest() { - return new byte[DIGEST_LENGHT]; // return non-null value + return new byte[DIGEST_LENGTH]; // return non-null value } }; byte[] b = new byte[5]; try { // test: null output buffer - md.engineDigest(null, 1, DIGEST_LENGHT); + md.engineDigest(null, 1, DIGEST_LENGTH); fail("No expected NullPointerException"); } catch (NullPointerException e) { } try { //test: len param < digest length - md.engineDigest(b, 1, DIGEST_LENGHT - 1); + md.engineDigest(b, 1, DIGEST_LENGTH - 1); fail("No expected DigestException"); } catch (DigestException e) { } @@ -153,7 +153,7 @@ public class MessageDigestSpiTest extends TestCase { // ok } - assertEquals("incorrect result", DIGEST_LENGHT, md + assertEquals("incorrect result", DIGEST_LENGTH, md .engineDigest(b, 1, 3)); // Regression for HARMONY-3045 diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/NoSuchAlgorithmException2Test.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/NoSuchAlgorithmException2Test.java deleted file mode 100644 index 289047b..0000000 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/NoSuchAlgorithmException2Test.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.security.tests.java.security; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.security.NoSuchAlgorithmException; - -@TestTargetClass(NoSuchAlgorithmException.class) -public class NoSuchAlgorithmException2Test extends junit.framework.TestCase { - - /** - * @tests java.security.NoSuchAlgorithmException#NoSuchAlgorithmException() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "NoSuchAlgorithmException", - args = {} - ) - public void test_Constructor() { - try { - throw new NoSuchAlgorithmException(); - } catch (NoSuchAlgorithmException e) { - assertNull("Message should be null", e.getMessage()); - assertEquals("Unexpected toString value", - "java.security.NoSuchAlgorithmException", e.toString()); - } - } - - /** - * @tests java.security.NoSuchAlgorithmException#NoSuchAlgorithmException(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Null parameter checking missed", - method = "NoSuchAlgorithmException", - args = {java.lang.String.class} - ) - public void test_ConstructorLjava_lang_String() { - // Test for method - // java.security.NoSuchAlgorithmException(java.lang.String) - try { - throw new NoSuchAlgorithmException("Test string"); - } catch (NoSuchAlgorithmException e) { - assertEquals("Wrong message", "Test string", e.getMessage()); - assertEquals("Unexpected toString value", - "java.security.NoSuchAlgorithmException: Test string", e - .toString()); - } - } -}
\ No newline at end of file diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/NoSuchProviderException2Test.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/NoSuchProviderException2Test.java deleted file mode 100644 index 256ed66..0000000 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/NoSuchProviderException2Test.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.security.tests.java.security; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.security.NoSuchProviderException; - -@TestTargetClass(NoSuchProviderException.class) -public class NoSuchProviderException2Test extends junit.framework.TestCase { - - /** - * @tests java.security.NoSuchProviderException#NoSuchProviderException() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "NoSuchProviderException", - args = {} - ) - public void test_Constructor() { - // Test for method java.security.NoSuchProviderException() - try { - throw new NoSuchProviderException(); - } catch (NoSuchProviderException e) { - assertNull("Message should be null", e.getMessage()); - assertEquals("Unexpected toString value", - "java.security.NoSuchProviderException", e.toString()); - } - } - - /** - * @tests java.security.NoSuchProviderException#NoSuchProviderException(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Null parameter checking missed", - method = "NoSuchProviderException", - args = {java.lang.String.class} - ) - public void test_ConstructorLjava_lang_String() { - // Test for method - // java.security.NoSuchProviderException(java.lang.String) - try { - throw new NoSuchProviderException("Test string"); - } catch (NoSuchProviderException e) { - assertEquals("Wrong message", "Test string", e.getMessage()); - assertEquals("Unexpected toString value", - "java.security.NoSuchProviderException: Test string", e - .toString()); - } - } -}
\ No newline at end of file diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/Permissions2Test.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/Permissions2Test.java index af33804..a60adbf 100644 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/Permissions2Test.java +++ b/security/src/test/java/org/apache/harmony/security/tests/java/security/Permissions2Test.java @@ -55,7 +55,7 @@ public class Permissions2Test extends junit.framework.TestCase { public void test_Constructor() { // Test for method java.security.Permissions() new Permissions(); - } + } /** * @tests java.security.Permissions#add(java.security.Permission) @@ -192,4 +192,4 @@ public class Permissions2Test extends junit.framework.TestCase { public void checkPermission(Permission permission) { } } -}
\ No newline at end of file +} diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/PolicyTest.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/PolicyTest.java index 78038b5..cfa2af1 100644 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/PolicyTest.java +++ b/security/src/test/java/org/apache/harmony/security/tests/java/security/PolicyTest.java @@ -395,7 +395,7 @@ public class PolicyTest extends TestCase { String policyFile = getClass().getClassLoader().getResource( "PolicyTest.txt").toString(); - String oldSysProp = System.getProperty(JAVA_SECURITY_POLICY); + String oldJavaPolicy = System.getProperty(JAVA_SECURITY_POLICY); Policy oldPolicy = Policy.getPolicy(); try { @@ -404,12 +404,20 @@ public class PolicyTest extends TestCase { // test: absolute paths assertCodeBasePropertyExpansion("/11111/*", "/11111/-"); assertCodeBasePropertyExpansion("/22222/../22222/*", "/22222/-"); + assertCodeBasePropertyExpansion("/33333/*", "/33333/../33333/-"); + assertCodeBasePropertyExpansion("/44444/../44444/-", "/44444/*"); + assertCodeBasePropertyExpansion("/55555/../55555/-", "/55555/../55555/-"); + assertCodeBasePropertyExpansion("/666 66 66/-", "/666 66 66/-"); // test: relative paths - assertCodeBasePropertyExpansion("44444/*", "44444/-"); - assertCodeBasePropertyExpansion("55555/../55555/*", "55555/-"); + assertCodeBasePropertyExpansion("11111/*", "11111/-"); + assertCodeBasePropertyExpansion("22222/../22222/*", "22222/-"); + assertCodeBasePropertyExpansion("33333/*", "33333/../33333/-"); + assertCodeBasePropertyExpansion("44444/../44444/-", "44444/*"); + assertCodeBasePropertyExpansion("55555/../55555/-", "55555/../55555/-"); + assertCodeBasePropertyExpansion("666 66 66/-", "666 66 66/-"); } finally { - TestUtils.setSystemProperty(JAVA_SECURITY_POLICY, oldSysProp); + TestUtils.setSystemProperty(JAVA_SECURITY_POLICY, oldJavaPolicy); Policy.setPolicy(oldPolicy); } } diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/Provider2Test.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/Provider2Test.java index 48e8f32..a8ec69a 100644 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/Provider2Test.java +++ b/security/src/test/java/org/apache/harmony/security/tests/java/security/Provider2Test.java @@ -22,7 +22,10 @@ import dalvik.annotation.TestTargets; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetNew; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; import java.security.Provider; +import java.security.Security; @TestTargetClass(Provider.class) public class Provider2Test extends junit.framework.TestCase { @@ -172,4 +175,44 @@ public class Provider2Test extends junit.framework.TestCase { // Regression for HARMONY-3734 assertEquals("provTest version 1.2", provTest.toString()); } + + // Regression Test for Provider.Service.getAlias(), which is an package + // private method but will lead to NPE thrown at + // Secure.SecurityDorr.getAliases + public void test_getAlias() throws Exception { + MockProvider mockProvider = new MockProvider("MOCKNAME", 1.0, + "MOCKINFO"); + Provider.Service service = new Provider.Service(mockProvider, + "MOCKTYPE", "MOCKALGORITHM", "TESTCLASSNAME", null, null); + mockProvider.putService(service); + Security.addProvider(mockProvider); + try { + MessageDigest messageDigest = MessageDigest + .getInstance("NOTEXISTS"); + } + + catch (NoSuchAlgorithmException e) { + // expected + } finally { + Security.removeProvider("MOCKNAME"); + } + } + + public static class MockProvider extends Provider { + + private static final long serialVersionUID = 1L; + + public MockProvider(String name, double version, String info) { + super(name, version, info); + + } + + public void putService(Provider.Service service) { + super.putService(service); + } + + public void removeService(Provider.Service service) { + super.removeService(service); + } + } } diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/ProviderException2Test.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/ProviderException2Test.java deleted file mode 100644 index 4b0f2ec..0000000 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/ProviderException2Test.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.security.tests.java.security; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; - -import java.security.ProviderException; - -@TestTargetClass(ProviderException.class) -public class ProviderException2Test extends junit.framework.TestCase { - - /** - * @tests java.security.ProviderException#ProviderException() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "ProviderException", - args = {} - ) - public void test_Constructor() { - // Test for method java.security.ProviderException() - ProviderException e = new ProviderException(); - assertEquals("Failed toString test for constructed instance", - "java.security.ProviderException", e.toString()); - } - - /** - * @tests java.security.ProviderException#ProviderException(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Verification with null/empty parameter is absent", - method = "ProviderException", - args = {java.lang.String.class} - ) - public void test_ConstructorLjava_lang_String() { - // Test for method java.security.ProviderException(java.lang.String) - ProviderException e = new ProviderException("test message"); - assertEquals("Failed toString test for constructed instance", - "java.security.ProviderException: test message", e - .toString()); - } -}
\ No newline at end of file diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/ProviderServiceTest.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/ProviderServiceTest.java index c93011c..730e329 100644 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/ProviderServiceTest.java +++ b/security/src/test/java/org/apache/harmony/security/tests/java/security/ProviderServiceTest.java @@ -138,22 +138,16 @@ public class ProviderServiceTest extends TestCase { method = "newInstance", args = {java.lang.Object.class} ) - public void testNewInstance() { + public void testNewInstance() throws Exception { Provider p = new MyProvider(); Provider.Service s = new Provider.Service(p, "SecureRandom", - "algorithm", "org.apache.harmony.security.tests.support.RandomImpl", null, - null); - Object o = null; - try { - o = s.newInstance(null); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - fail("newInstance() failed"); - } - if (!(o instanceof RandomImpl)) { - fail("incorrect instance"); - } + "algorithm", + "org.apache.harmony.security.tests.support.RandomImpl", + null, null); + Object o = s.newInstance(null); + assertTrue("incorrect instance", o instanceof RandomImpl); + try { o = s.newInstance(new Object()); fail("No expected NoSuchAlgorithmException"); diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/ProviderTest.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/ProviderTest.java index a3b3077..3cc447f 100644 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/ProviderTest.java +++ b/security/src/test/java/org/apache/harmony/security/tests/java/security/ProviderTest.java @@ -129,27 +129,9 @@ public class ProviderTest extends TestCase { ) public final void testClear() { p.clear(); - if (p.getProperty("MessageDigest.ASH-1") != null) { - fail("Provider contains properties"); - } + assertNull(p.getProperty("MessageDigest.SHA-1")); } - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "", - method = "clear", - args = {} - ) - public final void testClear_SecurityManager() { - TestSecurityManager sm = new TestSecurityManager("clearProviderProperties.MyProvider"); - System.setSecurityManager(sm); - p.clear(); - assertTrue("Provider.clear must call checkPermission with " - + "SecurityPermission clearProviderProperties.NAME", - sm.called); - System.setSecurityManager(null); - } - /* * Class under test for void Provider(String, double, String) */ @@ -161,22 +143,13 @@ public class ProviderTest extends TestCase { ) public final void testProviderStringdoubleString() { Provider p = new MyProvider("Provider name", 123.456, "Provider info"); - if (!p.getName().equals("Provider name") || p.getVersion() != 123.456 - || !p.getInfo().equals("Provider info")) { - fail("Incorrect values"); - } + assertEquals("Provider name", p.getName()); + assertEquals(123.456, p.getVersion(), 0L); + assertEquals("Provider info", p.getInfo()); } - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getName", - args = {} - ) public final void testGetName() { - if (!p.getName().equals("MyProvider")) { - fail("Incorrect provider name"); - } + assertEquals("MyProvider", p.getName()); } @TestTargetNew( @@ -186,9 +159,7 @@ public class ProviderTest extends TestCase { args = {} ) public final void testGetVersion() { - if (p.getVersion() != 1.0) { - fail("Incorrect provider version"); - } + assertEquals(1.0, p.getVersion(), 0L); } @TestTargetNew( @@ -198,9 +169,7 @@ public class ProviderTest extends TestCase { args = {} ) public final void testGetInfo() { - if (!p.getInfo().equals("Provider for testing")) { - fail("Incorrect provider info"); - } + assertEquals("Provider for testing", p.getInfo()); } /* @@ -213,19 +182,16 @@ public class ProviderTest extends TestCase { args = {java.util.Map.class} ) public final void testPutAllMap() { - HashMap<String, String> hm = new HashMap<String, String>(); - hm.put("MessageDigest.ASH-1", "aaa.bbb.ccc.ddd"); + HashMap hm = new HashMap(); + hm.put("MessageDigest.SHA-1", "aaa.bbb.ccc.ddd"); hm.put("Property 1", "value 1"); hm.put("serviceName.algName attrName", "attrValue"); - hm.put("Alg.Alias.engineClassName.aliasName", "stanbdardName"); + hm.put("Alg.Alias.engineClassName.aliasName", "standardName"); p.putAll(hm); - if (!"value 1".equals(p.getProperty("Property 1").trim()) - || !"attrValue".equals(p.getProperty( - "serviceName.algName attrName").trim()) - || !"stanbdardName".equals(p.getProperty( - "Alg.Alias.engineClassName.aliasName").trim()) - || !"aaa.bbb.ccc.ddd".equals(p.getProperty( - "MessageDigest.ASH-1").trim())) { + if (!"value 1".equals(p.getProperty("Property 1").trim()) || + !"attrValue".equals(p.getProperty("serviceName.algName attrName").trim()) || + !"standardName".equals(p.getProperty("Alg.Alias.engineClassName.aliasName").trim()) || + !"aaa.bbb.ccc.ddd".equals(p.getProperty("MessageDigest.SHA-1").trim()) ) { fail("Incorrect property value"); } } @@ -240,48 +206,43 @@ public class ProviderTest extends TestCase { args = {} ) public final void testEntrySet() { - p.put("MessageDigest.ASH-256", "aaa.bbb.ccc.ddd"); - - Set<Map.Entry<Object, Object>> s = p.entrySet(); + p.put("MessageDigest.SHA-256", "aaa.bbb.ccc.ddd"); + + Set s = p.entrySet(); try { s.clear(); fail("Must return unmodifiable set"); } catch (UnsupportedOperationException e) { } - + assertEquals("Incorrect set size", 8, s.size()); - - for (Iterator<Entry<Object, Object>> it = s.iterator(); it.hasNext();) { - Entry<Object, Object> e = it.next(); - String key = (String) e.getKey(); - String val = (String) e.getValue(); - if (key.equals("MessageDigest.ASH-1") - && val.equals("SomeClassName")) { + + for (Iterator it = s.iterator(); it.hasNext();) { + Entry e = (Entry)it.next(); + String key = (String)e.getKey(); + String val = (String)e.getValue(); + if (key.equals("MessageDigest.SHA-1") && val.equals("SomeClassName")) { continue; } - if (key.equals("Alg.Alias.MessageDigest.ASH1") - && val.equals("ASH-1")) { + if (key.equals("Alg.Alias.MessageDigest.SHA1") && val.equals("SHA-1")) { continue; } if (key.equals("MessageDigest.abc") && val.equals("SomeClassName")) { continue; } - if (key.equals("Provider.id className") - && val.equals(p.getClass().getName())) { + if (key.equals("Provider.id className") && val.equals(p.getClass().getName())) { continue; } if (key.equals("Provider.id name") && val.equals("MyProvider")) { continue; } - if (key.equals("MessageDigest.ASH-256") - && val.equals("aaa.bbb.ccc.ddd")) { + if (key.equals("MessageDigest.SHA-256") && val.equals("aaa.bbb.ccc.ddd")) { continue; } if (key.equals("Provider.id version") && val.equals("1.0")) { continue; } - if (key.equals("Provider.id info") - && val.equals("Provider for testing")) { + if (key.equals("Provider.id info") && val.equals("Provider for testing")) { continue; } fail("Incorrect set"); @@ -298,30 +259,27 @@ public class ProviderTest extends TestCase { args = {} ) public final void testKeySet() { - p.put("MessageDigest.ASH-256", "aaa.bbb.ccc.ddd"); + p.put("MessageDigest.SHA-256", "aaa.bbb.ccc.ddd"); Set<Object> s = p.keySet(); try { s.clear(); } catch (UnsupportedOperationException e) { } - Set<Object> s1 = p.keySet(); - if ((s == s1) || s1.isEmpty()) { - fail("Must return unmodifiable set"); - } - if (s1.size() != 8) { - fail("Incorrect set size"); - } - if (!s1.contains("MessageDigest.ASH-256") - || !s1.contains("MessageDigest.ASH-1") - || !s1.contains("Alg.Alias.MessageDigest.ASH1") - || !s1.contains("MessageDigest.abc") - || !s1.contains("Provider.id info") - || !s1.contains("Provider.id className") - || !s1.contains("Provider.id version") - || !s1.contains("Provider.id name")) { - fail("Incorrect set"); - } + Set s1 = p.keySet(); + + assertNotSame(s, s1); + assertFalse(s1.isEmpty()); + assertEquals(8, s1.size()); + + assertTrue(s1.contains("MessageDigest.SHA-256")); + assertTrue(s1.contains("MessageDigest.SHA-1")); + assertTrue(s1.contains("Alg.Alias.MessageDigest.SHA1")); + assertTrue(s1.contains("MessageDigest.abc")); + assertTrue(s1.contains("Provider.id info")); + assertTrue(s1.contains("Provider.id className")); + assertTrue(s1.contains("Provider.id version")); + assertTrue(s1.contains("Provider.id name")); } /* @@ -341,19 +299,19 @@ public class ProviderTest extends TestCase { c.clear(); } catch (UnsupportedOperationException e) { } - Collection<Object> c1 = p.values(); - if ((c == c1) || c1.isEmpty()) { - fail("Must return unmodifiable set"); - } - if (c1.size() != 8) { - fail("Incorrect set size " + c1.size()); - } - if (!c1.contains("MyProvider") || !c1.contains("aaa.bbb.ccc.ddd") - || !c1.contains("Provider for testing") || !c1.contains("1.0") - || !c1.contains("SomeClassName") || !c1.contains("ASH-1") - || !c1.contains(p.getClass().getName())) { - fail("Incorrect set"); - } + Collection c1 = p.values(); + + assertNotSame(c, c1); + assertFalse(c1.isEmpty()); + assertEquals(8, c1.size()); + + assertTrue(c1.contains("MyProvider")); + assertTrue(c1.contains("aaa.bbb.ccc.ddd")); + assertTrue(c1.contains("Provider for testing")); + assertTrue(c1.contains("1.0")); + assertTrue(c1.contains("SomeClassName")); + assertTrue(c1.contains("SHA-1")); + assertTrue(c1.contains(p.getClass().getName())); } /* @@ -366,38 +324,124 @@ public class ProviderTest extends TestCase { args = {java.lang.Object.class, java.lang.Object.class} ) public final void testPutObjectObject() { - p.put("MessageDigest.ASH-1", "aaa.bbb.ccc.ddd"); + p.put("MessageDigest.SHA-1", "aaa.bbb.ccc.ddd"); p.put("Type.Algorithm", "className"); - if (!"aaa.bbb.ccc.ddd".equals(p.getProperty("MessageDigest.ASH-1") - .trim())) { - fail("Incorrect property value"); - } - - Set<Service> services = p.getServices(); - if (services.size() != 3) { - fail("incorrect size"); - } - for (Iterator<Service> it = services.iterator(); it.hasNext();) { - Provider.Service s = it.next(); - if ("Type".equals(s.getType()) - && "Algorithm".equals(s.getAlgorithm()) - && "className".equals(s.getClassName())) { + assertEquals("aaa.bbb.ccc.ddd", p.getProperty("MessageDigest.SHA-1") + .trim()); + + Set services = p.getServices(); + assertEquals(3, services.size()); + + for (Iterator it = services.iterator(); it.hasNext();) { + Provider.Service s = (Provider.Service)it.next(); + if ("Type".equals(s.getType()) && + "Algorithm".equals(s.getAlgorithm()) && + "className".equals(s.getClassName())) { continue; } - if ("MessageDigest".equals(s.getType()) - && "ASH-1".equals(s.getAlgorithm()) - && "aaa.bbb.ccc.ddd".equals(s.getClassName())) { + if ("MessageDigest".equals(s.getType()) && + "SHA-1".equals(s.getAlgorithm()) && + "aaa.bbb.ccc.ddd".equals(s.getClassName())) { continue; } - if ("MessageDigest".equals(s.getType()) - && "abc".equals(s.getAlgorithm()) - && "SomeClassName".equals(s.getClassName())) { + if ("MessageDigest".equals(s.getType()) && + "abc".equals(s.getAlgorithm()) && + "SomeClassName".equals(s.getClassName())) { continue; } fail("Incorrect service"); } } + /* + * Class under test for Object remove(Object) + */ + @TestTargetNew( + level = TestLevel.COMPLETE, + notes = "", + method = "remove", + args = {java.lang.Object.class} + ) + public final void testRemoveObject() { + Object o = p.remove("MessageDigest.SHA-1"); + + assertEquals("SomeClassName", o); + assertNull(p.getProperty("MessageDigest.SHA-1")); + assertEquals(1, p.getServices().size()); + } + + public final void testService1() { + p.put("MessageDigest.SHA-1", "AnotherClassName"); + Provider.Service s = p.getService("MessageDigest", "SHA-1"); + + assertEquals("AnotherClassName", s.getClassName()); + } + + // Regression for HARMONY-2760. + @TestTargetNew( + level = TestLevel.PARTIAL_COMPLETE, + notes = "Regression test: verifies constructor with two null parameters.", + method = "Provider", + args = {java.lang.String.class, double.class, java.lang.String.class} + ) + public void testConstructor() { + MyProvider myProvider = new MyProvider(null, 1, null); + assertNull(myProvider.getName()); + assertNull(myProvider.getInfo()); + assertEquals("null", myProvider.getProperty("Provider.id name")); + assertEquals("null", myProvider.getProperty("Provider.id info")); + } + + class MyProvider extends Provider { + MyProvider() { + super("MyProvider", 1.0, "Provider for testing"); + put("MessageDigest.SHA-1", "SomeClassName"); + put("MessageDigest.abc", "SomeClassName"); + put("Alg.Alias.MessageDigest.SHA1", "SHA-1"); + } + + MyProvider(String name, double version, String info) { + super(name, version, info); + } + + // BEGIN android-added + public void putService(Provider.Service s) { + super.putService(s); + } + // END android-added + + // BEGIN android-added + public void removeService(Provider.Service s) { + super.removeService(s); + } + // END android-added + + // BEGIN android-added + public int getNumServices() { + return getServices().size(); + } + // END android-added + } + + // BEGIN android-added + @TestTargetNew( + level = TestLevel.PARTIAL_COMPLETE, + notes = "", + method = "clear", + args = {} + ) + public final void testClear_SecurityManager() { + TestSecurityManager sm = new TestSecurityManager("clearProviderProperties.MyProvider"); + System.setSecurityManager(sm); + p.clear(); + assertTrue("Provider.clear must call checkPermission with " + + "SecurityPermission clearProviderProperties.NAME", + sm.called); + System.setSecurityManager(null); + } + // END android-added + + // BEGIN android-added @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "", @@ -414,39 +458,9 @@ public class ProviderTest extends TestCase { + "SecurityPermission putProviderProperty.Name", sm.called); System.setSecurityManager(null); } + // END android-added - /* - * Class under test for Object remove(Object) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "remove", - args = {java.lang.Object.class} - ) - public final void testRemoveObject() { - Object o = p.remove("MessageDigest.ASH-1"); - if (!"SomeClassName".equals(o)) { - fail("Incorrect return value"); - } - if (p.getProperty("MessageDigest.ASH-1") != null) { - fail("Provider contains properties"); - } - if (p.getServices().size() != 1) { - fail("Service not removed"); - } - - try { - p.remove(null); - fail("expected NullPointerException"); - } catch (NullPointerException e) { - // ok - } - } - - /* - * Class under test for Object remove(Object) - */ + // BEGIN android-added @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "", @@ -463,35 +477,9 @@ public class ProviderTest extends TestCase { sm.called); System.setSecurityManager(null); } + // END android-added - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getService", - args = {java.lang.String.class, java.lang.String.class} - ) - public final void testService1() { - p.put("MessageDigest.ASH-1", "AnotherClassName"); - Provider.Service s = p.getService("MessageDigest", "ASH-1"); - if (!"AnotherClassName".equals(s.getClassName())) { - fail("Incorrect class name " + s.getClassName()); - } - - try { - p.getService("MessageDigest", null); - fail("expected NullPointerException"); - } catch (NullPointerException e) { - // ok; - } - - try { - p.getService(null, "ASH-1"); - fail("expected NullPointerException"); - } catch (NullPointerException e) { - // ok - } - } - + // BEGIN android-added @TestTargetNew( level = TestLevel.COMPLETE, notes = "", @@ -516,23 +504,9 @@ public class ProviderTest extends TestCase { } catch (NoSuchAlgorithmException e) { } } - - - // Regression for HARMONY-2760. - @TestTargetNew( - level = TestLevel.PARTIAL_COMPLETE, - notes = "Regression test: verifies constructor with two null parameters.", - method = "Provider", - args = {java.lang.String.class, double.class, java.lang.String.class} - ) - public void testConstructor() { - MyProvider myProvider = new MyProvider(null, 1, null); - assertNull(myProvider.getName()); - assertNull(myProvider.getInfo()); - assertEquals("null", myProvider.getProperty("Provider.id name")); - assertEquals("null", myProvider.getProperty("Provider.id info")); - } + // END android-added + // BEGIN android-added @TestTargetNew( level = TestLevel.COMPLETE, notes = "", @@ -576,7 +550,9 @@ public class ProviderTest extends TestCase { assertTrue(!actual.contains(s[1])); assertTrue(actual.contains(s[2])); } + // END android-added + // BEGIN android-added @TestTargetNew( level = TestLevel.COMPLETE, notes = "", @@ -631,7 +607,9 @@ public class ProviderTest extends TestCase { // expected } } + // END android-added + // BEGIN android-added @TestTargetNew( level = TestLevel.COMPLETE, notes = "", @@ -703,10 +681,9 @@ public class ProviderTest extends TestCase { // expected } } + // END android-added - /* - * Class under test for void load(InputStream) - */ + // BEGIN android-added @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "", @@ -735,7 +712,9 @@ public class ProviderTest extends TestCase { // expected } } - + // END android-added + + // BEGIN android-added @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "", @@ -755,11 +734,12 @@ public class ProviderTest extends TestCase { p.load(new TestInputStream()); fail("expected IOException"); } catch (IOException e) { - // ok + // expected } - } + // END android-added + // BEGIN android-added protected byte[] writeProperties() { ByteArrayOutputStream bout = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(bout); @@ -769,34 +749,9 @@ public class ProviderTest extends TestCase { ps.close(); return bout.toByteArray(); } + // END android-added - class MyProvider extends Provider { - // private Set<Provider.Service> services = null; - - MyProvider() { - super("MyProvider", 1.0, "Provider for testing"); - put("MessageDigest.ASH-1", "SomeClassName"); - put("MessageDigest.abc", "SomeClassName"); - put("Alg.Alias.MessageDigest.ASH1", "ASH-1"); - } - - MyProvider(String name, double version, String info) { - super(name, version, info); - } - - public void putService(Provider.Service s) { - super.putService(s); - } - - public void removeService(Provider.Service s) { - super.removeService(s); - } - - public int getNumServices() { - return getServices().size(); - } - } - + // BEGIN android-added static class TestSecurityManager extends SecurityManager { boolean called = false; private final String permissionName; @@ -814,4 +769,5 @@ public class ProviderTest extends TestCase { } } } + // END android-added } diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/Security2Test.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/Security2Test.java index 49a0365..a59ada5 100644 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/Security2Test.java +++ b/security/src/test/java/org/apache/harmony/security/tests/java/security/Security2Test.java @@ -358,4 +358,4 @@ public class Security2Test extends junit.framework.TestCase { Security.removeProvider(entrust.getName()); } } -}
\ No newline at end of file +} diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/SecurityTest.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/SecurityTest.java index c03afc5..aa4c71b 100644 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/SecurityTest.java +++ b/security/src/test/java/org/apache/harmony/security/tests/java/security/SecurityTest.java @@ -205,9 +205,7 @@ public class SecurityTest extends TestCase { } assertEquals("Providers not removed", 0, Security.getProviders().length); - } catch (Exception e) { - e.printStackTrace(); - } finally { // restore providers + } finally { // restore providers for (int i = 0; i < providers.length; i++) { Security.addProvider(providers[i]); } @@ -453,6 +451,9 @@ public class SecurityTest extends TestCase { fail("No expected NullPointerException."); } catch (NullPointerException e) { } + + Security.setProperty("myprop","test white space "); + assertEquals("test white space", Security.getProperty("myprop")); } /** diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/Signature2Test.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/Signature2Test.java index 20bc4b1..a657f60 100644 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/Signature2Test.java +++ b/security/src/test/java/org/apache/harmony/security/tests/java/security/Signature2Test.java @@ -39,6 +39,7 @@ import java.security.SignatureException; import java.security.cert.Certificate; import java.security.spec.DSAParameterSpec; import java.util.HashSet; +import java.util.Locale; import java.util.Set; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/SignatureException2Test.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/SignatureException2Test.java deleted file mode 100644 index 9a6209a..0000000 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/SignatureException2Test.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.security.tests.java.security; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; - -import java.security.SignatureException; - -@TestTargetClass(SignatureException.class) -public class SignatureException2Test extends junit.framework.TestCase { - - /** - * @tests java.security.SignatureException#SignatureException() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "SignatureException", - args = {} - ) - public void test_Constructor() { - // Test for method java.security.SignatureException() - SignatureException e = new SignatureException(); - assertEquals("Failed toString test for constructed instance", "java.security.SignatureException", e - .toString()); - } - - /** - * @tests java.security.SignatureException#SignatureException(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Verification with null string parameter missed", - method = "SignatureException", - args = {java.lang.String.class} - ) - public void test_ConstructorLjava_lang_String() { - // Test for method java.security.SignatureException(java.lang.String) - SignatureException e = new SignatureException("test message"); - assertEquals("Failed toString test for constructed instance", - "java.security.SignatureException: test message", e - .toString()); - } -}
\ No newline at end of file diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/SignedObjectTest.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/SignedObjectTest.java index 77f341b..89d872e 100644 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/SignedObjectTest.java +++ b/security/src/test/java/org/apache/harmony/security/tests/java/security/SignedObjectTest.java @@ -15,11 +15,6 @@ * limitations under the License. */ -/** -* @author Boris V. Kuznetsov -* @version $Revision$ -*/ - package org.apache.harmony.security.tests.java.security; import dalvik.annotation.TestLevel; @@ -27,6 +22,11 @@ import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; import dalvik.annotation.TestTargets; +import java.security.NoSuchAlgorithmException; +import java.security.Signature; +import java.security.SignedObject; +import java.util.Properties; + import junit.framework.TestCase; import org.apache.harmony.security.tests.support.TestKeyPair; @@ -47,7 +47,6 @@ import java.util.Properties; @TestTargetClass(SignedObject.class) /** * Tests for <code>SignedObject</code> constructor and methods - * */ public class SignedObjectTest extends TestCase { @@ -83,17 +82,11 @@ public class SignedObjectTest extends TestCase { args = {java.security.PublicKey.class, java.security.Signature.class} ) }) - public void testSignedObject() { - Signature sig = null; + public void testSignedObject() throws Exception { TestKeyPair tkp = null; Properties prop; - - try { - sig = Signature.getInstance("SHA1withDSA"); - } catch (NoSuchAlgorithmException e) { - fail(e.toString()); - } - + Signature sig = Signature.getInstance("SHA1withDSA"); + try { tkp = new TestKeyPair("DSA"); } catch (NoSuchAlgorithmException e) { @@ -102,133 +95,14 @@ public class SignedObjectTest extends TestCase { } prop = new Properties(); prop.put("aaa", "bbb"); - SignedObject so = null; - try { - so = new SignedObject(prop, tkp.getPrivate(), sig); - } catch (IOException e) { - fail(e.toString()); - } catch (SignatureException e) { - fail(e.toString()); - } catch (InvalidKeyException e) { - fail(e.toString()); - } catch (InvalidKeySpecException e) { - fail(e.toString()); - } + + SignedObject so = new SignedObject(prop, tkp.getPrivate(), sig); assertEquals("SHA1withDSA", so.getAlgorithm()); - - try { - assertEquals(so.getObject(), prop); - } catch (ClassNotFoundException e) { - fail(e.toString()); - } catch (IOException e) { - fail(e.toString()); - } - try { - if (!so.verify(tkp.getPublic(), sig)) { - fail("verify() failed"); - } - } catch (SignatureException e) { - fail(e.toString()); - } catch (InvalidKeyException e) { - fail(e.toString()); - } catch (InvalidKeySpecException e) { - fail(e.toString()); - } - - if (so.getSignature() == null) { - fail("signature is null"); - } - - try { - TestKeyPair tkp2 = new TestKeyPair("DH"); - so = new SignedObject(prop, tkp2.getPrivate(), sig); - } catch(InvalidKeyException e) { - // ok - } catch (NoSuchAlgorithmException e) { - fail(e.toString()); - } catch (SignatureException e) { - fail(e.toString()); - } catch (InvalidKeySpecException e) { - fail(e.toString()); - } catch (IOException e) { - fail(e.toString()); - } - - try { - new SignedObject(new Serializable() { - private void writeObject(ObjectOutputStream out) throws IOException { - throw new IOException(); - } - }, tkp.getPrivate(), sig); - } catch(InvalidKeyException e) { - fail(e.toString()); - } catch (SignatureException e) { - fail(e.toString()); - } catch (InvalidKeySpecException e) { - fail(e.toString()); - } catch (IOException e) { - // ok - } + assertEquals(prop, so.getObject()); - - try { - new SignedObject(prop, tkp.getPrivate(), new Signature("TST") { - - @Override - protected boolean engineVerify(byte[] sigBytes) throws SignatureException { - throw new SignatureException(); - } - - @Override - protected void engineUpdate(byte[] b, int off, int len) - throws SignatureException { - throw new SignatureException(); - } - - @Override - protected void engineUpdate(byte b) throws SignatureException { - throw new SignatureException(); - } - - @Override - protected byte[] engineSign() throws SignatureException { - throw new SignatureException(); - } - - @Override - protected void engineSetParameter(String param, Object value) - throws InvalidParameterException { - - } - - @Override - protected void engineInitVerify(PublicKey publicKey) - throws InvalidKeyException { - - } - - @Override - protected void engineInitSign(PrivateKey privateKey) - throws InvalidKeyException { - - } - - @Override - protected Object engineGetParameter(String param) - throws InvalidParameterException { - return null; - } - }); - } catch(InvalidKeyException e) { - fail(e.toString()); - } catch (SignatureException e) { - // ok - } catch (InvalidKeySpecException e) { - fail(e.toString()); - } catch (IOException e) { - fail(e.toString()); - } - + assertTrue("verify() failed", so.verify(tkp.getPublic(), sig)); + + assertNotNull("signature is null", so.getSignature()); } } diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/TimestampTest.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/TimestampTest.java index c3414f4..1015521 100644 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/TimestampTest.java +++ b/security/src/test/java/org/apache/harmony/security/tests/java/security/TimestampTest.java @@ -118,7 +118,7 @@ public class TimestampTest extends TestCase { args = {} ) public void testGetTimestamp() { - Timestamp t = new Timestamp(now, cpath); + Timestamp t = new Timestamp(now, cpath); assertEquals(now, t.getTimestamp()); assertNotSame(now, t.getTimestamp()); } diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/UnrecoverableKeyException2Test.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/UnrecoverableKeyException2Test.java deleted file mode 100644 index ce97d60..0000000 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/UnrecoverableKeyException2Test.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.harmony.security.tests.java.security; - -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; - -import java.security.UnrecoverableKeyException; - -@TestTargetClass(UnrecoverableKeyException.class) -public class UnrecoverableKeyException2Test extends junit.framework.TestCase { - - /** - * @tests java.security.UnrecoverableKeyException#UnrecoverableKeyException() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "UnrecoverableKeyException", - args = {} - ) - public void test_Constructor() { - // Test for method java.security.UnrecoverableKeyException() - UnrecoverableKeyException e = new UnrecoverableKeyException(); - assertEquals("Failed toString test for constructed instance", "java.security.UnrecoverableKeyException", e - .toString()); - } - - /** - * @tests java.security.UnrecoverableKeyException#UnrecoverableKeyException(java.lang.String) - */ - @TestTargetNew( - level = TestLevel.PARTIAL, - notes = "Verification with null string parameter missed", - method = "UnrecoverableKeyException", - args = {java.lang.String.class} - ) - public void test_ConstructorLjava_lang_String() { - // Test for method - // java.security.UnrecoverableKeyException(java.lang.String) - UnrecoverableKeyException e = new UnrecoverableKeyException( - "test message"); - assertEquals("Failed toString test for constructed instance", - "java.security.UnrecoverableKeyException: test message", e - .toString()); - } -}
\ No newline at end of file diff --git a/security/src/test/java/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.java b/security/src/test/java/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.java index ce02e9d..d03b43d 100644 --- a/security/src/test/java/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.java +++ b/security/src/test/java/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.java @@ -42,6 +42,11 @@ import org.apache.harmony.testframework.serialization.SerializationTest; import tests.util.SerializationTester; +import org.apache.harmony.testframework.serialization.SerializationTest; +import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert; + +import tests.util.SerializationTester; + import junit.framework.TestCase; @TestTargetClass(UnresolvedPermission.class) @@ -111,7 +116,6 @@ public class UnresolvedPermissionTest extends TestCase { assertFalse(up.implies(new AllPermission())); assertFalse(up.implies(new SecurityPermission("a.b.c"))); } - @TestTargetNew( level = TestLevel.COMPLETE, notes = "", @@ -134,7 +138,6 @@ public class UnresolvedPermissionTest extends TestCase { assertEquals("actions", deserializedUp.getUnresolvedActions()); assertNull(deserializedUp.getUnresolvedCerts()); } - @TestTargetNew( level = TestLevel.COMPLETE, notes = "", @@ -155,14 +158,11 @@ public class UnresolvedPermissionTest extends TestCase { assertEquals("java.security.SecurityPermission", deserializedUp .getUnresolvedType()); assertEquals("a.b.c", deserializedUp.getUnresolvedName()); - assertEquals("action", deserializedUp.getUnresolvedActions()); - Certificate[] certs = deserializedUp.getUnresolvedCerts(); - assertNotNull(certs); - assertEquals(1, certs.length); + assertEquals("actions", deserializedUp.getUnresolvedActions()); + assertNull(deserializedUp.getUnresolvedCerts()); } }); } - @TestTargetNew( level = TestLevel.COMPLETE, notes = "", diff --git a/security/src/test/java/tests/api/java/security/PermissionCollectionTest.java b/security/src/test/java/tests/api/java/security/PermissionCollectionTest.java index 35e3749..267923a 100644 --- a/security/src/test/java/tests/api/java/security/PermissionCollectionTest.java +++ b/security/src/test/java/tests/api/java/security/PermissionCollectionTest.java @@ -265,6 +265,7 @@ public class PermissionCollectionTest extends junit.framework.TestCase { "testing permissionCollection-isREadOnly"); assertNotNull("toString should have returned a string of elements", permi.newPermissionCollection().toString()); + assertTrue(permi.newPermissionCollection().toString().endsWith("\n")); } // FIXME move me to Support_Resources diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.golden.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.golden.ser Binary files differindex 2937f2f..931ee3f 100755 --- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.golden.ser +++ b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.golden.ser |