Patch: New java.security.* basics
Warren Levy
warrenl@cygnus.com
Thu Mar 9 18:41:00 GMT 2000
Folks,
I'm committing the following patch of a bunch of java.security stuff that
Tom Tromey and I have been working on recently. It is just the basics of
java.security and some of it is indeed stubbed. It has been tried with
the 20000120 snapshot of Cryptix JCE http://www.cryptix.org/products/jce
so it is usable.
Please note that it is mostly JDK 1.1 based but there are some JDK 1.2
things included. Enjoy!
--warrenl
2000-03-09 Warren Levy <warrenl@cygnus.com>
* java/security/AlgorithmParameterGeneratorSpi.java: New file.
* java/security/DigestException.java: New file.
* java/security/GeneralSecurityException.java: New file.
* java/security/InvalidAlgorithmParameterException.java: New file.
* java/security/InvalidKeyException.java: New file.
* java/security/InvalidParameterException.java: New file.
* java/security/Key.java: New file.
* java/security/KeyException.java: New file.
* java/security/KeyPair.java: New file.
* java/security/KeyPairGenerator.java: New file.
* java/security/KeyPairGeneratorSpi.java: New file.
* java/security/NoSuchProviderException.java: New file.
* java/security/PrivateKey.java: New file.
* java/security/Provider.java: New file.
* java/security/PublicKey.java: New file.
* java/security/SecureRandom.java: New file.
* java/security/Security.java: New file.
* java/security/Signature.java: New file.
* java/security/SignatureException.java: New file.
* java/security/interfaces/DSAKey.java: New file.
* java/security/interfaces/DSAParams.java: New file.
* java/security/interfaces/DSAPrivateKey.java: New file.
* java/security/interfaces/DSAPublicKey.java: New file.
* java/security/interfaces/RSAPrivateCrtKey.java: New file.
* java/security/interfaces/RSAPrivateKey.java: New file.
* java/security/interfaces/RSAPublicKey.java: New file.
* java/security/spec/AlgorithmParameterSpec.java: New file.
* java/security/spec/InvalidKeySpecException.java: New file.
* java/security/spec/InvalidParameterSpecException.java: New file.
* java/security/spec/KeySpec.java: New file.
* java/security/spec/RSAPrivateCrtKeySpec.java: New file.
* java/security/spec/RSAPrivateKeySpec.java: New file.
* java/security/spec/RSAPublicKeySpec.java: New file.
* Makefile.am: Added above java.security files.
* Makefile.in: Rebuilt.
* java/security/MessageDigest.java: Rewritten.
* java/security/SecureClassLoader.java: Added JDK1.2 comment.
Index: java/security/AlgorithmParameterGeneratorSpi.java
===================================================================
RCS file: AlgorithmParameterGeneratorSpi.java
diff -N AlgorithmParameterGeneratorSpi.java
--- /dev/null Tue May 5 13:32:27 1998
+++ AlgorithmParameterGeneratorSpi.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,25 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 7, 2000.
+ */
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification.
+ * Status: Stubbed.
+ */
+
+// JDK1.2
+public abstract class AlgorithmParameterGeneratorSpi
+{
+ // FIXME: Stubbed.
+}
Index: java/security/DigestException.java
===================================================================
RCS file: DigestException.java
diff -N DigestException.java
--- /dev/null Tue May 5 13:32:27 1998
+++ DigestException.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,32 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 1, 2000.
+ */
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification.
+ * Status: Believed complete and correct.
+ */
+
+public class DigestException extends GeneralSecurityException
+{
+ public DigestException()
+ {
+ super();
+ }
+
+ public DigestException(String msg)
+ {
+ super(msg);
+ }
+}
Index: java/security/GeneralSecurityException.java
===================================================================
RCS file: GeneralSecurityException.java
diff -N GeneralSecurityException.java
--- /dev/null Tue May 5 13:32:27 1998
+++ GeneralSecurityException.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,33 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 1, 2000.
+ */
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification.
+ * Status: Believed complete and correct.
+ */
+
+// JDK1.2
+public class GeneralSecurityException extends Exception
+{
+ public GeneralSecurityException()
+ {
+ super();
+ }
+
+ public GeneralSecurityException(String msg)
+ {
+ super(msg);
+ }
+}
Index: java/security/InvalidAlgorithmParameterException.java
===================================================================
RCS file: InvalidAlgorithmParameterException.java
diff -N InvalidAlgorithmParameterException.java
--- /dev/null Tue May 5 13:32:27 1998
+++ InvalidAlgorithmParameterException.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,33 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 2, 2000.
+ */
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification.
+ * Status: Believed complete and correct.
+ */
+
+// JDK1.2
+public class InvalidAlgorithmParameterException extends GeneralSecurityException
+{
+ public InvalidAlgorithmParameterException()
+ {
+ super();
+ }
+
+ public InvalidAlgorithmParameterException(String msg)
+ {
+ super(msg);
+ }
+}
Index: java/security/InvalidKeyException.java
===================================================================
RCS file: InvalidKeyException.java
diff -N InvalidKeyException.java
--- /dev/null Tue May 5 13:32:27 1998
+++ InvalidKeyException.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,32 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 1, 2000.
+ */
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification.
+ * Status: Believed complete and correct.
+ */
+
+public class InvalidKeyException extends KeyException
+{
+ public InvalidKeyException()
+ {
+ super();
+ }
+
+ public InvalidKeyException(String msg)
+ {
+ super(msg);
+ }
+}
Index: java/security/InvalidParameterException.java
===================================================================
RCS file: InvalidParameterException.java
diff -N InvalidParameterException.java
--- /dev/null Tue May 5 13:32:27 1998
+++ InvalidParameterException.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,32 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 1, 2000.
+ */
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification.
+ * Status: Believed complete and correct.
+ */
+
+public class InvalidParameterException extends IllegalArgumentException
+{
+ public InvalidParameterException()
+ {
+ super();
+ }
+
+ public InvalidParameterException(String msg)
+ {
+ super(msg);
+ }
+}
Index: java/security/Key.java
===================================================================
RCS file: Key.java
diff -N Key.java
--- /dev/null Tue May 5 13:32:27 1998
+++ Key.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,29 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security;
+import java.io.Serializable;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 1, 2000.
+ */
+
+/* Written using on-line Java Platform 1.2 API Specification.
+ * Status: Believed complete and correct.
+ */
+
+public interface Key extends Serializable
+{
+ // FIXME: need to set this at some point when serialization is implemented.
+ public static final long serialVersionUID;
+
+ public String getAlgorithm();
+ public String getFormat();
+ public byte[] getEncoded();
+}
Index: java/security/KeyException.java
===================================================================
RCS file: KeyException.java
diff -N KeyException.java
--- /dev/null Tue May 5 13:32:27 1998
+++ KeyException.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,32 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 1, 2000.
+ */
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification.
+ * Status: Believed complete and correct.
+ */
+
+public class KeyException extends GeneralSecurityException
+{
+ public KeyException()
+ {
+ super();
+ }
+
+ public KeyException(String msg)
+ {
+ super(msg);
+ }
+}
Index: java/security/KeyPair.java
===================================================================
RCS file: KeyPair.java
diff -N KeyPair.java
--- /dev/null Tue May 5 13:32:27 1998
+++ KeyPair.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,41 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security;
+
+/**
+ * @author Tom Tromey <tromey@cygnus.com>
+ * @date February 9, 2000.
+ */
+
+/* Written using on-line Java Platform 1.2 API Specification.
+ * Status: Believed complete and correct.
+ */
+
+public class KeyPair /* FIXME: implements serializable */
+{
+ public KeyPair (PublicKey publicKey, PrivateKey privateKey)
+ {
+ this.publicKey = publicKey;
+ this.privateKey = privateKey;
+ }
+
+ public PublicKey getPublic ()
+ {
+ return publicKey;
+ }
+
+ public PrivateKey getPrivate ()
+ {
+ return privateKey;
+ }
+
+ // The keys.
+ private PublicKey publicKey;
+ private PrivateKey privateKey;
+}
Index: java/security/KeyPairGenerator.java
===================================================================
RCS file: KeyPairGenerator.java
diff -N KeyPairGenerator.java
--- /dev/null Tue May 5 13:32:27 1998
+++ KeyPairGenerator.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,86 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 10, 2000.
+ */
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification.
+ * Status: Partially implemented to the 1.1 spec.
+ * It is known not to comply with the 1.2 spec.
+ */
+
+public abstract class KeyPairGenerator extends KeyPairGeneratorSpi
+{
+ protected KeyPairGenerator(String algorithm)
+ {
+ name = algorithm;
+ }
+
+ public static KeyPairGenerator getInstance(String algorithm)
+ throws NoSuchAlgorithmException
+ {
+ String name = "KeyPairGenerator." + algorithm;
+ Provider[] provs = Security.getProviders();
+ for (int i = 0; i < provs.length; ++i)
+ {
+ String val = provs[i].getProperty(name);
+ if (val != null)
+ {
+ try
+ {
+ return (KeyPairGenerator) Class.forName(val).newInstance();
+ }
+ catch (Throwable _)
+ {
+ // We just ignore failures.
+ }
+ }
+ }
+
+ throw new NoSuchAlgorithmException(algorithm);
+ }
+
+ public static KeyPairGenerator getInstance(String algorithm, String provider)
+ throws NoSuchAlgorithmException, NoSuchProviderException
+ {
+ String name = "KeyPairGenerator." + algorithm;
+ Provider p = Security.getProvider(provider);
+ if (p == null)
+ throw new NoSuchProviderException(provider);
+ String val = p.getProperty(name);
+ if (val != null)
+ {
+ try
+ {
+ return (KeyPairGenerator) Class.forName(val).newInstance();
+ }
+ catch (Throwable _)
+ {
+ // Nothing.
+ }
+ }
+
+ throw new NoSuchAlgorithmException(algorithm);
+ }
+
+ public String getAlgorithm()
+ {
+ return name;
+ }
+
+ public abstract void initialize(int strength, SecureRandom random);
+ public abstract KeyPair generateKeyPair();
+
+ // Algorithm name.
+ private String name;
+}
Index: java/security/KeyPairGeneratorSpi.java
===================================================================
RCS file: KeyPairGeneratorSpi.java
diff -N KeyPairGeneratorSpi.java
--- /dev/null Tue May 5 13:32:27 1998
+++ KeyPairGeneratorSpi.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,26 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 7, 2000.
+ */
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification.
+ * Status: Partially implemented.
+ */
+
+// JDK1.2
+public abstract class KeyPairGeneratorSpi
+{
+ public abstract void initialize(int keysize, SecureRandom random);
+ public abstract KeyPair generateKeyPair();
+}
Index: java/security/MessageDigest.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/security/MessageDigest.java,v
retrieving revision 1.3
diff -u -p -r1.3 MessageDigest.java
--- MessageDigest.java 2000/03/07 19:55:27 1.3
+++ MessageDigest.java 2000/03/10 02:35:09
@@ -1,6 +1,6 @@
// MessageDigest.java
-/* Copyright (C) 1999 Free Software Foundation
+/* Copyright (C) 2000 Free Software Foundation
This file is part of libgcj.
@@ -10,55 +10,135 @@ details. */
package java.security;
-// FIXME: This is just a stub for a proper implementation.
+/**
+ * @author Tom Tromey <tromey@cygnus.com>
+ * @date February 11, 2000.
+ */
+
+/**
+ * Written using on-line Java Platform 1.1 API Specification.
+ * Status: Believed complete and correct to 1.1 spec.
+ * It is known not to comply with the 1.2 spec.
+ */
+
public abstract class MessageDigest
{
- private static final byte[] dummy = { 0 };
+ protected MessageDigest (String algorithm)
+ {
+ name = algorithm;
+ }
+
+ public static MessageDigest getInstance (String algorithm)
+ throws NoSuchAlgorithmException
+ {
+ String name = "MessageDigest." + algorithm;
+ Provider[] provs = Security.getProviders ();
+ for (int i = 0; i < provs.length; ++i)
+ {
+ String val = provs[i].getProperty (name);
+ if (val != null)
+ {
+ try
+ {
+ return (MessageDigest) Class.forName(val).newInstance ();
+ }
+ catch (Throwable _)
+ {
+ // We just ignore failures.
+ }
+ }
+ }
+
+ throw new NoSuchAlgorithmException (algorithm);
+ }
+
+ public static MessageDigest getInstance (String algorithm, String provider)
+ throws NoSuchAlgorithmException, NoSuchProviderException
+ {
+ String name = "MessageDigest." + algorithm;
+ Provider p = Security.getProvider (provider);
+ if (p == null)
+ throw new NoSuchProviderException (provider);
+ String val = p.getProperty (name);
+ if (val != null)
+ {
+ try
+ {
+ return (MessageDigest) Class.forName(val).newInstance ();
+ }
+ catch (Throwable _)
+ {
+ // Nothing.
+ }
+ }
+
+ throw new NoSuchAlgorithmException (algorithm);
+ }
+
+ public void update (byte input)
+ {
+ engineUpdate (input);
+ }
+
+ public void update (byte[] input, int offset, int len)
+ {
+ engineUpdate (input, offset, len);
+ }
+
+ public void update (byte[] input)
+ {
+ engineUpdate (input, 0, input.length);
+ }
+
+ public byte[] digest ()
+ {
+ return engineDigest ();
+ }
+
+ public byte[] digest (byte[] input)
+ {
+ update (input);
+ return engineDigest ();
+ }
+
+ public String toString ()
+ {
+ // There is no spec for this.
+ return "[MessageDigest: " + name + "]";
+ }
+
+ public static boolean isEqual (byte[] digesta, byte[] digestb)
+ {
+ if (digesta == digestb)
+ return true;
+ if (digesta.length != digestb.length)
+ return false;
+ for (int i = digesta.length - 1; i >= 0; --i)
+ if (digesta[i] != digestb[i])
+ return false;
+ return true;
+ }
+
+ public void reset ()
+ {
+ engineReset ();
+ }
+
+ public final String getAlgorithm ()
+ {
+ return name;
+ }
+
+ protected abstract void engineUpdate (byte input);
+ protected abstract void engineUpdate (byte input[], int offset, int len);
+ protected abstract byte[] engineDigest ();
+ protected abstract void engineReset ();
+
+ public Object clone() throws CloneNotSupportedException
+ {
+ return super.clone ();
+ }
- public static MessageDigest getInstance(String algorithm)
- throws NoSuchAlgorithmException
- {
- Object obj;
-
- try {
- obj = Class.forName(algorithm).newInstance();
- } catch (Exception e) {
- throw new NoSuchAlgorithmException("algorithm "
- + algorithm
- + " not available.");
- }
-
- return (MessageDigest) obj;
- }
-
- public void update(byte input)
- {
- // FIXME
- }
-
- public void update(byte[] input, int offset, int len)
- {
- // FIXME
- }
-
- public void update(byte[] input)
- {
- // FIXME
- }
-
- public byte[] digest()
- {
- return dummy;
- }
-
- public byte[] digest(byte[] input)
- {
- update(input);
- return digest();
- }
-
- public void reset()
- {
- // FIXME
- }
+ // Algorithm name.
+ private String name;
}
Index: java/security/NoSuchProviderException.java
===================================================================
RCS file: NoSuchProviderException.java
diff -N NoSuchProviderException.java
--- /dev/null Tue May 5 13:32:27 1998
+++ NoSuchProviderException.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,32 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 4, 2000.
+ */
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification.
+ * Status: Believed complete and correct.
+ */
+
+public class NoSuchProviderException extends GeneralSecurityException
+{
+ public NoSuchProviderException()
+ {
+ super();
+ }
+
+ public NoSuchProviderException(String msg)
+ {
+ super(msg);
+ }
+}
Index: java/security/PrivateKey.java
===================================================================
RCS file: PrivateKey.java
diff -N PrivateKey.java
--- /dev/null Tue May 5 13:32:27 1998
+++ PrivateKey.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,24 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 1, 2000.
+ */
+
+/* Written using on-line Java Platform 1.2 API Specification.
+ * Status: Believed complete and correct.
+ */
+
+public interface PrivateKey extends Key
+{
+ // This interface contains no methods or constants. It merely serves
+ // to group (and provide type safety for) all private key interfaces.
+}
Index: java/security/Provider.java
===================================================================
RCS file: Provider.java
diff -N Provider.java
--- /dev/null Tue May 5 13:32:27 1998
+++ Provider.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,53 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security;
+import java.util.Properties;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 7, 2000.
+ */
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification.
+ * Status: Partially implemented.
+ */
+
+public abstract class Provider extends Properties
+{
+ // FIXME: Check the following property values against specs!
+ protected Provider(String name, double version, String info)
+ {
+ super();
+ put("java.security.Provider.Name", name);
+ put("java.security.Provider.Version", Double.toString(version));
+ put("java.security.Provider.Info", info);
+ }
+
+ public String getName()
+ {
+ return getProperty("java.security.Provider.Name");
+ }
+
+ public double getVersion()
+ {
+ return Double.valueOf(getProperty("java.security.Provider.Version")).doubleValue();
+ }
+
+ public String getInfo()
+ {
+ return getProperty("java.security.Provider.Info");
+ }
+
+ public String toString()
+ {
+ // FIXME: Check this string against the spec.
+ return getName() + " " + getProperty("java.security.Provider.Version");
+ }
+}
Index: java/security/PublicKey.java
===================================================================
RCS file: PublicKey.java
diff -N PublicKey.java
--- /dev/null Tue May 5 13:32:27 1998
+++ PublicKey.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,24 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 1, 2000.
+ */
+
+/* Written using on-line Java Platform 1.2 API Specification.
+ * Status: Believed complete and correct.
+ */
+
+public interface PublicKey extends Key
+{
+ // This interface contains no methods or constants. It merely serves
+ // to group (and provide type safety for) all private key interfaces.
+}
Index: java/security/SecureClassLoader.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/security/SecureClassLoader.java,v
retrieving revision 1.3
diff -u -p -r1.3 SecureClassLoader.java
--- SecureClassLoader.java 2000/03/07 19:55:27 1.3
+++ SecureClassLoader.java 2000/03/10 02:35:09
@@ -8,6 +8,7 @@ details. */
package java.security;
+// JDK1.2
public class SecureClassLoader extends ClassLoader
{
public SecureClassLoader ()
Index: java/security/SecureRandom.java
===================================================================
RCS file: SecureRandom.java
diff -N SecureRandom.java
--- /dev/null Tue May 5 13:32:27 1998
+++ SecureRandom.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,25 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security;
+import java.util.Random;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 7, 2000.
+ */
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification.
+ * Status: Stubbed.
+ */
+
+public class SecureRandom extends Random
+{
+ // FIXME: Stubbed.
+}
Index: java/security/Security.java
===================================================================
RCS file: Security.java
diff -N Security.java
--- /dev/null Tue May 5 13:32:27 1998
+++ Security.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,107 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security;
+
+import java.util.Enumeration;
+import java.util.Properties;
+import java.util.Vector;
+
+/**
+ * @author Tom Tromey <tromey@cygnus.com>
+ * @date February 8, 2000.
+ */
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification.
+ * Status: Still missing the deprecated getAlgorithmProperty method.
+ */
+
+public final class Security
+{
+ public static int insertProviderAt (Provider provider, int position)
+ {
+ SecurityManager sm = System.getSecurityManager ();
+ if (sm != null)
+ {
+ // FIXME: need SecurityPermission.
+ // sm.checkSecurityAccess ("insertProvider." + provider.getName ());
+ }
+ if (providers.indexOf (provider) != -1)
+ return -1;
+ if (position > providers.size ())
+ position = providers.size ();
+ providers.insertElementAt (provider, position);
+ return providers.indexOf (provider);
+ }
+
+ public static int addProvider (Provider provider)
+ {
+ return insertProviderAt (provider, providers.size ());
+ }
+
+ public static void removeProvider (String name)
+ {
+ SecurityManager sm = System.getSecurityManager ();
+ if (sm != null)
+ {
+ // FIXME: need SecurityPermission.
+ // sm.checkSecurityAccess ("removeProvider." + name);
+ }
+ Provider p = getProvider (name);
+ if (p != null)
+ providers.removeElement (p);
+ }
+
+ public static Provider[] getProviders ()
+ {
+ Provider[] r = new Provider[providers.size ()];
+ providers.copyInto (r);
+ return r;
+ }
+
+ public static Provider getProvider (String name)
+ {
+ Enumeration e = providers.elements ();
+ while (e.hasMoreElements ())
+ {
+ Provider p = (Provider) e.nextElement ();
+ if (name.equals (p.getName ()))
+ return p;
+ }
+ return null;
+ }
+
+ public static String getProperty (String key)
+ {
+ SecurityManager sm = System.getSecurityManager ();
+ if (sm != null)
+ {
+ // FIXME: need SecurityPermission.
+ // sm.checkSecurityAccess ("getProperty." + key);
+ }
+ return props.getProperty (key);
+ }
+
+ public static void setProperty (String key, String value)
+ {
+ SecurityManager sm = System.getSecurityManager ();
+ if (sm != null)
+ {
+ // FIXME: need SecurityPermission.
+ // sm.checkSecurityAccess ("setProperty." + key);
+ }
+ props.setProperty (key, value);
+ }
+
+ // The providers we list.
+ private static Vector providers = new Vector ();
+
+ // Security propertiesl
+ private static Properties props = new Properties ();
+}
Index: java/security/Signature.java
===================================================================
RCS file: Signature.java
diff -N Signature.java
--- /dev/null Tue May 5 13:32:27 1998
+++ Signature.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,173 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security;
+
+/**
+ * @author Tom Tromey <tromey@cygnus.com>
+ * @date February 11, 2000.
+ */
+
+/**
+ * Written using on-line Java Platform 1.1 API Specification.
+ * Status: Believed complete and correct to 1.1 spec.
+ * It is known not to comply with the 1.2 spec.
+ */
+
+public abstract class Signature
+{
+ protected Signature (String name)
+ {
+ state = UNINITIALIZED;
+ this.name = name;
+ }
+
+ public static Signature getInstance (String algorithm)
+ throws NoSuchAlgorithmException
+ {
+ String name = "Signature." + algorithm;
+ Provider[] provs = Security.getProviders ();
+ for (int i = 0; i < provs.length; ++i)
+ {
+ String val = provs[i].getProperty (name);
+ if (val != null)
+ {
+ try
+ {
+ return (Signature) Class.forName(val).newInstance ();
+ }
+ catch (Throwable _)
+ {
+ // We just ignore failures.
+ }
+ }
+ }
+
+ throw new NoSuchAlgorithmException (algorithm);
+ }
+
+ public static Signature getInstance (String algorithm, String provider)
+ throws NoSuchAlgorithmException, NoSuchProviderException
+ {
+ String name = "Signature." + algorithm;
+ Provider p = Security.getProvider (provider);
+ if (p == null)
+ throw new NoSuchProviderException (provider);
+ String val = p.getProperty (name);
+ if (val != null)
+ {
+ try
+ {
+ return (Signature) Class.forName(val).newInstance ();
+ }
+ catch (Throwable _)
+ {
+ // Nothing.
+ }
+ }
+
+ throw new NoSuchAlgorithmException (algorithm);
+ }
+
+ public final void initVerify (PublicKey publicKey)
+ throws InvalidKeyException
+ {
+ engineInitVerify (publicKey);
+ }
+
+ public final void initSign (PrivateKey privateKey)
+ throws InvalidKeyException
+ {
+ engineInitSign (privateKey);
+ }
+
+ public final byte[] sign ()
+ throws SignatureException
+ {
+ return engineSign ();
+ }
+
+ public final boolean verify (byte[] signature)
+ throws SignatureException
+ {
+ return engineVerify (signature);
+ }
+
+ public final void update (byte b)
+ throws SignatureException
+ {
+ engineUpdate (b);
+ }
+
+ public final void update (byte[] data)
+ throws SignatureException
+ {
+ engineUpdate (data, 0, data.length);
+ }
+
+ public final void update (byte[] data, int off, int len)
+ throws SignatureException
+ {
+ engineUpdate (data, off, len);
+ }
+
+ public final String getAlgorithm ()
+ {
+ return name;
+ }
+
+ public String toString ()
+ {
+ // There is no spec for this. FIXME: this is a bad choice.
+ return name + "; state = " + state;
+ }
+
+ public final void setParameter (String param, Object value)
+ throws InvalidParameterException
+ {
+ engineSetParameter (param, value);
+ }
+
+ public final Object getParameter (String param)
+ throws InvalidParameterException
+ {
+ return engineGetParameter (param);
+ }
+
+ protected abstract void engineInitVerify (PublicKey publicKey)
+ throws InvalidKeyException;
+ protected abstract void engineInitSign (PrivateKey privateKey)
+ throws InvalidKeyException;
+ protected abstract void engineUpdate (byte b)
+ throws SignatureException;
+ protected abstract void engineUpdate (byte[] b, int off, int len)
+ throws SignatureException;
+ protected abstract byte[] engineSign ()
+ throws SignatureException;
+ protected abstract boolean engineVerify (byte[] sigBytes)
+ throws SignatureException;
+ protected abstract void engineSetParameter (String param, Object value)
+ throws InvalidParameterException;
+ protected abstract Object engineGetParameter (String param)
+ throws InvalidParameterException;
+
+ public Object clone() throws CloneNotSupportedException
+ {
+ return super.clone ();
+ }
+
+ protected static final int UNINITIALIZED = 0;
+ protected static final int SIGN = 2;
+ protected static final int VERIFY = 3;
+
+ // Current state.
+ protected int state;
+
+ // Name of this object.
+ private String name;
+}
Index: java/security/SignatureException.java
===================================================================
RCS file: SignatureException.java
diff -N SignatureException.java
--- /dev/null Tue May 5 13:32:27 1998
+++ SignatureException.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,32 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 1, 2000.
+ */
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification.
+ * Status: Believed complete and correct.
+ */
+
+public class SignatureException extends GeneralSecurityException
+{
+ public SignatureException()
+ {
+ super();
+ }
+
+ public SignatureException(String msg)
+ {
+ super(msg);
+ }
+}
Index: java/security/interfaces/DSAKey.java
===================================================================
RCS file: DSAKey.java
diff -N DSAKey.java
--- /dev/null Tue May 5 13:32:27 1998
+++ DSAKey.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,23 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security.interfaces;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 1, 2000.
+ */
+
+/* Written using on-line Java Platform 1.2 API Specification.
+ * Status: Believed complete and correct.
+ */
+
+public interface DSAKey
+{
+ public DSAParams getParams();
+}
Index: java/security/interfaces/DSAParams.java
===================================================================
RCS file: DSAParams.java
diff -N DSAParams.java
--- /dev/null Tue May 5 13:32:27 1998
+++ DSAParams.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,26 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security.interfaces;
+import java.math.BigInteger;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 1, 2000.
+ */
+
+/* Written using on-line Java Platform 1.2 API Specification.
+ * Status: Believed complete and correct.
+ */
+
+public interface DSAParams
+{
+ public BigInteger getP();
+ public BigInteger getQ();
+ public BigInteger getG();
+}
Index: java/security/interfaces/DSAPrivateKey.java
===================================================================
RCS file: DSAPrivateKey.java
diff -N DSAPrivateKey.java
--- /dev/null Tue May 5 13:32:27 1998
+++ DSAPrivateKey.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,27 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security.interfaces;
+import java.security.PrivateKey;
+import java.math.BigInteger;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 1, 2000.
+ */
+
+/* Written using on-line Java Platform 1.2 API Specification.
+ * Status: Believed complete and correct.
+ */
+
+public interface DSAPrivateKey extends DSAKey, PrivateKey
+{
+ public static final long serialVersionUID;
+
+ public BigInteger getX();
+}
Index: java/security/interfaces/DSAPublicKey.java
===================================================================
RCS file: DSAPublicKey.java
diff -N DSAPublicKey.java
--- /dev/null Tue May 5 13:32:27 1998
+++ DSAPublicKey.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,27 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security.interfaces;
+import java.security.PublicKey;
+import java.math.BigInteger;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 1, 2000.
+ */
+
+/* Written using on-line Java Platform 1.2 API Specification.
+ * Status: Believed complete and correct.
+ */
+
+public interface DSAPublicKey extends DSAKey, PublicKey
+{
+ public static final long serialVersionUID;
+
+ public BigInteger getY();
+}
Index: java/security/interfaces/RSAPrivateCrtKey.java
===================================================================
RCS file: RSAPrivateCrtKey.java
diff -N RSAPrivateCrtKey.java
--- /dev/null Tue May 5 13:32:27 1998
+++ RSAPrivateCrtKey.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,30 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security.interfaces;
+import java.math.BigInteger;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 1, 2000.
+ */
+
+/* Written using on-line Java Platform 1.2 API Specification.
+ * Status: Believed complete and correct.
+ */
+
+// JDK1.2
+public interface RSAPrivateCrtKey extends RSAPrivateKey
+{
+ public BigInteger getPublicExponent();
+ public BigInteger getPrimeP();
+ public BigInteger getPrimeQ();
+ public BigInteger getPrimeExponentP();
+ public BigInteger getPrimeExponentQ();
+ public BigInteger getCrtCoefficient();
+}
Index: java/security/interfaces/RSAPrivateKey.java
===================================================================
RCS file: RSAPrivateKey.java
diff -N RSAPrivateKey.java
--- /dev/null Tue May 5 13:32:27 1998
+++ RSAPrivateKey.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,27 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security.interfaces;
+import java.security.PrivateKey;
+import java.math.BigInteger;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 1, 2000.
+ */
+
+/* Written using on-line Java Platform 1.2 API Specification.
+ * Status: Believed complete and correct.
+ */
+
+// JDK1.2
+public interface RSAPrivateKey extends PrivateKey
+{
+ public BigInteger getModulus();
+ public BigInteger getPrivateExponent();
+}
Index: java/security/interfaces/RSAPublicKey.java
===================================================================
RCS file: RSAPublicKey.java
diff -N RSAPublicKey.java
--- /dev/null Tue May 5 13:32:27 1998
+++ RSAPublicKey.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,27 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security.interfaces;
+import java.security.PublicKey;
+import java.math.BigInteger;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 1, 2000.
+ */
+
+/* Written using on-line Java Platform 1.2 API Specification.
+ * Status: Believed complete and correct.
+ */
+
+// JDK1.2
+public interface RSAPublicKey extends PublicKey
+{
+ public BigInteger getModulus();
+ public BigInteger getPublicExponent();
+}
Index: java/security/spec/AlgorithmParameterSpec.java
===================================================================
RCS file: AlgorithmParameterSpec.java
diff -N AlgorithmParameterSpec.java
--- /dev/null Tue May 5 13:32:27 1998
+++ AlgorithmParameterSpec.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,25 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security.spec;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 1, 2000.
+ */
+
+/* Written using on-line Java Platform 1.2 API Specification.
+ * Status: Believed complete and correct.
+ */
+
+// JDK1.2
+public interface AlgorithmParameterSpec
+{
+ // This interface contains no methods or constants. Its only purpose is
+ // to group (and provide type safety for) all key specifications.
+}
Index: java/security/spec/InvalidKeySpecException.java
===================================================================
RCS file: InvalidKeySpecException.java
diff -N InvalidKeySpecException.java
--- /dev/null Tue May 5 13:32:27 1998
+++ InvalidKeySpecException.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,33 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security.spec;
+import java.security.GeneralSecurityException;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 1, 2000.
+ */
+
+/* Written using on-line Java Platform 1.2 API Specification.
+ * Status: Believed complete and correct.
+ */
+
+// JDK1.2
+public class InvalidKeySpecException extends GeneralSecurityException
+{
+ public InvalidKeySpecException()
+ {
+ super();
+ }
+
+ public InvalidKeySpecException(String msg)
+ {
+ super(msg);
+ }
+}
Index: java/security/spec/InvalidParameterSpecException.java
===================================================================
RCS file: InvalidParameterSpecException.java
diff -N InvalidParameterSpecException.java
--- /dev/null Tue May 5 13:32:27 1998
+++ InvalidParameterSpecException.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,33 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security.spec;
+import java.security.GeneralSecurityException;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 1, 2000.
+ */
+
+/* Written using on-line Java Platform 1.2 API Specification.
+ * Status: Believed complete and correct.
+ */
+
+// JDK1.2
+public class InvalidParameterSpecException extends GeneralSecurityException
+{
+ public InvalidParameterSpecException()
+ {
+ super();
+ }
+
+ public InvalidParameterSpecException(String msg)
+ {
+ super(msg);
+ }
+}
Index: java/security/spec/KeySpec.java
===================================================================
RCS file: KeySpec.java
diff -N KeySpec.java
--- /dev/null Tue May 5 13:32:27 1998
+++ KeySpec.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,25 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security.spec;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 1, 2000.
+ */
+
+/* Written using on-line Java Platform 1.2 API Specification.
+ * Status: Believed complete and correct.
+ */
+
+// JDK1.2
+public interface KeySpec
+{
+ // This interface contains no methods or constants. Its only purpose is
+ // to group (and provide type safety for) all key specifications.
+}
Index: java/security/spec/RSAPrivateCrtKeySpec.java
===================================================================
RCS file: RSAPrivateCrtKeySpec.java
diff -N RSAPrivateCrtKeySpec.java
--- /dev/null Tue May 5 13:32:27 1998
+++ RSAPrivateCrtKeySpec.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,23 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security.spec;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 7, 2000.
+ */
+
+/* Written using on-line Java Platform 1.2 API Specification.
+ * Status: Stubbed.
+ */
+
+// JDK1.2
+public class RSAPrivateCrtKeySpec extends RSAPrivateKeySpec
+{
+}
Index: java/security/spec/RSAPrivateKeySpec.java
===================================================================
RCS file: RSAPrivateKeySpec.java
diff -N RSAPrivateKeySpec.java
--- /dev/null Tue May 5 13:32:27 1998
+++ RSAPrivateKeySpec.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,23 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security.spec;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 7, 2000.
+ */
+
+/* Written using on-line Java Platform 1.2 API Specification.
+ * Status: Stubbed.
+ */
+
+// JDK1.2
+public class RSAPrivateKeySpec implements KeySpec
+{
+}
Index: java/security/spec/RSAPublicKeySpec.java
===================================================================
RCS file: RSAPublicKeySpec.java
diff -N RSAPublicKeySpec.java
--- /dev/null Tue May 5 13:32:27 1998
+++ RSAPublicKeySpec.java Thu Mar 9 18:35:09 2000
@@ -0,0 +1,23 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package java.security.spec;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date February 10, 2000.
+ */
+
+/* Written using on-line Java Platform 1.2 API Specification.
+ * Status: Stubbed.
+ */
+
+// JDK1.2
+public class RSAPublicKeySpec implements KeySpec
+{
+}
More information about the Java-patches
mailing list