aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/java/ChangeLog6
-rw-r--r--gcc/java/class.c1
-rw-r--r--gcc/java/decl.c1
-rw-r--r--libjava/ChangeLog53
-rw-r--r--libjava/Makefile.am77
-rw-r--r--libjava/Makefile.in216
-rw-r--r--libjava/gcj/Makefile.in2
-rw-r--r--libjava/gcj/javaprims.h10
-rw-r--r--libjava/gnu/gcj/runtime/VMClassLoader.java15
-rw-r--r--libjava/gnu/java/security/provider/DefaultPolicy.java55
-rw-r--r--libjava/java/lang/Class.h7
-rw-r--r--libjava/java/lang/Class.java58
-rw-r--r--libjava/java/lang/ClassLoader.java210
-rw-r--r--libjava/java/lang/Package.java287
-rw-r--r--libjava/java/lang/natClass.cc19
-rw-r--r--libjava/java/lang/natClassLoader.cc26
-rw-r--r--libjava/java/net/NetPermission.java65
-rw-r--r--libjava/java/net/SocketPermission.java377
-rw-r--r--libjava/java/security/AccessControlContext.java164
-rw-r--r--libjava/java/security/AccessControlException.java80
-rw-r--r--libjava/java/security/AccessController.java185
-rw-r--r--libjava/java/security/AlgorithmParameterGenerator.java219
-rw-r--r--libjava/java/security/AlgorithmParameterGeneratorSpi.java86
-rw-r--r--libjava/java/security/AlgorithmParameters.java265
-rw-r--r--libjava/java/security/AlgorithmParametersSpi.java134
-rw-r--r--libjava/java/security/AllPermission.java123
-rw-r--r--libjava/java/security/BasicPermission.java181
-rw-r--r--libjava/java/security/Certificate.java114
-rw-r--r--libjava/java/security/CodeSource.java316
-rw-r--r--libjava/java/security/DigestException.java52
-rw-r--r--libjava/java/security/DigestInputStream.java155
-rw-r--r--libjava/java/security/DigestOutputStream.java51
-rw-r--r--libjava/java/security/DomainCombiner.java53
-rw-r--r--libjava/java/security/DummyKeyPairGenerator.java48
-rw-r--r--libjava/java/security/DummyMessageDigest.java62
-rw-r--r--libjava/java/security/DummySignature.java83
-rw-r--r--libjava/java/security/GeneralSecurityException.java58
-rw-r--r--libjava/java/security/Guard.java44
-rw-r--r--libjava/java/security/GuardedObject.java84
-rw-r--r--libjava/java/security/Identity.java363
-rw-r--r--libjava/java/security/IdentityScope.java205
-rw-r--r--libjava/java/security/InvalidAlgorithmParameterException.java28
-rw-r--r--libjava/java/security/InvalidKeyException.java25
-rw-r--r--libjava/java/security/InvalidParameterException.java25
-rw-r--r--libjava/java/security/Key.java79
-rw-r--r--libjava/java/security/KeyException.java51
-rw-r--r--libjava/java/security/KeyFactory.java232
-rw-r--r--libjava/java/security/KeyFactorySpi.java120
-rw-r--r--libjava/java/security/KeyManagementException.java58
-rw-r--r--libjava/java/security/KeyPair.java73
-rw-r--r--libjava/java/security/KeyPairGenerator.java264
-rw-r--r--libjava/java/security/KeyPairGeneratorSpi.java82
-rw-r--r--libjava/java/security/KeyStore.java447
-rw-r--r--libjava/java/security/KeyStoreException.java57
-rw-r--r--libjava/java/security/KeyStoreSpi.java262
-rw-r--r--libjava/java/security/MessageDigest.java328
-rw-r--r--libjava/java/security/MessageDigestSpi.java147
-rw-r--r--libjava/java/security/NoSuchAlgorithmException.java52
-rw-r--r--libjava/java/security/NoSuchProviderException.java52
-rw-r--r--libjava/java/security/Permission.java274
-rw-r--r--libjava/java/security/PermissionCollection.java306
-rw-r--r--libjava/java/security/Permissions.java257
-rw-r--r--libjava/java/security/Policy.java150
-rw-r--r--libjava/java/security/Principal.java96
-rw-r--r--libjava/java/security/PrivateKey.java48
-rw-r--r--libjava/java/security/PrivilegedAction.java49
-rw-r--r--libjava/java/security/PrivilegedActionException.java102
-rw-r--r--libjava/java/security/PrivilegedExceptionAction.java52
-rw-r--r--libjava/java/security/ProtectionDomain.java132
-rw-r--r--libjava/java/security/Provider.java287
-rw-r--r--libjava/java/security/ProviderException.java58
-rw-r--r--libjava/java/security/PublicKey.java47
-rw-r--r--libjava/java/security/SecureClassLoader.java106
-rw-r--r--libjava/java/security/SecureRandom.java349
-rw-r--r--libjava/java/security/SecureRandomSpi.java72
-rw-r--r--libjava/java/security/Security.java339
-rw-r--r--libjava/java/security/SecurityPermission.java98
-rw-r--r--libjava/java/security/Signature.java513
-rw-r--r--libjava/java/security/SignatureException.java50
-rw-r--r--libjava/java/security/SignatureSpi.java243
-rw-r--r--libjava/java/security/SignedObject.java166
-rw-r--r--libjava/java/security/Signer.java142
-rw-r--r--libjava/java/security/UnrecoverableKeyException.java58
-rw-r--r--libjava/java/security/UnresolvedPermission.java184
-rw-r--r--libjava/java/security/acl/Acl.java138
-rw-r--r--libjava/java/security/acl/AclEntry.java132
-rw-r--r--libjava/java/security/acl/AclNotFoundException.java46
-rw-r--r--libjava/java/security/acl/Group.java79
-rw-r--r--libjava/java/security/acl/LastOwnerException.java47
-rw-r--r--libjava/java/security/acl/NotOwnerException.java49
-rw-r--r--libjava/java/security/acl/Owner.java84
-rw-r--r--libjava/java/security/acl/Permission.java56
-rw-r--r--libjava/java/security/interfaces/DSAKey.java50
-rw-r--r--libjava/java/security/interfaces/DSAKeyPairGenerator.java75
-rw-r--r--libjava/java/security/interfaces/DSAParams.java67
-rw-r--r--libjava/java/security/interfaces/DSAPrivateKey.java48
-rw-r--r--libjava/java/security/interfaces/DSAPublicKey.java48
-rw-r--r--libjava/java/security/interfaces/RSAKey.java44
-rw-r--r--libjava/java/security/interfaces/RSAPrivateCrtKey.java92
-rw-r--r--libjava/java/security/interfaces/RSAPrivateKey.java54
-rw-r--r--libjava/java/security/interfaces/RSAPublicKey.java54
-rw-r--r--libjava/java/security/spec/AlgorithmParameterSpec.java48
-rw-r--r--libjava/java/security/spec/DSAParameterSpec.java89
-rw-r--r--libjava/java/security/spec/DSAPrivateKeySpec.java102
-rw-r--r--libjava/java/security/spec/DSAPublicKeySpec.java102
-rw-r--r--libjava/java/security/spec/EncodedKeySpec.java74
-rw-r--r--libjava/java/security/spec/InvalidKeySpecException.java56
-rw-r--r--libjava/java/security/spec/InvalidParameterSpecException.java56
-rw-r--r--libjava/java/security/spec/KeySpec.java48
-rw-r--r--libjava/java/security/spec/PKCS8EncodedKeySpec.java70
-rw-r--r--libjava/java/security/spec/RSAKeyGenParameterSpec.java86
-rw-r--r--libjava/java/security/spec/RSAPrivateCrtKeySpec.java143
-rw-r--r--libjava/java/security/spec/RSAPrivateKeySpec.java80
-rw-r--r--libjava/java/security/spec/RSAPublicKeySpec.java80
-rw-r--r--libjava/java/security/spec/X509EncodedKeySpec.java71
115 files changed, 11888 insertions, 1550 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 43c5d49..a1464cf 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,9 @@
+2001-04-25 Bryce McKinlay <bryce@waitaki.otago.ac.nz>
+
+ * decl.c (init_decl_processing): Add new class "protectionDomain"
+ field.
+ * class.c (make_class_data): Set initial value for "protectionDomain".
+
2001-04-22 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* jvspec.c (lang_specific_driver): Fix memory allocation
diff --git a/gcc/java/class.c b/gcc/java/class.c
index c99dbaa..741881f 100644
--- a/gcc/java/class.c
+++ b/gcc/java/class.c
@@ -1455,6 +1455,7 @@ make_class_data (type)
PUSH_FIELD_VALUE (cons, "ancestors", null_pointer_node);
PUSH_FIELD_VALUE (cons, "idt", null_pointer_node);
PUSH_FIELD_VALUE (cons, "arrayclass", null_pointer_node);
+ PUSH_FIELD_VALUE (cons, "protectionDomain", null_pointer_node);
FINISH_RECORD_CONSTRUCTOR (cons);
diff --git a/gcc/java/decl.c b/gcc/java/decl.c
index 31e40b3..57bcf61 100644
--- a/gcc/java/decl.c
+++ b/gcc/java/decl.c
@@ -647,6 +647,7 @@ init_decl_processing ()
PUSH_FIELD (class_type_node, field, "ancestors", ptr_type_node);
PUSH_FIELD (class_type_node, field, "idt", ptr_type_node);
PUSH_FIELD (class_type_node, field, "arrayclass", ptr_type_node);
+ PUSH_FIELD (class_type_node, field, "protectionDomain", ptr_type_node);
for (t = TYPE_FIELDS (class_type_node); t != NULL_TREE; t = TREE_CHAIN (t))
FIELD_PRIVATE (t) = 1;
push_super_field (class_type_node, object_type_node);
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 540e0bb..8a0812a 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,56 @@
+2001-04-25 Bryce McKinlay <bryce@albatross.co.nz>
+
+ java.security merge and ClassLoader compliance fixes.
+
+ * java/lang/Class.h (Class): Include ProtectionDomain.h.
+ New protectionDomain field.
+ (forName): Add initialize parameter. Fixes declaration to comply with
+ JDK spec.
+ * java/lang/natClass.cc (forName): Correct declaration of the three-arg
+ variant. Honour "initialize" flag.
+ (getProtectionDomain0): New method.
+ * java/lang/Class.java: Fix forName() declaration.
+ (getPackage): New method based on Classpath implementation.
+ (getProtectionDomain0): New native method decl.
+ (getProtectionDomain): New method.
+ * java/lang/ClassLoader.java (getParent): Now final.
+ (definedPackages): New field.
+ (getPackage): New.
+ (defineClass): New variant with protectionDomain argument.
+ (definePackage): New.
+ (getPackages): New.
+ (findSystemClass): Now final.
+ (getSystemResourceAsStream): Remove redundant "final" modifier.
+ (getSystemResource): Remove redundant "final" modifier.
+ (getResources): Now final.
+ (protectionDomainPermission): New static field.
+ (unknownProtectionDomain): Ditto.
+ (defaultProtectionDomain): Ditto.
+ (getSystemClassLoader): Now non-native.
+ * java/util/ResourceBundle.java (tryGetSomeBundle): Use the correct
+ arguments for Class.forName().
+ * java/lang/Package.java: New file.
+ * gnu/gcj/runtime/VMClassLoader.java (getVMClassLoader): Removed.
+ (instance): Static initialize singleton.
+ (findClass): Override this, not findSystemClass.
+ * java/lang/natClassLoader.cc (defineClass0): Set class's
+ protectionDomain field as specified.
+ (getSystemClassLoader): Removed.
+ (findClass): Renamed from findSystemClass. Call the interpreter via
+ URLClassLoader.findClass if loading class via dlopen fails.
+
+ * java/security/*.java: java.security import/merge with Classpath.
+ * java/security/acl/*.java: Likewise.
+ * java/security/interfaces/*.java: Likewise.
+ * java/security/spec/*.java: Likewise.
+ * java/net/NetPermission.java: Likewise.
+ * java/net/SocketPermission.java: Likewise.
+ * gnu/java/security/provider/DefaultPolicy.java: Likewise.
+
+ * Makefile.am: Add new classes.
+ * Makefile.in: Rebuilt.
+ * gcj/javaprims.h: CNI namespace rebuild.
+
2001-04-24 Alexandre Oliva <aoliva@redhat.com>
* configure.in (CPPFLAGS): Added builddir and srcdir to CPPFLAGS
diff --git a/libjava/Makefile.am b/libjava/Makefile.am
index e07b116..0a61a4f 100644
--- a/libjava/Makefile.am
+++ b/libjava/Makefile.am
@@ -843,6 +843,7 @@ java/lang/NullPointerException.java \
java/lang/Number.java \
java/lang/NumberFormatException.java \
java/lang/OutOfMemoryError.java \
+java/lang/Package.java \
java/lang/Process.java \
java/lang/Runnable.java \
java/lang/Runtime.java \
@@ -1036,6 +1037,7 @@ gnu/java/locale/Calendar.java \
gnu/java/locale/Calendar_de.java \
gnu/java/locale/Calendar_en.java \
gnu/java/locale/Calendar_nl.java \
+gnu/java/security/provider/DefaultPolicy.java \
gnu/java/security/provider/Gnu.java \
gnu/java/security/provider/SHA.java \
gnu/java/security/provider/SHA1PRNG.java \
@@ -1068,6 +1070,7 @@ java/net/InetAddress.java \
java/net/JarURLConnection.java \
java/net/MalformedURLException.java \
java/net/MulticastSocket.java \
+java/net/NetPermission.java \
java/net/NoRouteToHostException.java \
java/net/PlainDatagramSocketImpl.java \
java/net/PlainSocketImpl.java \
@@ -1078,6 +1081,7 @@ java/net/SocketException.java \
java/net/SocketImpl.java \
java/net/SocketImplFactory.java \
java/net/SocketOptions.java \
+java/net/SocketPermission.java \
java/net/URL.java \
java/net/URLClassLoader.java \
java/net/URLConnection.java \
@@ -1087,34 +1091,80 @@ java/net/URLStreamHandler.java \
java/net/URLStreamHandlerFactory.java \
java/net/UnknownHostException.java \
java/net/UnknownServiceException.java \
+java/security/AccessControlContext.java \
+java/security/AccessControlException.java \
+java/security/AccessController.java \
+java/security/AlgorithmParameterGenerator.java \
+java/security/AlgorithmParameters.java \
java/security/AlgorithmParameterGeneratorSpi.java \
+java/security/AlgorithmParametersSpi.java \
+java/security/AllPermission.java \
java/security/BasicPermission.java \
+java/security/Certificate.java \
+java/security/CodeSource.java \
java/security/DigestException.java \
java/security/DigestOutputStream.java \
+java/security/DummyKeyPairGenerator.java \
+java/security/DummySignature.java \
+java/security/DigestInputStream.java \
+java/security/DomainCombiner.java \
+java/security/DummyMessageDigest.java \
java/security/GeneralSecurityException.java \
java/security/Guard.java \
+java/security/GuardedObject.java \
+java/security/Identity.java \
+java/security/IdentityScope.java \
java/security/InvalidAlgorithmParameterException.java \
java/security/InvalidKeyException.java \
java/security/InvalidParameterException.java \
java/security/Key.java \
-java/security/KeyException.java \
-java/security/KeyPair.java \
+java/security/KeyFactorySpi.java \
java/security/KeyPairGenerator.java \
+java/security/KeyStoreException.java \
+java/security/KeyException.java \
+java/security/KeyManagementException.java \
java/security/KeyPairGeneratorSpi.java \
+java/security/KeyStoreSpi.java \
+java/security/KeyFactory.java \
+java/security/KeyPair.java \
+java/security/KeyStore.java \
java/security/MessageDigest.java \
+java/security/MessageDigestSpi.java \
java/security/NoSuchAlgorithmException.java \
java/security/NoSuchProviderException.java \
java/security/Permission.java \
-java/security/PermissionCollection.java \
java/security/Principal.java \
+java/security/PrivilegedExceptionAction.java \
+java/security/PublicKey.java \
+java/security/PermissionCollection.java \
java/security/PrivateKey.java \
+java/security/ProtectionDomain.java \
+java/security/Permissions.java \
+java/security/PrivilegedAction.java \
java/security/Provider.java \
-java/security/PublicKey.java \
+java/security/Policy.java \
+java/security/PrivilegedActionException.java \
+java/security/ProviderException.java \
java/security/SecureClassLoader.java \
-java/security/SecureRandom.java \
+java/security/SecureRandomSpi.java \
+java/security/SecurityPermission.java \
+java/security/SignatureException.java \
+java/security/SignedObject.java \
+java/security/SecureRandom.java \
java/security/Security.java \
java/security/Signature.java \
-java/security/SignatureException.java \
+java/security/SignatureSpi.java \
+java/security/Signer.java \
+java/security/UnrecoverableKeyException.java \
+java/security/UnresolvedPermission.java \
+java/security/acl/Acl.java \
+java/security/acl/AclNotFoundException.java \
+java/security/acl/LastOwnerException.java \
+java/security/acl/Owner.java \
+java/security/acl/AclEntry.java \
+java/security/acl/Group.java \
+java/security/acl/NotOwnerException.java \
+java/security/acl/Permission.java \
java/security/cert/CRL.java \
java/security/cert/CRLException.java \
java/security/cert/Certificate.java \
@@ -1130,19 +1180,28 @@ java/security/cert/X509CRLEntry.java \
java/security/cert/X509Certificate.java \
java/security/cert/X509Extension.java \
java/security/interfaces/DSAKey.java \
-java/security/interfaces/DSAParams.java \
+java/security/interfaces/DSAKeyPairGenerator.java \
+java/security/interfaces/DSAParams.java \
java/security/interfaces/DSAPrivateKey.java \
java/security/interfaces/DSAPublicKey.java \
+java/security/interfaces/RSAKey.java \
java/security/interfaces/RSAPrivateCrtKey.java \
java/security/interfaces/RSAPrivateKey.java \
java/security/interfaces/RSAPublicKey.java \
java/security/spec/AlgorithmParameterSpec.java \
-java/security/spec/InvalidKeySpecException.java \
+java/security/spec/DSAParameterSpec.java \
+java/security/spec/DSAPrivateKeySpec.java \
+java/security/spec/DSAPublicKeySpec.java \
+java/security/spec/EncodedKeySpec.java \
+java/security/spec/InvalidKeySpecException.java \
java/security/spec/InvalidParameterSpecException.java \
-java/security/spec/KeySpec.java \
+java/security/spec/KeySpec.java \
+java/security/spec/PKCS8EncodedKeySpec.java \
+java/security/spec/RSAKeyGenParameterSpec.java \
java/security/spec/RSAPrivateCrtKeySpec.java \
java/security/spec/RSAPrivateKeySpec.java \
java/security/spec/RSAPublicKeySpec.java \
+java/security/spec/X509EncodedKeySpec.java \
java/sql/Array.java \
java/sql/BatchUpdateException.java \
java/sql/Blob.java \
diff --git a/libjava/Makefile.in b/libjava/Makefile.in
index 2dcc777..b191f86 100644
--- a/libjava/Makefile.in
+++ b/libjava/Makefile.in
@@ -119,43 +119,29 @@ here = @here@
libgcj_basedir = @libgcj_basedir@
AUTOMAKE_OPTIONS = foreign
-@TESTSUBDIR_TRUE@SUBDIRS = \
-@TESTSUBDIR_TRUE@$(DIRLTDL) testsuite gcj include
-@TESTSUBDIR_FALSE@SUBDIRS = \
-@TESTSUBDIR_FALSE@$(DIRLTDL) gcj include
-@USE_LIBDIR_TRUE@toolexeclibdir = \
-@USE_LIBDIR_TRUE@$(libdir)$(MULTISUBDIR)
-@USE_LIBDIR_FALSE@toolexeclibdir = \
-@USE_LIBDIR_FALSE@$(toolexecdir)/lib$(MULTISUBDIR)
-@USE_LIBDIR_FALSE@toolexecdir = \
-@USE_LIBDIR_FALSE@$(exec_prefix)/$(target_alias)
-@XLIB_AWT_TRUE@cond_x_ltlibrary = \
-@XLIB_AWT_TRUE@libgcjx.la
-@XLIB_AWT_FALSE@cond_x_ltlibrary = \
+@TESTSUBDIR_TRUE@SUBDIRS = @TESTSUBDIR_TRUE@$(DIRLTDL) testsuite gcj include
+@TESTSUBDIR_FALSE@SUBDIRS = @TESTSUBDIR_FALSE@$(DIRLTDL) gcj include
+@USE_LIBDIR_TRUE@toolexeclibdir = @USE_LIBDIR_TRUE@$(libdir)$(MULTISUBDIR)
+@USE_LIBDIR_FALSE@toolexeclibdir = @USE_LIBDIR_FALSE@$(toolexecdir)/lib$(MULTISUBDIR)
+@USE_LIBDIR_FALSE@toolexecdir = @USE_LIBDIR_FALSE@$(exec_prefix)/$(target_alias)
+@XLIB_AWT_TRUE@cond_x_ltlibrary = @XLIB_AWT_TRUE@libgcjx.la
+@XLIB_AWT_FALSE@cond_x_ltlibrary =
toolexeclib_LTLIBRARIES = libgcj.la $(cond_x_ltlibrary)
toolexeclib_DATA = libgcj.spec
data_DATA = libgcj.jar
-@NEEDS_DATA_START_TRUE@toolexeclib_LIBRARIES = \
-@NEEDS_DATA_START_TRUE@libgcjdata.a
-@NEEDS_DATA_START_TRUE@libgcjdata_a_SOURCES = \
-@NEEDS_DATA_START_TRUE@libgcjdata.c
+@NEEDS_DATA_START_TRUE@toolexeclib_LIBRARIES = @NEEDS_DATA_START_TRUE@libgcjdata.a
+@NEEDS_DATA_START_TRUE@libgcjdata_a_SOURCES = @NEEDS_DATA_START_TRUE@libgcjdata.c
-@NATIVE_TRUE@bin_PROGRAMS = \
-@NATIVE_TRUE@jv-convert gij
+@NATIVE_TRUE@bin_PROGRAMS = @NATIVE_TRUE@jv-convert gij
bin_SCRIPTS = addr2name.awk
-@CANADIAN_TRUE@@NULL_TARGET_TRUE@ZIP = \
-@CANADIAN_TRUE@@NULL_TARGET_TRUE@$(MULTIBUILDTOP)../$(COMPPATH)/fastjar/fastjar$(EXEEXT)
-@CANADIAN_TRUE@@NULL_TARGET_FALSE@ZIP = \
-@CANADIAN_TRUE@@NULL_TARGET_FALSE@fastjar
-@CANADIAN_FALSE@ZIP = \
-@CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/fastjar/fastjar$(EXEEXT)
-@CANADIAN_TRUE@GCJH = \
-@CANADIAN_TRUE@gcjh
-@CANADIAN_FALSE@GCJH = \
-@CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/gcc/gcjh$(EXEEXT)
+@CANADIAN_TRUE@@NULL_TARGET_TRUE@ZIP = @CANADIAN_TRUE@@NULL_TARGET_TRUE@$(MULTIBUILDTOP)../$(COMPPATH)/fastjar/fastjar$(EXEEXT)
+@CANADIAN_TRUE@@NULL_TARGET_FALSE@ZIP = @CANADIAN_TRUE@@NULL_TARGET_FALSE@fastjar
+@CANADIAN_FALSE@ZIP = @CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/fastjar/fastjar$(EXEEXT)
+@CANADIAN_TRUE@GCJH = @CANADIAN_TRUE@gcjh
+@CANADIAN_FALSE@GCJH = @CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/gcc/gcjh$(EXEEXT)
GCJ_WITH_FLAGS = $(GCJ) --encoding=UTF-8
@@ -174,10 +160,8 @@ AM_CXXFLAGS = -fno-rtti -fvtable-thunks -fnon-call-exceptions \
-fdollars-in-identifiers \
@LIBGCJ_CXXFLAGS@ @X_CFLAGS@ $(WARNINGS) -D_GNU_SOURCE
-@USING_GCC_TRUE@AM_CFLAGS = \
-@USING_GCC_TRUE@@LIBGCJ_CFLAGS@ $(WARNINGS)
-@USING_GCC_FALSE@AM_CFLAGS = \
-@USING_GCC_FALSE@@LIBGCJ_CFLAGS@
+@USING_GCC_TRUE@AM_CFLAGS = @USING_GCC_TRUE@@LIBGCJ_CFLAGS@ $(WARNINGS)
+@USING_GCC_FALSE@AM_CFLAGS = @USING_GCC_FALSE@@LIBGCJ_CFLAGS@
JCFLAGS = -g
JC1FLAGS = @LIBGCJ_JAVAFLAGS@ $(GCJFLAGS)
@@ -245,8 +229,7 @@ extra_headers = java/lang/Object.h java/lang/Class.h
NM = nm
-@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@noinst_PROGRAMS = \
-@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@gen-from-JIS
+@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@noinst_PROGRAMS = @NATIVE_TRUE@@MAINTAINER_MODE_TRUE@gen-from-JIS
CONVERT_DIR = gnu/gcj/convert
@@ -592,6 +575,7 @@ java/lang/NullPointerException.java \
java/lang/Number.java \
java/lang/NumberFormatException.java \
java/lang/OutOfMemoryError.java \
+java/lang/Package.java \
java/lang/Process.java \
java/lang/Runnable.java \
java/lang/Runtime.java \
@@ -779,6 +763,7 @@ gnu/java/locale/Calendar.java \
gnu/java/locale/Calendar_de.java \
gnu/java/locale/Calendar_en.java \
gnu/java/locale/Calendar_nl.java \
+gnu/java/security/provider/DefaultPolicy.java \
gnu/java/security/provider/Gnu.java \
gnu/java/security/provider/SHA.java \
gnu/java/security/provider/SHA1PRNG.java \
@@ -811,6 +796,7 @@ java/net/InetAddress.java \
java/net/JarURLConnection.java \
java/net/MalformedURLException.java \
java/net/MulticastSocket.java \
+java/net/NetPermission.java \
java/net/NoRouteToHostException.java \
java/net/PlainDatagramSocketImpl.java \
java/net/PlainSocketImpl.java \
@@ -821,6 +807,7 @@ java/net/SocketException.java \
java/net/SocketImpl.java \
java/net/SocketImplFactory.java \
java/net/SocketOptions.java \
+java/net/SocketPermission.java \
java/net/URL.java \
java/net/URLClassLoader.java \
java/net/URLConnection.java \
@@ -830,34 +817,80 @@ java/net/URLStreamHandler.java \
java/net/URLStreamHandlerFactory.java \
java/net/UnknownHostException.java \
java/net/UnknownServiceException.java \
+java/security/AccessControlContext.java \
+java/security/AccessControlException.java \
+java/security/AccessController.java \
+java/security/AlgorithmParameterGenerator.java \
+java/security/AlgorithmParameters.java \
java/security/AlgorithmParameterGeneratorSpi.java \
+java/security/AlgorithmParametersSpi.java \
+java/security/AllPermission.java \
java/security/BasicPermission.java \
+java/security/Certificate.java \
+java/security/CodeSource.java \
java/security/DigestException.java \
java/security/DigestOutputStream.java \
+java/security/DummyKeyPairGenerator.java \
+java/security/DummySignature.java \
+java/security/DigestInputStream.java \
+java/security/DomainCombiner.java \
+java/security/DummyMessageDigest.java \
java/security/GeneralSecurityException.java \
java/security/Guard.java \
+java/security/GuardedObject.java \
+java/security/Identity.java \
+java/security/IdentityScope.java \
java/security/InvalidAlgorithmParameterException.java \
java/security/InvalidKeyException.java \
java/security/InvalidParameterException.java \
java/security/Key.java \
-java/security/KeyException.java \
-java/security/KeyPair.java \
+java/security/KeyFactorySpi.java \
java/security/KeyPairGenerator.java \
+java/security/KeyStoreException.java \
+java/security/KeyException.java \
+java/security/KeyManagementException.java \
java/security/KeyPairGeneratorSpi.java \
+java/security/KeyStoreSpi.java \
+java/security/KeyFactory.java \
+java/security/KeyPair.java \
+java/security/KeyStore.java \
java/security/MessageDigest.java \
+java/security/MessageDigestSpi.java \
java/security/NoSuchAlgorithmException.java \
java/security/NoSuchProviderException.java \
java/security/Permission.java \
-java/security/PermissionCollection.java \
java/security/Principal.java \
+java/security/PrivilegedExceptionAction.java \
+java/security/PublicKey.java \
+java/security/PermissionCollection.java \
java/security/PrivateKey.java \
+java/security/ProtectionDomain.java \
+java/security/Permissions.java \
+java/security/PrivilegedAction.java \
java/security/Provider.java \
-java/security/PublicKey.java \
+java/security/Policy.java \
+java/security/PrivilegedActionException.java \
+java/security/ProviderException.java \
java/security/SecureClassLoader.java \
-java/security/SecureRandom.java \
+java/security/SecureRandomSpi.java \
+java/security/SecurityPermission.java \
+java/security/SignatureException.java \
+java/security/SignedObject.java \
+java/security/SecureRandom.java \
java/security/Security.java \
java/security/Signature.java \
-java/security/SignatureException.java \
+java/security/SignatureSpi.java \
+java/security/Signer.java \
+java/security/UnrecoverableKeyException.java \
+java/security/UnresolvedPermission.java \
+java/security/acl/Acl.java \
+java/security/acl/AclNotFoundException.java \
+java/security/acl/LastOwnerException.java \
+java/security/acl/Owner.java \
+java/security/acl/AclEntry.java \
+java/security/acl/Group.java \
+java/security/acl/NotOwnerException.java \
+java/security/acl/Permission.java \
java/security/cert/CRL.java \
java/security/cert/CRLException.java \
java/security/cert/Certificate.java \
@@ -873,19 +906,28 @@ java/security/cert/X509CRLEntry.java \
java/security/cert/X509Certificate.java \
java/security/cert/X509Extension.java \
java/security/interfaces/DSAKey.java \
-java/security/interfaces/DSAParams.java \
+java/security/interfaces/DSAKeyPairGenerator.java \
+java/security/interfaces/DSAParams.java \
java/security/interfaces/DSAPrivateKey.java \
java/security/interfaces/DSAPublicKey.java \
+java/security/interfaces/RSAKey.java \
java/security/interfaces/RSAPrivateCrtKey.java \
java/security/interfaces/RSAPrivateKey.java \
java/security/interfaces/RSAPublicKey.java \
java/security/spec/AlgorithmParameterSpec.java \
-java/security/spec/InvalidKeySpecException.java \
+java/security/spec/DSAParameterSpec.java \
+java/security/spec/DSAPrivateKeySpec.java \
+java/security/spec/DSAPublicKeySpec.java \
+java/security/spec/EncodedKeySpec.java \
+java/security/spec/InvalidKeySpecException.java \
java/security/spec/InvalidParameterSpecException.java \
-java/security/spec/KeySpec.java \
+java/security/spec/KeySpec.java \
+java/security/spec/PKCS8EncodedKeySpec.java \
+java/security/spec/RSAKeyGenParameterSpec.java \
java/security/spec/RSAPrivateCrtKeySpec.java \
java/security/spec/RSAPrivateKeySpec.java \
java/security/spec/RSAPublicKeySpec.java \
+java/security/spec/X509EncodedKeySpec.java \
java/sql/Array.java \
java/sql/BatchUpdateException.java \
java/sql/Blob.java \
@@ -1320,6 +1362,7 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/gnu/java/lang/reflect/TypeSignature.P \
.deps/gnu/java/locale/Calendar.P .deps/gnu/java/locale/Calendar_de.P \
.deps/gnu/java/locale/Calendar_en.P .deps/gnu/java/locale/Calendar_nl.P \
+.deps/gnu/java/security/provider/DefaultPolicy.P \
.deps/gnu/java/security/provider/Gnu.P \
.deps/gnu/java/security/provider/SHA.P \
.deps/gnu/java/security/provider/SHA1PRNG.P .deps/interpret.P \
@@ -1546,12 +1589,13 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/java/lang/NoSuchMethodException.P \
.deps/java/lang/NullPointerException.P .deps/java/lang/Number.P \
.deps/java/lang/NumberFormatException.P .deps/java/lang/Object.P \
-.deps/java/lang/OutOfMemoryError.P .deps/java/lang/Process.P \
-.deps/java/lang/Runnable.P .deps/java/lang/Runtime.P \
-.deps/java/lang/RuntimeException.P .deps/java/lang/RuntimePermission.P \
-.deps/java/lang/SecurityException.P .deps/java/lang/SecurityManager.P \
-.deps/java/lang/Short.P .deps/java/lang/StackOverflowError.P \
-.deps/java/lang/String.P .deps/java/lang/StringBuffer.P \
+.deps/java/lang/OutOfMemoryError.P .deps/java/lang/Package.P \
+.deps/java/lang/Process.P .deps/java/lang/Runnable.P \
+.deps/java/lang/Runtime.P .deps/java/lang/RuntimeException.P \
+.deps/java/lang/RuntimePermission.P .deps/java/lang/SecurityException.P \
+.deps/java/lang/SecurityManager.P .deps/java/lang/Short.P \
+.deps/java/lang/StackOverflowError.P .deps/java/lang/String.P \
+.deps/java/lang/StringBuffer.P \
.deps/java/lang/StringIndexOutOfBoundsException.P \
.deps/java/lang/System.P .deps/java/lang/Thread.P \
.deps/java/lang/ThreadDeath.P .deps/java/lang/ThreadGroup.P \
@@ -1605,45 +1649,80 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/java/net/HttpURLConnection.P .deps/java/net/InetAddress.P \
.deps/java/net/JarURLConnection.P \
.deps/java/net/MalformedURLException.P .deps/java/net/MulticastSocket.P \
-.deps/java/net/NoRouteToHostException.P \
+.deps/java/net/NetPermission.P .deps/java/net/NoRouteToHostException.P \
.deps/java/net/PlainDatagramSocketImpl.P \
.deps/java/net/PlainSocketImpl.P .deps/java/net/ProtocolException.P \
.deps/java/net/ServerSocket.P .deps/java/net/Socket.P \
.deps/java/net/SocketException.P .deps/java/net/SocketImpl.P \
.deps/java/net/SocketImplFactory.P .deps/java/net/SocketOptions.P \
-.deps/java/net/URL.P .deps/java/net/URLClassLoader.P \
-.deps/java/net/URLConnection.P .deps/java/net/URLDecoder.P \
-.deps/java/net/URLEncoder.P .deps/java/net/URLStreamHandler.P \
+.deps/java/net/SocketPermission.P .deps/java/net/URL.P \
+.deps/java/net/URLClassLoader.P .deps/java/net/URLConnection.P \
+.deps/java/net/URLDecoder.P .deps/java/net/URLEncoder.P \
+.deps/java/net/URLStreamHandler.P \
.deps/java/net/URLStreamHandlerFactory.P \
.deps/java/net/UnknownHostException.P \
.deps/java/net/UnknownServiceException.P \
.deps/java/net/natInetAddress.P \
.deps/java/net/natPlainDatagramSocketImpl.P \
.deps/java/net/natPlainSocketImpl.P \
+.deps/java/security/AccessControlContext.P \
+.deps/java/security/AccessControlException.P \
+.deps/java/security/AccessController.P \
+.deps/java/security/AlgorithmParameterGenerator.P \
.deps/java/security/AlgorithmParameterGeneratorSpi.P \
-.deps/java/security/BasicPermission.P \
-.deps/java/security/DigestException.P \
+.deps/java/security/AlgorithmParameters.P \
+.deps/java/security/AlgorithmParametersSpi.P \
+.deps/java/security/AllPermission.P \
+.deps/java/security/BasicPermission.P .deps/java/security/Certificate.P \
+.deps/java/security/CodeSource.P .deps/java/security/DigestException.P \
+.deps/java/security/DigestInputStream.P \
.deps/java/security/DigestOutputStream.P \
+.deps/java/security/DomainCombiner.P \
+.deps/java/security/DummyKeyPairGenerator.P \
+.deps/java/security/DummyMessageDigest.P \
+.deps/java/security/DummySignature.P \
.deps/java/security/GeneralSecurityException.P \
-.deps/java/security/Guard.P \
+.deps/java/security/Guard.P .deps/java/security/GuardedObject.P \
+.deps/java/security/Identity.P .deps/java/security/IdentityScope.P \
.deps/java/security/InvalidAlgorithmParameterException.P \
.deps/java/security/InvalidKeyException.P \
.deps/java/security/InvalidParameterException.P \
.deps/java/security/Key.P .deps/java/security/KeyException.P \
+.deps/java/security/KeyFactory.P .deps/java/security/KeyFactorySpi.P \
+.deps/java/security/KeyManagementException.P \
.deps/java/security/KeyPair.P .deps/java/security/KeyPairGenerator.P \
.deps/java/security/KeyPairGeneratorSpi.P \
-.deps/java/security/MessageDigest.P \
+.deps/java/security/KeyStore.P .deps/java/security/KeyStoreException.P \
+.deps/java/security/KeyStoreSpi.P .deps/java/security/MessageDigest.P \
+.deps/java/security/MessageDigestSpi.P \
.deps/java/security/NoSuchAlgorithmException.P \
.deps/java/security/NoSuchProviderException.P \
.deps/java/security/Permission.P \
.deps/java/security/PermissionCollection.P \
+.deps/java/security/Permissions.P .deps/java/security/Policy.P \
.deps/java/security/Principal.P .deps/java/security/PrivateKey.P \
-.deps/java/security/Provider.P .deps/java/security/PublicKey.P \
+.deps/java/security/PrivilegedAction.P \
+.deps/java/security/PrivilegedActionException.P \
+.deps/java/security/PrivilegedExceptionAction.P \
+.deps/java/security/ProtectionDomain.P .deps/java/security/Provider.P \
+.deps/java/security/ProviderException.P .deps/java/security/PublicKey.P \
.deps/java/security/SecureClassLoader.P \
-.deps/java/security/SecureRandom.P .deps/java/security/Security.P \
+.deps/java/security/SecureRandom.P \
+.deps/java/security/SecureRandomSpi.P .deps/java/security/Security.P \
+.deps/java/security/SecurityPermission.P \
.deps/java/security/Signature.P \
-.deps/java/security/SignatureException.P .deps/java/security/cert/CRL.P \
-.deps/java/security/cert/CRLException.P \
+.deps/java/security/SignatureException.P \
+.deps/java/security/SignatureSpi.P .deps/java/security/SignedObject.P \
+.deps/java/security/Signer.P \
+.deps/java/security/UnrecoverableKeyException.P \
+.deps/java/security/UnresolvedPermission.P \
+.deps/java/security/acl/Acl.P .deps/java/security/acl/AclEntry.P \
+.deps/java/security/acl/AclNotFoundException.P \
+.deps/java/security/acl/Group.P \
+.deps/java/security/acl/LastOwnerException.P \
+.deps/java/security/acl/NotOwnerException.P \
+.deps/java/security/acl/Owner.P .deps/java/security/acl/Permission.P \
+.deps/java/security/cert/CRL.P .deps/java/security/cert/CRLException.P \
.deps/java/security/cert/Certificate.P \
.deps/java/security/cert/CertificateEncodingException.P \
.deps/java/security/cert/CertificateException.P \
@@ -1657,19 +1736,28 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/java/security/cert/X509Certificate.P \
.deps/java/security/cert/X509Extension.P \
.deps/java/security/interfaces/DSAKey.P \
+.deps/java/security/interfaces/DSAKeyPairGenerator.P \
.deps/java/security/interfaces/DSAParams.P \
.deps/java/security/interfaces/DSAPrivateKey.P \
.deps/java/security/interfaces/DSAPublicKey.P \
+.deps/java/security/interfaces/RSAKey.P \
.deps/java/security/interfaces/RSAPrivateCrtKey.P \
.deps/java/security/interfaces/RSAPrivateKey.P \
.deps/java/security/interfaces/RSAPublicKey.P \
.deps/java/security/spec/AlgorithmParameterSpec.P \
+.deps/java/security/spec/DSAParameterSpec.P \
+.deps/java/security/spec/DSAPrivateKeySpec.P \
+.deps/java/security/spec/DSAPublicKeySpec.P \
+.deps/java/security/spec/EncodedKeySpec.P \
.deps/java/security/spec/InvalidKeySpecException.P \
.deps/java/security/spec/InvalidParameterSpecException.P \
.deps/java/security/spec/KeySpec.P \
+.deps/java/security/spec/PKCS8EncodedKeySpec.P \
+.deps/java/security/spec/RSAKeyGenParameterSpec.P \
.deps/java/security/spec/RSAPrivateCrtKeySpec.P \
.deps/java/security/spec/RSAPrivateKeySpec.P \
-.deps/java/security/spec/RSAPublicKeySpec.P .deps/java/sql/Array.P \
+.deps/java/security/spec/RSAPublicKeySpec.P \
+.deps/java/security/spec/X509EncodedKeySpec.P .deps/java/sql/Array.P \
.deps/java/sql/BatchUpdateException.P .deps/java/sql/Blob.P \
.deps/java/sql/CallableStatement.P .deps/java/sql/Clob.P \
.deps/java/sql/Connection.P .deps/java/sql/DataTruncation.P \
@@ -2111,7 +2199,7 @@ distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
- cp -pr $$/$$file $(distdir)/$$file; \
+ cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
diff --git a/libjava/gcj/Makefile.in b/libjava/gcj/Makefile.in
index d676a05..de12124 100644
--- a/libjava/gcj/Makefile.in
+++ b/libjava/gcj/Makefile.in
@@ -202,7 +202,7 @@ distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
- cp -pr $$/$$file $(distdir)/$$file; \
+ cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
diff --git a/libjava/gcj/javaprims.h b/libjava/gcj/javaprims.h
index 6255451..f16e97d 100644
--- a/libjava/gcj/javaprims.h
+++ b/libjava/gcj/javaprims.h
@@ -39,7 +39,6 @@ extern "Java"
{
namespace io
{
- class BlockDataException;
class BufferedInputStream;
class BufferedOutputStream;
class BufferedReader;
@@ -176,6 +175,7 @@ extern "Java"
class NumberFormatException;
class Object;
class OutOfMemoryError;
+ class Package;
class Process;
class Runnable;
class Runtime;
@@ -233,10 +233,12 @@ extern "Java"
class ArrayList;
class Arrays;
class Arrays$ListImpl;
+ class BasicMapEntry;
class BitSet;
class Calendar;
class Collection;
class Collections;
+ class Collections$ReverseComparator;
class Collections$SynchronizedCollection;
class Collections$SynchronizedIterator;
class Collections$SynchronizedList;
@@ -302,6 +304,12 @@ extern "Java"
class Timer$TaskQueue;
class TimerTask;
class TooManyListenersException;
+ class TreeMap;
+ class TreeMap$Node;
+ class TreeMap$SubMap;
+ class TreeMap$TreeIterator;
+ class TreeMap$VerifyResult;
+ class TreeSet;
class Vector;
class WeakHashMap;
class WeakHashMap$Entry;
diff --git a/libjava/gnu/gcj/runtime/VMClassLoader.java b/libjava/gnu/gcj/runtime/VMClassLoader.java
index 77051d2..cc34369 100644
--- a/libjava/gnu/gcj/runtime/VMClassLoader.java
+++ b/libjava/gnu/gcj/runtime/VMClassLoader.java
@@ -65,18 +65,11 @@ final class VMClassLoader extends java.net.URLClassLoader
/** This is overridden to search the internal hash table, which
* will only search existing linked-in classes. This will make
* the default implementation of loadClass (in ClassLoader) work right.
+ * The implementation of this method is in java/lang/natClassLoader.cc.
*/
- protected final native Class findSystemClass(String name)
- throws java.lang.ClassNotFoundException, java.lang.LinkageError;
-
- // Return the sole VMClassLoader.
- private static synchronized VMClassLoader getVMClassLoader ()
- {
- if (redirect == null)
- redirect = new VMClassLoader ();
- return redirect;
- }
+ protected native Class findClass(String name)
+ throws java.lang.ClassNotFoundException;
// The only VMClassLoader that can exist.
- private static VMClassLoader redirect;
+ public static VMClassLoader instance = new VMClassLoader ();
}
diff --git a/libjava/gnu/java/security/provider/DefaultPolicy.java b/libjava/gnu/java/security/provider/DefaultPolicy.java
new file mode 100644
index 0000000..a4b9f35
--- /dev/null
+++ b/libjava/gnu/java/security/provider/DefaultPolicy.java
@@ -0,0 +1,55 @@
+/* DefaultPolicy.java
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package gnu.java.security.provider;
+
+import java.security.*;
+
+/**
+ * This is just a stub policy implementation which grants all permissions
+ * to any code source. FIXME: This should be replaced with a real
+ * implementation that reads the policy configuration from a file, like
+ * $JAVA_HOME/jre/lib/security/java.security.
+ */
+public class DefaultPolicy extends Policy
+{
+ static Permissions allPermissions = new Permissions();
+
+ static
+ {
+ allPermissions.add(new AllPermission());
+ }
+
+ public PermissionCollection getPermissions(CodeSource codesource)
+ {
+ return allPermissions;
+ }
+
+ public void refresh()
+ {
+ // Nothing.
+ }
+}
diff --git a/libjava/java/lang/Class.h b/libjava/java/lang/Class.h
index 9736b78..a0cd730 100644
--- a/libjava/java/lang/Class.h
+++ b/libjava/java/lang/Class.h
@@ -19,6 +19,7 @@ details. */
#include <java/lang/String.h>
#include <java/net/URL.h>
#include <java/lang/reflect/Modifier.h>
+#include <java/security/ProtectionDomain.h>
// We declare these here to avoid including gcj/cni.h.
extern "C" void _Jv_InitClass (jclass klass);
@@ -105,7 +106,8 @@ struct _Jv_ifaces
class java::lang::Class : public java::lang::Object
{
public:
- static jclass forName (jstring className, java::lang::ClassLoader *loader);
+ static jclass forName (jstring className, jboolean initialize,
+ java::lang::ClassLoader *loader);
static jclass forName (jstring className);
JArray<jclass> *getClasses (void);
@@ -135,6 +137,7 @@ private:
jint offset);
java::lang::reflect::Field *getPrivateField (jstring);
java::lang::reflect::Method *getPrivateMethod (jstring, JArray<jclass> *);
+ java::security::ProtectionDomain *getProtectionDomain0 ();
public:
JArray<java::lang::reflect::Field *> *getFields (void);
@@ -380,6 +383,8 @@ private:
_Jv_IDispatchTable *idt;
// Pointer to the class that represents an array of this class.
jclass arrayclass;
+ // Security Domain to which this class belongs (or null).
+ java::security::ProtectionDomain *protectionDomain;
};
#endif /* __JAVA_LANG_CLASS_H__ */
diff --git a/libjava/java/lang/Class.java b/libjava/java/lang/Class.java
index 0f081eb..549eaec 100644
--- a/libjava/java/lang/Class.java
+++ b/libjava/java/lang/Class.java
@@ -12,6 +12,7 @@ package java.lang;
import java.io.Serializable;
import java.io.InputStream;
import java.lang.reflect.*;
+import java.security.*;
/**
* @author Tom Tromey <tromey@cygnus.com>
@@ -30,7 +31,9 @@ public final class Class implements Serializable
{
public static native Class forName (String className)
throws ClassNotFoundException;
- public static native Class forName (String className, ClassLoader loader)
+ /** @since 1.2 */
+ public static native Class forName (String className, boolean initialize,
+ ClassLoader loader)
throws ClassNotFoundException;
public native Class[] getClasses ();
public native ClassLoader getClassLoader ();
@@ -88,6 +91,30 @@ public final class Class implements Serializable
private native Field[] _getFields (Field[] result, int offset);
public native Field[] getFields () throws SecurityException;
+ /**
+ * Returns the <code>Package</code> in which this class is defined
+ * Returns null when this information is not available from the
+ * classloader of this class or when the classloader of this class
+ * is null.
+ *
+ * @since 1.2
+ */
+ public Package getPackage()
+ {
+ ClassLoader cl = getClassLoader();
+ if (cl != null)
+ {
+ String name = getName();
+ String pkg = "";
+ int idx = name.lastIndexOf('.');
+ if (idx >= 0)
+ pkg = name.substring(0, idx);
+ return cl.getPackage(pkg);
+ }
+ else
+ return null;
+ }
+
public native Class[] getInterfaces ();
private final native void getSignature (StringBuffer buffer);
@@ -154,6 +181,35 @@ public final class Class implements Serializable
public native Object newInstance ()
throws InstantiationException, IllegalAccessException;
+ // We need a native method to retrieve the protection domain, because we
+ // can't add fields to java.lang.Class that are accessible from Java.
+ private native ProtectionDomain getProtectionDomain0();
+
+ /**
+ * Returns the protection domain of this class. If the classloader
+ * did not record the protection domain when creating this class
+ * the unknown protection domain is returned which has a <code>null</code>
+ * code source and all permissions.
+ *
+ * @exception SecurityException if a security manager exists and the caller
+ * does not have <code>RuntimePermission("getProtectionDomain")</code>.
+ *
+ * @since 1.2
+ */
+ public ProtectionDomain getProtectionDomain()
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(ClassLoader.protectionDomainPermission);
+
+ ProtectionDomain protectionDomain = getProtectionDomain0();
+
+ if (protectionDomain == null)
+ return ClassLoader.unknownProtectionDomain;
+ else
+ return protectionDomain;
+ }
+
public String toString ()
{
if (isPrimitive ())
diff --git a/libjava/java/lang/ClassLoader.java b/libjava/java/lang/ClassLoader.java
index 402e812..56d73e6 100644
--- a/libjava/java/lang/ClassLoader.java
+++ b/libjava/java/lang/ClassLoader.java
@@ -1,6 +1,6 @@
// ClassLoader.java - Define policies for loading Java classes.
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation
This file is part of libgcj.
@@ -14,7 +14,14 @@ import java.io.InputStream;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
+import java.security.AllPermission;
+import java.security.CodeSource;
+import java.security.Permission;
+import java.security.Permissions;
+import java.security.Policy;
+import java.security.ProtectionDomain;
import java.util.Enumeration;
+import java.util.HashMap;
import java.util.Stack;
/**
@@ -25,18 +32,24 @@ import java.util.Stack;
* @author Kresten Krab Thorup
*/
-public abstract class ClassLoader {
-
+public abstract class ClassLoader
+{
static private ClassLoader system;
private ClassLoader parent;
+ private HashMap definedPackages = new HashMap();
- public ClassLoader getParent ()
+ public final ClassLoader getParent ()
{
/* FIXME: security */
return parent;
}
-
- public static native ClassLoader getSystemClassLoader ();
+
+ public static ClassLoader getSystemClassLoader ()
+ {
+ if (system == null)
+ system = gnu.gcj.runtime.VMClassLoader.instance;
+ return system;
+ }
/**
* Creates a <code>ClassLoader</code> with no parent.
@@ -55,6 +68,7 @@ public abstract class ClassLoader {
* <code>checkCreateClassLoader</code> on the current
* security manager.
* @exception java.lang.SecurityException if not allowed
+ * @since 1.2
*/
protected ClassLoader(ClassLoader parent)
{
@@ -71,11 +85,15 @@ public abstract class ClassLoader {
* @see ClassLoader#loadClass(String,boolean)
* @exception java.lang.ClassNotFoundException
*/
- public Class loadClass(String name)
- throws java.lang.ClassNotFoundException, java.lang.LinkageError
+ public Class loadClass(String name)
+ throws java.lang.ClassNotFoundException
{
return loadClass (name, false);
}
+
+ /* findClass implementation for the system classloader.
+ native Class systemFindClass(String name)
+ throws java.lang.ClassNotFoundException;
/**
* Loads the class by the given name. The default implementation
@@ -96,7 +114,7 @@ public abstract class ClassLoader {
* @deprecated
*/
protected Class loadClass(String name, boolean link)
- throws java.lang.ClassNotFoundException, java.lang.LinkageError
+ throws java.lang.ClassNotFoundException
{
Class c = findLoadedClass (name);
@@ -106,7 +124,7 @@ public abstract class ClassLoader {
if (parent != null)
return parent.loadClass (name, link);
else
- c = findSystemClass (name);
+ c = system.findClass (name);
} catch (ClassNotFoundException ex) {
/* ignore, we'll try findClass */;
}
@@ -130,6 +148,7 @@ public abstract class ClassLoader {
* @param name Name of the class to find.
* @return The class found.
* @exception java.lang.ClassNotFoundException
+ * @since 1.2
*/
protected Class findClass (String name)
throws ClassNotFoundException
@@ -137,6 +156,28 @@ public abstract class ClassLoader {
throw new ClassNotFoundException (name);
}
+ // Protection Domain definitions
+ // FIXME: should there be a special protection domain used for native code?
+
+ // The permission required to check what a classes protection domain is.
+ static final Permission protectionDomainPermission
+ = new RuntimePermission("getProtectionDomain");
+ // The protection domain returned if we cannot determine it.
+ static ProtectionDomain unknownProtectionDomain;
+ // Protection domain to use when a class is defined without one specified.
+ static ProtectionDomain defaultProtectionDomain;
+
+ static
+ {
+ Permissions permissions = new Permissions();
+ permissions.add(new AllPermission());
+ unknownProtectionDomain = new ProtectionDomain(null, permissions);
+
+ CodeSource cs = new CodeSource(null, null);
+ defaultProtectionDomain =
+ new ProtectionDomain(cs, Policy.getPolicy().getPermissions(cs));
+ }
+
/**
* Defines a class, given the class-data. According to the JVM, this
* method should not be used; instead use the variant of this method
@@ -158,9 +199,14 @@ public abstract class ClassLoader {
protected final Class defineClass(byte[] data, int off, int len)
throws ClassFormatError
{
- return defineClass (null, data, off, len);
+ return defineClass (null, data, off, len, defaultProtectionDomain);
}
+ protected final Class defineClass(String name, byte[] data, int off, int len)
+ {
+ return defineClass (name, data, off, len, defaultProtectionDomain);
+ }
+
/**
* Defines a class, given the class-data. This is preferable
* over <code>defineClass(byte[],off,len)</code> since it is more
@@ -182,6 +228,7 @@ public abstract class ClassLoader {
* @param data bytes in class file format.
* @param off offset to start interpreting data.
* @param len length of data in class file.
+ * @param protectionDomain security protection domain for the class.
* @return the class defined.
* @exception java.lang.ClassNotFoundException
* @exception java.lang.LinkageError
@@ -189,7 +236,8 @@ public abstract class ClassLoader {
protected final synchronized Class defineClass(String name,
byte[] data,
int off,
- int len)
+ int len,
+ ProtectionDomain protectionDomain)
throws ClassFormatError
{
if (data==null || data.length < off+len || off<0 || len<0)
@@ -201,13 +249,16 @@ public abstract class ClassLoader {
throw new java.lang.LinkageError ("class "
+ name
+ " already loaded");
+
+ if (protectionDomain == null)
+ protectionDomain = defaultProtectionDomain;
try {
// Since we're calling into native code here,
// we better make sure that any generated
// exception is to spec!
- return defineClass0 (name, data, off, len);
+ return defineClass0 (name, data, off, len, protectionDomain);
} catch (ClassFormatError x) {
throw x; // rethrow
@@ -229,10 +280,10 @@ public abstract class ClassLoader {
private native Class defineClass0 (String name,
byte[] data,
int off,
- int len)
+ int len,
+ ProtectionDomain protectionDomain)
throws ClassFormatError;
-
/**
* Link the given class. This will bring the class to a state where
* the class initializer can be run. Linking involves the following
@@ -262,13 +313,11 @@ public abstract class ClassLoader {
* @exception java.lang.LinkageError
*/
protected final void resolveClass(Class clazz)
- throws java.lang.LinkageError
{
resolveClass0(clazz);
}
static void resolveClass0(Class clazz)
- throws java.lang.LinkageError
{
synchronized (clazz)
{
@@ -288,14 +337,123 @@ public abstract class ClassLoader {
/** Internal method. Calls _Jv_PrepareClass and
* _Jv_PrepareCompiledClass. This is only called from resolveClass. */
- private static native void linkClass0(Class clazz)
- throws java.lang.LinkageError;
+ private static native void linkClass0(Class clazz);
/** Internal method. Marks the given clazz to be in an erroneous
* state, and calls notifyAll() on the class object. This should only
* be called when the caller has the lock on the class object. */
private static native void markClassErrorState0(Class clazz);
+ /**
+ * Defines a new package and creates a Package object.
+ * The package should be defined before any class in the package is
+ * defined with <code>defineClass()</code>. The package should not yet
+ * be defined before in this classloader or in one of its parents (which
+ * means that <code>getPackage()</code> should return <code>null</code>).
+ * All parameters except the <code>name</code> of the package may be
+ * <code>null</code>.
+ * <p>
+ * Subclasses should call this method from their <code>findClass()</code>
+ * implementation before calling <code>defineClass()</code> on a Class
+ * in a not yet defined Package (which can be checked by calling
+ * <code>getPackage()</code>).
+ *
+ * @param name The name of the Package
+ * @param specTitle The name of the specification
+ * @param specVendor The name of the specification designer
+ * @param specVersion The version of this specification
+ * @param implTitle The name of the implementation
+ * @param implVendor The vendor that wrote this implementation
+ * @param implVersion The version of this implementation
+ * @param sealed If sealed the origin of the package classes
+ * @return the Package object for the specified package
+ *
+ * @exception IllegalArgumentException if the package name is null or if
+ * it was already defined by this classloader or one of its parents.
+ *
+ * @see Package
+ * @since 1.2
+ */
+ protected Package definePackage(String name,
+ String specTitle, String specVendor,
+ String specVersion, String implTitle,
+ String implVendor, String implVersion,
+ URL sealed)
+ {
+ if (getPackage(name) != null)
+ throw new IllegalArgumentException("Package " + name
+ + " already defined");
+ Package p = new Package(name,
+ specTitle, specVendor, specVersion,
+ implTitle, implVendor, implVersion,
+ sealed);
+ synchronized (definedPackages)
+ {
+ definedPackages.put(name, p);
+ }
+ return p;
+ }
+
+ /**
+ * Returns the Package object for the requested package name. It returns
+ * null when the package is not defined by this classloader or one of its
+ * parents.
+ *
+ * @since 1.2
+ */
+ protected Package getPackage(String name)
+ {
+ Package p;
+ if (parent == null)
+ // XXX - Should we use the bootstrap classloader?
+ p = null;
+ else
+ p = parent.getPackage(name);
+
+ if (p == null)
+ {
+ synchronized (definedPackages)
+ {
+ p = (Package) definedPackages.get(name);
+ }
+ }
+
+ return p;
+ }
+
+ /**
+ * Returns all Package objects defined by this classloader and its parents.
+ *
+ * @since 1.2
+ */
+ protected Package[] getPackages()
+ {
+ Package[] allPackages;
+
+ // Get all our packages.
+ Package[] packages;
+ synchronized(definedPackages)
+ {
+ packages = new Package[definedPackages.size()];
+ definedPackages.values().toArray(packages);
+ }
+
+ // If we have a parent get all packages defined by our parents.
+ if (parent != null)
+ {
+ Package[] parentPackages = parent.getPackages();
+ allPackages = new Package[parentPackages.length + packages.length];
+ System.arraycopy(parentPackages, 0, allPackages, 0,
+ parentPackages.length);
+ System.arraycopy(packages, 0, allPackages, parentPackages.length,
+ packages.length);
+ }
+ else
+ // XXX - Should we use the bootstrap classloader?
+ allPackages = packages;
+
+ return allPackages;
+ }
/**
* Returns a class found in a system-specific way, typically
@@ -307,14 +465,14 @@ public abstract class ClassLoader {
* @exception java.lang.LinkageError
* @exception java.lang.ClassNotFoundException
*/
- protected Class findSystemClass(String name)
- throws java.lang.ClassNotFoundException, java.lang.LinkageError
+ protected final Class findSystemClass(String name)
+ throws java.lang.ClassNotFoundException
{
return getSystemClassLoader ().loadClass (name);
}
/*
- * Does currently nothing.
+ * Does currently nothing. FIXME.
*/
protected final void setSigners(Class claz, Object[] signers) {
/* claz.setSigners (signers); */
@@ -328,13 +486,13 @@ public abstract class ClassLoader {
* @param name class to find.
* @return the class loaded, or null.
*/
- protected native Class findLoadedClass(String name);
+ protected final native Class findLoadedClass(String name);
- public static final InputStream getSystemResourceAsStream(String name) {
+ public static InputStream getSystemResourceAsStream(String name) {
return getSystemClassLoader().getResourceAsStream (name);
}
- public static final URL getSystemResource(String name) {
+ public static URL getSystemResource(String name) {
return getSystemClassLoader().getResource (name);
}
@@ -397,7 +555,7 @@ public abstract class ClassLoader {
return null;
}
- public Enumeration getResources (String name) throws IOException
+ public final Enumeration getResources (String name) throws IOException
{
// The rules say search the parent class if non-null,
// otherwise search the built-in class loader (assumed to be
diff --git a/libjava/java/lang/Package.java b/libjava/java/lang/Package.java
new file mode 100644
index 0000000..26bcb98
--- /dev/null
+++ b/libjava/java/lang/Package.java
@@ -0,0 +1,287 @@
+/* java.lang.Package - Everything you ever wanted to know about a package.
+ Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.lang;
+
+import java.net.URL;
+import java.util.NoSuchElementException;
+import java.util.StringTokenizer;
+
+/**
+ * Everything you ever wanted to know about a package. This class makes it
+ * possible to attach specification and implementation information to a
+ * package as explained in the
+ * <a href="http://java.sun.com/products/jdk/1.3/docs/guide/versioning/spec/VersioningSpecification.html#PackageVersionSpecification">Package Versioning Specification</a>
+ * section of the
+ * <a href="http://java.sun.com/products/jdk/1.3/docs/guide/versioning/spec/VersioningSpecification.html">Product Versioning Specification</a>.
+ * It also allows packages to be sealed with respect to the originating URL.
+ * <p>
+ * The most usefull method is the <code>isCompatibleWith()</code> method that
+ * compares a desired version of a specification with the version of the
+ * specification as implemented by a package. A package is considered
+ * compatible with another version if the version of the specification is
+ * equal or higher then the requested version. Version numbers are represented
+ * as strings of positive numbers seperated by dots (e.g. "1.2.0").
+ * The first number is called the major number, the second the minor,
+ * the third the micro, etc. A version is considered higher then another
+ * version if it has a bigger major number then the another version or when
+ * the major numbers of the versions are equal if it has a bigger minor number
+ * then the other version, etc. (If a version has no minor, micro, etc numbers
+ * then they are considered the be 0.)
+ *
+ * @since 1.2
+ * @author Mark Wielaard (mark@klomp.org)
+ */
+public class Package
+{
+ /** The name of the Package */
+ final private String name;
+
+ /** The name if the implementation */
+ final private String implTitle;
+ /** The vendor that wrote this implementation */
+ final private String implVendor;
+ /** The version of this implementation */
+ final private String implVersion;
+
+ /** The name of the specification */
+ final private String specTitle;
+ /** The name of the specification designer */
+ final private String specVendor;
+ /** The version of this specification */
+ final private String specVersion;
+
+ /** If sealed the origin of the package classes, otherwise null */
+ final private URL sealed;
+
+ /**
+ * A package local constructor for the Package class.
+ * All parameters except the <code>name</code> of the package may be
+ * <code>null</code>.
+ * There are no public constructors defined for Package this is a package
+ * local constructor that is used by java.lang.Classloader.definePackage().
+ *
+ * @param name The name of the Package
+ * @param specTitle The name of the specification
+ * @param specVendor The name of the specification designer
+ * @param specVersion The version of this specification
+ * @param implTitle The name of the implementation
+ * @param implVendor The vendor that wrote this implementation
+ * @param implVersion The version of this implementation
+ * @param sealed If sealed the origin of the package classes
+ */
+ Package(String name,
+ String specTitle, String specVendor, String specVersion,
+ String implTitle, String implVendor, String implVersion, URL sealed)
+ {
+ if (name == null)
+ throw new IllegalArgumentException("null Package name");
+
+ this.name = name;
+
+ this.implTitle = implTitle;
+ this.implVendor = implVendor;
+ this.implVersion = implVersion;
+
+ this.specTitle = specTitle;
+ this.specVendor = specVendor;
+ this.specVersion = specVersion;
+
+ this.sealed = sealed;
+ }
+
+ /**
+ * Returns the Package name.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Returns the name of the implementation or null if unknown.
+ */
+ public String getImplementationTitle()
+ {
+ return implTitle;
+ }
+
+ /**
+ * Returns the vendor that wrote this implementation or null if unknown.
+ */
+ public String getImplementationVendor()
+ {
+ return implVendor;
+ }
+
+ /**
+ * Returns the version of this implementation or null if unknown.
+ */
+ public String getImplementationVersion()
+ {
+ return implVersion;
+ }
+
+ /**
+ * Returns the name of the specification or null if unknown.
+ */
+ public String getSpecificationTitle()
+ {
+ return specTitle;
+ }
+
+ /**
+ * Returns the name of the specification designer or null if unknown.
+ */
+ public String getSpecificationVendor()
+ {
+ return specVendor;
+ }
+
+ /**
+ * Returns the version of the specification or null if unknown.
+ */
+ public String getSpecificationVersion()
+ {
+ return specVersion;
+ }
+
+ /**
+ * Returns true if this Package is sealed.
+ */
+ public boolean isSealed()
+ {
+ return (sealed != null);
+ }
+
+ /**
+ * Returns true if this Package is sealed and the origin of the classes is
+ * the given URL.
+ *
+ * @param url
+ */
+ public boolean isSealed(URL url)
+ {
+ return url.equals(sealed);
+ }
+
+ /**
+ * Checks if the version of the specification is higher or at least as high
+ * as the desired version.
+ * @param version the (minimal) desired version of the specification
+ * @exception NumberFormatException when either version or the
+ * specification version is not a correctly formatted version number
+ * @exception NullPointerException if the supplied version or the
+ * Package specification version is null.
+ */
+ public boolean isCompatibleWith(String version) throws NumberFormatException
+ {
+ StringTokenizer versionTokens = new StringTokenizer(version, ".");
+ StringTokenizer specTokens = new StringTokenizer(specVersion, ".");
+ try
+ {
+ while (versionTokens.hasMoreElements())
+ {
+ int vers = Integer.parseInt(versionTokens.nextToken());
+ int spec = Integer.parseInt(specTokens.nextToken());
+ if (spec < vers)
+ return false;
+ else if (spec > vers)
+ return true;
+ // They must be equal, next Token please!
+ }
+ }
+ catch (NoSuchElementException e)
+ {
+ // this must have been thrown by spec.netToken() so return false
+ return false;
+ }
+
+ // They must have been exactly the same version.
+ // Or the specVersion has more subversions. That is also good.
+ return true;
+ }
+
+ /**
+ * Returns the named package if it is known by the callers class loader.
+ * It may return null if the package is unknown, when there is no
+ * information on that particular package available or when the callers
+ * classloader is null.
+ * @param name the name of the desired package
+ */
+ public static Package getPackage(String name)
+ {
+ // Get the caller's classloader
+ SecurityManager sm = System.getSecurityManager();
+ Class c = sm.getClassContext()[1];
+ ClassLoader cl = c.getClassLoader();
+
+ if (cl != null)
+ return cl.getPackage(name);
+ else
+ return null;
+ }
+
+ /**
+ * Returns all the packages that are known to the callers class loader.
+ * It may return an empty array if the classloader of the caller is null.
+ */
+ public static Package[] getPackages()
+ {
+ // Get the caller's classloader
+ SecurityManager sm = System.getSecurityManager();
+ Class c = sm.getClassContext()[1];
+ ClassLoader cl = c.getClassLoader();
+
+ if (cl != null)
+ return cl.getPackages();
+ else
+ return new Package[0];
+ }
+
+ /**
+ * Returns the hashCode of the name of this package.
+ */
+ public int hashCode()
+ {
+ return name.hashCode();
+ }
+
+ /**
+ * Returns a string representation of this package name, specification,
+ * implementation and class origin if sealed.
+ */
+ public String toString()
+ {
+ return "package: " + name +
+ " spec: " + specTitle +
+ " version: " + specVersion +
+ " vendor: " + specVendor +
+ " implementation: " + implTitle +
+ " version: " + implVersion +
+ " vendor: " + implVendor + " sealed: " + sealed;
+ }
+}
diff --git a/libjava/java/lang/natClass.cc b/libjava/java/lang/natClass.cc
index 25e92c7..d7c2a54 100644
--- a/libjava/java/lang/natClass.cc
+++ b/libjava/java/lang/natClass.cc
@@ -72,7 +72,8 @@ static _Jv_Utf8Const *finit_leg_name = _Jv_makeUtf8Const ("$finit$", 7);
jclass
-java::lang::Class::forName (jstring className, java::lang::ClassLoader *loader)
+java::lang::Class::forName (jstring className, jboolean initialize,
+ java::lang::ClassLoader *loader)
{
if (! className)
throw new java::lang::NullPointerException;
@@ -90,11 +91,12 @@ java::lang::Class::forName (jstring className, java::lang::ClassLoader *loader)
? _Jv_FindClassFromSignature (name->data, loader)
: _Jv_FindClass (name, loader));
- if (klass)
- _Jv_InitClass (klass);
- else
+ if (klass == NULL)
throw new java::lang::ClassNotFoundException (className);
+ if (initialize)
+ _Jv_InitClass (klass);
+
return klass;
}
@@ -102,7 +104,7 @@ jclass
java::lang::Class::forName (jstring className)
{
// FIXME: should use class loader from calling method.
- return forName (className, NULL);
+ return forName (className, true, NULL);
}
java::lang::reflect::Constructor *
@@ -1415,3 +1417,10 @@ java::lang::Class::getPrivateMethod (jstring name, JArray<jclass> *param_types)
}
throw new java::lang::NoSuchMethodException;
}
+
+// Private accessor method for Java code to retrieve the protection domain.
+java::security::ProtectionDomain *
+java::lang::Class::getProtectionDomain0 ()
+{
+ return protectionDomain;
+}
diff --git a/libjava/java/lang/natClassLoader.cc b/libjava/java/lang/natClassLoader.cc
index 84fe0c4..6b7f5fa 100644
--- a/libjava/java/lang/natClassLoader.cc
+++ b/libjava/java/lang/natClassLoader.cc
@@ -48,20 +48,12 @@ details. */
/////////// java.lang.ClassLoader native methods ////////////
-java::lang::ClassLoader *
-java::lang::ClassLoader::getSystemClassLoader (void)
-{
- JvSynchronize sync (&ClassLoaderClass);
- if (! system)
- system = gnu::gcj::runtime::VMClassLoader::getVMClassLoader ();
- return system;
-}
-
java::lang::Class *
java::lang::ClassLoader::defineClass0 (jstring name,
jbyteArray data,
jint offset,
- jint length)
+ jint length,
+ java::security::ProtectionDomain *pd)
{
#ifdef INTERPRETER
jclass klass;
@@ -109,6 +101,8 @@ java::lang::ClassLoader::defineClass0 (jstring name,
throw ex;
}
+
+ klass->protectionDomain = pd;
// if everything proceeded sucessfully, we're loaded.
JvAssert (klass->state == JV_STATE_LOADED);
@@ -180,10 +174,10 @@ java::lang::ClassLoader::markClassErrorState0 (java::lang::Class *klass)
}
-/** this is the only native method in VMClassLoader, so
- we define it here. */
+// This is the findClass() implementation for the System classloader. It is
+// the only native method in VMClassLoader, so we define it here.
jclass
-gnu::gcj::runtime::VMClassLoader::findSystemClass (jstring name)
+gnu::gcj::runtime::VMClassLoader::findClass (jstring name)
{
_Jv_Utf8Const *name_u = _Jv_makeUtf8Const (name);
jclass klass = _Jv_FindClassInCache (name_u, 0);
@@ -213,6 +207,12 @@ gnu::gcj::runtime::VMClassLoader::findSystemClass (jstring name)
}
}
+ // Now try loading using the interpreter.
+ if (! klass)
+ {
+ klass = java::net::URLClassLoader::findClass (name);
+ }
+
return klass;
}
diff --git a/libjava/java/net/NetPermission.java b/libjava/java/net/NetPermission.java
new file mode 100644
index 0000000..f458b1c
--- /dev/null
+++ b/libjava/java/net/NetPermission.java
@@ -0,0 +1,65 @@
+/* NetPermission.java -- A class for basic miscellaneous network permission
+ Copyright (C) 1998, 2000 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.net;
+
+import java.security.BasicPermission;
+
+/**
+ * This class is used to model miscellaneous network permissions. It is
+ * a subclass of BasicPermission. This means that it models a "boolean"
+ * permission. One that you either have or do not have. Thus there is
+ * no permitted action list associated with this object.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public final class NetPermission extends BasicPermission
+ implements java.io.Serializable
+{
+ /**
+ * Initializes a new instance of <code>NetPermission</code> with the
+ * specified name.
+ *
+ * @param name The name of this permission.
+ */
+ public NetPermission(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Initializes a new instance of <code>NetPermission</code> with the
+ * specified name and value. Note that the value field is irrelevant and is
+ * ignored. This constructor should never need to be used.
+ *
+ * @param name The name of this permission
+ * @param perms The permitted actions of this permission (ignored)
+ */
+ public NetPermission(String name, String perms)
+ {
+ super(name);
+ }
+}
diff --git a/libjava/java/net/SocketPermission.java b/libjava/java/net/SocketPermission.java
new file mode 100644
index 0000000..0ddadad
--- /dev/null
+++ b/libjava/java/net/SocketPermission.java
@@ -0,0 +1,377 @@
+/* SocketPermission.java -- Class modeling permissions for socket operations
+ Copyright (C) 1998, 2000 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.net;
+
+import java.security.Permission;
+import java.security.PermissionCollection;
+
+/**
+ * This class models a specific set of permssions for connecting to a
+ * host. There are two elements to this, the host/port combination and
+ * the permission list.
+ * <p>
+ * The host/port combination is specified as followed
+ * <p>
+ * <pre>
+ * hostname[:[-]port[-[port]]]
+ * </pre>
+ * <p>
+ * The hostname portion can be either a hostname or IP address. If it is
+ * a hostname, a wildcard is allowed in hostnames. This wildcard is a "*"
+ * and matches one or more characters. Only one "*" may appear in the
+ * host and it must be the leftmost character. For example,
+ * "*.urbanophile.com" matches all hosts in the "urbanophile.com" domain.
+ * <p>
+ * The port portion can be either a single value, or a range of values
+ * treated as inclusive. The first or the last port value in the range
+ * can be omitted in which case either the minimum or maximum legal
+ * value for a port (respectively) is used by default. Here are some
+ * examples:
+ * <p><ul>
+ * <li>8080 - Represents port 8080 only
+ * <li>2000-3000 - Represents ports 2000 through 3000 inclusive
+ * <li>-4000 - Represents ports 0 through 4000 inclusive
+ * <li>1024- - Represents ports 1024 through 65535 inclusive
+ * </ul><p>
+ * The permission list is a comma separated list of individual permissions.
+ * These individual permissions are:
+ * <p>
+ * accept<br>
+ * connect<br>
+ * listen<br>
+ * resolve<br>
+ * <p>
+ * The "listen" permission is only relevant if the host is localhost. If
+ * any permission at all is specified, then resolve permission is implied to
+ * exist.
+ * <p>
+ * Here are a variety of examples of how to create SocketPermission's
+ * <p><pre>
+ * SocketPermission("www.urbanophile.com", "connect");
+ * Can connect to any port on www.urbanophile.com
+ * SocketPermission("www.urbanophile.com:80", "connect,accept");
+ * Can connect to or accept connections from www.urbanophile.com on port 80
+ * SocketPermission("localhost:1024-", "listen,accept,connect");
+ * Can connect to, accept from, an listen on any local port number 1024 and up.
+ * SocketPermission("*.edu", "connect");
+ * Can connect to any host in the edu domain
+ * SocketPermission("197.197.20.1", "accept");
+ * Can accept connections from 197.197.20.1
+ * </pre><p>
+ *
+ * @since 1.2
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public final class SocketPermission extends Permission
+ implements java.io.Serializable
+{
+
+// FIXME: Needs serialization work, including readObject/writeObject methods.
+ /**
+ * A hostname/port combination as described above
+ */
+ protected transient String hostport;
+
+ /**
+ * A comma separated list of actions for which we have permission
+ */
+ protected String actions;
+
+ /**
+ * Initializes a new instance of <code>SocketPermission</code> with the
+ * specified host/port combination and actions string.
+ *
+ * @param hostport The hostname/port number combination
+ * @param perms The actions string
+ */
+ public SocketPermission(String hostport, String actions)
+ {
+ super(hostport);
+
+ this.hostport = hostport;
+ this.actions = actions;
+ }
+
+ /**
+ * Tests this object for equality against another. This will be true if
+ * and only if the passed object is an instance of
+ * <code>SocketPermission</code> and both its hostname/port combination
+ * and permissions string are identical.
+ *
+ * @param obj The object to test against for equality
+ *
+ * @return <code>true</code> if object is equal to this object,
+ * <code>false</code> otherwise.
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj == null)
+ return (false);
+
+ if (!(obj instanceof SocketPermission))
+ return (false);
+
+ if (((SocketPermission) obj).hostport.equals(hostport))
+ if (((SocketPermission) obj).actions.equals(actions))
+ return (true);
+
+ return (false);
+ }
+
+ /**
+ * Returns a hash code value for this object. Overrides the
+ * Permission.hashCode()
+ *
+ * @return A hash code
+ */
+ public int hashCode()
+ {
+ int hash = 100;
+
+ // FIXME: Get a real hash function
+ for (int i = 0; i < hostport.length(); i++)
+ hash = hash + (int) hostport.charAt(i) * 7;
+
+ return (hash);
+ }
+
+ /**
+ * Returns the list of permission actions in this object in canonical
+ * order. The canonical order is "connect,listen,accept,resolve"
+ *
+ * @return The permitted action string.
+ */
+ public String getActions()
+ {
+ boolean found = false;
+ StringBuffer sb = new StringBuffer("");
+
+ if (actions.indexOf("connect") != -1)
+ {
+ sb.append("connect");
+ found = true;
+ }
+
+ if (actions.indexOf("listen") != -1)
+ if (found)
+ sb.append(",listen");
+ else
+ {
+ sb.append("listen");
+ found = true;
+ }
+
+ if (actions.indexOf("accept") != -1)
+ if (found)
+ sb.append(",accept");
+ else
+ {
+ sb.append("accept");
+ found = true;
+ }
+
+ if (found)
+ sb.append(",resolve");
+ else if (actions.indexOf("resolve") != -1)
+ sb.append("resolve");
+
+ return (sb.toString());
+ }
+
+ /**
+ * Returns a new <code>PermissionCollection</code> object that can hold
+ * <code>SocketPermission</code>'s.
+ *
+ * @return A new <code>PermissionCollection</code>.
+ */
+ public PermissionCollection newPermissionCollection()
+ {
+ // FIXME: Implement
+
+ return (null);
+ }
+
+ /**
+ * Returns true if the permission object passed it is implied by the
+ * this permission. This will be true if
+ * <p><ul>
+ * <li>The argument is of type SocketPermission
+ * <li>The actions list of the argument are in this object's actions
+ * <li>The port range of the argument is within this objects port range
+ * <li>The hostname is equal to or a subset of this objects hostname
+ * </ul>
+ * <p>
+ * The argument's hostname will be a subset of this object's hostname if:
+ * <p><ul>
+ * <li>The argument's hostname or IP address is equal to this object's.
+ * <li>The argument's canonical hostname is equal to this object's.
+ * <li>The argument's canonical name matches this domains hostname with wildcards
+ * </ul>
+ *
+ * @param perm The Permission to check against
+ *
+ * @return <code>true</code> if the <code>Permission</code> is implied by
+ * this object, <code>false</code> otherwise.
+ */
+ public boolean implies(Permission perm)
+ {
+ SocketPermission p;
+
+ // First make sure we are the right object type
+ if (perm instanceof SocketPermission)
+ p = (SocketPermission) perm;
+ else
+ return (false);
+
+ // Next check the actions
+ String ourlist = getActions();
+ String theirlist = p.getActions();
+
+ if (!ourlist.startsWith(theirlist))
+ return (false);
+
+ // Now check ports
+ int ourfirstport = 0, ourlastport = 0, theirfirstport = 0, theirlastport =
+ 0;
+
+ // Get ours
+ if (hostport.indexOf(":") == -1)
+ {
+ ourfirstport = 0;
+ ourlastport = 65535;
+ }
+ else
+ {
+ // FIXME: Needs bulletproofing.
+ // This will dump if hostport if all sorts of bad data was passed to
+ // the constructor
+ String range = hostport.substring(hostport.indexOf(":") + 1);
+ if (range.startsWith("-"))
+ ourfirstport = 0;
+ else if (range.indexOf("-") == -1)
+ ourfirstport = Integer.parseInt(range);
+ else
+ ourfirstport =
+ Integer.parseInt(range.substring(0, range.indexOf("-")));
+
+ if (range.endsWith("-"))
+ ourlastport = 65535;
+ else if (range.indexOf("-") == -1)
+ ourlastport = Integer.parseInt(range);
+ else
+ ourlastport =
+ Integer.parseInt(range.
+ substring(range.indexOf("-") + 1,
+ range.length()));
+ }
+
+ // Get theirs
+ if (p.hostport.indexOf(":") == -1)
+ {
+ theirfirstport = 0;
+ ourlastport = 65535;
+ }
+ else
+ {
+ // This will dump if hostport if all sorts of bad data was passed to
+ // the constructor
+ String range = p.hostport.substring(hostport.indexOf(":") + 1);
+ if (range.startsWith("-"))
+ theirfirstport = 0;
+ else if (range.indexOf("-") == -1)
+ theirfirstport = Integer.parseInt(range);
+ else
+ theirfirstport =
+ Integer.parseInt(range.substring(0, range.indexOf("-")));
+
+ if (range.endsWith("-"))
+ theirlastport = 65535;
+ else if (range.indexOf("-") == -1)
+ theirlastport = Integer.parseInt(range);
+ else
+ theirlastport =
+ Integer.parseInt(range.
+ substring(range.indexOf("-") + 1,
+ range.length()));
+ }
+
+ // Now check them
+ if ((theirfirstport < ourfirstport) || (theirlastport > ourlastport))
+ return (false);
+
+ // Finally we can check the hosts
+ String ourhost, theirhost;
+
+ // Get ours
+ if (hostport.indexOf(":") == -1)
+ ourhost = hostport;
+ else
+ ourhost = hostport.substring(0, hostport.indexOf(":"));
+
+ // Get theirs
+ if (p.hostport.indexOf(":") == -1)
+ theirhost = p.hostport;
+ else
+ theirhost = p.hostport.substring(0, p.hostport.indexOf(":"));
+
+ // Are they equal?
+ if (ourhost.equals(theirhost))
+ return (true);
+
+ // Try the canonical names
+ String ourcanonical = null, theircanonical = null;
+ try
+ {
+ ourcanonical = InetAddress.getByName(ourhost).getHostName();
+ theircanonical = InetAddress.getByName(theirhost).getHostName();
+ }
+ catch (UnknownHostException e)
+ {
+ // Who didn't resolve? Just assume current address is canonical enough
+ // Is this ok to do?
+ if (ourcanonical == null)
+ ourcanonical = ourhost;
+ if (theircanonical == null)
+ theircanonical = theirhost;
+ }
+
+ if (ourcanonical.equals(theircanonical))
+ return (true);
+
+ // Well, last chance. Try for a wildcard
+ if (ourhost.indexOf("*.") != -1)
+ {
+ String wild_domain = ourhost.substring(ourhost.indexOf("*" + 1));
+ if (theircanonical.endsWith(wild_domain))
+ return (true);
+ }
+
+ // Didn't make it
+ return (false);
+ }
+}
diff --git a/libjava/java/security/AccessControlContext.java b/libjava/java/security/AccessControlContext.java
new file mode 100644
index 0000000..5daa044
--- /dev/null
+++ b/libjava/java/security/AccessControlContext.java
@@ -0,0 +1,164 @@
+/* AccessControlContext.java --- Access Control Context Class
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+
+/**
+ AccessControlContext makes system resource access decsion
+ based on permission rights.
+
+ It is used for a specific context and has only one method
+ checkPermission. It is similar to AccessController except
+ that it makes decsions based on the current context instead
+ of the the current thread.
+
+ It is created by call AccessController.getContext method.
+
+ @author Mark Benvenuto
+ @since JDK 1.2
+ */
+public final class AccessControlContext
+{
+ private ProtectionDomain protectionDomain[];
+ private DomainCombiner combiner;
+
+ /**
+ Construct a new AccessControlContext with the specified
+ ProtectionDomains. <code>context</code> must not be
+ null and duplicates will be removed.
+
+ @param context The ProtectionDomains to use
+ */
+ public AccessControlContext(ProtectionDomain[]context)
+ {
+ int i, j, k, count = context.length, count2 = 0;
+ for (i = 0, j = 0; i < count; i++)
+ {
+ for (k = 0; k < i; k++)
+ if (context[k] == protectionDomain[i])
+ break;
+ if (k != i) //it means previous loop did not complete
+ continue;
+
+ count2++;
+ }
+
+ protectionDomain = new ProtectionDomain[count2];
+ for (i = 0, j = 0; i < count2; i++)
+ {
+ for (k = 0; k < i; k++)
+ if (context[k] == protectionDomain[i])
+ break;
+ if (k != i) //it means previous loop did not complete
+ continue;
+
+ protectionDomain[j++] = context[i];
+ }
+ }
+
+ /**
+ Construct a new AccessControlContext with the specified
+ ProtectionDomains and DomainCombiner
+
+ @param context The ProtectionDomains to use
+
+ @since JDK 1.3
+ */
+ public AccessControlContext(AccessControlContext acc,
+ DomainCombiner combiner)
+ {
+ this(acc.protectionDomain);
+ this.combiner = combiner;
+ }
+
+ /**
+ Returns the Domain Combiner associated with the AccessControlContext
+
+ @returns the DomainCombiner
+ */
+ public DomainCombiner getDomainCombiner()
+ {
+ return combiner;
+ }
+
+ /**
+ Determines whether or not the specific permission is granted
+ depending on the context it is within.
+
+ @param perm a permission to check
+
+ @throws AccessControlException if the permssion is not permitted
+ */
+ public void checkPermission(Permission perm) throws AccessControlException
+ {
+ for (int i = 0; i < protectionDomain.length; i++)
+ if (protectionDomain[i].implies(perm) == true)
+ return;
+
+ throw new AccessControlException("Permission not granted");
+ }
+
+ /**
+ Checks if two AccessControlContexts are equal.
+
+ It first checks if obj is an AccessControlContext class, and
+ then checks if each ProtectionDomain matches.
+
+ @param obj The object to compare this class to
+
+ @return true if equal, false otherwise
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof AccessControlContext)
+ {
+ AccessControlContext acc = (AccessControlContext) obj;
+
+ if (acc.protectionDomain.length != protectionDomain.length)
+ return false;
+
+ for (int i = 0; i < protectionDomain.length; i++)
+ if (acc.protectionDomain[i] != protectionDomain[i])
+ return false;
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ Computes a hash code of this class
+
+ @return a hash code representing this class
+ */
+ public int hashCode()
+ {
+ int h = 0;
+ for (int i = 0; i < protectionDomain.length; i++)
+ h ^= protectionDomain[i].hashCode();
+
+ return h;
+ }
+}
diff --git a/libjava/java/security/AccessControlException.java b/libjava/java/security/AccessControlException.java
new file mode 100644
index 0000000..2749a9d
--- /dev/null
+++ b/libjava/java/security/AccessControlException.java
@@ -0,0 +1,80 @@
+/* AccessControlException.java -- Permission is denied
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+
+/**
+ * This exception is thrown when the <code>AccessController</code> denies
+ * an attempt to perform an operation.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public class AccessControlException extends SecurityException
+{
+ /**
+ * The <code>Permission</code> associated with this exception
+ */
+ private Permission perm;
+
+ /**
+ * This method initializes a new instance of <code>AccessControlException</code>
+ * with a descriptive error message. There will be no <code>Permission</code>
+ * object associated with this exception.
+ *
+ * @param msg The descriptive error message
+ */
+ public AccessControlException(String msg)
+ {
+ super(msg);
+ }
+
+ /**
+ * This method initializes a new instance of <code>AccessControlException</code>
+ * with a descriptive error message and an instance of <code>Permission</code>
+ * that is the permission that caused the exception to be thrown.
+ *
+ * @param msg The descriptive error message
+ * @param perm The <code>Permission</code> object that caused this exception.
+ */
+ public AccessControlException(String msg, Permission perm)
+ {
+ super(msg);
+ this.perm = perm;
+ }
+
+ /**
+ * This method returns the <code>Permission</code> object that caused
+ * this exception to be thrown.
+ *
+ * @return The requested <code>Permission</code> object, or <code>null</code> if none is available.
+ */
+ public Permission getPermission()
+ {
+ return (perm);
+ }
+}
diff --git a/libjava/java/security/AccessController.java b/libjava/java/security/AccessController.java
new file mode 100644
index 0000000..c830fa4
--- /dev/null
+++ b/libjava/java/security/AccessController.java
@@ -0,0 +1,185 @@
+/* AccessController.java --- Access control context and permission checker
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+
+/**
+ * Access control context and permission checker.
+ * Can check permissions in the access control context of the current thread
+ * through the <code>checkPermission()</code> method.
+ * Manipulates the access control context for code that needs to be executed
+ * the protection domain of the calling class (by explicitly ignoring the
+ * context of the calling code) in the <code>doPriviliged()</code> methods.
+ * And provides a <code>getContext()</code> method which gives the access
+ * control context of the current thread that can be used for checking
+ * permissions at a later time and/or in another thread.
+ * <p>
+ * XXX - Mostly a stub implementation at the moment. Needs native support
+ * from the VM to function correctly. XXX - Do not forget to think about
+ * how to handle <code>java.lang.reflect.Method.invoke()</code> on the
+ * <code>doPrivileged()</code> methods.
+ *
+ * @author Mark Wielaard (mark@klomp.org)
+ * @since 1.2
+ */
+public final class AccessController
+{
+ /**
+ * This class only has static methods so there is no public contructor.
+ */
+ private AccessController()
+ {
+ }
+
+ /**
+ * Checks wether the access control context of the current thread allows
+ * the given Permission. Throws an <code>AccessControlException</code>
+ * when the permission is not allowed in the current context. Otherwise
+ * returns silently without throwing an exception.
+ *
+ * @param perm the permission to be checked.
+ * @exception AccessControlException thrown if the current context does not
+ * allow the given permission.
+ */
+ public static void checkPermission(Permission perm)
+ {
+ getContext().checkPermission(perm);
+ }
+
+ /**
+ * Calls the <code>run()</code> method of the given action with as
+ * (initial) access control context only the protection domain of the
+ * calling class. Calls to <code>checkPermission()</code> in the
+ * <code>run()</code> method ignore all earlier protection domains of
+ * classes in the call chain. Note that the protection domains of classes
+ * called by the code in the <code>run()</code> method are not ignored.
+ *
+ * @param action the <code>PrivilegedAction</code> whose <code>run()</code>
+ * should be be called.
+ * @returns the result of the <code>action.run()</code> method.
+ */
+ public static Object doPrivileged(PrivilegedAction action)
+ {
+ return action.run();
+ }
+
+ /**
+ * Calls the <code>run()</code> method of the given action with as
+ * (initial) access control context the given context combined with the
+ * protection domain of the calling class. Calls to
+ * <code>checkPermission()</code> in the <code>run()</code> method ignore
+ * all earlier protection domains of classes in the call chain, but add
+ * checks for the protection domains given in the supplied context.
+ *
+ * @param action the <code>PrivilegedAction</code> whose <code>run()</code>
+ * should be be called.
+ * @param context the <code>AccessControlContext</code> whose protection
+ * domains should be added to the protection domain of the calling class.
+ * @returns the result of the <code>action.run()</code> method.
+ */
+ public static Object doPrivileged(PrivilegedAction action,
+ AccessControlContext context)
+ {
+ return action.run();
+ }
+
+ /**
+ * Calls the <code>run()</code> method of the given action with as
+ * (initial) access control context only the protection domain of the
+ * calling class. Calls to <code>checkPermission()</code> in the
+ * <code>run()</code> method ignore all earlier protection domains of
+ * classes in the call chain. Note that the protection domains of classes
+ * called by the code in the <code>run()</code> method are not ignored.
+ * If the <code>run()</code> method throws an exception then this method
+ * will wrap that exception in an <code>PrivilegedActionException</code>.
+ *
+ * @param action the <code>PrivilegedExceptionAction</code> whose
+ * <code>run()</code> should be be called.
+ * @returns the result of the <code>action.run()</code> method.
+ * @exception PriviligedActionException wrapped around any exception that
+ * is thrown in the <code>run()</code> method.
+ */
+ public static Object doPrivileged(PrivilegedExceptionAction action)
+ throws PrivilegedActionException
+ {
+
+ try
+ {
+ return action.run();
+ }
+ catch (Exception e)
+ {
+ throw new PrivilegedActionException(e);
+ }
+ }
+
+ /**
+ * Calls the <code>run()</code> method of the given action with as
+ * (initial) access control context the given context combined with the
+ * protection domain of the calling class. Calls to
+ * <code>checkPermission()</code> in the <code>run()</code> method ignore
+ * all earlier protection domains of classes in the call chain, but add
+ * checks for the protection domains given in the supplied context.
+ * If the <code>run()</code> method throws an exception then this method
+ * will wrap that exception in an <code>PrivilegedActionException</code>.
+ *
+ * @param action the <code>PrivilegedExceptionAction</code> whose
+ * <code>run()</code> should be be called.
+ * @param context the <code>AccessControlContext</code> whose protection
+ * domains should be added to the protection domain of the calling class.
+ * @returns the result of the <code>action.run()</code> method.
+ * @exception PriviligedActionException wrapped around any exception that
+ * is thrown in the <code>run()</code> method.
+ */
+ public static Object doPrivileged(PrivilegedExceptionAction action,
+ AccessControlContext context)
+ throws PrivilegedActionException
+ {
+
+ try
+ {
+ return action.run();
+ }
+ catch (Exception e)
+ {
+ throw new PrivilegedActionException(e);
+ }
+ }
+
+ /**
+ * Returns the complete access control context of the current thread.
+ * <p>
+ * XXX - Should this include all the protection domains in the call chain
+ * or only the domains till the last <code>doPrivileged()</code> call?
+ * <p>
+ * XXX - needs native support. Currently returns an empty context.
+ */
+ public static AccessControlContext getContext()
+ {
+ // For now just return an new empty context
+ return new AccessControlContext(new ProtectionDomain[0]);
+ }
+}
diff --git a/libjava/java/security/AlgorithmParameterGenerator.java b/libjava/java/security/AlgorithmParameterGenerator.java
new file mode 100644
index 0000000..b10cb48
--- /dev/null
+++ b/libjava/java/security/AlgorithmParameterGenerator.java
@@ -0,0 +1,219 @@
+/* AlgorithmParameterGenerator.java --- Algorithm Parameter Generator
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+import java.security.spec.AlgorithmParameterSpec;
+
+/**
+ AlgorithmParameterGenerator is used to generate
+ algorithm parameters for specified algorithms.
+ This class is used to generate the algorithm parameters
+ for a specific algorithm.
+
+ @since JDK 1.2
+ @author Mark Benvenuto
+ */
+public class AlgorithmParameterGenerator
+{
+ private AlgorithmParameterGeneratorSpi paramGenSpi;
+ private Provider provider;
+ private String algorithm;
+
+ /**
+ Creates an instance of AlgorithmParameters
+
+ @param paramSpi A parameters engine to use
+ @param provider A provider to use
+ @param algorithm The algorithm
+ */
+ protected AlgorithmParameterGenerator(AlgorithmParameterGeneratorSpi
+ paramGenSpi, Provider provider,
+ String algorithm)
+ {
+ this.paramGenSpi = paramGenSpi;
+ this.provider = provider;
+ this.algorithm = algorithm;
+ }
+
+ /**
+ Returns the name of the algorithm used
+
+ @return A string with the name of the algorithm
+ */
+ public final String getAlgorithm()
+ {
+ return algorithm;
+ }
+
+ /**
+ Gets an instance of the AlgorithmParameterGenerator class
+ which generates algorithm parameters for the specified algorithm.
+ If the algorithm is not found then, it throws NoSuchAlgorithmException.
+
+ @param algorithm the name of algorithm to choose
+ @return a AlgorithmParameterGenerator repesenting the desired algorithm
+
+ @throws NoSuchAlgorithmException if the algorithm is not implemented by providers
+ */
+ public static AlgorithmParameterGenerator getInstance(String algorithm)
+ throws NoSuchAlgorithmException
+ {
+ Provider[] p = Security.getProviders();
+
+ for (int i = 0; i < p.length; i++)
+ {
+ String classname =
+ p[i].getProperty("AlgorithmParameterGenerator." + algorithm);
+ if (classname != null)
+ return getInstance(classname, algorithm, p[i]);
+ }
+
+ throw new NoSuchAlgorithmException(algorithm);
+ }
+
+ /**
+ Gets an instance of the AlgorithmParameterGenerator class
+ which generates algorithm parameters for the specified algorithm.
+ If the algorithm is not found then, it throws NoSuchAlgorithmException.
+
+ @param algorithm the name of algorithm to choose
+ @param provider the name of the provider to find the algorithm in
+ @return a AlgorithmParameterGenerator repesenting the desired algorithm
+
+ @throws NoSuchAlgorithmException if the algorithm is not implemented by the provider
+ @throws NoSuchProviderException if the provider is not found
+ */
+ public static AlgorithmParameterGenerator getInstance(String algorithm,
+ String provider)
+ throws NoSuchAlgorithmException, NoSuchProviderException
+ {
+ Provider p = Security.getProvider(provider);
+ if (p == null)
+ throw new NoSuchProviderException();
+
+ return getInstance(p.
+ getProperty("AlgorithmParameterGenerator." +
+ algorithm), algorithm, p);
+ }
+
+ private static AlgorithmParameterGenerator getInstance(String classname,
+ String algorithm,
+ Provider provider)
+ throws NoSuchAlgorithmException
+ {
+
+ try
+ {
+ return new
+ AlgorithmParameterGenerator((AlgorithmParameterGeneratorSpi) Class.
+ forName(classname).newInstance(),
+ provider, algorithm);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ throw new NoSuchAlgorithmException("Class not found");
+ }
+ catch (InstantiationException ie)
+ {
+ throw new NoSuchAlgorithmException("Class instantiation failed");
+ }
+ catch (IllegalAccessException iae)
+ {
+ throw new NoSuchAlgorithmException("Illegal Access");
+ }
+ }
+
+ /**
+ Gets the provider that the class is from.
+
+ @return the provider of this class
+ */
+ public final Provider getProvider()
+ {
+ return provider;
+ }
+
+ /**
+ Initializes the Algorithm Parameter Generator with the specified
+ size. (Since no source of randomness is supplied, a default
+ one is supplied).
+
+ @param size size (in bits) to use
+ */
+ public final void init(int size)
+ {
+ init(size, new SecureRandom());
+ }
+
+ /**
+ Initializes the Algorithm Parameter Generator with the specified
+ size and source of randomness.
+
+ @param size size (in bits) to use
+ @param random source of randomness to use
+ */
+ public final void init(int size, SecureRandom random)
+ {
+ paramGenSpi.engineInit(size, random);
+ }
+
+ /**
+ Initializes the Algorithm Parameter Generator with the specified
+ AlgorithmParameterSpec. (Since no source of randomness is supplied,
+ a default one is supplied).
+
+ @param genParamSpec the AlgorithmParameterSpec class to use
+ */
+ public final void init(AlgorithmParameterSpec genParamSpec) throws
+ InvalidAlgorithmParameterException
+ {
+ init(genParamSpec, new SecureRandom());
+ }
+
+ /**
+ Initializes the Algorithm Parameter Generator with the specified
+ AlgorithmParameterSpec and source of randomness.
+
+ @param genParamSpec the AlgorithmParameterSpec class to use
+ @param random source of randomness to use
+ */
+ public final void init(AlgorithmParameterSpec genParamSpec,
+ SecureRandom random) throws
+ InvalidAlgorithmParameterException
+ {
+ paramGenSpi.engineInit(genParamSpec, random);
+ }
+
+ /**
+ Generate a new set of AlgorithmParameters.
+
+ @returns a new set of algorithm parameters
+ */
+ public final AlgorithmParameters generateParameters()
+ {
+ return paramGenSpi.engineGenerateParameters();
+ }
+}
diff --git a/libjava/java/security/AlgorithmParameterGeneratorSpi.java b/libjava/java/security/AlgorithmParameterGeneratorSpi.java
index 476e1bb..6cae430 100644
--- a/libjava/java/security/AlgorithmParameterGeneratorSpi.java
+++ b/libjava/java/security/AlgorithmParameterGeneratorSpi.java
@@ -1,25 +1,83 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* AlgorithmParameterGeneratorSpi.java --- Algorithm Parameter Generator SPI
+ Copyright (C) 1999 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
package java.security;
+import java.security.spec.AlgorithmParameterSpec;
/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 7, 2000.
- */
+ AlgorithmParameterGeneratorSpi is the Service Provider
+ Interface for the AlgorithmParameterGenerator class.
+ This class is used to generate the algorithm parameters
+ for a specific algorithm.
-/**
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Stubbed.
+ @since JDK 1.2
+ @author Mark Benvenuto
*/
-
-// JDK1.2
public abstract class AlgorithmParameterGeneratorSpi
{
- // FIXME: Stubbed.
+
+ /**
+ Constructs a new AlgorithmParameterGeneratorSpi
+ */
+ public AlgorithmParameterGeneratorSpi()
+ {
+ }
+
+ /**
+ Initializes the parameter generator with the specified size
+ and SecureRandom
+
+ @param size the size( in number of bits)
+ @param random the SecureRandom class to use for randomness
+ */
+ protected abstract void engineInit(int size, SecureRandom random);
+
+ /**
+ Initializes the parameter generator with the specified
+ AlgorithmParameterSpec and SecureRandom classes.
+
+ If genParamSpec is an invalid AlgorithmParameterSpec for this
+ AlgorithmParameterGeneratorSpi then it throws
+ InvalidAlgorithmParameterException
+
+ @param genParamSpec the AlgorithmParameterSpec class to use
+ @param random the SecureRandom class to use for randomness
+
+ @throws InvalidAlgorithmParameterException genParamSpec is invalid
+ */
+ protected abstract void engineInit(AlgorithmParameterSpec genParamSpec,
+ SecureRandom random) throws
+ InvalidAlgorithmParameterException;
+
+
+ /**
+ Generate a new set of AlgorithmParameters.
+
+ @returns a new set of algorithm parameters
+ */
+ protected abstract AlgorithmParameters engineGenerateParameters();
+
}
diff --git a/libjava/java/security/AlgorithmParameters.java b/libjava/java/security/AlgorithmParameters.java
new file mode 100644
index 0000000..5c570b5
--- /dev/null
+++ b/libjava/java/security/AlgorithmParameters.java
@@ -0,0 +1,265 @@
+/* AlgorithmParameters.java --- Algorithm Parameters Implementation Class
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+
+package java.security;
+import java.security.spec.InvalidParameterSpecException;
+import java.security.spec.AlgorithmParameterSpec;
+import java.io.IOException;
+
+/**
+ AlgorithmParameters is the Algorithm Parameters class which
+ provides an interface through which to modify parameters for
+ classes. This class is used to manage the algorithm parameters.
+
+ @since JDK 1.2
+ @author Mark Benvenuto
+ */
+public class AlgorithmParameters
+{
+ private AlgorithmParametersSpi paramSpi;
+ private Provider provider;
+ private String algorithm;
+
+ /**
+ Creates an instance of AlgorithmParameters
+
+ @param paramSpi A parameters engine to use
+ @param provider A provider to use
+ @param algorithm The algorithm
+ */
+ protected AlgorithmParameters(AlgorithmParametersSpi paramSpi,
+ Provider provider, String algorithm)
+ {
+ this.paramSpi = paramSpi;
+ this.provider = provider;
+ this.algorithm = algorithm;
+ }
+
+ /**
+ Returns the name of the algorithm used
+
+ @return A string with the name of the algorithm
+ */
+ public final String getAlgorithm()
+ {
+ return algorithm;
+ }
+
+ /**
+ Gets an instance of the AlgorithmParameters class representing
+ the specified algorithm parameters. If the algorithm is not
+ found then, it throws NoSuchAlgorithmException.
+
+ The returned AlgorithmParameters must still be intialized with
+ init().
+
+ @param algorithm the name of algorithm to choose
+ @return a AlgorithmParameters repesenting the desired algorithm
+
+ @throws NoSuchAlgorithmException if the algorithm is not implemented by providers
+ */
+ public static AlgorithmParameters getInstance(String algorithm) throws
+ NoSuchAlgorithmException
+ {
+ Provider[] p = Security.getProviders();
+
+ for (int i = 0; i < p.length; i++)
+ {
+ String classname =
+ p[i].getProperty("AlgorithmParameters." + algorithm);
+ if (classname != null)
+ return getInstance(classname, algorithm, p[i]);
+ }
+
+ throw new NoSuchAlgorithmException(algorithm);
+ }
+
+ /**
+ Gets an instance of the AlgorithmParameters class representing
+ the specified algorithm parameters from the specified provider.
+ If the algorithm is not found then, it throws
+ NoSuchAlgorithmException. If the provider is not found, then
+ it throws NoSuchProviderException.
+
+ The returned AlgorithmParameters must still be intialized with
+ init().
+
+ @param algorithm the name of algorithm to choose
+ @param provider the name of the provider to find the algorithm in
+ @return a AlgorithmParameters repesenting the desired algorithm
+
+ @throws NoSuchAlgorithmException if the algorithm is not implemented by the provider
+ @throws NoSuchProviderException if the provider is not found
+ */
+ public static AlgorithmParameters getInstance(String algorithm,
+ String provider) throws
+ NoSuchAlgorithmException, NoSuchProviderException
+ {
+ Provider p = Security.getProvider(provider);
+ if (p == null)
+ throw new NoSuchProviderException();
+
+ return getInstance(p.getProperty("AlgorithmParameters." + algorithm),
+ algorithm, p);
+ }
+
+ private static AlgorithmParameters getInstance(String classname,
+ String algorithm,
+ Provider provider)
+ throws NoSuchAlgorithmException
+ {
+
+ try
+ {
+ return new AlgorithmParameters((AlgorithmParametersSpi) Class.
+ forName(classname).newInstance(),
+ provider, algorithm);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ throw new NoSuchAlgorithmException("Class not found");
+ }
+ catch (InstantiationException ie)
+ {
+ throw new NoSuchAlgorithmException("Class instantiation failed");
+ }
+ catch (IllegalAccessException iae)
+ {
+ throw new NoSuchAlgorithmException("Illegal Access");
+ }
+ }
+
+ /**
+ Gets the provider that the class is from.
+
+ @return the provider of this class
+ */
+ public final Provider getProvider()
+ {
+ return provider;
+ }
+
+ /**
+ Initializes the engine with the specified
+ AlgorithmParameterSpec class.
+
+ @param paramSpec A AlgorithmParameterSpec to initialize with
+
+ @throws InvalidParameterSpecException For an inapporiate ParameterSpec class
+ */
+ public final void init(AlgorithmParameterSpec paramSpec) throws
+ InvalidParameterSpecException
+ {
+ paramSpi.engineInit(paramSpec);
+ }
+
+ /**
+ Initializes the engine with the specified
+ parameters stored in the byte array and decodes them
+ according to the ASN.1 specification. If the ASN.1
+ specification exists then it succeeds or else it throws
+ IOException.
+
+ @param params Parameters to initialize with
+
+ @throws IOException Decoding Error
+ */
+ public final void init(byte[]params) throws IOException
+ {
+ paramSpi.engineInit(params);
+ }
+
+ /**
+ Initializes the engine with the specified
+ parameters stored in the byte array and decodes them
+ according to the specified decoding specification.
+ If format is null, then it is decoded using the ASN.1
+ specification if it exists or else it throws
+ IOException.
+
+ @param params Parameters to initialize with
+ @param format Name of decoding format to use
+
+ @throws IOException Decoding Error
+ */
+ public final void init(byte[]params, String format) throws IOException
+ {
+ paramSpi.engineInit(params, format);
+ }
+
+ /**
+ Returns a specification of this AlgorithmParameters object.
+ paramSpec identifies the class to return the AlgortihmParameters
+ in.
+
+ @param paramSpec Class to return AlgorithmParameters in
+
+ @return the parameter specification
+
+ @throws InvalidParameterSpecException if the paramSpec is an invalid parameter class
+ */
+ public final AlgorithmParameterSpec getParameterSpec(Class paramSpec) throws
+ InvalidParameterSpecException
+ {
+ return paramSpi.engineGetParameterSpec(paramSpec);
+ }
+
+ /**
+ Returns the parameters in the default encoding format.
+ The primary encoding format is ASN.1 format if it exists
+ for the specified type.
+
+ @return byte array representing the parameters
+ */
+ public final byte[] getEncoded() throws IOException
+ {
+ return paramSpi.engineGetEncoded();
+ }
+
+ /**
+ Returns the parameters in the specified encoding format.
+ If <code>format</code> is <code>null</code> then the
+ primary encoding format is used, the ASN.1 format,
+ if it exists for the specified type.
+
+ @return byte array representing the parameters
+ */
+ public final byte[] getEncoded(String format) throws IOException
+ {
+ return paramSpi.engineGetEncoded(format);
+ }
+
+ /**
+ Returns a string representation of the encoding format
+
+ @return a string containing the string representation
+ */
+ public final String toString()
+ {
+ return paramSpi.engineToString();
+ }
+}
diff --git a/libjava/java/security/AlgorithmParametersSpi.java b/libjava/java/security/AlgorithmParametersSpi.java
new file mode 100644
index 0000000..04f9027
--- /dev/null
+++ b/libjava/java/security/AlgorithmParametersSpi.java
@@ -0,0 +1,134 @@
+/* AlgorithmParametersSpi.java --- Algorithm Parameters SPI
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+import java.security.spec.InvalidParameterSpecException;
+import java.security.spec.AlgorithmParameterSpec;
+import java.io.IOException;
+
+/**
+ AlgorithmParametersSpi is the Service Provider Interface
+ for the Algorithm Parameters class. This class is used
+ to manage the algorithm parameters.
+
+ @since JDK 1.2
+ @author Mark Benvenuto
+ */
+public abstract class AlgorithmParametersSpi
+{
+ /**
+ Creates a new instance of AlgorithmParametersSpi
+ */
+ public AlgorithmParametersSpi()
+ {
+ }
+
+ /**
+ Initializes the engine with the specified
+ AlgorithmParameterSpec class.
+
+ @param paramSpec A AlgorithmParameterSpec to initialize with
+
+ @throws InvalidParameterSpecException For an inapporiate ParameterSpec class
+ */
+ protected abstract void engineInit(AlgorithmParameterSpec paramSpec) throws
+ InvalidParameterSpecException;
+
+ /**
+ Initializes the engine with the specified
+ parameters stored in the byte array and decodes them
+ according to the ASN.1 specification. If the ASN.1
+ specification exists then it succeeds or else it throws
+ IOException.
+
+ @param params Parameters to initialize with
+
+ @throws IOException Decoding Error
+ */
+ protected abstract void engineInit(byte[]params) throws IOException;
+
+ /**
+ Initializes the engine with the specified
+ parameters stored in the byte array and decodes them
+ according to the specified decoding specification.
+ If format is null, then it is decoded using the ASN.1
+ specification if it exists or else it throws
+ IOException.
+
+ @param params Parameters to initialize with
+ @param format Name of decoding format to use
+
+ @throws IOException Decoding Error
+ */
+ protected abstract void engineInit(byte[]params,
+ String format) throws IOException;
+
+
+ /**
+ Returns a specification of this AlgorithmParameters object.
+ paramSpec identifies the class to return the AlgortihmParameters
+ in.
+
+ @param paramSpec Class to return AlgorithmParameters in
+
+ @return the parameter specification
+
+ @throws InvalidParameterSpecException if the paramSpec is an invalid parameter class
+ */
+ protected abstract AlgorithmParameterSpec engineGetParameterSpec(Class
+ paramSpec)
+ throws InvalidParameterSpecException;
+
+
+ /**
+ Returns the parameters in the default encoding format.
+ The primary encoding format is ASN.1 format if it exists
+ for the specified type.
+
+ @return byte array representing the parameters
+ */
+ protected abstract byte[] engineGetEncoded() throws IOException;
+
+
+ /**
+ Returns the parameters in the specified encoding format.
+ If <code>format</code> is <code>null</code> then the
+ primary encoding format is used, the ASN.1 format,
+ if it exists for the specified type.
+
+ @return byte array representing the parameters
+ */
+ protected abstract byte[] engineGetEncoded(String format) throws
+ IOException;
+
+ /**
+ Returns a string describing the parameters in the
+ AlgorithmParametersSpi class.
+
+ @return A string representing the format of the parameters.
+ */
+ protected abstract String engineToString();
+}
diff --git a/libjava/java/security/AllPermission.java b/libjava/java/security/AllPermission.java
new file mode 100644
index 0000000..1c1c94b
--- /dev/null
+++ b/libjava/java/security/AllPermission.java
@@ -0,0 +1,123 @@
+/* AllPermission.java -- Permission to do anything
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+
+/**
+ * This class is a permission that implies all other permissions. Granting
+ * this permission effectively grants all others. Extreme caution should
+ * be exercised in granting this permission.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public class AllPermission extends Permission
+{
+ /**
+ * This method initializes a new instance of <code>AllPermission</code>. It
+ * performs no actions.
+ */
+ public AllPermission()
+ {
+ super("all");
+ }
+
+ /**
+ * This method initializes a new instance of <code>AllPermission</code>. The
+ * arguments passed to this method are used to set internal field for the
+ * permission name. However, these are not used in
+ * determining the actual permissions granted. This class always will
+ * return <code>true</code> in its implies method.
+ *
+ * @param name The name of this permission.
+ * @param actions The action list for this permission - ignored in this class.
+ */
+ public AllPermission(String name, String actions)
+ {
+ super(name);
+ }
+
+ /**
+ * This method always returns <code>true</code> to indicate that this
+ * permission always implies that any other permission is also granted.
+ *
+ * @param perm The <code>Permission</code> to test against - ignored in this class.
+ *
+ * @return Always returns <code>true</code>
+ */
+ public boolean implies(Permission perm)
+ {
+ return (true);
+ }
+
+ /**
+ * This method tests this class for equality against another <code>Object</code>.
+ * This will return <code>true</code> if and only if the specified
+ * <code>Object</code> is an instance of <code>AllPermission</code>.
+ *
+ * @param obj The <code>Object</code> to test for equality to this object
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof AllPermission)
+ return (true);
+
+ return (false);
+ }
+
+ /**
+ * This method returns a hash code for this object.
+ *
+ * @return A hash value for this object.
+ */
+ public int hashCode()
+ {
+ return (System.identityHashCode(this));
+ }
+
+ /**
+ * This method returns the list of actions associated with this object.
+ * This will always be the empty string ("") for this class.
+ *
+ * @return The action list.
+ */
+ public String getActions()
+ {
+ return ("");
+ }
+
+ /**
+ * This method returns a new instance of <code>PermissionCollection</code>
+ * suitable for holding instance of <code>AllPermission</code>.
+ *
+ * @return A new <code>PermissionCollection</code>.
+ */
+ public PermissionCollection newPermissionCollection()
+ {
+ return (null);
+ }
+}
diff --git a/libjava/java/security/BasicPermission.java b/libjava/java/security/BasicPermission.java
index f2e70ed..4c7e5fb 100644
--- a/libjava/java/security/BasicPermission.java
+++ b/libjava/java/security/BasicPermission.java
@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -24,7 +24,6 @@ resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
-
package java.security;
import java.io.Serializable;
@@ -32,34 +31,28 @@ import java.util.Hashtable;
import java.util.Enumeration;
/**
- * This class implements a simple model for named permissions without an
- * associated action list. That is, either the named permission is granted
- * or it is not.
- * <p>
- * It also supports trailing wildcards to allow the
- * easy granting of permissions in a hierarchical fashion. (For example,
- * the name "org.gnu.*" might grant all permissions under the "org.gnu"
- * permissions hierarchy). The only valid wildcard character is a '*'
- * which matches anything. It must be the rightmost element in the
- * permission name and must follow a '.' or else the Permission name must
- * consist of only a '*'. Any other occurrence of a '*' is not valid.
- * <p>
- * This class ignores the action list. Subclasses can choose to implement
- * actions on top of this class if desired.
- *
- * @version 0.1
- *
- * @author Aaron M. Renn (arenn@urbanophile.com)
- */
-public abstract class BasicPermission extends Permission implements Serializable
+ * This class implements a simple model for named permissions without an
+ * associated action list. That is, either the named permission is granted
+ * or it is not.
+ * <p>
+ * It also supports trailing wildcards to allow the
+ * easy granting of permissions in a hierarchical fashion. (For example,
+ * the name "org.gnu.*" might grant all permissions under the "org.gnu"
+ * permissions hierarchy). The only valid wildcard character is a '*'
+ * which matches anything. It must be the rightmost element in the
+ * permission name and must follow a '.' or else the Permission name must
+ * consist of only a '*'. Any other occurrence of a '*' is not valid.
+ * <p>
+ * This class ignores the action list. Subclasses can choose to implement
+ * actions on top of this class if desired.
+ *
+ * @version 0.1
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public abstract class BasicPermission extends Permission implements
+ Serializable
{
-
- /*************************************************************************/
-
- /*
- * Constructors
- */
-
/**
* This method initializes a new instance of <code>BasicPermission</code>
* with the specified name. If the name contains an illegal wildcard
@@ -70,23 +63,21 @@ public abstract class BasicPermission extends Permission implements Serializable
* @exception IllegalArgumentException If the name contains an invalid wildcard character
* @exception NullPointerException If the name is null
*/
- public
- BasicPermission(String name) throws IllegalArgumentException, NullPointerException
+ public BasicPermission(String name)
+ throws IllegalArgumentException, NullPointerException
{
super(name);
if (name.indexOf("*") != -1)
{
if (!name.endsWith(".*") && !name.equals("*"))
- throw new IllegalArgumentException("Bad wildcard: " + name);
+ throw new IllegalArgumentException("Bad wildcard: " + name);
if (name.indexOf("*") != name.lastIndexOf("*"))
- throw new IllegalArgumentException("Bad wildcard: " + name);
+ throw new IllegalArgumentException("Bad wildcard: " + name);
}
}
- /*************************************************************************/
-
/**
* This method initializes a new instance of <code>BasicPermission</code>
* with the specified name. If the name contains an illegal wildcard
@@ -99,15 +90,13 @@ public abstract class BasicPermission extends Permission implements Serializable
* @exception IllegalArgumentException If the name contains an invalid wildcard character
* @exception NullPointerException If the name is null
*/
- public
- BasicPermission(String name, String actions) throws IllegalArgumentException, NullPointerException
+ public BasicPermission(String name, String actions)
+ throws IllegalArgumentException, NullPointerException
{
// ignore actions
this(name);
}
- /*************************************************************************/
-
/**
* This method tests to see if the specified permission is implied by
* this permission. This will be true if the following conditions are met:
@@ -124,8 +113,7 @@ public abstract class BasicPermission extends Permission implements Serializable
*
* @return <code>true</code> if the specified permission is implied by this one or <code>false</code> otherwise.
*/
- public boolean
- implies(Permission perm)
+ public boolean implies(Permission perm)
{
if (!(perm instanceof BasicPermission))
return false;
@@ -144,8 +132,6 @@ public abstract class BasicPermission extends Permission implements Serializable
return false;
}
- /*************************************************************************/
-
/**
* This method tests to see if this object is equal to the specified
* <code>Object</code>. This will be true if and only if the specified
@@ -160,20 +146,17 @@ public abstract class BasicPermission extends Permission implements Serializable
*
* @return <code>true</code> if the specified <code>Object</code> is equal to this object or <code>false</code> otherwise.
*/
- public boolean
- equals(Object obj)
+ public boolean equals(Object obj)
{
if (!(obj instanceof BasicPermission))
- return(false);
+ return (false);
- if (!getName().equals(((BasicPermission)obj).getName()))
- return(false);
+ if (!getName().equals(((BasicPermission) obj).getName()))
+ return (false);
- return(true);
+ return (true);
}
- /*************************************************************************/
-
/**
* This method returns a hash code for this permission object. The hash
* code returned is the value returned by calling the <code>hashCode</code>
@@ -181,14 +164,11 @@ public abstract class BasicPermission extends Permission implements Serializable
*
* @return A hash value for this object
*/
- public int
- hashCode()
+ public int hashCode()
{
- return(getName().hashCode());
+ return (getName().hashCode());
}
- /*************************************************************************/
-
/**
* This method returns a list of the actions associated with this
* permission. This method always returns the empty string ("") since
@@ -196,14 +176,11 @@ public abstract class BasicPermission extends Permission implements Serializable
*
* @return The action list.
*/
- public String
- getActions()
+ public String getActions()
{
- return("");
+ return ("");
}
- /*************************************************************************/
-
/**
* This method returns an instance of <code>PermissionCollection</code>
* suitable for storing <code>BasicPermission</code> objects. This returns
@@ -214,58 +191,58 @@ public abstract class BasicPermission extends Permission implements Serializable
*
* @return A new empty <code>PermissionCollection</code> object.
*/
- public PermissionCollection
- newPermissionCollection()
+ public PermissionCollection newPermissionCollection()
{
- return new PermissionCollection()
+ return new PermissionCollection()
+ {
+ Hashtable permissions = new Hashtable();
+ boolean allAllowed = false;
+
+ public void add(Permission permission)
+ {
+ if (isReadOnly())
+ throw new IllegalStateException("readonly");
+
+ BasicPermission bp = (BasicPermission) permission;
+ String name = bp.getName();
+ if (name.equals("*"))
+ allAllowed = true;
+ permissions.put(name, bp);
+ }
+
+ public boolean implies(Permission permission)
{
- Hashtable permissions = new Hashtable();
- boolean allAllowed = false;
-
- public void add(Permission permission)
- {
- if (isReadOnly())
- throw new IllegalStateException("readonly");
+ if (!(permission instanceof BasicPermission))
+ return false;
- BasicPermission bp = (BasicPermission) permission;
- String name = bp.getName();
- if (name.equals("*"))
- allAllowed = true;
- permissions.put(name, bp);
- }
-
- public boolean implies(Permission permission)
- {
- if (!(permission instanceof BasicPermission))
- return false;
-
- if (allAllowed)
- return true;
+ if (allAllowed)
+ return true;
- BasicPermission toImply = (BasicPermission) permission;
- String name = toImply.getName();
- if (name.equals("*"))
- return false;
+ BasicPermission toImply = (BasicPermission) permission;
+ String name = toImply.getName();
+ if (name.equals("*"))
+ return false;
- int prefixLength = name.length();
- if (name.endsWith("*"))
- prefixLength -= 2;
+ int prefixLength = name.length();
+ if (name.endsWith("*"))
+ prefixLength -= 2;
- while (true) {
+ while (true)
+ {
if (permissions.get(name) != null)
return true;
-
+
prefixLength = name.lastIndexOf('.', prefixLength);
if (prefixLength < 0)
return false;
name = name.substring(0, prefixLength + 1) + '*';
}
- }
-
- public Enumeration elements()
- {
- return permissions.elements();
- }
- };
+ }
+
+ public Enumeration elements()
+ {
+ return permissions.elements();
+ }
+ };
}
-} // class BasicPermission
+}
diff --git a/libjava/java/security/Certificate.java b/libjava/java/security/Certificate.java
new file mode 100644
index 0000000..af3ce1e
--- /dev/null
+++ b/libjava/java/security/Certificate.java
@@ -0,0 +1,114 @@
+/* Certificate.java -- Interface for modeling digital certificates
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
+/**
+ * This interface models a digital certificate which verifies the
+ * authenticity of a party. This class simply allows certificate
+ * information to be queried, it does not guarantee that the certificate
+ * is valid.
+ * <p>
+ * This class is deprecated in favor of the new java.security.cert package.
+ * It exists for backward compatibility only.
+ *
+ * @deprecated
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public interface Certificate
+{
+
+ /**
+ * This method returns the <code>Principal</code> that is guaranteeing
+ * this certificate.
+ *
+ * @return The <code>Principal</code> guaranteeing the certificate
+ */
+ public abstract Principal getGuarantor();
+
+ /**
+ * This method returns the <code>Principal</code> being guaranteed by
+ * this certificate.
+ *
+ * @return The <code>Principal</code> guaranteed by this certificate.
+ */
+ public abstract Principal getPrincipal();
+
+ /**
+ * This method returns the public key for the <code>Principal</code> that
+ * is being guaranteed.
+ *
+ * @return The <code>PublicKey</code> of the <code>Principal</code> being guaranteed
+ */
+ public abstract PublicKey getPublicKey();
+
+ /**
+ * This method returns the encoding format of the certificate (e.g., "PGP",
+ * "X.509"). This format is used by the <code>encode</code. and
+ * <code>decode</code> methods.
+ *
+ * @return The encoding format being used
+ */
+ public abstract String getFormat();
+
+ /**
+ * This method writes the certificate to an <code>OutputStream</code> in
+ * a format that can be understood by the <code>decode</code> method.
+ *
+ * @param out The <code>OutputStream</code> to write to.
+ *
+ * @exception KeyException If there is a problem with the internals of this certificate
+ * @exception IOException If an error occurs writing to the stream.
+ */
+ public abstract void
+ encode(OutputStream out) throws KeyException, IOException;
+
+ /**
+ * This method reads an encoded certificate from an <code>InputStream</code>.
+ *
+ * @param in The <code>InputStream</code> to read from.
+ *
+ * @param KeyException If there is a problem with the certificate data
+ * @param IOException If an error occurs reading from the stream.
+ */
+ public abstract void
+ decode(InputStream in) throws KeyException, IOException;
+
+ /**
+ * This method returns a <code>String</code> representation of the contents
+ * of this certificate.
+ *
+ * @param detail <code>true</code> to provided detailed information about this certificate, <code>false</code> otherwise
+ */
+ public abstract String toString(boolean detail);
+}
diff --git a/libjava/java/security/CodeSource.java b/libjava/java/security/CodeSource.java
new file mode 100644
index 0000000..3ee6795
--- /dev/null
+++ b/libjava/java/security/CodeSource.java
@@ -0,0 +1,316 @@
+/* CodeSource.java -- Code location and certifcates
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+
+import java.io.Serializable;
+import java.net.URL;
+import java.net.SocketPermission;
+
+/**
+ * This class represents a location from which code is loaded (as
+ * represented by a URL) and the list of certificates that are used to
+ * check the signatures of signed code loaded from this source.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public class CodeSource implements Serializable
+{
+ private static final String linesep = System.getProperty("line.separator");
+
+ /**
+ * This is the URL that represents the code base from which code will
+ * be loaded.
+ */
+ private URL location;
+
+ /**
+ * This is the list of certificates for this code base
+ */
+ // What is the serialized form of this?
+ private java.security.cert.Certificate[] certs;
+
+ /**
+ * This method initializes a new instance of <code>CodeSource</code> that
+ * loads code from the specified URL location and which uses the
+ * specified certificates for verifying signatures.
+ *
+ * @param location The location from which code will be loaded
+ * @param certs The list of certificates used for verifying signatures on code from this source
+ */
+ public CodeSource(URL location, java.security.cert.Certificate[] certs)
+ {
+ this.location = location;
+ this.certs = certs;
+ }
+
+ /**
+ * This method returns the URL specifying the location from which code
+ * will be loaded under this <code>CodeSource</code>.
+ *
+ * @return The code location for this <code>CodeSource</code>.
+ */
+ public final URL getLocation()
+ {
+ return location;
+ }
+
+ /**
+ * This method returns the list of digital certificates that can be used
+ * to verify the signatures of code loaded under this <code>CodeSource</code>.
+ *
+ * @return The certifcate list for this <code>CodeSource</code>.
+ */
+ public final java.security.cert.Certificate[] getCertificates()
+ {
+ return certs;
+ }
+
+ /**
+ * This method tests to see if a specified <code>CodeSource</code> is
+ * implied by this object. Effectively, to meet this test, the specified
+ * object must have all the certifcates this object has (but may have
+ * more) and must have a location that is a subset of this object's. In order
+ * for this object to imply the specified object, the following must be
+ * true:
+ * <p>
+ * <ol>
+ * <li>The specified <code>CodeSource</code> must not be <code>null</code>.
+ * <li>If the specified <code>CodeSource</code> has a certificate list,
+ * all of that object's certificates must be present in the certificate
+ * list of this object.
+ * <li>If this object does not have a <code>null</code> location, then
+ * the following addtional tests must be passed.
+ * <ol>
+ * <li>The specified <code>CodeSource</code> must not have a <code>null</code> location.
+ * <li>The specified <code>CodeSource</code>'s location must be equal to
+ * this object's location, or<br>
+ * <ul>
+ * <li>The specifiec <code>CodeSource</code>'s location protocol, port,
+ * and ref (aka, anchor) must equal this objects, and
+ * <li>The specified <code>CodeSource</code>'s location host must imply this
+ * object's location host, as determined by contructing
+ * <code>SocketPermission</code> objects from each with no action list and
+ * using that classes's <code>implies</code> method. And,
+ * <li>If this object's location file ends with a '/', then the specified
+ * object's location file must start with this object's location file.
+ * Otherwise, the specified object's location file must start with this
+ * object's location file with the '/' character appended to it.
+ * </ul>
+ * </ol>
+ * </ol>
+ *
+ * @param cs The <code>CodeSource</code> to test against this object
+ *
+ * @return <code>true</code> if this specified <code>CodeSource</code> is specified by this object, <code>false</code> otherwise.
+ */
+ public boolean implies(CodeSource cs)
+ {
+ if (cs == null)
+ return false;
+
+ // First check the certificate list
+ java.security.cert.Certificate[] their_certs = cs.getCertificates();
+ java.security.cert.Certificate[] our_certs = getCertificates();
+
+ if (our_certs != null)
+ {
+ if (their_certs == null)
+ return false;
+
+ for (int i = 0; i < our_certs.length; i++)
+ {
+ int j;
+ for (j = 0; j < their_certs.length; j++)
+ if (our_certs[i].equals(their_certs[j]))
+ break;
+
+ if (j == their_certs.length)
+ return false;
+ }
+ }
+
+ // Next check the location
+ URL their_loc = getLocation();
+ URL our_loc = getLocation();
+
+ if (our_loc == null)
+ return true;
+ else if (their_loc == null)
+ return false;
+
+ if (!our_loc.getProtocol().equals(their_loc.getProtocol()))
+ return false;
+
+ if (our_loc.getPort() != -1)
+ if (our_loc.getPort() != their_loc.getPort())
+ return false;
+
+ if (our_loc.getRef() != null)
+ if (!our_loc.getRef().equals(their_loc.getRef()))
+ return false;
+
+ // See javadoc comments for what we are doing here.
+ if (our_loc.getHost() != null)
+ {
+ String their_host = their_loc.getHost();
+ if (their_host == null)
+ return false;
+
+ SocketPermission our_sockperm =
+ new SocketPermission(our_loc.getHost(), "accept");
+ SocketPermission their_sockperm =
+ new SocketPermission(their_host, "accept");
+
+ if (!our_sockperm.implies(their_sockperm))
+ return false;
+ }
+
+ String our_file = our_loc.getFile();
+ if (our_file != null)
+ {
+ if (!our_file.endsWith("/"))
+ our_file = our_file + "/";
+
+ String their_file = their_loc.getFile();
+ if (their_file == null)
+ return false;
+
+ if (!their_file.startsWith(our_file))
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * This method tests the specified <code>Object</code> for equality with
+ * this object. This will be true if and only if:
+ * <p>
+ * <ul>
+ * <li>The specified object is not <code>null</code>.
+ * <li>The specified object is an instance of <code>CodeSource</code>.
+ * <li>The specified object's location is the same as this object's.
+ * <li>The specified object's certificate list contains the exact same
+ * entries as the object's. Note that the order of the certificate lists
+ * is not significant.
+ * </ul>
+ *
+ * @param obj The <code>Object</code> to test against.
+ *
+ * @return <code>true</code> if the specified object is equal to this one, <code>false</code> otherwise.
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj == null)
+ return false;
+
+ if (!(obj instanceof CodeSource))
+ return false;
+
+ CodeSource cs = (CodeSource) obj;
+
+ // First check the certificate list
+ java.security.cert.Certificate[] their_certs = cs.getCertificates();
+ java.security.cert.Certificate[] our_certs = getCertificates();
+
+ if ((our_certs == null) && (their_certs != null))
+ return false;
+ else if ((our_certs != null) && (their_certs == null))
+ return false;
+
+ if (our_certs != null)
+ {
+ if (our_certs.length != their_certs.length)
+ return false;
+
+ for (int i = 0; i < our_certs.length; i++)
+ {
+ int j;
+ for (j = 0; j < their_certs.length; j++)
+ if (our_certs[i].equals(their_certs[j]))
+ break;
+
+ if (j == their_certs.length)
+ return false;
+ }
+ }
+
+ // Now the location
+ URL their_loc = cs.getLocation();
+ URL our_loc = getLocation();
+
+ if ((our_loc == null) && (their_loc != null))
+ return false;
+
+ if (!our_loc.equals(their_loc))
+ return false;
+
+ return true;
+ }
+
+ /**
+ * This method returns a hash value for this object.
+ *
+ * @return A hash value for this object.
+ */
+ public int hashCode()
+ {
+ URL location = getLocation();
+ if (location == null)
+ return System.identityHashCode(this);
+
+ return location.hashCode();
+ }
+
+ /**
+ * This method returns a <code>String</code> that represents this object.
+ * This <code>String</code> will contain the object's hash code, location,
+ * and certificate list.
+ *
+ * @return A <code>String</code> for this object
+ */
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer("");
+
+ sb.append(super.toString() + " (" + linesep);
+ sb.append("Location: " + getLocation() + linesep);
+
+ java.security.cert.Certificate[] certs = getCertificates();
+ if (certs == null)
+ sb.append("<none>" + linesep);
+ else
+ for (int i = 0; i < certs.length; i++)
+ sb.append(certs[i] + linesep);
+
+ sb.append(")" + linesep);
+
+ return sb.toString();
+ }
+}
diff --git a/libjava/java/security/DigestException.java b/libjava/java/security/DigestException.java
index 8c6b2db..3199408 100644
--- a/libjava/java/security/DigestException.java
+++ b/libjava/java/security/DigestException.java
@@ -1,30 +1,56 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* DigestException.java -- A generic message digest exception
+ Copyright (C) 1998 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
-package java.security;
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
/**
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
+ * This exception indicates that a generic message digest exception has
+ * occurred.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
*/
-
public class DigestException extends GeneralSecurityException
{
+ /**
+ * This method initializes a new <code>DigestException</code> with no
+ * descriptive message.
+ */
public DigestException()
{
super();
}
+ /**
+ * This method initializes a new instance of <code>DigestException</code>
+ * with a descriptive error message.
+ *
+ * @param msg The descriptive message
+ */
public DigestException(String msg)
{
super(msg);
diff --git a/libjava/java/security/DigestInputStream.java b/libjava/java/security/DigestInputStream.java
new file mode 100644
index 0000000..bfb6c40
--- /dev/null
+++ b/libjava/java/security/DigestInputStream.java
@@ -0,0 +1,155 @@
+/* DigestInputStream.java --- An Input stream tied to a message digest
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+//import java.security.MessageDigest;
+import java.io.InputStream;
+import java.io.FilterInputStream;
+import java.io.IOException;
+
+/**
+ DigestInputStream is a class that ties an InputStream with a
+ MessageDigest. The Message Digest is used by the class to
+ update it self as bytes are read from the InputStream.
+
+ The updating to the digest depends on the on flag which is set
+ to true by default to tell the class to update the data
+ in the message digest.
+
+ @version 0.0
+ @author Mark Benvenuto <ivymccough@worldnet.att.net>
+ */
+public class DigestInputStream extends FilterInputStream
+{
+ /**
+ The message digest for the DigestInputStream
+ */
+ protected MessageDigest digest;
+
+ //Manages the on flag
+ private boolean state = true;
+
+ /**
+ Constructs a new DigestInputStream.
+ It associates a MessageDigest with the stream to
+ compute the stream as data is written.
+
+ @param stream An InputStream to associate this stream with
+ @param digest A MessageDigest to hash the stream with
+ */
+ public DigestInputStream(InputStream stream, MessageDigest digest)
+ {
+ super(stream);
+ //this.in = stream;
+ this.digest = digest;
+ }
+
+ /**
+ Returns the MessageDigest associated with this DigestInputStream
+
+ @return The MessageDigest used to hash this stream
+ */
+ public MessageDigest getMessageDigest()
+ {
+ return digest;
+ }
+
+ /**
+ Sets the current MessageDigest to current parameter
+
+ @param digest A MessageDigest to associate with this stream
+ */
+ public void setMessageDigest(MessageDigest digest)
+ {
+ this.digest = digest;
+ }
+
+ /**
+ Reads a byte from the input stream and updates the digest.
+ This method reads the underlying input stream and if the
+ on flag is true then updates the message digest.
+
+ @return Returns a byte from the input stream, -1 is returned to indicate that
+ the end of stream was reached before this read call
+
+ @throws IOException if an IO error occurs in the underlying input stream,
+ this error is thrown
+ */
+ public int read() throws IOException
+ {
+ int temp = in.read();
+
+ if (state == true && temp != -1)
+ digest.update((byte) temp);
+
+ return temp;
+ }
+
+ /**
+ Reads bytes from the input stream and updates the digest.
+ This method reads the underlying input stream and if the
+ on flag is true then updates the message digest.
+
+ @param b a byte array to store the data from the input stream
+ @param off an offset to start at in the array
+ @param len length of data to read
+ @return Returns count of bytes read, -1 is returned to indicate that
+ the end of stream was reached before this read call
+
+ @throws IOException if an IO error occurs in the underlying input stream,
+ this error is thrown
+ */
+ public int read(byte[]b, int off, int len) throws IOException
+ {
+ int temp = in.read(b, off, len);
+
+ if (state == true && temp != -1)
+ digest.update(b, off, len);
+
+ return temp;
+ }
+
+ /**
+ Sets the flag specifing if this DigestInputStream updates the
+ digest in the write() methods. The default is on;
+
+ @param on True means it digests stream, false means it does not
+ */
+ public void on(boolean on)
+ {
+ state = on;
+ }
+
+ /**
+ Converts the input stream and underlying message digest to a string.
+
+ @return A string representing the input stream and message digest.
+ */
+ public String toString()
+ {
+ return "[Digest Input Stream] " + digest.toString();
+ }
+}
diff --git a/libjava/java/security/DigestOutputStream.java b/libjava/java/security/DigestOutputStream.java
index 8d51278..6817a45 100644
--- a/libjava/java/security/DigestOutputStream.java
+++ b/libjava/java/security/DigestOutputStream.java
@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -24,7 +24,6 @@ resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
-
package java.security;
import java.io.OutputStream;
@@ -42,12 +41,12 @@ import java.io.IOException;
@version 0.0
@author Mark Benvenuto <ivymccough@worldnet.att.net>
-*/
+ */
public class DigestOutputStream extends FilterOutputStream
{
/**
The message digest for the DigestOutputStream
- */
+ */
protected MessageDigest digest;
//Manages the on flag
@@ -60,10 +59,10 @@ public class DigestOutputStream extends FilterOutputStream
@param stream An OutputStream to associate this stream with
@param digest A MessageDigest to hash the stream with
- */
- public DigestOutputStream (OutputStream stream, MessageDigest digest)
+ */
+ public DigestOutputStream(OutputStream stream, MessageDigest digest)
{
- super (stream);
+ super(stream);
this.digest = digest;
}
@@ -71,18 +70,18 @@ public class DigestOutputStream extends FilterOutputStream
Returns the MessageDigest associated with this DigestOutputStream
@return The MessageDigest used to hash this stream
- */
- public MessageDigest getMessageDigest ()
+ */
+ public MessageDigest getMessageDigest()
{
return digest;
}
-
+
/**
Sets the current MessageDigest to current parameter
-
+
@param digest A MessageDigest to associate with this stream
- */
- public void setMessageDigest (MessageDigest digest)
+ */
+ public void setMessageDigest(MessageDigest digest)
{
this.digest = digest;
}
@@ -93,16 +92,16 @@ public class DigestOutputStream extends FilterOutputStream
the underlying output stream.
@param b A byte to write to the output stream
-
+
@exception IOException if the underlying output stream
cannot write the byte, this is thrown.
- */
- public void write (int b) throws IOException
+ */
+ public void write(int b) throws IOException
{
if (state)
- digest.update ((byte)b);
-
- super.write (b);
+ digest.update((byte) b);
+
+ super.write(b);
}
/**
@@ -115,13 +114,13 @@ public class DigestOutputStream extends FilterOutputStream
@exception IOException if the underlying output stream
cannot write the bytes, this is thrown.
- */
- public void write (byte[] b, int off, int len) throws IOException
+ */
+ public void write(byte[]b, int off, int len) throws IOException
{
if (state)
- digest.update (b, off, len);
+ digest.update(b, off, len);
- super.write (b, off, len);
+ super.write(b, off, len);
}
/**
@@ -129,8 +128,8 @@ public class DigestOutputStream extends FilterOutputStream
digest in the write() methods. The default is on;
@param on True means it digests stream, false means it does not
- */
- public void on (boolean on)
+ */
+ public void on(boolean on)
{
state = on;
}
@@ -139,7 +138,7 @@ public class DigestOutputStream extends FilterOutputStream
Converts the output stream and underlying message digest to a string.
@return A string representing the output stream and message digest.
- */
+ */
public String toString()
{
return "[Digest Output Stream] " + digest.toString();
diff --git a/libjava/java/security/DomainCombiner.java b/libjava/java/security/DomainCombiner.java
new file mode 100644
index 0000000..57f78b1
--- /dev/null
+++ b/libjava/java/security/DomainCombiner.java
@@ -0,0 +1,53 @@
+/* DomainCombiner.java - Combines ProtectionDomains
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+
+/**
+ A public interface used to combine two ProtectionDomains in a new
+ ProtectionDomain and update the current Protection Domains
+ associated with the current AccessControllerContext.
+
+ It can add, subtract, or update ProtectionDomains or possibly
+ remove duplicates or any possible complex action but just not add
+ ones that do not already exist in either array.
+
+ @since JDK 1.3
+ @author Mark Benvenuto
+ */
+public interface DomainCombiner
+{
+ /**
+ Combines the current ProtectionDomains of the Thread with new
+ ProtectionDomains.
+
+ @param currentDomains - the ProtectionDomains for the current thread.
+ @param assignedDomains - ProtectionsDomains to add
+ @returns a new array of all the ProtectionDomains
+ */
+ public ProtectionDomain[] combine(ProtectionDomain[]currentDomains,
+ ProtectionDomain[]assignedDomains);
+}
diff --git a/libjava/java/security/DummyKeyPairGenerator.java b/libjava/java/security/DummyKeyPairGenerator.java
new file mode 100644
index 0000000..6b3f146
--- /dev/null
+++ b/libjava/java/security/DummyKeyPairGenerator.java
@@ -0,0 +1,48 @@
+/* DummyKeyPairGenerator.java
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+
+final class DummyKeyPairGenerator extends KeyPairGenerator
+{
+ private KeyPairGeneratorSpi kpgSpi = null;
+
+ public DummyKeyPairGenerator(KeyPairGeneratorSpi kpgSpi, String algorithm)
+ {
+ super(algorithm);
+ this.kpgSpi = kpgSpi;
+ }
+
+ public void initialize(int keysize, SecureRandom random)
+ {
+ kpgSpi.initialize(keysize, random);
+ }
+
+ public KeyPair generateKeyPair()
+ {
+ return kpgSpi.generateKeyPair();
+ }
+}
diff --git a/libjava/java/security/DummyMessageDigest.java b/libjava/java/security/DummyMessageDigest.java
new file mode 100644
index 0000000..775afa0
--- /dev/null
+++ b/libjava/java/security/DummyMessageDigest.java
@@ -0,0 +1,62 @@
+/* DummyMessageDigest.java
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+
+import java.security.MessageDigest;
+import java.security.MessageDigestSpi;
+import java.security.DigestException;
+
+final class DummyMessageDigest extends MessageDigest
+{
+ private MessageDigestSpi mdSpi = null;
+
+ public DummyMessageDigest(MessageDigestSpi mdSpi, String algorithm)
+ {
+ super(algorithm);
+ this.mdSpi = mdSpi;
+ }
+
+ protected void engineUpdate(byte input)
+ {
+ mdSpi.engineUpdate(input);
+ }
+
+ protected void engineUpdate(byte[]input, int offset, int len)
+ {
+ mdSpi.engineUpdate(input, offset, len);
+ }
+
+ protected byte[] engineDigest()
+ {
+ return mdSpi.engineDigest();
+ }
+
+ protected void engineReset()
+ {
+ mdSpi.engineReset();
+ }
+}
diff --git a/libjava/java/security/DummySignature.java b/libjava/java/security/DummySignature.java
new file mode 100644
index 0000000..6c0624c
--- /dev/null
+++ b/libjava/java/security/DummySignature.java
@@ -0,0 +1,83 @@
+/* DummySignature.java
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+
+final class DummySignature extends Signature
+{
+ private SignatureSpi sigSpi = null;
+
+ public DummySignature(SignatureSpi sigSpi, String algorithm)
+ {
+ super(algorithm);
+ this.sigSpi = sigSpi;
+ }
+
+ protected void engineInitVerify(PublicKey publicKey)
+ throws InvalidKeyException
+ {
+ sigSpi.engineInitVerify(publicKey);
+ }
+
+ protected void engineInitSign(PrivateKey privateKey)
+ throws InvalidKeyException
+ {
+ sigSpi.engineInitSign(privateKey);
+ }
+
+ protected void engineUpdate(byte b) throws SignatureException
+ {
+ sigSpi.engineUpdate(b);
+ }
+
+ protected void engineUpdate(byte[]b, int off, int len)
+ throws SignatureException
+ {
+ sigSpi.engineUpdate(b, off, len);
+ }
+
+ protected byte[] engineSign() throws SignatureException
+ {
+ return sigSpi.engineSign();
+ }
+
+ protected boolean engineVerify(byte[]sigBytes) throws SignatureException
+ {
+ return sigSpi.engineVerify(sigBytes);
+ }
+
+ protected void engineSetParameter(String param, Object value)
+ throws InvalidParameterException
+ {
+ sigSpi.engineSetParameter(param, value);
+ }
+
+ protected Object engineGetParameter(String param)
+ throws InvalidParameterException
+ {
+ return sigSpi.engineGetParameter(param);
+ }
+}
diff --git a/libjava/java/security/GeneralSecurityException.java b/libjava/java/security/GeneralSecurityException.java
index 9d30737..f0bf39bb 100644
--- a/libjava/java/security/GeneralSecurityException.java
+++ b/libjava/java/security/GeneralSecurityException.java
@@ -1,31 +1,61 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* GeneralSecurityException.java -- Common superclass of security exceptions
+ Copyright (C) 1998 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
-package java.security;
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
/**
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
+ * This class is the common superclass of all security exceptions. All
+ * exceptions in java.security extend this class with the exception (no
+ * pun intended) of <code>AccessControlException</code> and
+ * <code>CertificateException</code> which extend <code>SecurityException</code>
+ * and <code>ProviderException</code> which extens <code>RuntimeException</code>.
+ * and <code>InvalidParamterException</code> which extends
+ * <code>IllegalArgumentException</code>.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
*/
-
-// JDK1.2
public class GeneralSecurityException extends Exception
{
+ /**
+ * This method initializes a new instance of <code>GeneralSecurityException</code>
+ * with no descriptive error message.
+ */
public GeneralSecurityException()
{
super();
}
+ /**
+ * This method initializes a new instance of <code>GeneralSecurityException</code>
+ * with a descriptive error message.
+ *
+ * @param msg The descriptive error message.
+ */
public GeneralSecurityException(String msg)
{
super(msg);
diff --git a/libjava/java/security/Guard.java b/libjava/java/security/Guard.java
index b397ddd..c442073 100644
--- a/libjava/java/security/Guard.java
+++ b/libjava/java/security/Guard.java
@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -24,31 +24,27 @@ resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
-
package java.security;
/**
- * This interface specifies a mechanism for querying whether or not
- * access is allowed to a guarded object.
- *
- * @version 0.0
- *
- * @author Aaron M. Renn (arenn@urbanophile.com)
- */
+ * This interface specifies a mechanism for querying whether or not
+ * access is allowed to a guarded object.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
public interface Guard
{
-
-/**
- * This method tests whether or not access is allowed to the specified
- * guarded object. Access is allowed if this method returns silently. If
- * access is denied, an exception is generated.
- *
- * @param obj The <code>Object</code> to test
- *
- * @exception SecurityException If access to the object is denied.
- */
-public abstract void
-checkGuard(Object obj) throws SecurityException;
-
-} // interface Guard
-
+ /**
+ * This method tests whether or not access is allowed to the specified
+ * guarded object. Access is allowed if this method returns silently. If
+ * access is denied, an exception is generated.
+ *
+ * @param obj The <code>Object</code> to test
+ *
+ * @exception SecurityException If access to the object is denied.
+ */
+ public abstract void checkGuard(Object obj) throws SecurityException;
+
+}
diff --git a/libjava/java/security/GuardedObject.java b/libjava/java/security/GuardedObject.java
new file mode 100644
index 0000000..4e46896
--- /dev/null
+++ b/libjava/java/security/GuardedObject.java
@@ -0,0 +1,84 @@
+/* GuardedObject.java -- An object protected by a Guard
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+
+import java.io.Serializable;
+
+/**
+ * This class is an object that is guarded by a <code>Guard</code> object.
+ * The object that is being guarded is retrieved by a call to the only
+ * method in this class - <code>getObject</code>. That method returns the
+ * guarded <code>Object</code> after first checking with the
+ * <code>Guard</code>. If the <code>Guard</code> disallows access, an
+ * exception will be thrown.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public class GuardedObject implements Serializable
+{
+ /**
+ * This is the Guard that is protecting the object.
+ */
+ private Guard guard;
+
+ /**
+ * This is the object that is being guarded.
+ */
+ private Object object;
+
+ /**
+ * This method initializes a new instance of <code>GuardedObject</code>
+ * that protects the specified <code>Object</code> using the specified
+ * <code>Guard</code>
+ *
+ * @param object The <code>Object</code> to guard
+ * @param guard The <code>Guard</code> that is protecting the object.
+ */
+ public GuardedObject(Object object, Guard guard)
+ {
+ this.object = object;
+ this.guard = guard;
+ }
+
+ /**
+ * This method first call the <code>checkGuard</code> method on the
+ * <code>Guard</code> object protecting the guarded object. If the
+ * <code>Guard</code> disallows access, an exception is thrown, otherwise
+ * the <code>Object</code> is returned.
+ *
+ * @return The object being guarded
+ *
+ * @exception SecurityException If the <code>Guard</code> disallows access to the object.
+ */
+ public Object getObject() throws SecurityException
+ {
+ guard.checkGuard(object);
+ return (object);
+ }
+}
diff --git a/libjava/java/security/Identity.java b/libjava/java/security/Identity.java
new file mode 100644
index 0000000..d8e024f
--- /dev/null
+++ b/libjava/java/security/Identity.java
@@ -0,0 +1,363 @@
+/* Identity.java --- Identity Class
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+import java.io.Serializable;
+import java.util.Vector;
+
+/**
+ The Identity class is used to repsent people and companies that
+ can be authenticated using public key encryption. The identities
+ can also be abstract objects such as smart cards.
+
+ Identity object store a name and public key for each identity.
+ The names cannot be changed and the identities can be scoped.
+ Each identity (name and public key) within a scope is unique
+ to that scope.
+
+ Each identity has a set of ceritificates which all specify the
+ same public key but not necessarily the same name.
+
+ The Identity class can be subclassed to allow additional
+ information to be attached to it.
+
+ @since JDK 1.1
+
+ @deprecated Use java.security.KeyStore, the java.security.cert
+ package, and java.security.Principal.
+
+ @author Mark Benvenuto
+ */
+public abstract class Identity implements Principal, Serializable
+{
+ private String name;
+ private IdentityScope scope;
+ private PublicKey publicKey;
+ private String info;
+ private Vector certificates;
+
+ /**
+ Creates a new instance of Identity from Serialized Data
+ */
+ protected Identity()
+ {
+ }
+
+ /**
+ Creates a new instance of Identity with the specified name
+ and IdentityScope.
+
+ @param name the name to use
+ @param scope the scope to use
+
+ @throws KeyManagementException if the identity is already
+ present
+ */
+ public Identity(String name, IdentityScope scope)
+ throws KeyManagementException
+ {
+ this.name = name;
+ this.scope = scope;
+ }
+
+ /**
+ Creates a new instance of Identity with the specified name
+ and no scope.
+
+ @param name the name to use
+ */
+ public Identity(String name)
+ {
+ this.name = name;
+ this.scope = null;
+ }
+
+ /**
+ Gets the name for this Identity.
+
+ @return the name
+ */
+ public final String getName()
+ {
+ return name;
+ }
+
+ /**
+ Gets the scope for this Identity.
+
+ @return the scope
+ */
+ public final IdentityScope getScope()
+ {
+ return scope;
+ }
+
+ /**
+ Gets the public key for this identity.
+
+ @return the public key
+ */
+ public PublicKey getPublicKey()
+ {
+ return publicKey;
+ }
+
+ /**
+ Sets the public key for this identity.
+ The old key and all certificates are removed.
+
+ This class checks the security manager with the call
+ checkSecurityAccess with "setIdentityPublicKey".
+
+ @param key the public key to use
+
+ @throws KeyManagementException if this public key is used by
+ another identity in the current scope.
+ @throws SecurityException - if the security manager denies
+ access to "setIdentityPublicKey"
+ */
+ public void setPublicKey(PublicKey key) throws KeyManagementException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkSecurityAccess("setIdentityPublicKey");
+
+ this.publicKey = key;
+ }
+
+ /**
+ Sets the general information string.
+
+ This class checks the security manager with the call
+ checkSecurityAccess with "setIdentityInfo".
+
+ @param info the general information string.
+
+ @throws SecurityException - if the security manager denies
+ access to "setIdentityInfo"
+ */
+ public void setInfo(String info)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkSecurityAccess("setIdentityInfo");
+
+ this.info = info;
+ }
+
+ /**
+ Gets the general information string.
+
+ @return the string
+ */
+ public String getInfo()
+ {
+ return info;
+ }
+
+ /**
+ Adds a certificate to the list of ceritificates for this
+ identity. The public key in this certificate must match the
+ existing public key if it exists.
+
+ This class checks the security manager with the call
+ checkSecurityAccess with "addIdentityCertificate".
+
+ @param certificate the certificate to add
+
+ @throws KeyManagementException if the certificate is invalid
+ or the public key conflicts
+ @throws SecurityException - if the security manager denies
+ access to "addIdentityCertificate"
+ */
+ public void addCertificate(java.security.Certificate certificate)
+ throws KeyManagementException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkSecurityAccess("addIdentityCertificate");
+
+ //Check public key of this certificate against the first one
+ //in the vector
+ if (certificates.size() > 0)
+ {
+ if (((Certificate) certificates.firstElement()).getPublicKey() !=
+ publicKey)
+ throw new KeyManagementException("Public key does not match");
+ }
+ certificates.addElement(certificate);
+ }
+
+ /**
+ Removes a certificate from the list of ceritificates for this
+ identity.
+
+ This class checks the security manager with the call
+ checkSecurityAccess with "removeIdentityCertificate".
+
+ @param certificate the certificate to add
+
+ @throws KeyManagementException if the certificate is invalid
+ @throws SecurityException - if the security manager denies
+ access to "removeIdentityCertificate"
+ */
+ public void removeCertificate(Certificate certificate)
+ throws KeyManagementException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkSecurityAccess("removeIdentityCertificate");
+
+ if (certificates.contains(certificate) == false)
+ throw new KeyManagementException("Certificate not found");
+
+ certificates.removeElement(certificate);
+ }
+
+ /**
+ Returns an array of certificates for this identity.
+
+ @returns array of certificates
+ */
+ public Certificate[] certificates()
+ {
+ Certificate certs[] = new Certificate[certificates.size()];
+ int max = certificates.size();
+ for (int i = 0; i < max; i++)
+ certs[i] = (Certificate) certificates.elementAt(i);
+ return certs;
+ }
+
+ /**
+ Checks for equality between this Identity and the specified
+ object. If first checks if they are the same object, then
+ if the name and scope matches and returns true if successful.
+ If these tests fail, identityEquals is called.
+
+ @return true if they are equal, false otherwise
+ */
+ public final boolean equals(Object identity)
+ {
+ if (identity instanceof Identity)
+ {
+ if (identity == this)
+ return true;
+
+ if ((((Identity) identity).getName() == this.name) &&
+ (((Identity) identity).getScope() == this.scope))
+ return true;
+
+ return identityEquals((Identity) identity);
+ }
+ return false;
+ }
+
+ /**
+ Checks for equality between this Identity and the specified
+ object. A subclass should override this method. The default
+ behavior is to return true if the public key and names match.
+
+ @return true if they are equal, false otherwise
+ */
+ protected boolean identityEquals(Identity identity)
+ {
+ return ((identity.getName() == this.name) &&
+ (identity.getPublicKey() == this.publicKey));
+ }
+
+ /**
+ Returns a string representing this Identity.
+
+ This class checks the security manager with the call
+ checkSecurityAccess with "printIdentity".
+
+ @returns a string representing this Identity.
+
+ @throws SecurityException - if the security manager denies
+ access to "printIdentity"
+ */
+ public String toString()
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkSecurityAccess("printIdentity");
+
+ /* TODO: Insert proper format here */
+ return (name + ":@" + scope + " Public Key: " + publicKey);
+ }
+
+ /**
+ Returns a detailed string representing this Identity.
+
+ This class checks the security manager with the call
+ checkSecurityAccess with "printIdentity".
+
+ @param detailed indicates whether or not to provide detailed
+ information
+
+ @returns a string representing this Identity.
+
+ @throws SecurityException - if the security manager denies
+ access to "printIdentity"
+ */
+ public String toString(boolean detailed)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkSecurityAccess("printIdentity");
+
+ if (detailed)
+ {
+ /* TODO: Insert proper detailed format here */
+ return (name + ":@" + scope + " Public Key: " + publicKey);
+ }
+ else
+ {
+ /* TODO: Insert proper format here */
+ return (name + ":@" + scope + " Public Key: " + publicKey);
+ }
+ }
+
+ /**
+ Gets the hashcode for this Identity.
+
+ @returns the hashcode
+ */
+ public int hashCode()
+ {
+ int ret = name.hashCode();
+ if (publicKey != null)
+ ret |= publicKey.hashCode();
+ if (scope != null)
+ ret |= scope.hashCode();
+ if (info != null)
+ ret |= info.hashCode();
+ if (certificates != null)
+ ret |= certificates.hashCode();
+
+ return ret;
+ }
+}
diff --git a/libjava/java/security/IdentityScope.java b/libjava/java/security/IdentityScope.java
new file mode 100644
index 0000000..4054888
--- /dev/null
+++ b/libjava/java/security/IdentityScope.java
@@ -0,0 +1,205 @@
+/* IdentityScope.java --- IdentityScope Class
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+import java.util.Enumeration;
+
+/**
+ IdentityScope represents a scope of an identity. IdentityScope
+ is also an Identity and can have a name and scope along with
+ the other qualitites identities posses.
+
+ An IdentityScope contains other Identity objects. All Identity
+ objects are manipulated in the scope the same way. The scope
+ is suppose to apply different scope to different type of
+ Identities.
+
+ No identity within the same scope can have the same public key.
+
+ @since JDK 1.1
+
+ @deprecated Use java.security.KeyStore, the java.security.cert
+ package, and java.security.Principal.
+
+ @author Mark Benvenuto
+ */
+public abstract class IdentityScope extends Identity
+{
+ private static IdentityScope systemScope = null;
+
+ /**
+ Creates a new instance of IdentityScope from Serialized Data
+ */
+ protected IdentityScope()
+ {
+ super();
+ }
+
+ /**
+ Creates a new instance of IdentityScope with the specified name
+ and no scope.
+
+ @param name the name to use
+ */
+ public IdentityScope(String name)
+ {
+ super(name);
+ }
+
+ /**
+ Creates a new instance of IdentityScope with the specified name
+ and IdentityScope.
+
+ @param name the name to use
+ @param scope the scope to use
+
+ @throws KeyManagementException if the identity scope is already
+ present
+ */
+ public IdentityScope(String name, IdentityScope scope)
+ throws KeyManagementException
+ {
+ super(name, scope);
+ }
+
+ /**
+ Gets the system's Scope.
+ */
+ public static IdentityScope getSystemScope()
+ {
+ if (systemScope == null)
+ {
+ //Load it
+ //systemScope;
+ }
+ return systemScope;
+ }
+
+ /**
+ Sets the scope of the system.
+
+ This class checks the security manager with the call
+ checkSecurityAccess with "setSystemScope".
+
+ @param scope the new sustem scope
+
+ @throws SecurityException - if the security manager denies
+ access to "setSystemScope"
+ */
+ protected static void setSystemScope(IdentityScope scope)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkSecurityAccess("setSystemScope");
+
+ systemScope = scope;
+ }
+
+ /**
+ Gets the number of entries within this IdentityScope.
+
+ @returns the number of entries
+ */
+ public abstract int size();
+
+ /**
+ Gets the specified Identity within this scope
+ by specified name.
+
+ @param name name of Identity to get
+
+ @returns an identity representing the name or null if it
+ cannot be found
+ */
+ public abstract Identity getIdentity(String name);
+
+ /**
+ Gets the specified Identity within this scope
+ by the specified Principal.
+
+ @param principal The Principal of the Identity to get
+
+ @returns an identity representing the principal or null if it
+ cannot be found
+ */
+ public Identity getIdentity(Principal principal)
+ {
+ return getIdentity(principal.getName());
+ }
+
+ /**
+ Gets the specified Identity within this scope
+ by the specified public key.
+
+ @param key the PublicKey of the Identity to get
+
+ @returns an identity representing the public key or null if it
+ cannot be found
+ */
+ public abstract Identity getIdentity(PublicKey key);
+
+ /**
+ Adds an identity to his scope.
+
+ @param identity the identity to add
+
+ @throws KeyManagementException if it is an invalid identity,
+ an identity with the same key exists, or another error
+ occurs.
+ */
+ public abstract void addIdentity(Identity identity)
+ throws KeyManagementException;
+
+ /**
+ Removes an identity to his scope.
+
+ @param identity the identity to remove
+
+ @throws KeyManagementException if it is a missing identity,
+ or another error occurs.
+ */
+ public abstract void removeIdentity(Identity identity)
+ throws KeyManagementException;
+
+ /**
+ Returns an Enumeration of identities.
+
+ @returns an enumeration of the identities.
+ */
+ public abstract Enumeration identities();
+
+ /**
+ Returns a string representing this IdentityScope.
+ It includes the name, the scope name, and number of identities.
+
+ @returns a string representing this IdentityScope.
+ */
+ public String toString()
+ {
+ return (super.getName() + " " + super.getScope().getName()
+ + " " + size());
+ }
+}
diff --git a/libjava/java/security/InvalidAlgorithmParameterException.java b/libjava/java/security/InvalidAlgorithmParameterException.java
index 35063a9..39f69f2 100644
--- a/libjava/java/security/InvalidAlgorithmParameterException.java
+++ b/libjava/java/security/InvalidAlgorithmParameterException.java
@@ -1,10 +1,28 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* InvalidAlgorithmParameterException.java
+ Copyright (C) 2000 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
package java.security;
diff --git a/libjava/java/security/InvalidKeyException.java b/libjava/java/security/InvalidKeyException.java
index 3a9a69a..64bc576 100644
--- a/libjava/java/security/InvalidKeyException.java
+++ b/libjava/java/security/InvalidKeyException.java
@@ -1,10 +1,27 @@
/* Copyright (C) 2000 Free Software Foundation
- This file is part of libgcj.
+This file is part of GNU Classpath.
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
package java.security;
diff --git a/libjava/java/security/InvalidParameterException.java b/libjava/java/security/InvalidParameterException.java
index 5ece012..1444130 100644
--- a/libjava/java/security/InvalidParameterException.java
+++ b/libjava/java/security/InvalidParameterException.java
@@ -1,10 +1,27 @@
/* Copyright (C) 2000 Free Software Foundation
- This file is part of libgcj.
+This file is part of GNU Classpath.
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
package java.security;
diff --git a/libjava/java/security/Key.java b/libjava/java/security/Key.java
index ae73bf6..bec79a3 100644
--- a/libjava/java/security/Key.java
+++ b/libjava/java/security/Key.java
@@ -1,28 +1,75 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* Key.java -- A abstract representation of a digital key
+ Copyright (C) 1998, 2000 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
-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.
+ * This interfaces models the base characteristics that all keys must
+ * have. These are: a key algorithm, an encoded form, and a format used
+ * to encode the key. Specific key types inherit from this interface.
+ * <p>
+ * Note that since this interface extends <code>Serializable</code>, all
+ * keys may be serialized.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
*/
-
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
public interface Key extends Serializable
{
+ /**
+ * The verion identifier used for serialization.
+ */
public static final long serialVersionUID = 6603384152749567654L;
- public String getAlgorithm();
- public String getFormat();
- public byte[] getEncoded();
+ /**
+ * This method returns the name of the algorithm for this key. This is a
+ * <code>String</code> such as "RSA".
+ *
+ * @return The name of the algorithm in use
+ */
+ public abstract String getAlgorithm();
+
+ /**
+ * This method returns the name of the encoding format for this key. This
+ * is the name of the ASN.1 data format used for this key, such as
+ * "X.509" or "PKCS#8". This method returns <code>null</code> if this key
+ * does not have an encoding format.
+ *
+ * @return The name of the encoding format for this key, or <code>null</code> if there is no such format.
+ */
+ public abstract String getFormat();
+
+ /**
+ * This method returns the encoded form of the key. If this key does not
+ * support encoding, this method returns <code>null</code>
+ *
+ * @return The encoded form of the key, or <code>null</code> if no encoded form is available.
+ */
+ public abstract byte[] getEncoded();
}
diff --git a/libjava/java/security/KeyException.java b/libjava/java/security/KeyException.java
index 634d8ce..7fa485c 100644
--- a/libjava/java/security/KeyException.java
+++ b/libjava/java/security/KeyException.java
@@ -1,30 +1,55 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* KeyException.java -- Thrown when there is a problem with a key
+ Copyright (C) 1998 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
-package java.security;
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
/**
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
+ * This exception is thrown when there is a problem with a key.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
*/
-
public class KeyException extends GeneralSecurityException
{
+ /**
+ * This method initializes a new instance of <code>KeyException</code>
+ * with no descriptive message.
+ */
public KeyException()
{
super();
}
+ /**
+ * This method initializes a new instance of <code>KeyException</code>
+ * with a descriptive message.
+ *
+ * @param msg The descriptive message.
+ */
public KeyException(String msg)
{
super(msg);
diff --git a/libjava/java/security/KeyFactory.java b/libjava/java/security/KeyFactory.java
new file mode 100644
index 0000000..7bbc355
--- /dev/null
+++ b/libjava/java/security/KeyFactory.java
@@ -0,0 +1,232 @@
+/* KeyFactory.java --- Key Factory Class
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+import java.security.spec.KeySpec;
+import java.security.spec.InvalidKeySpecException;
+
+/**
+ Key factories are used to convert keys (opaque cryptographic
+ keys of type Key) into key specifications (transparent
+ representations of the underlying key material).
+
+ Key factories are bi-directional. They allow a key class
+ to be converted into a key specification (key material) and
+ back again.
+
+ For example DSA public keys can be specified as
+ DSAPublicKeySpec or X509EncodedKeySpec. The key factory
+ translate these key specifications.
+
+ @since JDK 1.2
+ @author Mark Benvenuto
+ */
+public class KeyFactory
+{
+ private KeyFactorySpi keyFacSpi;
+ private Provider provider;
+ private String algorithm;
+
+ /**
+ Constructs a new keyFactory with the specified parameters.
+
+ @param keyFacSpi Key Factory SPI to use
+ @param provider the provider of the Key Factory SPI
+ @param algorithm the name of the key algorithm for this key factory
+ */
+ protected KeyFactory(KeyFactorySpi keyFacSpi, Provider provider,
+ String algorithm)
+ {
+ this.keyFacSpi = keyFacSpi;
+ this.provider = provider;
+ this.algorithm = algorithm;
+ }
+
+ /**
+ Gets an instance of the KeyFactory class representing
+ the specified key factory. If the algorithm is not
+ found then, it throws NoSuchAlgorithmException.
+
+ @param algorithm the name of algorithm to choose
+ @return a KeyFactory repesenting the desired algorithm
+
+ @throws NoSuchAlgorithmException if the algorithm is not implemented by providers
+ */
+ public static KeyFactory getInstance(String algorithm)
+ throws NoSuchAlgorithmException
+ {
+ Provider[] p = Security.getProviders();
+
+ for (int i = 0; i < p.length; i++)
+ {
+ String classname = p[i].getProperty("KeyFactory." + algorithm);
+ if (classname != null)
+ return getInstance(classname, algorithm, p[i]);
+ }
+
+ throw new NoSuchAlgorithmException(algorithm);
+ }
+
+ /**
+ Gets an instance of the KeyFactory class representing
+ the specified key factory from the specified provider.
+ If the algorithm is not found then, it throws
+ NoSuchAlgorithmException. If the provider is not found, then
+ it throws NoSuchProviderException.
+
+ @param algorithm the name of algorithm to choose
+ @param provider the name of the provider to find the algorithm in
+ @return a KeyFactory repesenting the desired algorithm
+
+ @throws NoSuchAlgorithmException if the algorithm is not implemented by the provider
+ @throws NoSuchProviderException if the provider is not found
+ */
+ public static KeyFactory getInstance(String algorithm, String provider)
+ throws NoSuchAlgorithmException, NoSuchProviderException
+ {
+ Provider p = Security.getProvider(provider);
+ if (p == null)
+ throw new NoSuchProviderException();
+
+ return getInstance(p.getProperty("KeyFactory." + algorithm),
+ algorithm, p);
+ }
+
+ private static KeyFactory getInstance(String classname,
+ String algorithm,
+ Provider provider)
+ throws NoSuchAlgorithmException
+ {
+
+ try
+ {
+ return new KeyFactory((KeyFactorySpi) Class.forName(classname).
+ newInstance(), provider, algorithm);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ throw new NoSuchAlgorithmException("Class not found");
+ }
+ catch (InstantiationException ie)
+ {
+ throw new NoSuchAlgorithmException("Class instantiation failed");
+ }
+ catch (IllegalAccessException iae)
+ {
+ throw new NoSuchAlgorithmException("Illegal Access");
+ }
+ }
+
+ /**
+ Gets the provider that the class is from.
+
+ @return the provider of this class
+ */
+ public final Provider getProvider()
+ {
+ return provider;
+ }
+
+ /**
+ Returns the name of the algorithm used
+
+ @return A string with the name of the algorithm
+ */
+ public final String getAlgorithm()
+ {
+ return algorithm;
+ }
+
+ /**
+ Generates a public key from the provided key specification.
+
+ @param keySpec key specification
+
+ @return the public key
+
+ @throws InvalidKeySpecException invalid key specification for
+ this key factory to produce a public key
+ */
+ public final PublicKey generatePublic(KeySpec keySpec) throws
+ InvalidKeySpecException
+ {
+ return keyFacSpi.engineGeneratePublic(keySpec);
+ }
+
+ /**
+ Generates a private key from the provided key specification.
+
+ @param keySpec key specification
+
+ @return the private key
+
+ @throws InvalidKeySpecException invalid key specification for
+ this key factory to produce a private key
+ */
+ public final PrivateKey generatePrivate(KeySpec keySpec) throws
+ InvalidKeySpecException
+ {
+ return keyFacSpi.engineGeneratePrivate(keySpec);
+ }
+
+ /**
+ Returns a key specification for the given key. keySpec
+ identifies the specification class to return the key
+ material in.
+
+ @param key the key
+ @param keySpec the specification class to return the
+ key material in.
+
+ @return the key specification in an instance of the requested
+ specification class
+
+ @throws InvalidKeySpecException the requested key specification
+ is inappropriate for this key or the key is
+ unrecognized.
+ */
+ public final KeySpec getKeySpec(Key key, Class keySpec)
+ throws InvalidKeySpecException
+ {
+ return keyFacSpi.engineGetKeySpec(key, keySpec);
+ }
+
+ /**
+ Translates the key from an unknown or untrusted provider
+ into a key for this key factory.
+
+ @param the key from an unknown or untrusted provider
+
+ @return the translated key
+
+ @throws InvalidKeySpecException if the key cannot be
+ processed by this key factory
+ */
+ public final Key translateKey(Key key) throws InvalidKeyException
+ {
+ return keyFacSpi.engineTranslateKey(key);
+ }
+}
diff --git a/libjava/java/security/KeyFactorySpi.java b/libjava/java/security/KeyFactorySpi.java
new file mode 100644
index 0000000..e53e1c0
--- /dev/null
+++ b/libjava/java/security/KeyFactorySpi.java
@@ -0,0 +1,120 @@
+/* KeyFactorySpi.java --- Key Factory Service Provider Interface
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+import java.security.spec.KeySpec;
+import java.security.spec.InvalidKeySpecException;
+
+/**
+ KeyFactorySpi is the Service Provider Interface (SPI) for the
+ KeyFactory class. This is the interface for providers to
+ supply to implement a key factory for an algorithm.
+
+ Key factories are used to convert keys (opaque cryptographic
+ keys of type Key) into key specifications (transparent
+ representations of the underlying key material).
+
+ Key factories are bi-directional. They allow a key class
+ to be converted into a key specification (key material) and
+ back again.
+
+ For example DSA public keys can be specified as
+ DSAPublicKeySpec or X509EncodedKeySpec. The key factory
+ translate these key specifications.
+
+ @since JDK 1.2
+ @author Mark Benvenuto
+ */
+public abstract class KeyFactorySpi
+{
+ /**
+ Constucts a new KeyFactorySpi.
+ */
+ public KeyFactorySpi()
+ {
+ }
+
+ /**
+ Generates a public key from the provided key specification.
+
+ @param keySpec key specification
+
+ @return the public key
+
+ @throws InvalidKeySpecException invalid key specification for
+ this key factory to produce a public key
+ */
+ protected abstract PublicKey engineGeneratePublic(KeySpec keySpec)
+ throws InvalidKeySpecException;
+
+
+ /**
+ Generates a private key from the provided key specification.
+
+ @param keySpec key specification
+
+ @return the private key
+
+ @throws InvalidKeySpecException invalid key specification for
+ this key factory to produce a private key
+ */
+ protected abstract PrivateKey engineGeneratePrivate(KeySpec keySpec)
+ throws InvalidKeySpecException;
+
+ /**
+ Returns a key specification for the given key. keySpec
+ identifies the specification class to return the key
+ material in.
+
+ @param key the key
+ @param keySpec the specification class to return the
+ key material in.
+
+ @return the key specification in an instance of the requested
+ specification class
+
+ @throws InvalidKeySpecException the requested key specification
+ is inappropriate for this key or the key is
+ unrecognized.
+ */
+ protected abstract KeySpec engineGetKeySpec(Key key, Class keySpec)
+ throws InvalidKeySpecException;
+
+
+ /**
+ Translates the key from an unknown or untrusted provider
+ into a key for this key factory.
+
+ @param the key from an unknown or untrusted provider
+
+ @return the translated key
+
+ @throws InvalidKeySpecException if the key cannot be
+ processed by this key factory
+ */
+ protected abstract Key engineTranslateKey(Key key)
+ throws InvalidKeyException;
+}
diff --git a/libjava/java/security/KeyManagementException.java b/libjava/java/security/KeyManagementException.java
new file mode 100644
index 0000000..7738c8f
--- /dev/null
+++ b/libjava/java/security/KeyManagementException.java
@@ -0,0 +1,58 @@
+/* KeyManagementException.java -- What it says
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+
+/**
+ * This exception is thrown whenever a problem related to the management of
+ * security keys is encountered.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public class KeyManagementException extends KeyException
+{
+ /**
+ * This method initializes a new instance of <code>KeyManagementException</code>
+ * with no descriptive error message.
+ */
+ public KeyManagementException()
+ {
+ super();
+ }
+
+ /**
+ * This method initializes a new instance of <code>KeyManagementException</code>
+ * with a descriptive error message.
+ *
+ * @param msg The descriptive error message
+ */
+ public KeyManagementException(String msg)
+ {
+ super(msg);
+ }
+}
diff --git a/libjava/java/security/KeyPair.java b/libjava/java/security/KeyPair.java
index 0aeb7c3..f5c474a 100644
--- a/libjava/java/security/KeyPair.java
+++ b/libjava/java/security/KeyPair.java
@@ -1,41 +1,74 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* KeyPair.java --- Key Pair Class
+ Copyright (C) 1999 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
-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 Tom Tromey <tromey@cygnus.com>
- * @date February 9, 2000.
- */
+ KeyPair serves as a simple container for public and private keys.
+ If properly initialized, this class should be treated like the
+ private key since it contains it and take approriate security
+ measures.
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
+ @author Mark Benvenuto
*/
-
-public class KeyPair implements java.io.Serializable
+public final class KeyPair implements Serializable
{
- public KeyPair (PublicKey publicKey, PrivateKey privateKey)
+ private PublicKey publicKey;
+ private PrivateKey privateKey;
+
+ /**
+ Initializes the KeyPair with a pubilc and private key.
+
+ @param publicKey Public Key to store
+ @param privateKey Private Key to store
+ */
+ public KeyPair(PublicKey publicKey, PrivateKey privateKey)
{
this.publicKey = publicKey;
this.privateKey = privateKey;
}
- public PublicKey getPublic ()
+ /**
+ Returns the public key stored in the KeyPair
+
+ @return The public key
+ */
+ public PublicKey getPublic()
{
return publicKey;
}
- public PrivateKey getPrivate ()
+ /**
+ Returns the private key stored in the KeyPair
+
+ @return The private key
+ */
+ public PrivateKey getPrivate()
{
return privateKey;
}
-
- // The keys.
- private PublicKey publicKey;
- private PrivateKey privateKey;
}
diff --git a/libjava/java/security/KeyPairGenerator.java b/libjava/java/security/KeyPairGenerator.java
index 7954c32..aff7310 100644
--- a/libjava/java/security/KeyPairGenerator.java
+++ b/libjava/java/security/KeyPairGenerator.java
@@ -1,86 +1,256 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* KeyPairGenerator.java --- Key Pair Generator Class
+ Copyright (C) 1999 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
package java.security;
+import java.security.spec.AlgorithmParameterSpec;
/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 10, 2000.
- */
+ KeyPairGenerator is the class used to generate key pairs
+ for a security algorithm.
-/**
- * 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.
- */
+ The KeyPairGenerator is created with the getInstance()
+ methods. The class is used to generate public and private
+ keys for an algorithm and associate it with
+ algorithm parameters.
+ @author Mark Benvenuto
+ */
public abstract class KeyPairGenerator extends KeyPairGeneratorSpi
{
+ private Provider provider;
+ private String algorithm;
+
+ /**
+ Constructs a new KeyPairGenerator
+
+ @param algorithm the algorithm to use
+ */
protected KeyPairGenerator(String algorithm)
{
- name = algorithm;
+ this.algorithm = algorithm;
+ this.provider = null;
}
- public static KeyPairGenerator getInstance(String algorithm)
- throws NoSuchAlgorithmException
+ /**
+ Returns the name of the algorithm used
+
+ @return A string with the name of the algorithm
+ */
+ public String getAlgorithm()
{
+ return algorithm;
+ }
+
+ /**
+ Gets an instance of the KeyPairGenerator class
+ which generates key pairs for the specified algorithm.
+ If the algorithm is not found then, it throws NoSuchAlgorithmException.
+
+ @param algorithm the name of algorithm to choose
+ @return a AlgorithmParameterGenerator repesenting the desired algorithm
+
+ @throws NoSuchAlgorithmException if the algorithm is not implemented by providers
+ */
+ public static KeyPairGenerator getInstance(String algorithm) throws
+ NoSuchAlgorithmException
+ {
+ Provider[] p = Security.getProviders();
+
String name = "KeyPairGenerator." + algorithm;
- Provider[] provs = Security.getProviders();
- for (int i = 0; i < provs.length; ++i)
+ for (int i = 0; i < p.length; i++)
{
- String val = provs[i].getProperty(name);
- if (val != null)
- {
- try
- {
- return (KeyPairGenerator) Class.forName(val).newInstance();
- }
- catch (Throwable _)
- {
- // We just ignore failures.
- }
- }
+ String classname = p[i].getProperty(name);
+ if (classname != null)
+ return getInstance(classname, algorithm, p[i]);
}
throw new NoSuchAlgorithmException(algorithm);
}
+ /**
+ Gets an instance of the KeyPairGenerator class
+ which generates key pairs for the specified algorithm.
+ If the algorithm is not found then, it throws NoSuchAlgorithmException.
+
+ @param algorithm the name of algorithm to choose
+ @param provider the name of the provider to find the algorithm in
+ @return a AlgorithmParameterGenerator repesenting the desired algorithm
+
+ @throws NoSuchAlgorithmException if the algorithm is not implemented by the provider
+ @throws NoSuchProviderException if the provider is not found
+ */
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)
+ throw new NoSuchProviderException();
+
+ return getInstance(p.getProperty("KeyPairGenerator." + algorithm),
+ algorithm, p);
+ }
+
+ private static KeyPairGenerator getInstance(String classname,
+ String algorithm,
+ Provider provider)
+ throws NoSuchAlgorithmException
+ {
+ try
{
- try
- {
- return (KeyPairGenerator) Class.forName(val).newInstance();
- }
- catch (Throwable _)
+ Object o = Class.forName(classname).newInstance();
+ KeyPairGenerator kpg;
+ if (o instanceof KeyPairGeneratorSpi)
+ kpg =
+ (KeyPairGenerator) (new
+ DummyKeyPairGenerator((KeyPairGeneratorSpi) o,
+ algorithm));
+ else
{
- // Nothing.
+ kpg = (KeyPairGenerator) o;
+ kpg.algorithm = algorithm;
}
+
+ kpg.provider = provider;
+ return kpg;
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ throw new NoSuchAlgorithmException("Class not found");
+ }
+ catch (InstantiationException ie)
+ {
+ throw new NoSuchAlgorithmException("Class instantiation failed");
}
+ catch (IllegalAccessException iae)
+ {
+ throw new NoSuchAlgorithmException("Illegal Access");
+ }
+ }
- throw new NoSuchAlgorithmException(algorithm);
+ /**
+ Gets the provider that the class is from.
+
+ @return the provider of this class
+ */
+ public final Provider getProvider()
+ {
+ return provider;
}
- public String getAlgorithm()
+ /**
+ Initializes the KeyPairGenerator for the specified key size.
+ (Since no source of randomness is specified, a default one is
+ provided.)
+
+ @param keysize Size of key to generate
+ */
+ public void initialize(int keysize)
+ {
+ initialize(keysize, new SecureRandom());
+ }
+
+ /**
+ Initializes the KeyPairGenerator for the specified key size
+ and specified SecureRandom.
+
+ @param keysize Size of key to generate
+ @param random SecureRandom to use
+
+ @since JDK 1.2
+ */
+ public void initialize(int keysize, SecureRandom random)
+ {
+ initialize(keysize, random);
+ }
+
+ /**
+ Initializes the KeyPairGenerator with the specified
+ AlgorithmParameterSpec class.
+ (Since no source of randomness is specified, a default one is
+ provided.)
+
+ @param params AlgorithmParameterSpec to initialize with
+
+ @since JDK 1.2
+ */
+ public void initialize(AlgorithmParameterSpec params)
+ throws InvalidAlgorithmParameterException
{
- return name;
+ initialize(params, new SecureRandom());
}
- public abstract void initialize(int strength, SecureRandom random);
- public abstract KeyPair generateKeyPair();
+ /**
+ Initializes the KeyPairGenerator with the specified
+ AlgorithmParameterSpec class and specified SecureRandom.
- // Algorithm name.
- private String name;
+ @param params AlgorithmParameterSpec to initialize with
+ @param random SecureRandom to use
+
+ @since JDK 1.2
+ */
+ public void initialize(AlgorithmParameterSpec params, SecureRandom random)
+ throws InvalidAlgorithmParameterException
+ {
+ super.initialize(params, random);
+ }
+
+ /**
+ Generates a KeyPair according the rules for the algorithm.
+ Unless intialized, algorithm defaults will be used. It
+ creates a unique key pair each time.
+
+ Same as generateKeyPair();
+
+ @return a key pair
+ */
+ public final KeyPair genKeyPair()
+ {
+ try
+ {
+ return getInstance("DSA", "GNU").generateKeyPair();
+ }
+ catch (Exception e)
+ {
+ System.err.println("genKeyPair failed: " + e);
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ /**
+ Generates a KeyPair according the rules for the algorithm.
+ Unless intialized, algorithm defaults will be used. It
+ creates a unique key pair each time.
+
+ Same as genKeyPair();
+
+ @return a key pair
+ */
+ public KeyPair generateKeyPair()
+ {
+ return genKeyPair();
+ }
}
diff --git a/libjava/java/security/KeyPairGeneratorSpi.java b/libjava/java/security/KeyPairGeneratorSpi.java
index 46520b4..39e6527 100644
--- a/libjava/java/security/KeyPairGeneratorSpi.java
+++ b/libjava/java/security/KeyPairGeneratorSpi.java
@@ -1,26 +1,82 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* KeyPairGeneratorSpi.java --- Key Pair Generator SPI Class
+ Copyright (C) 1999 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
package java.security;
+import java.security.spec.AlgorithmParameterSpec;
/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 7, 2000.
- */
+ KeyPairGeneratorSpi is the interface used to generate key pairs
+ for security algorithms.
-/**
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Partially implemented.
+ @author Mark Benvenuto
*/
-
-// JDK1.2
public abstract class KeyPairGeneratorSpi
{
+ /**
+ Constructs a new KeyPairGeneratorSpi
+ */
+ public KeyPairGeneratorSpi()
+ {
+ }
+
+ /**
+ Initialize the KeyPairGeneratorSpi with the specified
+ key size and source of randomness
+
+ @param keysize size of the key to generate
+ @param random A SecureRandom source of randomness
+ */
public abstract void initialize(int keysize, SecureRandom random);
+
+ /**
+ Initialize the KeyPairGeneratorSpi with the specified
+ AlgorithmParameterSpec and source of randomness
+
+ This is a concrete method. It may be overridden by the provider
+ and if the AlgorithmParameterSpec class is invalid
+ throw InvalidAlgorithmParameterException. By default this
+ method just throws UnsupportedOperationException.
+
+ @param params A AlgorithmParameterSpec to intialize with
+ @param random A SecureRandom source of randomness
+
+ @throws InvalidAlgorithmParameterException
+ */
+ public void initialize(AlgorithmParameterSpec params, SecureRandom random)
+ throws InvalidAlgorithmParameterException
+ {
+ throw new java.lang.UnsupportedOperationException();
+ }
+
+ /**
+ Generates a KeyPair according the rules for the algorithm.
+ Unless intialized, algorithm defaults will be used. It
+ creates a unique key pair each time.
+
+ @return a key pair
+ */
public abstract KeyPair generateKeyPair();
}
diff --git a/libjava/java/security/KeyStore.java b/libjava/java/security/KeyStore.java
new file mode 100644
index 0000000..bd9b025
--- /dev/null
+++ b/libjava/java/security/KeyStore.java
@@ -0,0 +1,447 @@
+/* KeyStore.java --- Key Store Class
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.security.cert.CertificateException;
+import java.util.Date;
+import java.util.Enumeration;
+
+/**
+ Keystore represents an in-memory collection of keys and
+ certificates. There are two types of entries:
+
+ * Key Entry
+
+ This type of keystore entry store sensitive crytographic key
+ information in a protected format.Typically this is a secret
+ key or a private key with a certificate chain.
+
+
+ * Trusted Ceritificate Entry
+
+ This type of keystore entry contains a single public key
+ certificate belonging to annother entity. It is called trusted
+ because the keystore owner trusts that the certificates
+ belongs to the subject (owner) of the certificate.
+
+ The keystore contains an "alias" string for each entry.
+
+ The structure and persistentence of the key store is not
+ specified. Any method could be used to protect sensitive
+ (private or secret) keys. Smart cards or integrated
+ cryptographic engines could be used or the keystore could
+ be simply stored in a file.
+ */
+public class KeyStore
+{
+ private KeyStoreSpi keyStoreSpi;
+ private Provider provider;
+ private String type;
+
+ /**
+ Creates an instance of KeyStore
+
+ @param keyStoreSpi A KeyStore engine to use
+ @param provider A provider to use
+ @param type The type of KeyStore
+ */
+ protected KeyStore(KeyStoreSpi keyStoreSpi, Provider provider, String type)
+ {
+ this.keyStoreSpi = keyStoreSpi;
+ this.provider = provider;
+ this.type = type;
+ }
+
+ /**
+ Gets an instance of the KeyStore class representing
+ the specified keystore. If the type is not
+ found then, it throws CertificateException.
+
+ @param type the type of certificate to choose
+
+ @return a KeyStore repesenting the desired type
+
+ @throws KeyStoreException if the type of keystore is not implemented by providers
+ */
+ public static KeyStore getInstance(String type) throws KeyStoreException
+ {
+ Provider[] p = Security.getProviders();
+
+ for (int i = 0; i < p.length; i++)
+ {
+ String classname = p[i].getProperty("KeyStore." + type);
+ if (classname != null)
+ return getInstance(classname, type, p[i]);
+ }
+
+ throw new KeyStoreException(type);
+ }
+
+ /**
+ Gets an instance of the KeyStore class representing
+ the specified key store from the specified provider.
+ If the type is not found then, it throws CertificateException.
+ If the provider is not found, then it throws
+ NoSuchProviderException.
+
+ @param type the type of certificate to choose
+
+ @return a KeyStore repesenting the desired type
+
+ @throws KeyStoreException if the type of keystore is not implemented by providers
+ @throws NoSuchProviderException if the provider is not found
+ */
+ public static KeyStore getInstance(String type, String provider)
+ throws KeyStoreException, NoSuchProviderException
+ {
+ Provider p = Security.getProvider(provider);
+ if (p == null)
+ throw new NoSuchProviderException();
+
+ return getInstance(p.getProperty("KeyStore." + type), type, p);
+ }
+
+ private static KeyStore getInstance(String classname,
+ String type,
+ Provider provider)
+ throws KeyStoreException
+ {
+ try
+ {
+ return new KeyStore((KeyStoreSpi) Class.forName(classname).
+ newInstance(), provider, type);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ throw new KeyStoreException("Class not found");
+ }
+ catch (InstantiationException ie)
+ {
+ throw new KeyStoreException("Class instantiation failed");
+ }
+ catch (IllegalAccessException iae)
+ {
+ throw new KeyStoreException("Illegal Access");
+ }
+ }
+
+
+ /**
+ Gets the provider that the class is from.
+
+ @return the provider of this class
+ */
+ public final Provider getProvider()
+ {
+ return provider;
+ }
+
+ /**
+ Returns the type of the KeyStore supported
+
+ @return A string with the type of KeyStore
+ */
+ public final String getType()
+ {
+ return type;
+ }
+
+ /**
+ Returns the key associated with given alias using the
+ supplied password.
+
+ @param alias an alias for the key to get
+ @param password password to access key with
+
+ @return the requested key, or null otherwise
+
+ @throws NoSuchAlgorithmException if there is no algorithm
+ for recovering the key
+ @throws UnrecoverableKeyException key cannot be reocovered
+ (wrong password).
+ */
+ public final Key getKey(String alias, char[]password)
+ throws KeyStoreException, NoSuchAlgorithmException,
+ UnrecoverableKeyException
+ {
+ return keyStoreSpi.engineGetKey(alias, password);
+ }
+
+ /**
+ Gets a Certificate chain for the specified alias.
+
+ @param alias the alias name
+
+ @return a chain of Certificates ( ordered from the user's
+ certificate to the Certificate Authority's ) or
+ null if the alias does not exist or there is no
+ certificate chain for the alias ( the alias refers
+ to a trusted certificate entry or there is no entry).
+ */
+ public final java.security.cert.
+ Certificate[] getCertificateChain(String alias) throws KeyStoreException
+ {
+ return keyStoreSpi.engineGetCertificateChain(alias);
+ }
+
+ /**
+ Gets a Certificate for the specified alias.
+
+ If there is a trusted certificate entry then that is returned.
+ it there is a key entry with a certificate chain then the
+ first certificate is return or else null.
+
+ @param alias the alias name
+
+ @return a Certificate or null if the alias does not exist
+ or there is no certificate for the alias
+ */
+ public final java.security.cert.Certificate getCertificate(String alias)
+ throws KeyStoreException
+ {
+ return keyStoreSpi.engineGetCertificate(alias);
+ }
+
+ /**
+ Gets entry creation date for the specified alias.
+
+ @param alias the alias name
+
+ @returns the entry creation date or null
+ */
+ public final Date getCreationDate(String alias) throws KeyStoreException
+ {
+ return keyStoreSpi.engineGetCreationDate(alias);
+ }
+
+ /**
+ Assign the key to the alias in the keystore, protecting it
+ with the given password. It will overwrite an existing
+ entry and if the key is a PrivateKey, also add the
+ certificate chain representing the corresponding public key.
+
+ @param alias the alias name
+ @param key the key to add
+ @password the password to protect with
+ @param chain the certificate chain for the corresponding
+ public key
+
+ @throws KeyStoreException if it fails
+ */
+ public final void setKeyEntry(String alias, Key key, char[]password,
+ java.security.cert.
+ Certificate[]chain) throws KeyStoreException
+ {
+ keyStoreSpi.engineSetKeyEntry(alias, key, password, chain);
+ }
+
+ /**
+ Assign the key to the alias in the keystore. It will overwrite
+ an existing entry and if the key is a PrivateKey, also
+ add the certificate chain representing the corresponding
+ public key.
+
+ @param alias the alias name
+ @param key the key to add
+ @param chain the certificate chain for the corresponding
+ public key
+
+ @throws KeyStoreException if it fails
+ */
+ public final void setKeyEntry(String alias, byte[]key,
+ java.security.cert.
+ Certificate[]chain) throws KeyStoreException
+ {
+ keyStoreSpi.engineSetKeyEntry(alias, key, chain);
+ }
+
+ /**
+ Assign the certificate to the alias in the keystore. It
+ will overwrite an existing entry.
+
+ @param alias the alias name
+ @param cert the certificate to add
+
+ @throws KeyStoreException if it fails
+ */
+ public final void setCertificateEntry(String alias,
+ java.security.cert.
+ Certificate cert) throws
+ KeyStoreException
+ {
+ keyStoreSpi.engineSetCertificateEntry(alias, cert);
+ }
+
+ /**
+ Deletes the entry for the specified entry.
+
+ @param alias the alias name
+
+ @throws KeyStoreException if it fails
+ */
+ public final void deleteEntry(String alias) throws KeyStoreException
+ {
+ keyStoreSpi.engineDeleteEntry(alias);
+ }
+
+ /**
+ Generates a list of all the aliases in the keystore.
+
+ @return an Enumeration of the aliases
+ */
+ public final Enumeration aliases() throws KeyStoreException
+ {
+ return keyStoreSpi.engineAliases();
+ }
+
+ /**
+ Determines if the keystore contains the specified alias.
+
+ @param alias the alias name
+
+ @return true if it contains the alias, false otherwise
+ */
+ public final boolean containsAlias(String alias) throws KeyStoreException
+ {
+ return keyStoreSpi.engineContainsAlias(alias);
+ }
+
+ /**
+ Returns the number of entries in the keystore.
+
+ @returns the number of keystore entries.
+ */
+ public final int size() throws KeyStoreException
+ {
+ return keyStoreSpi.engineSize();
+ }
+
+ /**
+ Determines if the keystore contains a key entry for
+ the specified alias.
+
+ @param alias the alias name
+
+ @return true if it is a key entry, false otherwise
+ */
+ public final boolean isKeyEntry(String alias) throws KeyStoreException
+ {
+ return keyStoreSpi.engineIsKeyEntry(alias);
+ }
+
+
+ /**
+ Determines if the keystore contains a certificate entry for
+ the specified alias.
+
+ @param alias the alias name
+
+ @return true if it is a certificate entry, false otherwise
+ */
+ public final boolean isCertificateEntry(String alias)
+ throws KeyStoreException
+ {
+ return keyStoreSpi.engineIsCertificateEntry(alias);
+ }
+
+ /**
+ Determines if the keystore contains the specified certificate
+ entry and returns the alias.
+
+ It checks every entry and for a key entry checks only the
+ first certificate in the chain.
+
+ @param cert Certificate to look for
+
+ @return alias of first matching certificate, null if it
+ does not exist.
+ */
+ public final String getCertificateAlias(java.security.cert.Certificate cert)
+ throws KeyStoreException
+ {
+ return keyStoreSpi.engineGetCertificateAlias(cert);
+ }
+
+ /**
+ Stores the keystore in the specified output stream and it
+ uses the specified key it keep it secure.
+
+ @param stream the output stream to save the keystore to
+ @param password the password to protect the keystore integrity with
+
+ @throws IOException if an I/O error occurs.
+ @throws NoSuchAlgorithmException the data integrity algorithm
+ used cannot be found.
+ @throws CertificateException if any certificates could not be
+ stored in the output stream.
+ */
+ public final void store(OutputStream stream, char[]password)
+ throws KeyStoreException, IOException, NoSuchAlgorithmException,
+ CertificateException
+ {
+ keyStoreSpi.engineStore(stream, password);
+ }
+
+ /**
+ Loads the keystore from the specified input stream and it
+ uses the specified password to check for integrity if supplied.
+
+ @param stream the input stream to load the keystore from
+ @param password the password to check the keystore integrity with
+
+ @throws IOException if an I/O error occurs.
+ @throws NoSuchAlgorithmException the data integrity algorithm
+ used cannot be found.
+ @throws CertificateException if any certificates could not be
+ stored in the output stream.
+ */
+ public final void load(InputStream stream, char[]password)
+ throws IOException, NoSuchAlgorithmException, CertificateException
+ {
+ keyStoreSpi.engineLoad(stream, password);
+ }
+
+ /**
+ Returns the default KeyStore type. This method looks up the
+ type in <JAVA_HOME>/lib/security/java.security with the
+ property "keystore.type" or if that fails then "jks" .
+ */
+ public static final String getDefaultType()
+ {
+ String tmp;
+ //Security reads every property in java.security so it
+ //will return this property if it exists.
+ tmp = Security.getProperty("keystore.type");
+
+ if (tmp == null)
+ tmp = "jks";
+
+ return tmp;
+ }
+}
diff --git a/libjava/java/security/KeyStoreException.java b/libjava/java/security/KeyStoreException.java
new file mode 100644
index 0000000..f7d3c0d
--- /dev/null
+++ b/libjava/java/security/KeyStoreException.java
@@ -0,0 +1,57 @@
+/* KeyStoreException.java -- Indicates a problem with the key store
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+
+/**
+ * Indicates a problem with the key store.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public class KeyStoreException extends GeneralSecurityException
+{
+ /**
+ * This method initializes a new <code>KeyStoreException</code> with no
+ * detailed error message.
+ */
+ public KeyStoreException()
+ {
+ super();
+ }
+
+ /**
+ * This method initializes a new <code>KeyStoreException</code> with a
+ * detailed error message.
+ *
+ * @param msg The descriptive error message.
+ */
+ public KeyStoreException(String msg)
+ {
+ super(msg);
+ }
+}
diff --git a/libjava/java/security/KeyStoreSpi.java b/libjava/java/security/KeyStoreSpi.java
new file mode 100644
index 0000000..73715f3a
--- /dev/null
+++ b/libjava/java/security/KeyStoreSpi.java
@@ -0,0 +1,262 @@
+/* KeyStoreSpi.java --- Key Store Service Provider Interface
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.security.cert.CertificateException;
+import java.util.Date;
+import java.util.Enumeration;
+
+/**
+ KeyStoreSpi is the Service Provider Interface (SPI) for the
+ KeyStore class. This is the interface for providers to
+ supply to implement a keystore for a particular keystore
+ type.
+
+ @since JDK 1.2
+ @author Mark Benvenuto
+ */
+public abstract class KeyStoreSpi
+{
+ /**
+ Constructs a new KeyStoreSpi
+ */
+ public KeyStoreSpi()
+ {
+ }
+
+ /**
+ Returns the key associated with given alias using the
+ supplied password.
+
+ @param alias an alias for the key to get
+ @param password password to access key with
+
+ @return the requested key, or null otherwise
+
+ @throws NoSuchAlgorithmException if there is no algorithm
+ for recovering the key
+ @throws UnrecoverableKeyException key cannot be reocovered
+ (wrong password).
+ */
+ public abstract Key engineGetKey(String alias, char[]password)
+ throws NoSuchAlgorithmException, UnrecoverableKeyException;
+
+ /**
+ Gets a Certificate chain for the specified alias.
+
+ @param alias the alias name
+
+ @return a chain of Certificates ( ordered from the user's
+ certificate to the Certificate Authority's ) or
+ null if the alias does not exist or there is no
+ certificate chain for the alias ( the alias refers
+ to a trusted certificate entry or there is no entry).
+ */
+ public abstract java.security.cert.
+ Certificate[] engineGetCertificateChain(String alias);
+
+
+ /**
+ Gets a Certificate for the specified alias.
+
+ If there is a trusted certificate entry then that is returned.
+ it there is a key entry with a certificate chain then the
+ first certificate is return or else null.
+
+ @param alias the alias name
+
+ @return a Certificate or null if the alias does not exist
+ or there is no certificate for the alias
+ */
+ public abstract java.security.cert.
+ Certificate engineGetCertificate(String alias);
+
+ /**
+ Gets entry creation date for the specified alias.
+
+ @param alias the alias name
+
+ @returns the entry creation date or null
+ */
+ public abstract Date engineGetCreationDate(String alias);
+
+ /**
+ Assign the key to the alias in the keystore, protecting it
+ with the given password. It will overwrite an existing
+ entry and if the key is a PrivateKey, also add the
+ certificate chain representing the corresponding public key.
+
+ @param alias the alias name
+ @param key the key to add
+ @password the password to protect with
+ @param chain the certificate chain for the corresponding
+ public key
+
+ @throws KeyStoreException if it fails
+ */
+ public abstract void engineSetKeyEntry(String alias, Key key,
+ char[]password,
+ java.security.cert.
+ Certificate[]chain) throws
+ KeyStoreException;
+
+ /**
+ Assign the key to the alias in the keystore. It will overwrite
+ an existing entry and if the key is a PrivateKey, also
+ add the certificate chain representing the corresponding
+ public key.
+
+ @param alias the alias name
+ @param key the key to add
+ @param chain the certificate chain for the corresponding
+ public key
+
+ @throws KeyStoreException if it fails
+ */
+ public abstract void engineSetKeyEntry(String alias, byte[]key,
+ java.security.cert.
+ Certificate[]chain) throws
+ KeyStoreException;
+
+
+ /**
+ Assign the certificate to the alias in the keystore. It
+ will overwrite an existing entry.
+
+ @param alias the alias name
+ @param cert the certificate to add
+
+ @throws KeyStoreException if it fails
+ */
+ public abstract void engineSetCertificateEntry(String alias,
+ java.security.cert.
+ Certificate cert) throws
+ KeyStoreException;
+
+ /**
+ Deletes the entry for the specified entry.
+
+ @param alias the alias name
+
+ @throws KeyStoreException if it fails
+ */
+ public abstract void engineDeleteEntry(String alias)
+ throws KeyStoreException;
+
+ /**
+ Generates a list of all the aliases in the keystore.
+
+ @return an Enumeration of the aliases
+ */
+ public abstract Enumeration engineAliases();
+
+ /**
+ Determines if the keystore contains the specified alias.
+
+ @param alias the alias name
+
+ @return true if it contains the alias, false otherwise
+ */
+ public abstract boolean engineContainsAlias(String alias);
+
+ /**
+ Returns the number of entries in the keystore.
+
+ @returns the number of keystore entries.
+ */
+ public abstract int engineSize();
+
+ /**
+ Determines if the keystore contains a key entry for
+ the specified alias.
+
+ @param alias the alias name
+
+ @return true if it is a key entry, false otherwise
+ */
+ public abstract boolean engineIsKeyEntry(String alias);
+
+ /**
+ Determines if the keystore contains a certificate entry for
+ the specified alias.
+
+ @param alias the alias name
+
+ @return true if it is a certificate entry, false otherwise
+ */
+ public abstract boolean engineIsCertificateEntry(String alias);
+
+ /**
+ Determines if the keystore contains the specified certificate
+ entry and returns the alias.
+
+ It checks every entry and for a key entry checks only the
+ first certificate in the chain.
+
+ @param cert Certificate to look for
+
+ @return alias of first matching certificate, null if it
+ does not exist.
+ */
+ public abstract String engineGetCertificateAlias(java.security.cert.
+ Certificate cert);
+
+ /**
+ Stores the keystore in the specified output stream and it
+ uses the specified key it keep it secure.
+
+ @param stream the output stream to save the keystore to
+ @param password the password to protect the keystore integrity with
+
+ @throws IOException if an I/O error occurs.
+ @throws NoSuchAlgorithmException the data integrity algorithm
+ used cannot be found.
+ @throws CertificateException if any certificates could not be
+ stored in the output stream.
+ */
+ public abstract void engineStore(OutputStream stream, char[]password)
+ throws IOException, NoSuchAlgorithmException, CertificateException;
+
+
+ /**
+ Loads the keystore from the specified input stream and it
+ uses the specified password to check for integrity if supplied.
+
+ @param stream the input stream to load the keystore from
+ @param password the password to check the keystore integrity with
+
+ @throws IOException if an I/O error occurs.
+ @throws NoSuchAlgorithmException the data integrity algorithm
+ used cannot be found.
+ @throws CertificateException if any certificates could not be
+ stored in the output stream.
+ */
+ public abstract void engineLoad(InputStream stream, char[]password)
+ throws IOException, NoSuchAlgorithmException, CertificateException;
+}
diff --git a/libjava/java/security/MessageDigest.java b/libjava/java/security/MessageDigest.java
index 04546cd..d8f6b06 100644
--- a/libjava/java/security/MessageDigest.java
+++ b/libjava/java/security/MessageDigest.java
@@ -1,144 +1,316 @@
-// MessageDigest.java
+/* MessageDigest.java --- The message digest interface.
+ Copyright (C) 1999 Free Software Foundation, Inc.
-/* Copyright (C) 2000 Free Software Foundation
+This file is part of GNU Classpath.
- This file is part of libgcj.
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
-package java.security;
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date February 11, 2000.
- */
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
-/**
- * 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.
- */
+package java.security;
-public abstract class MessageDigest
+public abstract class MessageDigest extends MessageDigestSpi
{
- protected MessageDigest (String algorithm)
+ private String algorithm;
+ private Provider provider;
+ private byte[] lastDigest;
+
+ /**
+ Creates a MessageDigest representing the specified
+ algorithm.
+
+ @param algorithm the name of digest algorithm to choose
+ */
+ protected MessageDigest(String algorithm)
{
- name = algorithm;
+ this.algorithm = algorithm;
+ provider = null;
}
- public static MessageDigest getInstance (String algorithm)
+ /**
+ Gets an instance of the MessageDigest class representing
+ the specified digest. If the algorithm is not found then,
+ it throws NoSuchAlgorithmException.
+
+ @param algorithm the name of digest algorithm to choose
+ @return a MessageDigest representing the desired algorithm
+
+ @exception NoSuchAlgorithmException if the algorithm is not implemented by providers
+ */
+ public static MessageDigest getInstance(String algorithm)
throws NoSuchAlgorithmException
{
+ Provider[] p = Security.getProviders();
String name = "MessageDigest." + algorithm;
- Provider[] provs = Security.getProviders ();
- for (int i = 0; i < provs.length; ++i)
+
+ for (int i = 0; i < p.length; i++)
{
- String val = provs[i].getProperty (name);
- if (val != null)
- {
- try
- {
- return (MessageDigest) Class.forName(val).newInstance ();
- }
- catch (Throwable _)
- {
- // We just ignore failures.
- }
- }
+ String classname = p[i].getProperty(name);
+ if (classname != null)
+ return getInstance(classname, algorithm, p[i]);
}
- throw new NoSuchAlgorithmException (algorithm);
+ throw new NoSuchAlgorithmException(algorithm);
}
- public static MessageDigest getInstance (String algorithm, String provider)
+ /**
+ Gets an instance of the MessageDigest class representing
+ the specified digest from the specified provider. If the
+ algorithm is not found then, it throws NoSuchAlgorithmException.
+ If the provider is not found, then it throws
+ NoSuchProviderException.
+
+ @param algorithm the name of digest algorithm to choose
+ @param provider the name of the provider to find the algorithm in
+ @return a MessageDigest representing the desired algorithm
+
+ @exception NoSuchAlgorithmException if the algorithm is not implemented by the provider
+ @exception NoSuchProviderException if the provider is not found
+ */
+
+ public static MessageDigest getInstance(String algorithm, String provider)
throws NoSuchAlgorithmException, NoSuchProviderException
{
- String name = "MessageDigest." + algorithm;
- Provider p = Security.getProvider (provider);
+ Provider p = Security.getProvider(provider);
+
if (p == null)
- throw new NoSuchProviderException (provider);
- String val = p.getProperty (name);
- if (val != null)
+ throw new NoSuchProviderException(provider);
+
+ return getInstance(p.getProperty("MessageDigest." + algorithm),
+ algorithm, p);
+ }
+
+ private static MessageDigest getInstance(String classname,
+ String algorithm,
+ Provider provider)
+ throws NoSuchAlgorithmException
+ {
+ if (classname == null)
+ throw new NoSuchAlgorithmException(algorithm);
+
+ try
+ {
+ MessageDigest m =
+ (MessageDigest) Class.forName(classname).newInstance();
+ m.algorithm = algorithm;
+ m.provider = provider;
+ return m;
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ throw new NoSuchAlgorithmException(algorithm + ": Class not found.");
+ }
+ catch (InstantiationException ie)
{
- try
- {
- return (MessageDigest) Class.forName(val).newInstance ();
- }
- catch (Throwable _)
- {
- // Nothing.
- }
+ throw new NoSuchAlgorithmException(algorithm
+ + ": Class instantiation failed.");
}
+ catch (IllegalAccessException iae)
+ {
+ throw new NoSuchAlgorithmException(algorithm + ": Illegal Access");
+ }
+ }
+
- throw new NoSuchAlgorithmException (algorithm);
+ /**
+ Gets the provider that the MessageDigest is from.
+
+ @return the provider the this MessageDigest
+ */
+ public final Provider getProvider()
+ {
+ return provider;
}
- public void update (byte input)
+ /**
+ Updates the digest with the byte.
+
+ @param input byte to update the digest with
+ */
+ public void update(byte input)
{
- engineUpdate (input);
+ engineUpdate(input);
}
- public void update (byte[] input, int offset, int len)
+ /**
+ Updates the digest with the bytes from the array from the
+ specified offset to the specified length.
+
+ @param input bytes to update the digest with
+ @param offset the offset to start at
+ @param len length of the data to update with
+ */
+ public void update(byte[]input, int offset, int len)
{
- engineUpdate (input, offset, len);
+ engineUpdate(input, 0, input.length);
}
- public void update (byte[] input)
+ /**
+ Updates the digest with the bytes from the array.
+
+ @param input bytes to update the digest with
+ */
+ public void update(byte[]input)
{
- engineUpdate (input, 0, input.length);
+ engineUpdate(input, 0, input.length);
}
- public byte[] digest ()
+ /**
+ Computes the digest of the stored data.
+
+ @return a byte array representing the message digest
+ */
+ public byte[] digest()
+ {
+ return lastDigest = engineDigest();
+ }
+
+ /**
+ Computes the final digest of the stored bytes and returns
+ them.
+
+ @param buf An array of bytes to store the digest
+ @param offset An offset to start storing the digest at
+ @param len The length of the buffer
+ @return Returns the length of the buffer
+ */
+ public int digest(byte[]buf, int offset, int len) throws DigestException
{
- return engineDigest ();
+ return engineDigest(buf, offset, len);
}
- public byte[] digest (byte[] input)
+ /**
+ Computes a final update using the input array of bytes,
+ then computes a final digest and returns it. It calls
+ update(input) and then digest();
+
+ @param buf An array of bytes to perform final update with
+ @return a byte array representing the message digest
+ */
+ public byte[] digest(byte[]input)
{
- update (input);
- return engineDigest ();
+ update(input);
+ return digest();
}
- public String toString ()
+ /**
+ Returns a representation of the MessageDigest as a String.
+
+ @return a string representing the message digest
+ */
+ public String toString()
{
- // There is no spec for this.
- return "[MessageDigest: " + name + "]";
+ return (getClass()).getName()
+ + " Message Digest <" + digestToString() + ">";
}
- public static boolean isEqual (byte[] digesta, byte[] digestb)
+ /**
+ Does a simple byte comparison of the two digests.
+
+ @param digesta first digest to compare
+ @param digestb second digest to compare
+ @return true if they are equal, false otherwise
+ */
+ 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 ()
+
+ /**
+ Resets the message digest.
+ */
+ public void reset()
+ {
+ engineReset();
+ }
+
+ /**
+ Gets the name of the algorithm currently used.
+ The names of algorithms are usually SHA-1 or MD5.
+
+ @return name of algorithm.
+ */
+ public final String getAlgorithm()
{
- engineReset ();
+ return algorithm;
}
- public final String getAlgorithm ()
+ /**
+ Gets the length of the message digest.
+ The default is zero which means that this message digest
+ does not implement this function.
+
+ @return length of the message digest
+ */
+ public final int getDigestLength()
{
- return name;
+ return engineGetDigestLength();
}
- protected abstract void engineUpdate (byte input);
- protected abstract void engineUpdate (byte input[], int offset, int len);
- protected abstract byte[] engineDigest ();
- protected abstract void engineReset ();
+ /**
+ Returns a clone of this class if supported.
+ If it does not then it throws CloneNotSupportedException.
+ The cloning of this class depends on whether the subclass
+ MessageDigestSpi implements Cloneable which contains the
+ actual implementation of the appropriate algorithm.
+ @return clone of this class
+
+ @exception CloneNotSupportedException this class does not support cloning
+ */
public Object clone() throws CloneNotSupportedException
{
- return super.clone ();
+ if (this instanceof Cloneable)
+ return super.clone();
+ else
+ throw new CloneNotSupportedException();
+ }
+
+ private String digestToString()
+ {
+ byte[] digest = lastDigest;
+
+ if (digest == null)
+ return "incomplete";
+
+ StringBuffer buf = new StringBuffer();
+ int len = digest.length;
+ for (int i = 0; i < len; ++i)
+ {
+ byte b = digest[i];
+ byte high = (byte) ((b & 0xff) >>> 4);
+ byte low = (byte) (b & 0xf);
+
+ buf.append(high > 9 ? ('a' - 10) + high : '0' + high);
+ buf.append(low > 9 ? ('a' - 10) + low : '0' + low);
+ }
+
+ return buf.toString();
}
- // Algorithm name.
- private String name;
}
diff --git a/libjava/java/security/MessageDigestSpi.java b/libjava/java/security/MessageDigestSpi.java
new file mode 100644
index 0000000..ce9e54d
--- /dev/null
+++ b/libjava/java/security/MessageDigestSpi.java
@@ -0,0 +1,147 @@
+/* MessageDigestSpi.java --- The message digest service provider interface.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+
+/**
+ This is the Service Provider Interface (SPI) for MessageDigest
+ class in java.security. It provides the back end functionality
+ for the MessageDigest class so that it can compute message
+ hashes. The default hashes are SHA-1 and MD5. A message hash
+ takes data of arbitrary length and produces a unique number
+ representing it.
+
+ Cryptography service providers who want to implement their
+ own message digest hashes need only to subclass this class.
+
+ The implementation of a Cloneable interface is left to up to
+ the programmer of a subclass.
+
+ @version 0.0
+
+ @author Mark Benvenuto <ivymccough@worldnet.att.net>
+ */
+public abstract class MessageDigestSpi
+{
+ /**
+ Default constructor of the MessageDigestSpi class
+ */
+ public MessageDigestSpi()
+ {
+ }
+
+ /**
+ Returns the length of the digest. It may be overridden by the
+ provider to return the length of the digest. Default is to
+ return 0. It is concrete for backwards compatibility with JDK1.1
+ message digest classes.
+
+ @return Length of Digest in Bytes
+
+ @since 1.2
+ */
+ protected int engineGetDigestLength()
+ {
+ return 0;
+ }
+
+ /**
+ Updates the digest with the specified byte.
+
+ @param input the byte to update digest with
+ */
+ protected abstract void engineUpdate(byte input);
+
+
+ /**
+ Updates the digest with the specified bytes starting with the
+ offset and proceeding for the specified length.
+
+ @param input the byte array to update digest with
+ @param offset the offset of the byte to start with
+ @param len the number of the bytes to update with
+ */
+ protected abstract void engineUpdate(byte[]input, int offset, int len);
+
+ /**
+ Computes the final digest of the stored bytes and returns
+ them. It performs any necessary padding. The message digest
+ should reset sensitive data after performing the digest.
+
+ @return An array of bytes containing the digest
+ */
+ protected abstract byte[] engineDigest();
+
+ /**
+ Computes the final digest of the stored bytes and returns
+ them. It performs any necessary padding. The message digest
+ should reset sensitive data after performing the digest. This
+ method is left concrete for backwards compatibility with JDK1.1
+ message digest classes.
+
+ @param buf An array of bytes to store the digest
+ @param offset An offset to start storing the digest at
+ @param len The length of the buffer
+ @return Returns the length of the buffer
+
+ @since 1.2
+ */
+ protected int engineDigest(byte[]buf, int offset, int len)
+ throws DigestException
+ {
+ if (engineGetDigestLength() > len)
+ throw new DigestException("Buffer is too small.");
+
+ byte tmp[] = engineDigest();
+ if (tmp.length > len)
+ throw new DigestException("Buffer is too small");
+
+ System.arraycopy(tmp, 0, buf, offset, tmp.length);
+ return tmp.length;
+ }
+
+ /**
+ Resets the digest engine. Reinitializes internal variables
+ and clears sensitive data.
+ */
+ protected abstract void engineReset();
+
+ /**
+ Returns a clone of this class.
+
+ If cloning is not supported, then by default the class throws a
+ CloneNotSupportedException. The MessageDigestSpi provider
+ implementation has to overload this class in order to be
+ cloneable.
+ */
+ public Object clone() throws CloneNotSupportedException
+ {
+ if (this instanceof Cloneable)
+ return super.clone();
+ else
+ throw new CloneNotSupportedException();
+ }
+}
diff --git a/libjava/java/security/NoSuchAlgorithmException.java b/libjava/java/security/NoSuchAlgorithmException.java
index d51bf32..966398b 100644
--- a/libjava/java/security/NoSuchAlgorithmException.java
+++ b/libjava/java/security/NoSuchAlgorithmException.java
@@ -1,20 +1,56 @@
-/* Copyright (C) 1999 Free Software Foundation
+/* NoSuchAlgorithmException.java -- What it says
+ Copyright (C) 1998 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
package java.security;
-
-public class NoSuchAlgorithmException extends Exception
+
+/**
+ * This exception is thrown when the requested security algorithm is
+ * not available
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public class NoSuchAlgorithmException extends GeneralSecurityException
{
+ /**
+ * This method initializes a new instance of <code>NoSuchAlgorithmException</code>
+ * with no descriptive error message.
+ */
public NoSuchAlgorithmException()
{
super();
}
+ /**
+ * This method initializes a new instance of <code>NoSuchAlgorithmException</code>
+ * with a descriptive error message.
+ *
+ * @param msg The descriptive error message
+ */
public NoSuchAlgorithmException(String msg)
{
super(msg);
diff --git a/libjava/java/security/NoSuchProviderException.java b/libjava/java/security/NoSuchProviderException.java
index d7d0c85..051d48a 100644
--- a/libjava/java/security/NoSuchProviderException.java
+++ b/libjava/java/security/NoSuchProviderException.java
@@ -1,30 +1,56 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* NoSuchProviderException.java -- What it says
+ Copyright (C) 1998 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
-package java.security;
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 4, 2000.
- */
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
/**
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
+ * This exception is thrown when the requested security provider is
+ * not available.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
*/
-
public class NoSuchProviderException extends GeneralSecurityException
{
+ /**
+ * This method initializes a new instance of <code>NoSuchProviderException</code>
+ * with no descriptive error message.
+ */
public NoSuchProviderException()
{
super();
}
+ /**
+ * This method initializes a new instance of <code>NoSuchProviderException</code>
+ * with a descriptive error message.
+ *
+ * @param msg The descriptive error message.
+ */
public NoSuchProviderException(String msg)
{
super(msg);
diff --git a/libjava/java/security/Permission.java b/libjava/java/security/Permission.java
index 620d5b4..4866df35 100644
--- a/libjava/java/security/Permission.java
+++ b/libjava/java/security/Permission.java
@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -24,168 +24,126 @@ resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
-
package java.security;
import java.io.Serializable;
/**
- * This class is the abstract superclass of all classes that implement
- * the concept of a permission. A permission consists of a permission name
- * and optionally a list of actions that relate to the permission. The
- * actual meaning of the name of the permission is defined only in the
- * context of a subclass. It may name a resource to which access permissions
- * are granted (for example, the name of a file) or it might represent
- * something else entirely. Similarly, the action list only has meaning
- * within the context of a subclass. Some permission names may have no
- * actions associated with them. That is, you either have the permission
- * or you don't.
- *
- * The most important method in this class is <code>implies</code>. This
- * checks whether if one has this permission, then the specified
- * permission is also implied. As a conceptual example, consider the
- * permissions "Read All Files" and "Read File foo". The permission
- * "Read All Files" implies that the caller has permission to read the
- * file foo.
- *
- * <code>Permission</code>'s are not dynamic objects. Once created, a
- * <code>Permission</code>'s name and action list cannot be changed.
- *
- * @version 0.0
- *
- * @author Aaron M. Renn (arenn@urbanophile.com)
- */
-public abstract class Permission implements Guard, Serializable
-{
-
-/*************************************************************************/
-
-/*
- * Instance Variables
- */
-
-/**
- * This is the name assigned to this permission object.
- */
-protected String name; // Taken from the serializable form information
-
-/*************************************************************************/
-
-/*
- * Constructors
+ * This class is the abstract superclass of all classes that implement
+ * the concept of a permission. A permission consists of a permission name
+ * and optionally a list of actions that relate to the permission. The
+ * actual meaning of the name of the permission is defined only in the
+ * context of a subclass. It may name a resource to which access permissions
+ * are granted (for example, the name of a file) or it might represent
+ * something else entirely. Similarly, the action list only has meaning
+ * within the context of a subclass. Some permission names may have no
+ * actions associated with them. That is, you either have the permission
+ * or you don't.
+ *
+ * The most important method in this class is <code>implies</code>. This
+ * checks whether if one has this permission, then the specified
+ * permission is also implied. As a conceptual example, consider the
+ * permissions "Read All Files" and "Read File foo". The permission
+ * "Read All Files" implies that the caller has permission to read the
+ * file foo.
+ *
+ * <code>Permission</code>'s are not dynamic objects. Once created, a
+ * <code>Permission</code>'s name and action list cannot be changed.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
*/
-
-/**
- * This method initializes a new instance of <code>Permission</code> to
- * have the specified name.
- */
-public
-Permission(String name)
-{
- this.name = name;
-}
-
-/*************************************************************************/
-
-/*
- * Instance Methods
- */
-
-/**
- * This method returns the name of this <code>Permission</code>
- *
- * @return The name of this <code>Permission</code>
- */
-public String
-getName()
-{
- return(name);
-}
-
-/*************************************************************************/
-
-/**
- * This method returns the list of actions for this <code>Permission</code>
- * as a <code>String</code>.
- *
- * @return The action list for this <code>Permission</code>.
- */
-public abstract String
-getActions();
-
-/*************************************************************************/
-
-/**
- * This method implements the <code>Guard</code> interface for this class.
- * It calls the <code>checkPermission</code> method in
- * <code>SecurityManager</code> with this <code>Permission</code> as its
- * argument. This method returns silently if the security check succeeds
- * or throws an exception if it fails.
- *
- * @param obj The <code>Object</code> being guarded - ignored by this class
- *
- * @exception SecurityException If the security check fails
- */
-public void
-checkGuard(Object obj) throws SecurityException
-{
- SecurityManager sm = System.getSecurityManager();
-// if (sm != null)
-// sm.checkPermission(this);
-}
-
-/*************************************************************************/
-
-/**
- * This method tests whether this <code>Permission</code> implies that the
- * specified <code>Permission</code> is also granted.
- *
- * @param perm The <code>Permission</code> to test against
- *
- * @return <code>true</code> if the specified <code>Permission</code> is implied by this one, <code>false</code> otherwise.
- */
-public abstract boolean
-implies(Permission perm);
-
-/*************************************************************************/
-
-/**
- * This method returns a hash code for this <code>Permission</code>.
- *
- * @return A hash value.
- */
-public abstract int
-hashCode();
-
-/*************************************************************************/
-
-/**
- * This method returns a <code>String</code> representation of this
- * <code>Permission</code> object.
- *
- * @return This object as a <code>String</code>.
- */
-public String
-toString()
-{
- return("'\"" + getClass().getName() + "\" \"" + getName() +
- "\"" + " \"" + getActions() + "\")'");
-}
-
-/*************************************************************************/
-
-/**
- * This method returns an empty <code>PermissionCollection</code> object
- * that can store permissions of this type, or <code>null</code> if no
- * such collection is defined.
- *
- * @return A new <code>PermissionCollection</code>
- */
-public PermissionCollection
-newPermissionCollection()
+public abstract class Permission implements Guard, Serializable
{
- return(null);
+ /**
+ * This is the name assigned to this permission object.
+ */
+ protected String name; // Taken from the serializable form information
+
+ /**
+ * This method initializes a new instance of <code>Permission</code> to
+ * have the specified name.
+ */
+ public Permission(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * This method returns the name of this <code>Permission</code>
+ *
+ * @return The name of this <code>Permission</code>
+ */
+ public String getName()
+ {
+ return (name);
+ }
+
+ /**
+ * This method returns the list of actions for this <code>Permission</code>
+ * as a <code>String</code>.
+ *
+ * @return The action list for this <code>Permission</code>.
+ */
+ public abstract String getActions();
+
+ /**
+ * This method implements the <code>Guard</code> interface for this class.
+ * It calls the <code>checkPermission</code> method in
+ * <code>SecurityManager</code> with this <code>Permission</code> as its
+ * argument. This method returns silently if the security check succeeds
+ * or throws an exception if it fails.
+ *
+ * @param obj The <code>Object</code> being guarded - ignored by this class
+ *
+ * @exception SecurityException If the security check fails
+ */
+ public void checkGuard(Object obj) throws SecurityException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(this);
+ }
+
+ /**
+ * This method tests whether this <code>Permission</code> implies that the
+ * specified <code>Permission</code> is also granted.
+ *
+ * @param perm The <code>Permission</code> to test against
+ *
+ * @return <code>true</code> if the specified <code>Permission</code> is implied by this one, <code>false</code> otherwise.
+ */
+ public abstract boolean implies(Permission perm);
+
+ /**
+ * This method returns a hash code for this <code>Permission</code>.
+ *
+ * @return A hash value.
+ */
+ public abstract int hashCode();
+
+ /**
+ * This method returns a <code>String</code> representation of this
+ * <code>Permission</code> object.
+ *
+ * @return This object as a <code>String</code>.
+ */
+ public String toString()
+ {
+ return ("'\"" + getClass().getName() + "\" \"" + getName() +
+ "\"" + " \"" + getActions() + "\")'");
+ }
+
+ /**
+ * This method returns an empty <code>PermissionCollection</code> object
+ * that can store permissions of this type, or <code>null</code> if no
+ * such collection is defined.
+ *
+ * @return A new <code>PermissionCollection</code>
+ */
+ public PermissionCollection newPermissionCollection()
+ {
+ return null;
+ }
}
-
-} // class Permission
-
diff --git a/libjava/java/security/PermissionCollection.java b/libjava/java/security/PermissionCollection.java
index 08a9c49..f709a0a 100644
--- a/libjava/java/security/PermissionCollection.java
+++ b/libjava/java/security/PermissionCollection.java
@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -24,184 +24,140 @@ resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
-
package java.security;
import java.io.Serializable;
import java.util.Enumeration;
-/**
- * This class models a group of Java permissions. It has convenient
- * methods for determining whether or not a given permission is implied
- * by any of the permissions in this collection.
- * <p>
- * Some care must be taken in storing permissions. First, a collection of
- * the appropriate type must be created. This is done by calling the
- * <code>newPermissionCollection</code> method on an object of the
- * permission class you wish to add to the collection. If this method
- * returns <code>null</code>, any type of <code>PermissionCollection</code>
- * can be used to store permissions of that type. However, if a
- * <code>PermissionCollection</code> collection object is returned, that
- * type must be used.
- * <p>
- * The <code>PermissionCollection</code>'s returned
- * by the <code>newPermissionCollection</code> instance in a subclass of
- * <code>Permission</code> is a homogeneous collection. It only will
- * hold permissions of one specified type - instances of the class that
- * created it. Not all <code>PermissionCollection</code> subclasses
- * have to hold permissions of only one type however. For example,
- * the <code>Permissions</code> class holds permissions of many types.
- * <p>
- * Since the <code>newPermissionCollection</code> in <code>Permission</code>
- * itself returns <code>null</code>, by default a permission can be stored
- * in any type of collection unless it overrides that method to create its
- * own collection type.
- *
- * @version 0.0
- *
- * @author Aaron M. Renn (arenn@urbanophile.com)
- */
-public abstract class PermissionCollection extends Object implements Serializable
-{
-
-/*************************************************************************/
-
-/*
- * Class Variables
- */
-
-public static final String linesep = null;
-
-static
-{
- String linesep = System.getProperty("line.separator");
- if (linesep == null);
- linesep = "\n";
-}
-
-/*************************************************************************/
-
-/*
- * Instance Variables
- */
-
-/**
- * Indicates whether or not this collection is read only.
- */
-private boolean readOnly;
-
-/*************************************************************************/
-
-/*
- * Constructors
- */
-
-/**
- * This method initializes a new instance of <code>PermissionCollection</code>.
- * This is provided only as a default constructor and does nothing in this
- * class.
- */
-public
-PermissionCollection()
+ /**
+ * This class models a group of Java permissions. It has convenient
+ * methods for determining whether or not a given permission is implied
+ * by any of the permissions in this collection.
+ * <p>
+ * Some care must be taken in storing permissions. First, a collection of
+ * the appropriate type must be created. This is done by calling the
+ * <code>newPermissionCollection</code> method on an object of the
+ * permission class you wish to add to the collection. If this method
+ * returns <code>null</code>, any type of <code>PermissionCollection</code>
+ * can be used to store permissions of that type. However, if a
+ * <code>PermissionCollection</code> collection object is returned, that
+ * type must be used.
+ * <p>
+ * The <code>PermissionCollection</code>'s returned
+ * by the <code>newPermissionCollection</code> instance in a subclass of
+ * <code>Permission</code> is a homogeneous collection. It only will
+ * hold permissions of one specified type - instances of the class that
+ * created it. Not all <code>PermissionCollection</code> subclasses
+ * have to hold permissions of only one type however. For example,
+ * the <code>Permissions</code> class holds permissions of many types.
+ * <p>
+ * Since the <code>newPermissionCollection</code> in <code>Permission</code>
+ * itself returns <code>null</code>, by default a permission can be stored
+ * in any type of collection unless it overrides that method to create its
+ * own collection type.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public abstract class PermissionCollection extends Object implements
+ Serializable
{
- ;
+ public static final String linesep = null;
+
+ static
+ {
+ String linesep = System.getProperty("line.separator");
+ if (linesep == null);
+ linesep = "\n";
+ }
+
+ /**
+ * Indicates whether or not this collection is read only.
+ */
+ private boolean readOnly;
+
+ /**
+ * This method initializes a new instance of <code>PermissionCollection</code>.
+ * This is provided only as a default constructor and does nothing in this
+ * class.
+ */
+ public PermissionCollection()
+ {
+ }
+
+ /**
+ * This method tests whether or not this <code>PermissionCollection</code>
+ * object is read only.
+ *
+ * @return <code>true</code> if this collection is read only, <code>false</code> otherwise
+ */
+ public boolean isReadOnly()
+ {
+ return (readOnly);
+ }
+
+ /**
+ * This method sets this <code>PermissionCollection</code> object to be
+ * read only. No further permissions can be added to it after calling this
+ * method.
+ */
+ public void setReadOnly()
+ {
+ readOnly = true;
+ }
+
+ /**
+ * This method adds a new <code>Permission</code> object to the collection.
+ *
+ * @param perm The <code>Permission</code> to add.
+ *
+ * @exception SecurityException If the collection is marked read only.
+ * @exception IllegalArgumentException If a permission of the specified type cannot be added
+ */
+ public abstract void
+ add(Permission perm) throws SecurityException, IllegalArgumentException;
+
+ /**
+ * This method returns an <code>Enumeration</code> of all the objects in
+ * this collection.
+ *
+ * @return An <code>Enumeration</code> of this collection's objects.
+ */
+ public abstract Enumeration elements();
+
+ /**
+ * This method tests whether the specified <code>Permission</code> object is
+ * implied by this collection of <code>Permission</code> objects.
+ *
+ * @param perm The <code>Permission</code> object to test.
+ *
+ * @return <code>true</code> if the specified <code>Permission</code> is implied by this collection, <code>false</code> otherwise.
+ */
+ public abstract boolean implies(Permission perm);
+
+ /**
+ * This method returns a <code>String</code> representation of this
+ * collection. It will print the class name and has code in the same
+ * manner as <code>Object.toString()</code> then print a listing of all
+ * the <code>Permission</code> objects contained.
+ *
+ * @return A <code>String</code> representing this object.
+ */
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer("");
+
+ sb.append(super.toString() + " (" + linesep);
+ Enumeration e = elements();
+ while (e.hasMoreElements())
+ {
+ Object obj = e.nextElement();
+ if (obj instanceof Permission)
+ sb.append(((Permission) obj).toString() + linesep);
+ }
+
+ sb.append(")" + linesep);
+ return (sb.toString());
+ }
}
-
-/*************************************************************************/
-
-/*
- * Instance Methods
- */
-
-/**
- * This method tests whether or not this <code>PermissionCollection</code>
- * object is read only.
- *
- * @return <code>true</code> if this collection is read only, <code>false</code> otherwise
- */
-public boolean
-isReadOnly()
-{
- return(readOnly);
-}
-
-/*************************************************************************/
-
-/**
- * This method sets this <code>PermissionCollection</code> object to be
- * read only. No further permissions can be added to it after calling this
- * method.
- */
-public void
-setReadOnly()
-{
- readOnly = true;
-}
-
-/*************************************************************************/
-
-/**
- * This method adds a new <code>Permission</code> object to the collection.
- *
- * @param perm The <code>Permission</code> to add.
- *
- * @exception SecurityException If the collection is marked read only.
- * @exception IllegalArgumentException If a permission of the specified type cannot be added
- */
-public abstract void
-add(Permission perm) throws SecurityException, IllegalArgumentException;
-
-/*************************************************************************/
-
-/**
- * This method returns an <code>Enumeration</code> of all the objects in
- * this collection.
- *
- * @return An <code>Enumeration</code> of this collection's objects.
- */
-public abstract Enumeration
-elements();
-
-/*************************************************************************/
-
-/**
- * This method tests whether the specified <code>Permission</code> object is
- * implied by this collection of <code>Permission</code> objects.
- *
- * @param perm The <code>Permission</code> object to test.
- *
- * @return <code>true</code> if the specified <code>Permission</code> is implied by this collection, <code>false</code> otherwise.
- */
-public abstract boolean
-implies(Permission perm);
-
-/*************************************************************************/
-
-/**
- * This method returns a <code>String</code> representation of this
- * collection. It will print the class name and has code in the same
- * manner as <code>Object.toString()</code> then print a listing of all
- * the <code>Permission</code> objects contained.
- *
- * @return A <code>String</code> representing this object.
- */
-public String
-toString()
-{
- StringBuffer sb = new StringBuffer("");
-
- sb.append(super.toString() + " (" + linesep);
- Enumeration e = elements();
- while (e.hasMoreElements())
- {
- Object obj = e.nextElement();
- if (obj instanceof Permission)
- sb.append(((Permission)obj).toString() + linesep);
- }
-
- sb.append(")" + linesep);
- return(sb.toString());
-}
-
-} // class PermissionCollection
-
diff --git a/libjava/java/security/Permissions.java b/libjava/java/security/Permissions.java
new file mode 100644
index 0000000..44bc3d3
--- /dev/null
+++ b/libjava/java/security/Permissions.java
@@ -0,0 +1,257 @@
+/* Permissions.java -- A collection of permission collections
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+
+import java.io.Serializable;
+import java.util.Hashtable;
+import java.util.Enumeration;
+import java.util.NoSuchElementException;
+
+/**
+ * This class is a heterogeneous collection of permissions. It is
+ * organized as a collection of <code>PermissionCollection</code>'s stored
+ * in a hashtable. Each individual <code>PermissionCollection</code>
+ * contains permissions of a single type. If a specific type of
+ * <code>Permission</code> does not provide a collection type to use
+ * via its <code>newPermissionCollection</code> method, then a default
+ * collection type which stores its permissions in a hash table will be
+ * used.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public class Permissions extends PermissionCollection implements Serializable
+{
+ /**
+ * Holds instances of <code>AllPermission</code>.
+ */
+ private PermissionCollection allPermission;
+
+ /**
+ * This is the <code>Hashtable</code> that contains our collections.
+ */
+ Hashtable perms = new Hashtable();
+
+ /**
+ * This method initializes a new instance of <code>Permissions</code>.
+ */
+ public Permissions()
+ {
+ }
+
+ /**
+ * This method adds a new <code>Permission</code> to this collection. It
+ * will be stored in a <code>PermissionCollection</code> of the appropriate
+ * type, as determined by calling <code>newPermissionCollection</code> on
+ * the specified permission (if an appropriate collection does not already
+ * exist). If this object does not specify a particular type of collection,
+ * a default collection which stores in permissions in a hash table will
+ * be used.
+ *
+ * @param perm The <code>Permission</code> object to be added to this collection.
+ *
+ * @exception SecurityException If this collection is marked as read only.
+ * @exception IllegalArgumentException If the specified <code>Permission</code> cannot be added to this collection
+ */
+ public void add(Permission perm)
+ throws SecurityException, IllegalArgumentException
+ {
+ if (isReadOnly())
+ throw new SecurityException("PermissionCollection is read only");
+
+ if (perm instanceof AllPermission)
+ {
+ if (allPermission == null)
+ {
+ allPermission = new
+ DefaultPermissionCollection("java.security.AllPermission");
+
+ perms.put("java.security.AllPermission", allPermission);
+ }
+ }
+ else
+ {
+ Object obj = perms.get(perm.getClass().getName());
+ if (obj != null)
+ {
+ if (!(obj instanceof PermissionCollection))
+ throw new RuntimeException("Internal error in Permissions");
+
+ ((PermissionCollection) obj).add(perm);
+ }
+ else
+ {
+ PermissionCollection pc = perm.newPermissionCollection();
+ if (pc == null)
+ pc = new DefaultPermissionCollection(perm.getClass().getName());
+
+ pc.add(perm);
+
+ perms.put(perm.getClass().getName(), pc);
+ }
+ }
+ }
+
+ /**
+ * This method tests whether or not the specified <code>Permission</code>
+ * is implied by this <code>PermissionCollection</code>.
+ *
+ * @param perm The <code>Permission</code> to test.
+ *
+ * @return <code>true</code> if the specified permission is implied by this <code>PermissionCollection</code>, or <code>false</code> otherwise.
+ */
+ public boolean implies(Permission perm)
+ {
+ if (allPermission != null)
+ return (true);
+
+ Object obj = perms.get(perm.getClass().getName());
+ if (obj == null)
+ return (false);
+
+ if (!(obj instanceof PermissionCollection))
+ return (false);
+
+ return (((PermissionCollection) obj).implies(perm));
+ }
+
+ /**
+ * This method returns an <code>Enumeration</code> which contains a
+ * list of all <code>Permission</code> objects contained in this
+ * collection.
+ *
+ * @return An <code>Enumeration</code> of this collection's elements.
+ */
+ public Enumeration elements()
+ {
+ return new Enumeration()
+ {
+ Enumeration main_enum = perms.elements();
+ Enumeration sub_enum;
+
+ public boolean hasMoreElements()
+ {
+ if (sub_enum == null)
+ if (main_enum == null)
+ return (false);
+ else
+ {
+ if (!main_enum.hasMoreElements())
+ return (false);
+ else
+ {
+ try
+ {
+ PermissionCollection pc =
+ (PermissionCollection) main_enum.nextElement();
+ sub_enum = pc.elements();
+ }
+ catch (NoSuchElementException e)
+ {
+ return (false);
+ }
+ }
+ }
+ else if (!sub_enum.hasMoreElements())
+ {
+ sub_enum = null;
+ return (hasMoreElements());
+ }
+
+ return (true);
+ }
+
+ public Object nextElement() throws NoSuchElementException
+ {
+ if (!hasMoreElements())
+ throw new NoSuchElementException();
+
+ return (sub_enum.nextElement());
+ }
+ };
+ }
+
+ static class DefaultPermissionCollection extends PermissionCollection
+ implements Serializable
+ {
+
+ // Type of Permission we can store
+ private Class permcls;
+
+ // Hashtable where we store permissions.
+ private Hashtable perms = new Hashtable();
+
+ DefaultPermissionCollection(String permtype) throws IllegalArgumentException
+ {
+ try
+ {
+ permcls = Class.forName(permtype);
+ }
+ catch(ClassNotFoundException e)
+ {
+ throw new IllegalArgumentException(e.getMessage());
+ }
+ }
+
+ public void add(Permission perm)
+ throws SecurityException, IllegalArgumentException
+ {
+ if (isReadOnly())
+ throw new SecurityException("PermissionCollection is read only");
+
+ if (!permcls.isInstance(perm))
+ throw new IllegalArgumentException("Wrong permission type: " +
+ perm.getClass().getName());
+
+ if (perms.get(perm.getName()) != null)
+ throw new IllegalArgumentException("Duplicate permission: " +
+ perm.getName());
+
+ perms.put(perm.getName(), perm);
+ }
+
+ public boolean implies(Permission perm)
+ {
+ Object obj = perms.get(perm.getName());
+ if (obj == null)
+ return(false);
+
+ if (!(obj instanceof Permission))
+ return(false);
+
+ Permission p = (Permission)obj;
+
+ return(p.implies(perm));
+ }
+
+ public Enumeration elements()
+ {
+ return(perms.elements());
+ }
+ }
+}
diff --git a/libjava/java/security/Policy.java b/libjava/java/security/Policy.java
new file mode 100644
index 0000000..3a4a493
--- /dev/null
+++ b/libjava/java/security/Policy.java
@@ -0,0 +1,150 @@
+/* Policy.java --- Policy Manager Class
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+
+/**
+ Policy is an abstract class for managing the system security
+ policy for the Java application environment. It specifies
+ which permissions are available for code from various
+ sources. The security policy is represented through a
+ subclass of Policy.
+
+ Only one Policy is in effect at any time. ProtectionDomain
+ initializes itself with information from this class on the
+ set of permssions to grant.
+
+ The location for the actual Policy could be anywhere in any
+ form because it depends on the Policy implementation. The
+ default system is in a flat ASCII file or it could be in a
+ database.
+
+ The current installed Policy can be accessed with getPolicy
+ and changed with setPolicy if the code has the correct
+ permissions.
+
+ The refresh method causes the Policy class to refresh/reload
+ its configuration. The method used to refresh depends on the
+ Policy implementation.
+
+ When a protection domain initializes its permissions it uses
+ code like:
+ <code>
+ policy = Policy.getPolicy();
+ permissionCollection perms = policy.getPermissions(MyCodeSource)
+ </code>
+ The protection domain passes the Policy handler a CodeSource
+ object which contains the codebase URL and public key. The
+ Policy implementation then returns the proper set of
+ permissions for the CodeSource.
+
+ The default Policy implementation can be changed by setting
+ the "policy.provider" security provider in java.security
+ to the correct Policy implementation class.
+
+ @author Mark Benvenuto
+
+ @since JDK 1.2
+ */
+public abstract class Policy
+{
+ // FIXME: The class name of the Policy provider should really be sourced
+ // from the "java.security" configuration file. For now, just hard-code
+ // a stub implementation.
+ static private Policy currentPolicy
+ = new gnu.java.security.provider.DefaultPolicy();
+
+ /**
+ Constructs a new Policy class.
+ */
+ public Policy()
+ {
+ }
+
+ /**
+ Gets the currently installed Policy handler. The value should
+ not be cached as it can be changed by setPolicy. This
+ function first calls <code>SecurityManager.checkPermission</code>
+ with <code>SecurityPermission("getPolicy")</code> to check
+ if the caller has Permission to get the current Policy.
+
+ @return the current Policy
+
+ @throws SecurityException if the security manager exists
+ the caller does not have permission to
+ <code>getPolicy</code>.
+ */
+ public static Policy getPolicy()
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(new SecurityPermission("getPolicy"));
+
+ return currentPolicy;
+ }
+
+ /**
+ Sets the currently installed Policy handler. This
+ function first calls <code>SecurityManager.checkPermission</code>
+ with <code>SecurityPermission("setPolicy")</code> to check
+ if the caller has Permission to get the current Policy.
+
+ @param policy the new Policy to use
+
+ @throws SecurityException if the security manager exists
+ the caller does not have permission to
+ <code>getPolicy</code>.
+ */
+ public static void setPolicy(Policy policy)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(new SecurityPermission("setPolicy"));
+
+ currentPolicy = policy;
+ }
+
+
+ /**
+ Evalutes the global policy and returns a set of Permissions
+ allowed for the specified CodeSource.
+
+ @param codesource The CodeSource to get Permission for
+
+ @return a set of permissions for codesource specified by
+ the current policy
+
+ @throws SecurityException if the current thread does not
+ have permission to call <code>getPermissions</code>
+ */
+ public abstract PermissionCollection getPermissions(CodeSource codesource);
+
+ /**
+ Refreshes and/or reloads the current Policy. The actual
+ behavior of this method depends on the implementation.
+ */
+ public abstract void refresh();
+}
diff --git a/libjava/java/security/Principal.java b/libjava/java/security/Principal.java
index 007ba1a..cdba3a1 100644
--- a/libjava/java/security/Principal.java
+++ b/libjava/java/security/Principal.java
@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -24,62 +24,48 @@ resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
-
package java.security;
/**
- * This interface models an entity (such as a user or a certificate authority)
- * for the purposes of applying the Java security model.
- *
- * @version 0.0
- *
- * @author Aaron M. Renn (arenn@urbanophile.com)
- */
+ * This interface models an entity (such as a user or a certificate authority)
+ * for the purposes of applying the Java security model.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
public interface Principal
{
-
-/**
- * This method returns a <code>String</code> that names this
- * <code>Principal</code>.
- *
- * @return The name of this <code>Principal</code>.
- */
-public abstract String
-getName();
-
-/*************************************************************************/
-
-/**
- * This method tests another <code>Principal</code> object for equality
- * with this one.
- *
- * @param obj The <code>Object</code> (which is a <code>Principal</code>) to test for equality against.
- *
- * @return <code>true</code> if the specified <code>Principal</code> is equal to this one, <code>false</code> otherwise.
- */
-public abstract boolean
-equals(Object obj);
-
-/*************************************************************************/
-
-/**
- * This method returns a hash code value for this <code>Principal</code>.
- *
- * @return A hash value
- */
-public abstract int
-hashCode();
-
-/*************************************************************************/
-
-/**
- * This method returns a <code>String</code> representation of this
- * <code>Principal</code>.
- *
- * @return This <code>Principal</code> represented as a <code>String</code>.
- */
-public abstract String
-toString();
-
-} // interface Principal
-
+ /**
+ * This method returns a <code>String</code> that names this
+ * <code>Principal</code>.
+ *
+ * @return The name of this <code>Principal</code>.
+ */
+ public abstract String getName();
+
+ /**
+ * This method tests another <code>Principal</code> object for equality
+ * with this one.
+ *
+ * @param obj The <code>Object</code> (which is a <code>Principal</code>) to test for equality against.
+ *
+ * @return <code>true</code> if the specified <code>Principal</code> is equal to this one, <code>false</code> otherwise.
+ */
+ public abstract boolean equals(Object obj);
+
+ /**
+ * This method returns a hash code value for this <code>Principal</code>.
+ *
+ * @return A hash value
+ */
+ public abstract int hashCode();
+
+ /**
+ * This method returns a <code>String</code> representation of this
+ * <code>Principal</code>.
+ *
+ * @return This <code>Principal</code> represented as a <code>String</code>.
+ */
+ public abstract String toString();
+}
diff --git a/libjava/java/security/PrivateKey.java b/libjava/java/security/PrivateKey.java
index 13b9be3..7a736a5 100644
--- a/libjava/java/security/PrivateKey.java
+++ b/libjava/java/security/PrivateKey.java
@@ -1,24 +1,40 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* PrivateKey.java -- "Super-interface" for all private keys
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+
+ As a special exception, if you link this library with other files to
+ produce an executable, this library does not by itself cause the
+ resulting executable to be covered by the GNU General Public License.
+ This exception does not however invalidate any other reasons why the
+ executable file might be covered by the GNU General Public License. */
- 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.
+ * This interface specified no methods. In simply provides a common
+ * super-interface for all algorithm specific private key values.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
*/
-
-public interface PrivateKey extends Key
+public interface PrivateKey
{
- // This interface contains no methods or constants. It merely serves
- // to group (and provide type safety for) all private key interfaces.
}
diff --git a/libjava/java/security/PrivilegedAction.java b/libjava/java/security/PrivilegedAction.java
new file mode 100644
index 0000000..c061d5f
--- /dev/null
+++ b/libjava/java/security/PrivilegedAction.java
@@ -0,0 +1,49 @@
+/* PrivilegedAction.java -- Perform a privileged action
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+
+/**
+ * This interface specifes a single <code>run</code> method that
+ * executes a privileged operation. This method is called by
+ * <code>AccessController.doPrivileged()</code> after that method
+ * activiates the required privileges.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public interface PrivilegedAction
+{
+ /**
+ * This method performs an operation that requires higher privileges to
+ * perform. It is called when a section of code invokes
+ * <code>AccessController.doPrivileged()</code>.
+ *
+ * @return obj An implementation dependent return value
+ */
+ public abstract Object run();
+}
diff --git a/libjava/java/security/PrivilegedActionException.java b/libjava/java/security/PrivilegedActionException.java
new file mode 100644
index 0000000..55f2e17
--- /dev/null
+++ b/libjava/java/security/PrivilegedActionException.java
@@ -0,0 +1,102 @@
+/* PrivilegedActionException.java -- An exception occurred in a
+ privileged action.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+/**
+ * This exception is thrown when an exception is thrown during a
+ * privileged action being performed with the
+ * <code>AccessController.doPrivileged()</code> method. It wrappers the
+ * actual exception thrown in the privileged code.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public class PrivilegedActionException extends Exception
+{
+
+ /**
+ * This is the actual exception that occurred
+ */
+ private Exception e;
+
+ /**
+ * This method initializes a new instance of <code>PrivilegedActionException</code>
+ * that wrappers the specified <code>Exception</code>.
+ *
+ * @param e The <code>Exception</code> to wrapper
+ */
+ public PrivilegedActionException(Exception e)
+ {
+ this.e = e;
+ }
+
+ /**
+ * This method returns the underlying <code>Exception</code> that caused
+ * this exception to be raised.
+ *
+ * @return The wrappered <code>Exception</code>.
+ */
+ public Exception getException()
+ {
+ return (e);
+ }
+
+ /**
+ * This method prints the stack trace of the wrappered exception.
+ */
+ public void printStackTrace()
+ {
+ e.printStackTrace();
+ }
+
+ /**
+ * This method prints the stack trace of the wrappered exception to the
+ * specified <code>PrintStream</code>.
+ *
+ * @param ps The <code>PrintStream</code> to print the stack trace to.
+ */
+ public void printStackTrace(PrintStream ps)
+ {
+ e.printStackTrace(ps);
+ }
+
+ /**
+ * This method prints the stack trace of the wrappered exception to the
+ * specified <code>PrintWriter</code>.
+ *
+ * @param pw The <code>PrintWriter</code> to print the stack trace to.
+ */
+ public void printStackTrace(PrintWriter pw)
+ {
+ e.printStackTrace(pw);
+ }
+}
diff --git a/libjava/java/security/PrivilegedExceptionAction.java b/libjava/java/security/PrivilegedExceptionAction.java
new file mode 100644
index 0000000..2ce97f5
--- /dev/null
+++ b/libjava/java/security/PrivilegedExceptionAction.java
@@ -0,0 +1,52 @@
+/* PrivilegedExceptionAction.java -- Perform a privileged operation
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+
+/**
+ * This interface defines a method that is called by
+ * <code>AccessController.doPrivileged()</code> in order to perform a
+ * privileged operation with higher privileges enabled. This interface
+ * differs from <code>PrivilegedAction</code> in that the <code>run</code>
+ * method in this interface may throw a checked exception.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public interface PrivilegedExceptionAction
+{
+ /**
+ * This method performs an operation that requires higher privileges to
+ * successfully complete. It is called when a section of code invokes
+ * <code>AccessController.doPrivileged()</code>.
+ *
+ * @return obj An implementation defined return value.
+ *
+ * @exception Exception An implementation specific exception.
+ */
+ public abstract Object run() throws Exception;
+}
diff --git a/libjava/java/security/ProtectionDomain.java b/libjava/java/security/ProtectionDomain.java
new file mode 100644
index 0000000..94eb141
--- /dev/null
+++ b/libjava/java/security/ProtectionDomain.java
@@ -0,0 +1,132 @@
+/* ProtectionDomain.java -- A security domain
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+
+/**
+ * This class represents a group of classes, along with the permissions
+ * they are granted. The classes are identified by a <code>CodeSource</code>.
+ * Thus, any class loaded from the specified <code>CodeSource</code> is
+ * treated as part of this domain. The set of permissions is represented
+ * by a <code>PermissionCollection</code>.
+ * <p>
+ * Every class in the system will belong to one and only one
+ * <code>ProtectionDomain</code>.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public class ProtectionDomain
+{
+ private static final String linesep = System.getProperty("line.separator");
+
+ /**
+ * This is the <code>CodeSource</code> for this protection domain
+ */
+ private CodeSource code_source;
+
+ /**
+ * This is the set of permissions granted to this domain
+ */
+ private PermissionCollection perms;
+
+ /**
+ * This method initializes a new instance of <code>ProtectionDomain</code>
+ * representing the specified <code>CodeSource</code> and permission set.
+ * No permissions may be added to the <code>PermissionCollection</code>
+ * and this contructor will call the <code>setReadOnly</code> method on
+ * the specified permission set.
+ *
+ * @param code_source The <code>CodeSource</code> for this domain
+ * @param perms The permission set for this domain
+ *
+ * @see java.security.PermissionCollection#setReadOnly()
+ */
+ public ProtectionDomain(CodeSource code_source, PermissionCollection perms)
+ {
+ this.code_source = code_source;
+ this.perms = perms;
+ if (perms != null)
+ perms.setReadOnly();
+ }
+
+ /**
+ * This method returns the <code>CodeSource</code> for this domain.
+ *
+ * @return This domain's <code>CodeSource</code>.
+ */
+ public final CodeSource getCodeSource()
+ {
+ return code_source;
+ }
+
+ /**
+ * This method returns the set of permissions granted to this domain.
+ *
+ * @return The permission set for this domain
+ */
+ public final PermissionCollection getPermissions()
+ {
+ return perms;
+ }
+
+ /**
+ * This method tests whether or not the specified <code>Permission</code> is
+ * implied by the set of permissions granted to this domain.
+ *
+ * @param perm The <code>Permission</code> to test.
+ *
+ * @return <code>true</code> if the specified <code>Permission</code> is implied for this domain, <code>false</code> otherwise.
+ */
+ public boolean implies(Permission perm)
+ {
+ PermissionCollection pc = getPermissions();
+ if (pc == null)
+ return (false);
+
+ return (pc.implies(perm));
+ }
+
+ /**
+ * This method returns a <code>String</code> representation of this
+ * object. It will print the <code>CodeSource</code> and
+ * permission set associated with this domain.
+ *
+ * @return A <code>String</code> representation of this object.
+ */
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer("");
+
+ sb.append(super.toString() + " (" + linesep);
+ sb.append(code_source.toString());
+ sb.append(perms.toString());
+ sb.append(")" + linesep);
+
+ return sb.toString();
+ }
+}
diff --git a/libjava/java/security/Provider.java b/libjava/java/security/Provider.java
index fbaa3c0..7668225 100644
--- a/libjava/java/security/Provider.java
+++ b/libjava/java/security/Provider.java
@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -24,176 +24,133 @@ resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
-
package java.security;
import java.io.Serializable;
import java.util.Properties;
/**
- * This class represents a Java security architecture service provider.
- * The services provided by a such a provider can range from security
- * algorithms to key generation.
- * <p>
- * Providers are installed by name and verion number. There is one
- * standard provider supplied with the class library. This is the
- * "GNU" provider, which can also be accessed by the alias "SUN" for
- * compatibility with the JDK.
- *
- * @version 0.0
- *
- * @author Aaron M. Renn (arenn@urbanophile.com)
- */
-public abstract class Provider extends Properties implements Serializable
-{
-
-/*************************************************************************/
-
-/*
- * Instance Variables
+ * This class represents a Java security architecture service provider.
+ * The services provided by a such a provider can range from security
+ * algorithms to key generation.
+ * <p>
+ * Providers are installed by name and verion number. There is one
+ * standard provider supplied with the class library. This is the
+ * "GNU" provider, which can also be accessed by the alias "SUN" for
+ * compatibility with the JDK.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
*/
-
-/**
- * This is a textual description of the provider
- */
-private String info;
-
-/**
- * This is the name of the provider
- */
-private String name;
-
-/**
- * This is the version number of the provider
- */
-private double version;
-
-private static final long serialVersionUID = -4298000515446427739L;
-
-/*************************************************************************/
-
-/*
- * Constructors
- */
-
-/**
- * This method initializes a new instance of <code>Provider</code> to have
- * the specified name, version, and description information.
- *
- * @param name The name to assign to this <code>Provider</code>.
- * @param version The version number for this <code>Provider</code>.
- * @param info A textual description of this provider.
- */
-protected
-Provider(String name, double version, String info)
-{
- this.name = name;
- this.version = version;
- this.info = info;
-}
-
-/*************************************************************************/
-
-/*
- * Instance Methods
- */
-
-/**
- * This method returns the name assigned to this <code>Provider</code>.
- *
- * @return The <code>Provider</code>'s name.
- */
-public String
-getName()
-{
- return(name);
-}
-
-/*************************************************************************/
-
-/**
- * This method retunrs the version number of this <code>Provider</code>.
- *
- * @return The <code>Provider</code>'s version number.
- */
-public double
-getVersion()
-{
- return(version);
-}
-
-/*************************************************************************/
-
-/**
- * This method returns a textual description of the <code>Provider</code>.
- *
- * @return A description of the <code>Provider</code>.
- */
-public String
-getInfo()
-{
- return(info);
-}
-
-/*************************************************************************/
-
-/**
- * This method sets the specified key to have the specified value.
- *
- * @param key The property key
- * @param value The property value
- *
- * @return The previous value for this key, or <code>null</code> if no previous value.
- */
-public Object
-put(Object key, Object value)
-{
- return(super.put(key, value));
-}
-
-/*************************************************************************/
-
-/**
- * This method removes the specified key entry (and its associated value)
- * from the property mapping list.
- *
- * @param key The key to remove
- *
- * @return The previous value for this key, or <code>null</code> if no previous value.
- */
-public Object
-remove(Object key)
-{
- return(super.remove(key));
-}
-
-/*************************************************************************/
-
-/**
- * This method clears the entire property list such that it no longer
- * contains the properties used to look up the services provided by
- * the <code>Provider</code>.
- */
-public void
-clear()
-{
- super.clear();
-}
-
-/*************************************************************************/
-
-/**
- * This method returns a <code>String</code> representation of this
- * object. This will include the <code>Provider</code> name and
- * version number.
- *
- * @return A <code>String</code> representation of this object.
- */
-public String
-toString()
+public abstract class Provider extends Properties implements Serializable
{
- return(getClass().getName() + ": name=" + getName() + " version=" + version);
+ /**
+ * This is a textual description of the provider
+ */
+ private String info;
+
+ /**
+ * This is the name of the provider
+ */
+ private String name;
+
+ /**
+ * This is the version number of the provider
+ */
+ private double version;
+
+ /**
+ * This method initializes a new instance of <code>Provider</code> to have
+ * the specified name, version, and description information.
+ *
+ * @param name The name to assign to this <code>Provider</code>.
+ * @param version The version number for this <code>Provider</code>.
+ * @param info A textual description of this provider.
+ */
+ protected Provider(String name, double version, String info)
+ {
+ this.name = name;
+ this.version = version;
+ this.info = info;
+ }
+
+ /**
+ * This method returns the name assigned to this <code>Provider</code>.
+ *
+ * @return The <code>Provider</code>'s name.
+ */
+ public String getName()
+ {
+ return (name);
+ }
+
+ /**
+ * This method retunrs the version number of this <code>Provider</code>.
+ *
+ * @return The <code>Provider</code>'s version number.
+ */
+ public double getVersion()
+ {
+ return (version);
+ }
+
+ /**
+ * This method returns a textual description of the <code>Provider</code>.
+ *
+ * @return A description of the <code>Provider</code>.
+ */
+ public String getInfo()
+ {
+ return (info);
+ }
+
+ /**
+ * This method sets the specified key to have the specified value.
+ *
+ * @param key The property key
+ * @param value The property value
+ *
+ * @return The previous value for this key, or <code>null</code> if no previous value.
+ */
+ public Object put(Object key, Object value)
+ {
+ return (super.put(key, value));
+ }
+
+ /**
+ * This method removes the specified key entry (and its associated value)
+ * from the property mapping list.
+ *
+ * @param key The key to remove
+ *
+ * @return The previous value for this key, or <code>null</code> if no previous value.
+ */
+ public Object remove(Object key)
+ {
+ return (super.remove(key));
+ }
+
+ /**
+ * This method clears the entire property list such that it no longer
+ * contains the properties used to look up the services provided by
+ * the <code>Provider</code>.
+ */
+ public void clear()
+ {
+ super.clear();
+ }
+
+ /**
+ * This method returns a <code>String</code> representation of this
+ * object. This will include the <code>Provider</code> name and
+ * version number.
+ *
+ * @return A <code>String</code> representation of this object.
+ */
+ public String toString()
+ {
+ return (getClass().getName() + ": name=" + getName() + " version=" +
+ version);
+ }
}
-
-} // class Provider
-
diff --git a/libjava/java/security/ProviderException.java b/libjava/java/security/ProviderException.java
new file mode 100644
index 0000000..e1b8322
--- /dev/null
+++ b/libjava/java/security/ProviderException.java
@@ -0,0 +1,58 @@
+/* ProviderException.java -- Generic security provider runtime exception
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+
+/**
+ * This exception indicates that a runtime problem was encounterd with
+ * a security provider.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public class ProviderException extends RuntimeException
+{
+ /**
+ * This method initializes a new instance of <code>ProviderException</code>
+ * with no descriptive error message.
+ */
+ public ProviderException()
+ {
+ super();
+ }
+
+ /**
+ * This method initializes a new instance of <code>ProviderException</code>
+ * with a descriptive error message.
+ *
+ * @param msg The descriptive error message.
+ */
+ public ProviderException(String msg)
+ {
+ super(msg);
+ }
+}
diff --git a/libjava/java/security/PublicKey.java b/libjava/java/security/PublicKey.java
index 5c30c62..a56ffe4 100644
--- a/libjava/java/security/PublicKey.java
+++ b/libjava/java/security/PublicKey.java
@@ -1,24 +1,39 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* PublicKey.java -- "Super-interface" for all public keys
+ Copyright (C) 1998 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
-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.
+ * This interface specified no methods. In simply provides a common
+ * super-interface for all algorithm specific public key values.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
*/
-
-public interface PublicKey extends Key
+public interface PublicKey
{
- // This interface contains no methods or constants. It merely serves
- // to group (and provide type safety for) all private key interfaces.
}
diff --git a/libjava/java/security/SecureClassLoader.java b/libjava/java/security/SecureClassLoader.java
index f49f8ac..f81b420 100644
--- a/libjava/java/security/SecureClassLoader.java
+++ b/libjava/java/security/SecureClassLoader.java
@@ -1,24 +1,96 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
+/* SecureClassLoader.java --- A Secure Class Loader
+ Copyright (C) 1999 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
package java.security;
-// JDK1.2
-public class SecureClassLoader extends ClassLoader
+/**
+ A Secure Class Loader for loading classes with additional
+ support for specifying code source and permissions when
+ they are retrieved by the system policy handler.
+
+ @since JDK 1.2
+
+ @author Mark Benvenuto
+ */
+public class SecureClassLoader extends ClassLoader
{
- public SecureClassLoader ()
- {
- this (null);
- }
-
- public SecureClassLoader (ClassLoader parent)
- {
- super (parent);
- }
-}
+ protected SecureClassLoader(ClassLoader parent)
+ {
+ super(parent);
+ // FIXME: What else?
+ }
+
+ protected SecureClassLoader()
+ {
+ // FIXME: What do we need to do here?
+ }
+ /**
+ Creates a class using an array of bytes and a
+ CodeSource.
+
+ @param name the name to give the class. null if unknown.
+ @param b the data representing the classfile, in classfile format.
+ @param off the offset into the data where the classfile starts.
+ @param len the length of the classfile data in the array.
+ @param cs the CodeSource for the class
+
+ @return the class that was defined and optional CodeSource.
+
+ @exception ClassFormatError if the byte array is not in proper classfile format.
+ */
+ protected final Class defineClass(String name, byte[] b, int off, int len,
+ CodeSource cs)
+ {
+ // FIXME: Need to cache ProtectionDomains according to 1.3 docs.
+ ProtectionDomain protectionDomain =
+ new ProtectionDomain(cs, getPermissions(cs));
+ try
+ {
+ return super.defineClass(name, b, off, len, protectionDomain);
+ }
+ catch (ClassFormatError cfe)
+ {
+ return null;
+ }
+ }
+
+ /**
+ Returns a PermissionCollection for the specified CodeSource.
+ The default implmentation invokes
+ java.security.Policy.getPermissions.
+
+ This method is called by defineClass that takes a CodeSource
+ arguement to build a proper ProtectionDomain for the class
+ being defined.
+
+ */
+ protected PermissionCollection getPermissions(CodeSource cs)
+ {
+ Policy policy = Policy.getPolicy();
+ return policy.getPermissions(cs);
+ }
+}
diff --git a/libjava/java/security/SecureRandom.java b/libjava/java/security/SecureRandom.java
index 6f396dc..39a3947 100644
--- a/libjava/java/security/SecureRandom.java
+++ b/libjava/java/security/SecureRandom.java
@@ -1,25 +1,348 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* SecureRandom.java --- Secure Random class implmentation
+ Copyright (C) 1999 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
package java.security;
+import java.io.Serializable;
import java.util.Random;
+import java.util.Enumeration;
/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 7, 2000.
- */
+ SecureRandom is the class interface for using SecureRandom
+ providers. It provides an interface to the SecureRandomSpi
+ engine so that programmers can generate pseudo-random numbers.
-/**
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Stubbed.
+ @author Mark Benvenuto <ivymccough@worldnet.att.net>
*/
-
public class SecureRandom extends Random
{
- // FIXME: Stubbed.
+ //Serialized Field
+ long counter = 0; //Serialized
+ MessageDigest digest = null;
+ Provider provider = null;
+ byte[] randomBytes = null; //Always null
+ int randomBytesUsed = 0;
+ SecureRandomSpi secureRandomSpi = null;
+ byte[] state = null;
+
+ /**
+ Default constructor for SecureRandom. It constructs a
+ new SecureRandom by instantating the first SecureRandom
+ algorithm in the default security provier.
+
+ It is not seeded and should be seeded using setseed or else
+ on the first call to getnextBytes it will force a seed.
+
+ It is maintained for backwards compatability and programs
+ should use getInstance.
+ */
+ public SecureRandom()
+ {
+ Provider p[] = Security.getProviders();
+
+ //Format of Key: SecureRandom.algname
+ String key;
+
+ String classname = null;
+ int i, flag = 0;
+ Enumeration e;
+ for (i = 0; i < p.length; i++)
+ {
+ e = p[i].propertyNames();
+ while (e.hasMoreElements())
+ {
+ key = (String) e.nextElement();
+ if (key.startsWith("SecureRandom."))
+ if ((classname = p[i].getProperty(key)) != null)
+ break;
+ }
+ if (classname != null)
+ break;
+ }
+
+ //if( classname == null)
+ // throw new NoSuchAlgorithmException();
+
+ try
+ {
+ this.secureRandomSpi =
+ (SecureRandomSpi) Class.forName(classname).newInstance();
+
+ //s.algorithm = algorithm;
+ this.provider = p[i];
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ //throw new NoSuchAlgorithmException("Class not found");
+ }
+ catch (InstantiationException ie)
+ {
+ //throw new NoSuchAlgorithmException("Class instantiation failed");
+ }
+ catch (IllegalAccessException iae)
+ {
+ //throw new NoSuchAlgorithmException("Illegal Access");
+ }
+ }
+
+ /**
+ A constructor for SecureRandom. It constructs a new
+ SecureRandom by instantating the first SecureRandom algorithm
+ in the default security provier.
+
+ It is seeded with the passed function and is useful if the user
+ has access to hardware random device (like a radiation detector).
+
+ It is maintained for backwards compatability and programs
+ should use getInstance.
+
+ @param seed Seed bytes for class
+ */
+ public SecureRandom(byte[] seed)
+ {
+ this();
+ setSeed(seed);
+ }
+
+ /**
+ A constructor for SecureRandom. It constructs a new
+ SecureRandom using the specified SecureRandomSpi from
+ the specified security provier.
+
+ @param secureRandomSpi A SecureRandomSpi class
+ @param provider A Provider class
+ */
+ protected SecureRandom(SecureRandomSpi secureRandomSpi, Provider provider)
+ {
+ this.secureRandomSpi = secureRandomSpi;
+ this.provider = provider;
+ }
+
+ /**
+ Returns an instance of a SecureRandom. It creates the class
+ for the specified algorithm if it exists from a provider.
+
+ @param algorithm A SecureRandom algorithm to use
+
+ @return Returns a new SecureRandom implmenting the chosen algorithm
+
+ @throws NoSuchAlgorithmException if the algorithm cannot be found
+ */
+ public static SecureRandom getInstance(String algorithm) throws
+ NoSuchAlgorithmException
+ {
+ Provider p[] = Security.getProviders();
+
+ //Format of Key: SecureRandom.algname
+ StringBuffer key = new StringBuffer("SecureRandom.");
+ key.append(algorithm);
+
+ String classname = null;
+ int i;
+ for (i = 0; i < p.length; i++)
+ {
+ if ((classname = p[i].getProperty(key.toString())) != null)
+ break;
+ }
+
+ if (classname == null)
+ throw new NoSuchAlgorithmException();
+
+ try
+ {
+ return new SecureRandom((SecureRandomSpi) Class.forName(classname).
+ newInstance(), p[i]);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ throw new NoSuchAlgorithmException("Class not found");
+ }
+ catch (InstantiationException ie)
+ {
+ throw new NoSuchAlgorithmException("Class instantiation failed");
+ }
+ catch (IllegalAccessException iae)
+ {
+ throw new NoSuchAlgorithmException("Illegal Access");
+ }
+
+ }
+
+ /**
+ Returns an instance of a SecureRandom. It creates the class
+ for the specified algorithm from the specified provider.
+
+ @param algorithm A SecureRandom algorithm to use
+ @param provider A security provider to use
+
+ @return Returns a new SecureRandom implmenting the chosen algorithm
+
+ @throws NoSuchAlgorithmException if the algorithm cannot be found
+ @throws NoSuchProviderException if the provider cannot be found
+ */
+ public static SecureRandom getInstance(String algorithm,
+ String provider) throws
+ NoSuchAlgorithmException, NoSuchProviderException
+ {
+ Provider p = Security.getProvider(provider);
+ if (p == null)
+ throw new NoSuchProviderException();
+
+ //Format of Key: SecureRandom.algName
+ StringBuffer key = new StringBuffer("SecureRandom.");
+ key.append(algorithm);
+
+ String classname = p.getProperty(key.toString());
+ if (classname == null)
+ throw new NoSuchAlgorithmException();
+
+ try
+ {
+ return new SecureRandom((SecureRandomSpi) Class.forName(classname).
+ newInstance(), p);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ throw new NoSuchAlgorithmException("Class not found");
+ }
+ catch (InstantiationException ie)
+ {
+ throw new NoSuchAlgorithmException("Class instantiation failed");
+ }
+ catch (IllegalAccessException iae)
+ {
+ throw new NoSuchAlgorithmException("Illegal Access");
+ }
+
+ }
+
+ /**
+ Returns the provider being used by the current SecureRandom class.
+
+ @return The provider from which this SecureRandom was attained
+ */
+ public final Provider getProvider()
+ {
+ return provider;
+ }
+
+ /**
+ Seeds the SecureRandom. The class is re-seeded for each call and
+ each seed builds on the previous seed so as not to weaken security.
+
+ @param seed seed bytes to seed with
+ */
+ public void setSeed(byte[] seed)
+ {
+ secureRandomSpi.engineSetSeed(seed);
+ }
+
+ /**
+ Seeds the SecureRandom. The class is re-seeded for each call and
+ each seed builds on the previous seed so as not to weaken security.
+
+ @param seed 8 seed bytes to seed with
+ */
+ public void setSeed(long seed)
+ {
+ byte tmp[] = { (byte) (0xff & (seed >> 56)), (byte) (0xff & (seed >> 48)),
+ (byte) (0xff & (seed >> 40)), (byte) (0xff & (seed >> 32)),
+ (byte) (0xff & (seed >> 24)), (byte) (0xff & (seed >> 16)),
+ (byte) (0xff & (seed >> 8)), (byte) (0xff & seed)
+ };
+ secureRandomSpi.engineSetSeed(tmp);
+ }
+
+ /**
+ Generates a user specified number of bytes. This function
+ is the basis for all the random functions.
+
+ @param bytes array to store generated bytes in
+ */
+ public void nextBytes(byte[] bytes)
+ {
+ randomBytesUsed += bytes.length;
+ counter++;
+ secureRandomSpi.engineNextBytes(bytes);
+ }
+
+ /**
+ Generates an integer containing the user specified
+ number of random bits. It is right justified and padded
+ with zeros.
+
+ @param numBits number of random bits to get, 0 <= numBits <= 32;
+
+ @return the random bits
+ */
+ protected final int next(int numBits)
+ {
+ if (numBits == 0)
+ return 0;
+
+ byte tmp[] = new byte[numBits / 8 + (1 * (numBits % 8))];
+
+ secureRandomSpi.engineNextBytes(tmp);
+ randomBytesUsed += tmp.length;
+ counter++;
+
+ int ret = 0;
+
+ for (int i = 0; i < tmp.length; i++)
+ ret |= tmp[i] << (8 * i);
+
+ return ret;
+ }
+
+ /**
+ Returns the given number of seed bytes. This method is
+ maintained only for backwards capability.
+
+ @param numBytes number of seed bytes to get
+
+ @return an array containing the seed bytes
+ */
+ public static byte[] getSeed(int numBytes)
+ {
+ byte tmp[] = new byte[numBytes];
+
+ new Random().nextBytes(tmp);
+ return tmp;
+ //return secureRandomSpi.engineGenerateSeed( numBytes );
+ }
+
+ /**
+ Returns the specified number of seed bytes.
+
+ @param numBytes number of seed bytes to get
+
+ @return an array containing the seed bytes
+ */
+ public byte[] generateSeed(int numBytes)
+ {
+ return secureRandomSpi.engineGenerateSeed(numBytes);
+ }
+
}
diff --git a/libjava/java/security/SecureRandomSpi.java b/libjava/java/security/SecureRandomSpi.java
new file mode 100644
index 0000000..e621445
--- /dev/null
+++ b/libjava/java/security/SecureRandomSpi.java
@@ -0,0 +1,72 @@
+/* SecureRandomSpi.java --- Secure Random Service Provider Interface
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+import java.io.Serializable;
+
+/**
+ SecureRandomSpi is the Service Provider Interface for SecureRandom
+ providers. It provides an interface for providers to the
+ SecureRandom engine to write their own pseudo-random number
+ generator.
+
+ @since JDK 1.2
+
+ @author Mark Benvenuto <ivymccough@worldnet.att.net>
+ */
+public abstract class SecureRandomSpi implements Serializable
+{
+ /**
+ Default Constructor for SecureRandomSpi
+ */
+ public SecureRandomSpi()
+ {
+ }
+
+ /**
+ Updates the seed for SecureRandomSpi but does not reset seed.
+ It does to this so repeated called never decrease randomness.
+ */
+ protected abstract void engineSetSeed(byte[] seed);
+
+ /**
+ Gets a user specified number of bytes depending on the length
+ of the array?
+
+ @param bytes array to fill with random bytes
+ */
+ protected abstract void engineNextBytes(byte[] bytes);
+
+ /**
+ Gets a user specified number of bytes specified by the
+ parameter.
+
+ @param numBytes number of random bytes to generate
+
+ @return an array full of random bytes
+ */
+ protected abstract byte[] engineGenerateSeed(int numBytes);
+}
diff --git a/libjava/java/security/Security.java b/libjava/java/security/Security.java
index 87a0088..c5187d8 100644
--- a/libjava/java/security/Security.java
+++ b/libjava/java/security/Security.java
@@ -1,107 +1,322 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* Security.java --- Java base security class implmentation
+ Copyright (C) 1999, 2001 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
-package java.security;
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+package java.security;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.FileNotFoundException;
+import java.security.Provider;
+import java.util.Vector;
import java.util.Enumeration;
import java.util.Properties;
-import java.util.Vector;
/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date February 8, 2000.
- */
+ Security class that loads the Providers and provides an
+ interface to security properties.
-/**
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Still missing the deprecated getAlgorithmProperty method.
+ @author Mark Benvenuto <ivymccough@worldnet.att.net>
*/
-public final class Security
+public final class Security extends Object
{
- public static int insertProviderAt (Provider provider, int position)
+ private static Vector providers = new Vector();
+ private static int providerCount = 0;
+ private static Properties secprops;
+
+ static
{
- SecurityManager sm = System.getSecurityManager ();
- if (sm != null)
+ loadProviders();
+ }
+
+ private static void loadProviders()
+ {
+ String separator = System.getProperty("file.separator");
+ String secfilestr = System.getProperty("java.home") +
+ separator + "lib" + separator + "security" + separator +
+ "classpath.security";
+
+ providerCount = 0;
+ try
+ {
+ File secFile = new File(secfilestr);
+ FileInputStream fin = new FileInputStream(secFile);
+ secprops = new Properties();
+ secprops.load(fin);
+
+ int i = 1;
+ String name;
+ StringBuffer pname = new StringBuffer("security.provider.");
+
+ while ((name = secprops.getProperty(pname.append(i).toString())) !=
+ null)
+ {
+ Exception exception = null;
+ try
+ {
+ providers.addElement(Class.forName(name).newInstance());
+ providerCount++;
+ i++;
+ }
+ catch (ClassNotFoundException x)
+ {
+ exception = x;
+ }
+ catch (InstantiationException x)
+ {
+ exception = x;
+ }
+ catch (IllegalAccessException x)
+ {
+ exception = x;
+ }
+ if (exception != null)
+ System.err.println ("Error loading security provider " + name
+ + ": " + exception);
+ }
+ }
+ catch (FileNotFoundException ignored)
+ {
+ // Actually we probibly shouldn't ignore these, once the security
+ // properties file is actually installed somewhere.
+ }
+ catch (IOException ignored)
{
- // 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)
+ /**
+ Gets a specific property for an algorithm. This is used to produce specialized
+ algorithm parsers.
+
+ @deprecated it used to a return the value of a propietary property
+ for the "SUN" Cryptographic Service Provider to obtain
+ algorithm-specific parameters. Used AlogorithmParameters and
+ KeyFactory instead.
+
+ @param algName name of algorithm to get property of
+ @param propName name of property to check
+
+ @return a string containing the value of the property
+ */
+ public static String getAlgorithmProperty(String algName, String propName)
{
- return insertProviderAt (provider, providers.size ());
+ /* TODO: Figure out what this actually does */
+ return null;
}
- public static void removeProvider (String name)
+ /**
+ Adds a new provider at the specified position. This allows dynamic loading
+ of providers. It will check for duplication of providers.
+
+ This class checks the security manager with the call checkSecurityAccess
+ with "insertProvider."+provider.getName() to see if the user can add this
+ provider.
+
+ @param provider the provider to add
+ @param position position to add the provider at
+
+ @return the position the provider was added at, or -1 if a duplicate provider
+ was found
+
+ @throws SecurityException - if the security manager denies access to add a
+ new provider
+ */
+ public static int insertProviderAt(Provider provider, int position)
{
- SecurityManager sm = System.getSecurityManager ();
+ SecurityManager sm = System.getSecurityManager();
if (sm != null)
+ sm.checkSecurityAccess("insertProvider." + provider.getName());
+
+ for (int i = 0; i < providerCount; i++)
{
- // FIXME: need SecurityPermission.
- // sm.checkSecurityAccess ("removeProvider." + name);
+ if (((Provider) providers.elementAt(i)).getName() ==
+ provider.getName())
+ return -1;
}
- 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;
+ if (position < 0)
+ position = 0;
+ if (position > providerCount)
+ position = providerCount;
+
+ providers.insertElementAt(provider, position);
+ providerCount++;
+
+ return position;
}
- public static Provider getProvider (String name)
+
+ /**
+ Adds a new provider. This allows dynamic loading
+ of providers. It will check for duplication of providers.
+
+ This method checks the security manager with the call checkSecurityAccess
+ with "insertProvider."+provider.getName() to see if the user can add this
+ provider.
+
+ @param provider the provider to add
+
+ @return the position the provider was added at, or -1 if a duplicate provider
+ was found
+
+ @throws SecurityException - if the security manager denies access to add a
+ new provider
+ */
+ public static int addProvider(Provider provider)
{
- Enumeration e = providers.elements ();
- while (e.hasMoreElements ())
+ SecurityManager sm = System.getSecurityManager();
+
+ if (sm != null)
+ sm.checkSecurityAccess("insertProvider." + provider.getName());
+
+ for (int i = 0; i < providerCount; i++)
{
- Provider p = (Provider) e.nextElement ();
- if (name.equals (p.getName ()))
- return p;
+ if (((Provider) providers.elementAt(i)).getName() ==
+ provider.getName())
+ return -1;
}
- return null;
+
+ providers.addElement(provider);
+ providerCount++;
+
+ return providerCount - 1;
}
- public static String getProperty (String key)
+ /**
+ Removes a provider. This allows dynamic unloading
+ of providers. It will automatically shift up providers to a higher
+ ranking. If the provider is not installed, it fails silently.
+
+ This method checks the security manager with the call checkSecurityAccess
+ with "removeProvider."+provider.getName() to see if the user can remove this
+ provider.
+
+ @param name name of the provider to add
+
+ @throws SecurityException - if the security manager denies access to remove a
+ new provider
+ */
+ public static void removeProvider(String name)
{
- SecurityManager sm = System.getSecurityManager ();
+ SecurityManager sm = System.getSecurityManager();
if (sm != null)
+ sm.checkSecurityAccess("removeProvider." + name);
+
+ Provider p = null;
+ for (int i = 0; i < providerCount; i++)
{
- // FIXME: need SecurityPermission.
- // sm.checkSecurityAccess ("getProperty." + key);
+ if (((Provider) providers.elementAt(i)).getName() == name)
+ {
+ p = (Provider) providers.elementAt(i);
+ break;
+ }
}
- return props.getProperty (key);
+
+ if (p != null)
+ if (providers.removeElement(p))
+ providerCount--;
+
}
- public static void setProperty (String key, String value)
+ /**
+ Returns array containing all the providers. It is in the preference order
+ of the providers.
+
+ @return an array of installed providers
+ */
+ public static Provider[] getProviders()
{
- SecurityManager sm = System.getSecurityManager ();
- if (sm != null)
+ Provider array[] = new Provider[providerCount];
+ for (int i = 0; i < providerCount; i++)
+ array[i] = (Provider) providers.elementAt(i);
+ return array;
+ }
+
+ /**
+ Returns the provider with the specified name. It will return null
+ if the provider cannot be found.
+
+ @param name name of the requested provider
+
+ @return requested provider
+ */
+ public static Provider getProvider(String name)
+ {
+ Provider p = null;
+ for (int i = 0; i < providerCount; i++)
{
- // FIXME: need SecurityPermission.
- // sm.checkSecurityAccess ("setProperty." + key);
+ p = (Provider) providers.elementAt(i);
+ if (p.getName() == name)
+ break;
}
- props.setProperty (key, value);
+ return p;
+ }
+
+ /**
+ Gets the value of a security property.
+
+ This method checks the security manager with the call checkSecurityAccess
+ with "getProperty."+key to see if the user can get this property.
+
+ @param key property to get
+
+ @return value of the property
+
+ @throws SecurityException - if the security manager denies access to
+ getting a property
+ */
+ public static String getProperty(String key)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkSecurityAccess("getProperty." + key);
+
+ return secprops.getProperty(key);
}
- // The providers we list.
- private static Vector providers = new Vector ();
- // Security propertiesl
- private static Properties props = new Properties ();
+ /**
+ Sets the value of a security property.
+
+ This method checks the security manager with the call checkSecurityAccess
+ with "setProperty."+key to see if the user can get this property.
+
+ @param key property to set
+ @param datnum new value of property
+
+ @throws SecurityException - if the security manager denies access to
+ setting a property
+ */
+ public static void setProperty(String key, String datnum)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkSecurityAccess("setProperty." + key);
+
+ secprops.put(key, datnum);
+ }
}
diff --git a/libjava/java/security/SecurityPermission.java b/libjava/java/security/SecurityPermission.java
new file mode 100644
index 0000000..1e95f0a
--- /dev/null
+++ b/libjava/java/security/SecurityPermission.java
@@ -0,0 +1,98 @@
+/* SecurityPermission.java -- Class for named security permissions
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+
+/**
+ * This class provides a mechanism for specified named permissions
+ * related to the Java security framework. These permissions have no
+ * associated actions list. They are either granted or no granted.
+ * <p>
+ * The list of valid permission names is:
+ * <p><ul>
+ * <li>getPolicy - Allows retrieval of the system security policy.
+ * <li>setPolicy - Allows the security policy to be changed.
+ * <li>getProperty.&lt;key&gt; - Allows retrieval of the value of the named
+ * property or all properties if &lt;key&gt is a '*'.
+ * <li>setProperty.&lt;key&gt; - Allows changing of the value of the named
+ * property or all properties if &lt;key&gt is a '*'.
+ * <li>insertProvider.&lt;key&gt; - Allows the named provider to be added,
+ * or any provide if the key is '*'.
+ * <li>removeProvider.&lt;key&gt; - Allows the named provider to be removed,
+ * or any provide if the key is '*'.
+ * <li>setSystemScope - Allows the system identity scope to be set.
+ * <li>setIdentityPublicKey - Allows the public key of an Identity to be set.
+ * <li>SetIdentityInfo - Allows the description of an Identity to be set.
+ * <li>addIdentityCertificate - Allows a certificate to be set for the public
+ * key of an identity.
+ * <li>removeIdentityCertificate - Allows a certificate to be removed from the
+ * public key of an identity.
+ * <li>clearProviderProperties.&lt;key%gt; - Allows the properties of the
+ * named provider to be cleared, or all providers if key is '*'.
+ * <li>putProviderProperty.&lt;key%gt; - Allows the properties of the
+ * named provider to be changed, or all providers if key is '*'.
+ * <li>removeProviderProperty.&lt;key%gt; - Allows the properties of the
+ * named provider to be deleted, or all providers if key is '*'.
+ * <li>getSignerPrivateKey - Allows the retrieval of the private key for
+ * a signer.
+ * <li>setSignerKeyPair - Allows the public and private key of a Signer to
+ * be changed.
+ * </ul>
+ * <p>
+ * There is some degree of security risk in granting any of these permissions.
+ * Some of them can completely compromise system security. Please exercise
+ * extreme caution in granting these permissions.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public final class SecurityPermission extends BasicPermission
+{
+ /**
+ * This method initializes a new instance of <code>SecurityPermission</code>
+ * to have the specified name.
+ *
+ * @param name The name to assign to this permission.
+ */
+ public SecurityPermission(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * This method initializes a new instance of <code>SecurityPermission</code>
+ * to have the specified name. The actions parameter is ignored in this
+ * class.
+ *
+ * @param name The name to assign to this permission.
+ * @param actions The action list for this permission - ignored.
+ */
+ public SecurityPermission(String name, String actions)
+ {
+ super(name, actions);
+ }
+}
diff --git a/libjava/java/security/Signature.java b/libjava/java/security/Signature.java
index 760f625..e9ea5cc 100644
--- a/libjava/java/security/Signature.java
+++ b/libjava/java/security/Signature.java
@@ -1,173 +1,488 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* Signature.java --- Signature Class
+ Copyright (C) 1999 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
package java.security;
+import java.security.spec.AlgorithmParameterSpec;
/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date February 11, 2000.
- */
+ Signature is used to provide an interface to digital signature
+ algorithms. Digital signatures provide authentication and data
+ integrity of digital data.
-/**
- * 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.
- */
+ The GNU provider provides the NIST standard DSA which uses DSA
+ and SHA-1. It can be specified by SHA/DSA, SHA-1/DSA or its
+ OID. If the RSA signature algorithm is provided then
+ it could be MD2/RSA. MD5/RSA, or SHA-1/RSA. The algorithm must
+ be specified because there is no default.
+
+ Signature provides implementation-independent algorithms which
+ are requested by the user through getInstance. It can be
+ requested by specifying just the algorithm name or by
+ specifying both the algorithm name and provider name.
-public abstract class Signature
+ The three phases of using Signature are:
+
+ 1. Initialing
+
+ * It must be initialized with a private key for
+ signing.
+ * It must be initialized with a public key for
+ verifying.
+
+ 2. Updating
+
+ Update the bytes for signing or verifying with calls
+ to update.
+
+ 3. Signing or Verify the signature on the currently stored
+ bytes by calling sign or verify.
+
+ @author Mark Benvenuto <ivymccough@worldnet.att.net>
+ @since JDK 1.1
+ */
+public abstract class Signature extends SignatureSpi
{
- protected Signature (String name)
+ /**
+ Possible state variable which signifies if it has not been
+ initialized.
+ */
+ protected static final int UNINITIALIZED = 1;
+
+ /**
+ Possible state variable which signifies if it has been
+ initialized for signing.
+ */
+ protected static final int SIGN = 2;
+
+ /**
+ Possible state variable which signifies if it has been
+ initialized for verifying.
+ */
+ protected static final int VERIFY = 3;
+
+ /**
+ State of this Signature class.
+ */
+ protected int state = UNINITIALIZED;
+
+ private String algorithm;
+ private Provider provider;
+
+ /**
+ Creates a new signature for this algorithm.
+
+ @param algorithm the algorithm to use
+ */
+ protected Signature(String algorithm)
{
+ this.algorithm = algorithm;
state = UNINITIALIZED;
- this.name = name;
}
- public static Signature getInstance (String algorithm)
+ /**
+ Gets an instance of the Signature class representing
+ the specified signature. If the algorithm is not found then,
+ it throws NoSuchAlgorithmException.
+
+ @param algorithm the name of signature algorithm to choose
+ @return a Signature repesenting the desired algorithm
+
+ @throws NoSuchAlgorithmException if the algorithm is not implemented by providers
+ */
+ public static Signature getInstance(String algorithm)
throws NoSuchAlgorithmException
{
String name = "Signature." + algorithm;
- Provider[] provs = Security.getProviders ();
- for (int i = 0; i < provs.length; ++i)
+ Provider[] p = Security.getProviders();
+
+ for (int i = 0; i < p.length; i++)
{
- String val = provs[i].getProperty (name);
- if (val != null)
- {
- try
- {
- return (Signature) Class.forName(val).newInstance ();
- }
- catch (Throwable _)
- {
- // We just ignore failures.
- }
- }
+ String classname = p[i].getProperty(name);
+ if (classname != null)
+ return getInstance(classname, algorithm, p[i]);
}
- throw new NoSuchAlgorithmException (algorithm);
+ throw new NoSuchAlgorithmException(algorithm);
}
- public static Signature getInstance (String algorithm, String provider)
+ /**
+ Gets an instance of the Signature class representing
+ the specified signature from the specified provider. If the
+ algorithm is not found then, it throws NoSuchAlgorithmException.
+ If the provider is not found, then it throws
+ NoSuchProviderException.
+
+ @param algorithm the name of signature algorithm to choose
+ @param provider the name of the provider to find the algorithm in
+ @return a Signature repesenting the desired algorithm
+
+ @throws NoSuchAlgorithmException if the algorithm is not implemented by the provider
+ @throws NoSuchProviderException if the provider is not found
+ */
+ public static Signature getInstance(String algorithm, String provider)
throws NoSuchAlgorithmException, NoSuchProviderException
{
- String name = "Signature." + algorithm;
- Provider p = Security.getProvider (provider);
+ Provider p = Security.getProvider(provider);
if (p == null)
- throw new NoSuchProviderException (provider);
- String val = p.getProperty (name);
- if (val != null)
+ throw new NoSuchProviderException();
+
+ return getInstance(p.getProperty("Signature." + algorithm), algorithm, p);
+ }
+
+ private static Signature getInstance(String classname,
+ String algorithm,
+ Provider provider)
+ throws NoSuchAlgorithmException
+ {
+ try
{
- try
- {
- return (Signature) Class.forName(val).newInstance ();
- }
- catch (Throwable _)
+ Object o = Class.forName(classname).newInstance();
+ Signature sig;
+ if (o instanceof SignatureSpi)
+ sig = (Signature) (new DummySignature((SignatureSpi) o, algorithm));
+ else
{
- // Nothing.
+ sig = (Signature) o;
+ sig.algorithm = algorithm;
}
+
+ sig.provider = provider;
+ return sig;
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ throw new NoSuchAlgorithmException("Class not found");
+ }
+ catch (InstantiationException ie)
+ {
+ throw new NoSuchAlgorithmException("Class instantiation failed");
+ }
+ catch (IllegalAccessException iae)
+ {
+ throw new NoSuchAlgorithmException("Illegal Access");
}
+ }
+
+ /**
+ Gets the provider that the Signature is from.
+
+ @return the provider the this Signature
+ */
+ public final Provider getProvider()
+ {
+ return provider;
+ }
+
+ /**
+ Initializes this class with the public key for
+ verification purposes.
+
+ @param publicKey the public key to verify with
- throw new NoSuchAlgorithmException (algorithm);
+ @throws InvalidKeyException invalid key
+ */
+ public final void initVerify(PublicKey publicKey) throws InvalidKeyException
+ {
+ state = VERIFY;
+ engineInitVerify(publicKey);
}
- public final void initVerify (PublicKey publicKey)
+ /**
+ Verify Signature with a certificate. This is a FIPS 140-1 compatible method
+ since it verifies a signature with a certificate.
+
+ If the certificate is an X.509 certificate, has a KeyUsage parameter and
+ the parameter indicates this key is not to be used for signing then an
+ error is returned.
+
+ @param certificate a certificate containing a public key to verify with
+ */
+ public final void initVerify(java.security.cert.Certificate certificate)
throws InvalidKeyException
{
- engineInitVerify (publicKey);
+ state = VERIFY;
+ if (certificate.getType().equals("X509"))
+ {
+ java.security.cert.X509Certificate cert =
+ (java.security.cert.X509Certificate) certificate;
+
+ boolean[]array = cert.getKeyUsage();
+ if (array != null && array[0] == false)
+ throw new InvalidKeyException
+ ("KeyUsage of this Certificate indicates it cannot be used for digital signing");
+ }
+ this.initVerify(certificate.getPublicKey());
}
- public final void initSign (PrivateKey privateKey)
+ /**
+ Initializes this class with the private key for
+ signing purposes.
+
+ @param privateKey the private key to sign with
+
+ @throws InvalidKeyException invalid key
+ */
+ public final void initSign(PrivateKey privateKey) throws InvalidKeyException
+ {
+ state = SIGN;
+ engineInitSign(privateKey);
+ }
+
+ /**
+ Initializes this class with the private key and source
+ of randomness for signing purposes.
+
+ @param privateKey the private key to sign with
+ @param random Source of randomness
+
+ @throws InvalidKeyException invalid key
+
+ @since JDK 1.2
+ */
+ public final void initSign(PrivateKey privateKey, SecureRandom random)
throws InvalidKeyException
{
- engineInitSign (privateKey);
+ state = SIGN;
+ engineInitSign(privateKey, random);
}
- public final byte[] sign ()
- throws SignatureException
+
+ /**
+ Returns the signature bytes of all the data fed to this class.
+ The format of the output depends on the underlying signature
+ algorithm.
+
+ @return the signature
+
+ @throws SignatureException engine not properly initialized
+ */
+ public final byte[] sign() throws SignatureException
{
- return engineSign ();
+ if (state == SIGN)
+ {
+ state = UNINITIALIZED;
+ return engineSign();
+ }
+ else
+ throw new SignatureException();
}
- public final boolean verify (byte[] signature)
+ /**
+ Generates signature bytes of all the data fed to this class
+ and outputs it to the passed array. The format of the
+ output depends on the underlying signature algorithm.
+
+ After calling this method, the signature is reset to its
+ initial state and can be used to generate additional
+ signatures.
+
+ @param outbuff array of bytes
+ @param offset the offset to start at in the array
+ @param len the length of the bytes to put into the array.
+ Neither this method or the GNU provider will
+ return partial digests. If len is less than the
+ signature length, this method will throw
+ SignatureException. If it is greater than or equal
+ then it is ignored.
+
+ @return number of bytes in outbuf
+
+ @throws SignatureException engine not properly initialized
+
+ @since JDK 1.2
+ */
+ public final int sign(byte[]outbuf, int offset, int len)
throws SignatureException
{
- return engineVerify (signature);
+ if (state == SIGN)
+ {
+ state = UNINITIALIZED;
+ return engineSign(outbuf, offset, len);
+ }
+ else
+ throw new SignatureException();
}
- public final void update (byte b)
- throws SignatureException
+ /**
+ Verifies the passed signature.
+
+ @param signature the signature bytes to verify
+
+ @return true if verified, false otherwise
+
+ @throws SignatureException engine not properly initialized
+ or wrong signature
+ */
+ public final boolean verify(byte[]signature) throws SignatureException
{
- engineUpdate (b);
+ if (state == VERIFY)
+ {
+ state = UNINITIALIZED;
+ return engineVerify(signature);
+ }
+ else
+ throw new SignatureException();
}
- public final void update (byte[] data)
- throws SignatureException
+ /**
+ Updates the data to be signed or verified with the specified
+ byte.
+
+ @param b byte to update with
+
+ @throws SignatureException Engine not properly initialized
+ */
+ public final void update(byte b) throws SignatureException
{
- engineUpdate (data, 0, data.length);
+ if (state != UNINITIALIZED)
+ engineUpdate(b);
+ else
+ throw new SignatureException();
}
- public final void update (byte[] data, int off, int len)
+ /**
+ Updates the data to be signed or verified with the specified
+ bytes.
+
+ @param data array of bytes
+
+ @throws SignatureException engine not properly initialized
+ */
+ public final void update(byte[]data) throws SignatureException
+ {
+ if (state != UNINITIALIZED)
+ engineUpdate(data, 0, data.length);
+ else
+ throw new SignatureException();
+ }
+
+ /**
+ Updates the data to be signed or verified with the specified
+ bytes.
+
+ @param data array of bytes
+ @param off the offset to start at in the array
+ @param len the length of the bytes to use in the array
+
+ @throws SignatureException engine not properly initialized
+ */
+ public final void update(byte[]data, int off, int len)
throws SignatureException
{
- engineUpdate (data, off, len);
+ if (state != UNINITIALIZED)
+ engineUpdate(data, off, len);
+ else
+ throw new SignatureException();
}
- public final String getAlgorithm ()
+ /**
+ Gets the name of the algorithm currently used.
+ The names of algorithms are usually SHA/DSA or SHA/RSA.
+
+ @return name of algorithm.
+ */
+ public final String getAlgorithm()
{
- return name;
+ return algorithm;
}
- public String toString ()
+ /**
+ Returns a representation of the Signature as a String
+
+ @return a string representing the signature
+ */
+ public String toString()
{
- // There is no spec for this. FIXME: this is a bad choice.
- return name + "; state = " + state;
+ return (algorithm + " Signature");
}
- public final void setParameter (String param, Object value)
+ /**
+ Sets the specified algorithm parameter to the specified value.
+
+ @param param parameter name
+ @param value parameter value
+
+ @throws InvalidParameterException invalid parameter, parameter
+ already set and cannot set again, a security exception,
+ etc.
+
+ @deprecated use the other setParameter
+ */
+ public final void setParameter(String param, Object value)
throws InvalidParameterException
{
- engineSetParameter (param, value);
+ engineSetParameter(param, value);
}
- public final Object getParameter (String param)
- throws InvalidParameterException
+ /**
+ Sets the signature engine with the specified
+ AlgorithmParameterSpec;
+
+ By default this always throws UnsupportedOperationException
+ if not overridden;
+
+ @param params the parameters
+
+ @throws InvalidParameterException invalid parameter, parameter
+ already set and cannot set again, a security exception,
+ etc.
+ */
+ public final void setParameter(AlgorithmParameterSpec params)
+ throws InvalidAlgorithmParameterException
{
- 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;
+ engineSetParameter(params);
+ }
- public Object clone() throws CloneNotSupportedException
+ /**
+ Gets the value for the specified algorithm parameter.
+
+ @param param parameter name
+
+ @return parameter value
+
+ @throws InvalidParameterException invalid parameter
+
+ @deprecated use the other getParameter
+ */
+ public final Object getParameter(String param)
+ throws InvalidParameterException
{
- return super.clone ();
+ return engineGetParameter(param);
}
- protected static final int UNINITIALIZED = 0;
- protected static final int SIGN = 2;
- protected static final int VERIFY = 3;
+ /**
+ Returns a clone if cloneable.
- // Current state.
- protected int state;
+ @return a clone if cloneable.
- // Name of this object.
- private String name;
+ @throws CloneNotSupportedException if the implementation does
+ not support cloning
+ */
+ public Object clone() throws CloneNotSupportedException
+ {
+ throw new CloneNotSupportedException();
+ }
}
diff --git a/libjava/java/security/SignatureException.java b/libjava/java/security/SignatureException.java
index dc1c87a..449b75f 100644
--- a/libjava/java/security/SignatureException.java
+++ b/libjava/java/security/SignatureException.java
@@ -1,30 +1,54 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* SignatureException.java -- Generic error in signature
+ Copyright (C) 1998 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
-package java.security;
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
/**
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
+ * This exception is thrown when a problem is encountered with a
+ * digital signature.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
*/
-
public class SignatureException extends GeneralSecurityException
{
+ /**
+ * This method initializes a new instance of <code>SignatureException</code>
+ * with no descriptive error message.
+ */
public SignatureException()
{
super();
}
+ /**
+ * This method initializes a new instance of <code>SignatureException</code>
+ * with a descriptive error message.
+ */
public SignatureException(String msg)
{
super(msg);
diff --git a/libjava/java/security/SignatureSpi.java b/libjava/java/security/SignatureSpi.java
new file mode 100644
index 0000000..17719a5
--- /dev/null
+++ b/libjava/java/security/SignatureSpi.java
@@ -0,0 +1,243 @@
+/* SignatureSpi.java --- Signature Service Provider Interface
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+import java.security.spec.AlgorithmParameterSpec;
+
+/**
+ SignatureSpi defines the Service Provider Interface (SPI)
+ for the Signature class. The signature class provides an
+ interface to a digital signature algorithm. Digital signatures
+ are used for authentication and integrity of data.
+
+ @author Mark Benvenuto <ivymccough@worldnet.att.net>
+
+ @since JDK 1.2
+ */
+public abstract class SignatureSpi
+{
+ /**
+ Source of randomness
+ */
+ protected SecureRandom appRandom;
+
+ /**
+ Creates a new instance of SignatureSpi.
+ */
+ public SignatureSpi()
+ {
+ appRandom = null;
+ }
+
+ /**
+ Initializes this class with the public key for
+ verification purposes.
+
+ @param publicKey the public key to verify with
+
+ @throws InvalidKeyException invalid key
+ */
+ protected abstract void engineInitVerify(PublicKey publicKey)
+ throws InvalidKeyException;
+
+ /**
+ Initializes this class with the private key for
+ signing purposes.
+
+ @param privateKey the private key to sign with
+
+ @throws InvalidKeyException invalid key
+ */
+ protected abstract void engineInitSign(PrivateKey privateKey)
+ throws InvalidKeyException;
+
+ /**
+ Initializes this class with the private key and source
+ of randomness for signing purposes.
+
+ This cannot be abstract backward compatibility reasons
+
+ @param privateKey the private key to sign with
+ @param random Source of randomness
+
+ @throws InvalidKeyException invalid key
+
+ @since JDK 1.2
+ */
+ protected void engineInitSign(PrivateKey privateKey, SecureRandom random)
+ throws InvalidKeyException
+ {
+ appRandom = random;
+ engineInitSign(privateKey);
+ }
+
+ /**
+ Updates the data to be signed or verified with the specified
+ byte.
+
+ @param b byte to update with
+
+ @throws SignatureException Engine not properly initialized
+ */
+ protected abstract void engineUpdate(byte b) throws SignatureException;
+
+ /**
+ Updates the data to be signed or verified with the specified
+ bytes.
+
+ @param b array of bytes
+ @param off the offset to start at in the array
+ @param len the length of the bytes to use in the array
+
+ @throws SignatureException engine not properly initialized
+ */
+ protected abstract void engineUpdate(byte[] b, int off, int len)
+ throws SignatureException;
+
+ /**
+ Returns the signature bytes of all the data fed to this class.
+ The format of the output depends on the underlying signature
+ algorithm.
+
+ @return the signature
+
+ @throws SignatureException engine not properly initialized
+ */
+ protected abstract byte[] engineSign() throws SignatureException;
+
+ /**
+ Generates signature bytes of all the data fed to this class
+ and outputs it to the passed array. The format of the
+ output depends on the underlying signature algorithm.
+
+ This cannot be abstract backward compatibility reasons.
+ After calling this method, the signature is reset to its
+ initial state and can be used to generate additional
+ signatures.
+
+ @param outbuff array of bytes
+ @param offset the offset to start at in the array
+ @param len the length of the bytes to put into the array.
+ Neither this method or the GNU provider will
+ return partial digests. If len is less than the
+ signature length, this method will throw
+ SignatureException. If it is greater than or equal
+ then it is ignored.
+
+ @return number of bytes in outbuf
+
+ @throws SignatureException engine not properly initialized
+
+ @since JDK 1.2
+ */
+ protected int engineSign(byte[] outbuf, int offset, int len)
+ throws SignatureException
+ {
+ byte tmp[] = engineSign();
+
+ if (tmp.length > len)
+ throw new SignatureException("Invalid Length");
+
+ System.arraycopy(outbuf, offset, tmp, 0, tmp.length);
+
+ return tmp.length;
+ }
+
+ /**
+ Verifies the passed signature.
+
+ @param sigBytes the signature bytes to verify
+
+ @return true if verified, false otherwise
+
+ @throws SignatureException engine not properly initialized
+ or wrong signature
+ */
+ protected abstract boolean engineVerify(byte[] sigBytes)
+ throws SignatureException;
+
+ /**
+ Sets the specified algorithm parameter to the specified value.
+
+ @param param parameter name
+ @param value parameter value
+
+ @throws InvalidParameterException invalid parameter, parameter
+ already set and cannot set again, a security exception,
+ etc.
+
+ @deprecated use the other setParameter
+ */
+ protected abstract void engineSetParameter(String param, Object value)
+ throws InvalidParameterException;
+
+ /**
+ Sets the signature engine with the specified
+ AlgorithmParameterSpec;
+
+ This cannot be abstract backward compatibility reasons
+ By default this always throws UnsupportedOperationException
+ if not overridden;
+
+ @param params the parameters
+
+ @throws InvalidParameterException invalid parameter, parameter
+ already set and cannot set again, a security exception,
+ etc.
+ */
+ protected void engineSetParameter(AlgorithmParameterSpec params)
+ throws InvalidAlgorithmParameterException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ Gets the value for the specified algorithm parameter.
+
+ @param param parameter name
+
+ @return parameter value
+
+ @throws InvalidParameterException invalid parameter
+
+ @deprecated use the other getParameter
+ */
+ protected abstract Object engineGetParameter(String param)
+ throws InvalidParameterException;
+
+ /**
+ Returns a clone if cloneable.
+
+ @return a clone if cloneable.
+
+ @throws CloneNotSupportedException if the implementation does
+ not support cloning
+ */
+ public Object clone() throws CloneNotSupportedException
+ {
+ throw new CloneNotSupportedException();
+ }
+}
diff --git a/libjava/java/security/SignedObject.java b/libjava/java/security/SignedObject.java
new file mode 100644
index 0000000..34f80e9
--- /dev/null
+++ b/libjava/java/security/SignedObject.java
@@ -0,0 +1,166 @@
+/* SignedObject.java --- Signed Object Class
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+/**
+ SignedObject is used for storing rutime objects whose integrity
+ cannot be compromised without being detected.
+
+ SignedObject contains a Serializable object which is yet to be
+ signed and its signature.
+
+ The signed copy is a "deep copy" (in serialized form) of the
+ original object. Any changes to the original will not affect
+ the original.
+
+ Several things to note are that, first there is no need to
+ initialize the signature engine as this class will handle that
+ automatically. Second, verification will only succeed if the
+ public key corresponds to the private key used to generate
+ the SignedObject.
+
+ For fexibility, the signature engine can be specified in the
+ constructor or the verify method. The programmer who writes
+ code that verifies the SignedObject has not changed should be
+ aware of the Signature engine they use. A malicious Signature
+ may choose to always return true on verification and
+ bypass the secrity check.
+
+ The GNU provider provides the NIST standard DSA which uses DSA
+ and SHA-1. It can be specified by SHA/DSA, SHA-1/DSA or its
+ OID. If the RSA signature algorithm is provided then
+ it could be MD2/RSA. MD5/RSA, or SHA-1/RSA. The algorithm must
+ be specified because there is no default.
+
+ @author Mark Benvenuto <ivymccough@worldnet.att.net>
+
+ @since JDK 1.2
+ */
+public final class SignedObject implements Serializable
+{
+ private byte[] content;
+ private byte[] signature;
+ private String thealgorithm;
+
+ /**
+ Constructs a new SignedObject from a Serializeable object. The
+ object is signed with private key and signature engine
+
+ @param object the object to sign
+ @param signingKey the key to sign with
+ @param signingEngine the signature engine to use
+
+ @throws IOException serialization error occured
+ @throws InvalidKeyException invalid key
+ @throws SignatureException signing error
+ */
+ public SignedObject(Serializable object, PrivateKey signingKey,
+ Signature signingEngine) throws IOException,
+ InvalidKeyException, SignatureException
+ {
+ thealgorithm = signingEngine.getAlgorithm();
+
+ ByteArrayOutputStream ostream = new ByteArrayOutputStream();
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
+ p.writeObject(object);
+ p.flush();
+
+ content = ostream.toByteArray();
+
+ signingEngine.initSign(signingKey);
+ signingEngine.update(content);
+ signature = signingEngine.sign();
+ }
+
+ /**
+ Returns the encapsulated object. The object is
+ de-serialized before being returned.
+
+ @return the encapsulated object
+
+ @throws IOException de-serialization error occured
+ @throws ClassNotFoundException de-serialization error occured
+ */
+ public Object getObject() throws IOException, ClassNotFoundException
+ {
+ ByteArrayInputStream istream = new ByteArrayInputStream(content);
+
+ return new ObjectInputStream(istream).readObject();
+ }
+
+ /**
+ Returns the signature of the encapsulated object.
+
+ @return a byte array containing the signature
+ */
+ public byte[] getSignature()
+ {
+ return signature;
+ }
+
+ /**
+ Returns the name of the signature algorithm.
+
+ @return the name of the signature algorithm.
+ */
+ public String getAlgorithm()
+ {
+ return thealgorithm;
+ }
+
+ /**
+ Verifies the SignedObject by checking that the signature that
+ this class contains for the encapsulated object.
+
+ @param verificationKey the public key to use
+ @param verificationEngine the signature engine to use
+
+ @return true if signature is correct, false otherwise
+
+ @throws InvalidKeyException invalid key
+ @throws SignatureException signature verification failed
+ */
+ public boolean verify(PublicKey verificationKey,
+ Signature verificationEngine) throws
+ InvalidKeyException, SignatureException
+ {
+ verificationEngine.initVerify(verificationKey);
+ verificationEngine.update(content);
+ return verificationEngine.verify(signature);
+ }
+
+ // readObject is called to restore the state of the SignedObject from a
+ // stream.
+ //private void readObject(ObjectInputStream s)
+ // throws IOException, ClassNotFoundException
+}
diff --git a/libjava/java/security/Signer.java b/libjava/java/security/Signer.java
new file mode 100644
index 0000000..9ba62c5
--- /dev/null
+++ b/libjava/java/security/Signer.java
@@ -0,0 +1,142 @@
+/* Signer.java --- Signer Class
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+
+/**
+ Signer is a subclass used to store a digital signature key with
+ an Identity.
+
+ @author Mark Benvenuto <ivymccough@worldnet.att.net>
+
+ @since JDK 1.1
+ */
+public abstract class Signer extends Identity
+{
+ private PrivateKey privateKey = null;
+
+ /**
+ Constructs a new Signer.
+ */
+ protected Signer()
+ {
+ }
+
+ /**
+ Constructs a new Signer with the specified name.
+
+ @param name the name of the identity.
+ */
+ public Signer(String name)
+ {
+ super(name);
+ }
+
+ /**
+ Constructs a new Signer with the specifid name and
+ IdentityScope.
+
+ @param name the name of the identity.
+ @scope the IdentityScope to use
+
+ @throws KeyManagementException if duplicate identity name
+ within scope
+ */
+ public Signer(String name, IdentityScope scope)
+ throws KeyManagementException
+ {
+ super(name, scope);
+ }
+
+ /**
+ Returns the private key for this signer.
+
+ This class checks the security manager with the call
+ checkSecurityAccess with "getSignerPrivateKey".
+
+ @returns the private key for the signer
+
+ @throws SecurityException - if the security manager denies
+ access to "getSignerPrivateKey"
+ */
+ public PrivateKey getPrivateKey()
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkSecurityAccess("getSignerPrivateKey");
+
+ return privateKey;
+ }
+
+ /**
+ Specifies the KeyPair associated with this Signer.
+
+ This class checks the security manager with the call
+ checkSecurityAccess with "setSignerKeyPair".
+
+ @param pair the keyPair
+
+ @throws InvalidParameterException invalidly intialized key pair
+ @throws KeyException another key error
+ @throws SecurityException - if the security manager denies
+ access to "getSignerPrivateKey"
+ */
+ public final void setKeyPair(KeyPair pair)
+ throws InvalidParameterException, KeyException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkSecurityAccess("setSignerKeyPair");
+
+ try
+ {
+ if (pair.getPublic() != null)
+ setPublicKey(pair.getPublic());
+ else
+ throw new InvalidParameterException();
+
+ }
+ catch (KeyManagementException kme)
+ {
+ throw new KeyException();
+ }
+
+ if (pair.getPrivate() != null)
+ privateKey = pair.getPrivate();
+ else
+ throw new InvalidParameterException();
+ }
+
+ /**
+ Returns a string representing this Signer.
+
+ @returns a string representing this Signer.
+ */
+ public String toString()
+ {
+ return (getName() + ": " + privateKey);
+ }
+}
diff --git a/libjava/java/security/UnrecoverableKeyException.java b/libjava/java/security/UnrecoverableKeyException.java
new file mode 100644
index 0000000..eae616a
--- /dev/null
+++ b/libjava/java/security/UnrecoverableKeyException.java
@@ -0,0 +1,58 @@
+/* UnrecoverableKeyException.java -- Cannot recover a key from the key store
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+
+/**
+ * This exception is thrown when a key cannot be recovered from the key
+ * store.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public class UnrecoverableKeyException extends GeneralSecurityException
+{
+ /**
+ * This method initializes a new instance of <code>UnrecoverableKeyException</code>
+ * with no descriptive error message.
+ */
+ public UnrecoverableKeyException()
+ {
+ super();
+ }
+
+ /**
+ * This method initializes a new instance of <code>UnrecoverableKeyException</code>
+ * with a descriptive error message.
+ *
+ * @param msg The descriptive error message.
+ */
+ public UnrecoverableKeyException(String msg)
+ {
+ super(msg);
+ }
+}
diff --git a/libjava/java/security/UnresolvedPermission.java b/libjava/java/security/UnresolvedPermission.java
new file mode 100644
index 0000000..f77ed62
--- /dev/null
+++ b/libjava/java/security/UnresolvedPermission.java
@@ -0,0 +1,184 @@
+/* UnresolvedPermission.java -- Placeholder for unresolved permissions.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security;
+
+import java.io.Serializable;
+
+/**
+ * This class is used to hold instances of all permissions that cannot
+ * be resolved to available permission classes when the security
+ * <code>Policy</code> object is instantiated. This may happen when the
+ * necessary security class has not yet been downloaded from the network.
+ * <p>
+ * Instances of this class are re-resolved when <code>AccessController</code>
+ * check is done. At that time, a scan is made of all existing
+ * <code>UnresolvedPermission</code> objects and they are converted to
+ * objects of the appropriate permission type if the class for that type
+ * is then available.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public class UnresolvedPermission extends Permission implements Serializable
+{
+
+ /**
+ * The list of actions associated with this permission object
+ */
+ private String actions;
+
+ /**
+ * The list of <code>Certificates</code> associated with this object
+ */
+ private Certificate[] certs;
+
+ /**
+ * The name of the class this object should be resolved to.
+ */
+ private String type;
+
+ /**
+ * This method initializes a new instance of <code>UnresolvedPermission</code>
+ * with all the information necessary to resolve it to an instance of the
+ * proper class at a future time.
+ *
+ * @param type The name of the desired class this permission should be resolved to
+ * @param name The name of this permission
+ * @param actions The action list for this permission
+ * @param certs The list of certificates this permission's class was signed with
+ */
+ public UnresolvedPermission(String type, String name, String actions,
+ Certificate[] certs)
+ {
+ super(name);
+
+ this.type = type;
+ this.actions = actions;
+ this.certs = certs;
+ }
+
+ /**
+ * This method returns the list of actions associated with this
+ * permission.
+ *
+ * @return The action list
+ */
+ public String getActions()
+ {
+ return (actions);
+ }
+
+ /**
+ * This method returns <code>false</code> always to indicate that this
+ * permission does not imply the specified permission. An
+ * <code>UnresolvedPermission</code> never grants any permissions.
+ *
+ * @param perm The <code>Permission</code> object to test against - ignored by this class
+ *
+ * @return <code>false</code> to indicate this permission does not imply the specified permission.
+ */
+ public boolean implies(Permission perm)
+ {
+ return (false);
+ }
+
+ /**
+ * This method tests this permission for equality against the specified
+ * <code>Object</code>. This will be true if and only if the following
+ * conditions are met:
+ * <p>
+ * <ul>
+ * <li>The specified <code>Object</code> is an instance of
+ * <code>UnresolvedPermission</code>, or a subclass.
+ * <li>The specified permission has the same type (i.e., desired class name)
+ * as this permission.
+ * <li>The specified permission has the same name as this one.
+ * <li>The specified permissoin has the same action list as this one.
+ * <li>The specified permission has the same certificate list as this one.
+ * </ul>
+ *
+ * @param obj The <code>Object</code> to test for equality
+ *
+ * @return <code>true</code> if the specified object is equal to this one, <code>false</code> otherwise.
+ */
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof UnresolvedPermission))
+ return (false);
+
+ UnresolvedPermission up = (UnresolvedPermission) obj;
+
+ if (!getName().equals(up.getName()))
+ return (false);
+
+ if (!getActions().equals(up.getActions()))
+ return (false);
+
+ if (!type.equals(up.type))
+ return (false);
+
+ if (!certs.equals(up.certs))
+ return (false);
+
+ return (true);
+ }
+
+ /**
+ * Returns a hash code value for this object.
+ *
+ * @return A hash value
+ */
+ public int hashCode()
+ {
+ return (System.identityHashCode(this));
+ }
+
+ /**
+ * This method returns a <code>String</code> representation of this
+ * class. The format is: '(unresolved "ClassName "name" "actions")'
+ *
+ * @return A <code>String</code> representation of this object
+ */
+ public String toString()
+ {
+ return "(unresolved " + type + " " + getName() + " " + getActions() + ")";
+ }
+
+ /**
+ * This class returns a <code>PermissionCollection</code> object that can
+ * be used to store instances of <code>UnresolvedPermission</code>. If
+ * <code>null</code> is returned, the caller is free to use any desired
+ * <code>PermissionCollection</code>.
+ *
+ * @return A new <code>PermissionCollection</code>.
+ */
+ public PermissionCollection newPermissionCollection()
+ {
+ return (null);
+ }
+}
diff --git a/libjava/java/security/acl/Acl.java b/libjava/java/security/acl/Acl.java
new file mode 100644
index 0000000..e5a3e08
--- /dev/null
+++ b/libjava/java/security/acl/Acl.java
@@ -0,0 +1,138 @@
+/* Acl.java -- An access control list
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security.acl;
+
+import java.security.Principal;
+import java.util.Enumeration;
+
+/**
+ * A Java access control list (ACL) is a group of individual ACL entries.
+ * These entries consist of a <code>Principal</code> and a list of
+ * permissions this <code>Principal</code> is either granted or denied.
+ * A given <code>Principal</code> can have at most one positive ACL entry
+ * (i.e., one that grants permissions) and one negative ACL entry (i.e., one
+ * that denies permissions). If a given permission is both granted and
+ * denied, the ACL treats it as if it were never granted or denied. If
+ * both a <code>Principal</code> and a <code>Group</code> to which the
+ * <code>Principal</code> belongs have an ACL entry, the permissions for
+ * the individual <code>Principal</code> take precedence over the
+ * permissions of the <code>Group</code> if there is a conflict.
+ * <p
+ * Additionally, the ACL interface extends the <code>Owner</code> interface
+ * and so an ACL has owners. Actions which modify the ACL are restricted
+ * to owners.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public interface Acl extends Owner
+{
+
+ /**
+ * This method returns the name of this ACL.
+ *
+ * @return The name of this ACL
+ */
+ public abstract String getName();
+
+ /**
+ * This method sets the name of the ACL
+ *
+ * @param caller The <code>Principal</code> requesting the action.
+ * @param name The new name for this ACL.
+ *
+ * @exception NotOwnerException If the caller is not an owner of this ACL.
+ */
+ public abstract void setName(Principal caller, String name)
+ throws NotOwnerException;
+
+ /**
+ * This method adds the specified entry to the ACL
+ *
+ * @param caller The <code>Principal</code> requesting the addition
+ * @param entry The ACL entry to add
+ *
+ * @return <code>true</code> if the entry was added, <code>false</code> if there is already an entry of the same type for the <code>Principal</code>.
+ *
+ * @exception NotOwnerException If the caller is not an owner of this ACL.
+ */
+ public abstract boolean addEntry(Principal caller, AclEntry entry)
+ throws NotOwnerException;
+
+ /**
+ * This method delets the specified entry from the ACL
+ *
+ * @param caller The <code>Principal</code> requesting the deletion.
+ * @param entry The ACL entry to delete
+ *
+ * @return <code>true</code> if the entry was deleted, or <code>false</code> if this entry was not part of the ACL to begin with
+ *
+ * @exception NotOwnerException If the caller is not an owner of this ACL.
+ */
+ public abstract boolean removeEntry(Principal caller, AclEntry entry)
+ throws NotOwnerException;
+
+ /**
+ * This method returns a list of all the entries in the ACL as an
+ * <code>Enumeration</code>.
+ *
+ * @return An enumeration of the ACL entries
+ */
+ public abstract Enumeration entries();
+
+ /**
+ * This method tests whether or not the specified <code>Principal</code>
+ * has the specified <code>Permission</code>
+ *
+ * @param user The <code>Principal</code> to test
+ * @param perm The <code>Permission</code> to test for
+ *
+ * @return <code>true</code> if the user has been granted the permission, <code>false</code> otherwise
+ */
+ public abstract boolean checkPermission(Principal user, Permission perm);
+
+ /**
+ * This method returns a list of <code>Permission</code>'s that are granted
+ * to a particular <code>Principal</code>. This includes any permissions
+ * that are granted to <code>Group</code>'s to which the <code>Principal</code>
+ * belongs unless they are overridden by a negative ACL. This permission
+ * list is returned as an <code>Enumeration</code>.
+ *
+ * @param user The <code>Principal</code> to retrieve permissions for.
+ *
+ * @return A list of permissions for the <code>Principal</code>.
+ */
+ public abstract Enumeration getPermissions(Principal user);
+
+ /**
+ * This method returns the ACL as a <code>String</code>
+ *
+ * @return A <code>String</code> representation of this ACL
+ */
+ public abstract String toString();
+}
diff --git a/libjava/java/security/acl/AclEntry.java b/libjava/java/security/acl/AclEntry.java
new file mode 100644
index 0000000..8741bce
--- /dev/null
+++ b/libjava/java/security/acl/AclEntry.java
@@ -0,0 +1,132 @@
+/* AclEntry.java -- An entry in an ACL list.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security.acl;
+
+import java.security.Principal;
+import java.util.Enumeration;
+
+/**
+ * This interface models an entry in an access control list (ACL). Java
+ * ACL's consist of a list of entries, where each consists of a
+ * <code>Principal</code> and a list of <code>Permission</code>'s which
+ * have been granted to that <code>Principal</code>. An ACL can also
+ * be <em>negative</em>, which indicates that the list of
+ * <code>Permission</code>'s is a list of permissions that are <em>not</em>
+ * granted to the <code>Principal</code>. A <code>Principal</code> can
+ * have at most one regular (or positive) ACL entry and one negative
+ * ACL entry.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public interface AclEntry extends Cloneable
+{
+ /**
+ * This method returns the <code>Principal</code> associated with this
+ * ACL entry.
+ *
+ * @return The <code>Principal</code> for this ACL entry
+ */
+ public abstract Principal getPrincipal();
+
+ /**
+ * This method sets ths <code>Principal</code> associated with this
+ * ACL entry. This operation will only succeed if there is not already
+ * a <code>Principal</code> assigned.
+ *
+ * @param user The <code>Principal</code> for this ACL entry
+ *
+ * @return <code>true</code> if the <code>Principal</code> was successfully set or <code>false</code> if this entry already has a <code>Principal</code>.
+ */
+ public abstract boolean setPrincipal(Principal user);
+
+ /**
+ * This method sets this ACL entry to be a <em>negative</em> entry, indicating
+ * that it contains a list of permissions that are <em>not</em> granted
+ * to the entry's <code>Principal</code>. Note that there is no way to
+ * undo this operation.
+ */
+ public abstract void setNegativePermissions();
+
+ /**
+ * This method tests whether or not this ACL entry is a negative entry or not.
+ *
+ * @return <code>true</code> if this ACL entry is negative, <code>false</code> otherwise
+ */
+ public abstract boolean isNegative();
+
+ /**
+ * This method adds the specified permission to this ACL entry.
+ *
+ * @param perm The <code>Permission</code> to add
+ *
+ * @return <code>true</code> if the permission was added or <code>false</code> if it was already set for this entry
+ */
+ public abstract boolean addPermission(Permission permission);
+
+ /**
+ * This method deletes the specified permission to this ACL entry.
+ *
+ * @param perm The <code>Permission</code> to delete from this ACL entry.
+ *
+ * @return <code>true</code> if the permission was successfully deleted or <code>false</code> if the permission was not part of this ACL to begin with
+ */
+ public abstract boolean removePermission(Permission perm);
+
+ /**
+ * This method tests whether or not the specified permission is associated
+ * with this ACL entry.
+ *
+ * @param perm The <code>Permission</code> to test
+ *
+ * @return <code>true</code> if this permission is associated with this entry or <code>false</code> otherwise
+ */
+ public abstract boolean checkPermission(Permission permission);
+
+ /**
+ * This method returns a list of all <code>Permission</code> objects
+ * associated with this ACL entry as an <code>Enumeration</code>.
+ *
+ * @return A list of permissions for this ACL entry
+ */
+ public abstract Enumeration permissions();
+
+ /**
+ * This method returns this object as a <code>String</code>.
+ *
+ * @return A <code>String</code> representation of this object
+ */
+ public abstract String toString();
+
+ /**
+ * This method returns a clone of this ACL entry
+ *
+ * @return A clone of this ACL entry
+ */
+ public abstract Object clone();
+}
diff --git a/libjava/java/security/acl/AclNotFoundException.java b/libjava/java/security/acl/AclNotFoundException.java
new file mode 100644
index 0000000..2593cff
--- /dev/null
+++ b/libjava/java/security/acl/AclNotFoundException.java
@@ -0,0 +1,46 @@
+/* AclNotFoundException.java -- What it says
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security.acl;
+
+/**
+ * This exception is thrown when a requested access control list (ACL) is
+ * not found.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public class AclNotFoundException extends Exception
+{
+ /**
+ * Initializes a new instance of this class with no descriptive message
+ */
+ public AclNotFoundException()
+ {
+ super();
+ }
+}
diff --git a/libjava/java/security/acl/Group.java b/libjava/java/security/acl/Group.java
new file mode 100644
index 0000000..ccdd037
--- /dev/null
+++ b/libjava/java/security/acl/Group.java
@@ -0,0 +1,79 @@
+/* Group.java -- Represents a group of Principals
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security.acl;
+
+import java.security.Principal;
+import java.util.Enumeration;
+
+/**
+ * This interface represents a group of <code>Principals</code>. Note that
+ * since this interface extends <code>Principal</code>, a <code>Group</code>
+ * can be used where ever a <code>Principal</code> is requested. This
+ * includes arguments to the methods in this interface.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public interface Group
+{
+ /**
+ * This method adds a new <code>Principal</code> to this group.
+ *
+ * @param user The new <code>Principal</code> to add
+ *
+ * @return <code>true</code> if the user was successfully added or <code>false</code> if the user is already a member
+ */
+ public abstract boolean addMember(Principal user);
+
+ /**
+ * This method deletes a member from the group.
+ *
+ * @param user The <code>Principal</code> to delete
+ *
+ * @return <code>true</code> if the user was successfully deleted or <code>false</code> if the user is not a member of the group
+ */
+ public abstract boolean removeMember(Principal user);
+
+ /**
+ * This method tests whether or not a given <code>Principal</code> is a
+ * member of this group.
+ *
+ * @param user The <code>Principal</code> to test for membership
+ *
+ * @return <code>true</code> if the user is member, <code>false</code> otherwise
+ */
+ public abstract boolean isMember();
+
+ /**
+ * This method returns a list of all members of the group as an
+ * <code>Enumeration</code>.
+ *
+ * @return The list of all members of the group
+ */
+ public abstract Enumeration members();
+}
diff --git a/libjava/java/security/acl/LastOwnerException.java b/libjava/java/security/acl/LastOwnerException.java
new file mode 100644
index 0000000..c85c2cb
--- /dev/null
+++ b/libjava/java/security/acl/LastOwnerException.java
@@ -0,0 +1,47 @@
+/* LastOwnerException.java -- User attempted to delete last ACL owner
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security.acl;
+
+/**
+ * This exception is thrown when an attempt is made to delete the last owner
+ * of an access control list (ACL)
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public class LastOwnerException extends java.lang.Exception
+{
+ /**
+ * Initialize a new instance of <code>LastOwnerException</code> that does
+ * not have a log message.
+ */
+ public LastOwnerException()
+ {
+ super();
+ }
+}
diff --git a/libjava/java/security/acl/NotOwnerException.java b/libjava/java/security/acl/NotOwnerException.java
new file mode 100644
index 0000000..80bc797
--- /dev/null
+++ b/libjava/java/security/acl/NotOwnerException.java
@@ -0,0 +1,49 @@
+/* NotOwnerException.java -- Attempt to modify an unowned ACL
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security.acl;
+
+/**
+ * This exception is thrown whenever an operation is attempted that requires
+ * the caller to be the owner of the access control list (ACL) when the caller
+ * is in fact not the owner of the ACL.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public class NotOwnerException extends java.lang.Exception
+{
+
+ /**
+ * Initializes a new instance of <code>NotOwnerException</code> that does
+ * not have a descriptive message.
+ */
+ public NotOwnerException()
+ {
+ super();
+ }
+}
diff --git a/libjava/java/security/acl/Owner.java b/libjava/java/security/acl/Owner.java
new file mode 100644
index 0000000..c6fec0f
--- /dev/null
+++ b/libjava/java/security/acl/Owner.java
@@ -0,0 +1,84 @@
+/* Owner.java -- ACL owner
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security.acl;
+
+import java.security.Principal;
+
+/**
+ * This interface provides a mechanism for maintaining a list of owners
+ * of an access control list (ACL). Since a <code>Principal</code> must
+ * be an owner in order to modify the owner list, a mechanism must be
+ * provided to specify the initial owner of the ACL. The proper way to do
+ * this is for the implementing class to specify the initial owner in
+ * the contructor for that class.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public interface Owner
+{
+ /**
+ * This method adds an owner to the access control list (ACL). Only a
+ * <code>Principal</code> who is already an owner can perform this operation.
+ *
+ * @param caller The <code>Principal</code> who is requesting that an owner be added
+ * @param owner The <code>Principal</code> to add as a new owner
+ *
+ * @param <code>true</code> if the new owner was successfully added or <code>false</code> if the specified new owner is already an owner
+ *
+ * @exception NotOwnerException If the caller is not already an owner of this ACL
+ */
+ public abstract boolean addOwner(Principal caller, Principal owner)
+ throws NotOwnerException;
+
+ /**
+ * This method delets an owner from the access control list (ACL). Only a
+ * <code>Principal</code> who is an owner can perform this operation. An
+ * owner can delete itself from the list. If there is only one
+ * owner remaining on this list, any attempt to delete it will throw an
+ * exception.
+ *
+ * @param caller The <code>Principal</code> who is requesting that an owner be deleted
+ * @param owner The <code>Principal</code> to delete as an owner
+ *
+ * @param <code>true</code> if the new owner was successfully deleted or <code>false</code> if the specified owner is not currently an owner
+ *
+ * @exception NotOwnerException If the caller is not already an owner of this ACL
+ * @exception LastOwnerException If completing the operation would delete the last ACL owner
+ */
+ public abstract boolean deleteOwner(Principal caller, Principal owner)
+ throws NotOwnerException, LastOwnerException;
+
+ /**
+ * This method tests whether or not a given <code>Principal</code> is an
+ * owner of this access control list (ACL).
+ *
+ * @return <code>true</code> if the <code>Principal</code> is an owner, <code>false</code> otherwise
+ */
+ public abstract boolean isOwner(Principal owner);
+}
diff --git a/libjava/java/security/acl/Permission.java b/libjava/java/security/acl/Permission.java
new file mode 100644
index 0000000..9569038
--- /dev/null
+++ b/libjava/java/security/acl/Permission.java
@@ -0,0 +1,56 @@
+/* Permission.java -- Information about an ACL permission
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security.acl;
+
+/**
+ * This interface provides information about a permission that can be
+ * granted. Note that this is <em>not</em> the same as the class
+ * <code>java.security.Permission</code>.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public interface Permission
+{
+ /**
+ * This method tests whether or not a specified <code>Permission</code>
+ * (passed as an <code>Object</code>) is the same as this permission.
+ *
+ * @param perm The permission to check for equality
+ *
+ * @return <code>true</code> if the specified permission is the same as this one, <code>false</code> otherwise
+ */
+ public abstract boolean equals(Object perm);
+
+ /**
+ * This method returns this <code>Permission</code> as a <code>String</code>.
+ *
+ * @return A <code>String</code> representing this permission.
+ */
+ public String toString();
+}
diff --git a/libjava/java/security/interfaces/DSAKey.java b/libjava/java/security/interfaces/DSAKey.java
index 3920d7b..1670b5a 100644
--- a/libjava/java/security/interfaces/DSAKey.java
+++ b/libjava/java/security/interfaces/DSAKey.java
@@ -1,23 +1,45 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* DSAKey.java -- Interface for Digital Signature Algorith key
+ Copyright (C) 1998 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
-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.
+ * This interface is implemented by a class to return the parameters
+ * of a Digital Signature Algorithm (DSA) public or private key.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
*/
-
public interface DSAKey
{
- public DSAParams getParams();
+ /**
+ * This method returns non-secret parameters of the DSA key
+ *
+ * @return The DSA parameters
+ */
+ public abstract DSAParams getParams();
}
diff --git a/libjava/java/security/interfaces/DSAKeyPairGenerator.java b/libjava/java/security/interfaces/DSAKeyPairGenerator.java
new file mode 100644
index 0000000..af087e0
--- /dev/null
+++ b/libjava/java/security/interfaces/DSAKeyPairGenerator.java
@@ -0,0 +1,75 @@
+/* DSAKeyPairGenerator.java -- Initialize a DSA key generator
+ Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security.interfaces;
+
+import java.security.SecureRandom;
+import java.security.InvalidParameterException;
+
+/**
+ * This interface contains methods for intializing a Digital Signature
+ * Algorithm key generation engine. The initialize methods may be called
+ * any number of times. If no explicity initialization call is made, then
+ * the engine defaults to generating 1024-bit keys using pre-calculated
+ * base, prime, and subprime values.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public interface DSAKeyPairGenerator
+{
+ /**
+ * Initializes the key generator with the specified DSA parameters and
+ * random bit source
+ *
+ * @param params The DSA parameters to use
+ * @param random The random bit source to use
+ *
+ * @exception InvalidParameterException If the parameters passed are not valid
+ */
+ public abstract void initialize(DSAParams params, SecureRandom random)
+ throws InvalidParameterException;
+
+ /**
+ * Initializes the key generator to a give modulus. If the <code>genParams</code>
+ * value is <code>true</code> then new base, prime, and subprime values
+ * will be generated for the given modulus. If not, the pre-calculated
+ * values will be used. If no pre-calculated values exist for the specified
+ * modulus, an exception will be thrown. It is guaranteed that there will
+ * always be pre-calculated values for all modulus values between 512 and
+ * 1024 bits inclusives.
+ *
+ * @param modlen The modulus length
+ * @param genParams <code>true</code> to generate new DSA parameters, <code>false</code> otherwise
+ * @param random The random bit source to use
+ *
+ * @exception InvalidParameterException If a parameter is invalid
+ */
+ public abstract void initialize(int modlen, boolean genParams,
+ SecureRandom random)
+ throws InvalidParameterException;
+}
diff --git a/libjava/java/security/interfaces/DSAParams.java b/libjava/java/security/interfaces/DSAParams.java
index 8483bd5..fea3aa8 100644
--- a/libjava/java/security/interfaces/DSAParams.java
+++ b/libjava/java/security/interfaces/DSAParams.java
@@ -1,26 +1,61 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* DSAParams.java -- Digital Signature Algorithm parameter access
+ Copyright (C) 1998 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
-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.
+ * This interface allows the Digital Signature Algorithm (DSA) parameters
+ * to be queried.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
*/
-
-/* 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();
+ /**
+ * Returns the base, or 'g' value
+ *
+ * @return The DSA base value
+ */
+ public abstract BigInteger getG();
+
+ /**
+ * Returns the prime, or 'p' value
+ *
+ * @return The DSA prime value
+ */
+ public abstract BigInteger getP();
+
+ /**
+ * Returns the subprime, or 'q' value
+ *
+ * @return The DSA subprime value
+ */
+ public abstract BigInteger getQ();
}
diff --git a/libjava/java/security/interfaces/DSAPrivateKey.java b/libjava/java/security/interfaces/DSAPrivateKey.java
index 5d70136..70a432d 100644
--- a/libjava/java/security/interfaces/DSAPrivateKey.java
+++ b/libjava/java/security/interfaces/DSAPrivateKey.java
@@ -1,27 +1,45 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* DSAPublicKey.java -- A Digital Signature Algorithm private key
+ Copyright (C) 1998, 2000 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
-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.
+ * This interface models a Digital Signature Algorithm (DSA) private key
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
*/
-
public interface DSAPrivateKey extends DSAKey, PrivateKey
{
- public static final long serialVersionUID = 7776497482533790279L;
-
+ /**
+ * This method returns the value of the DSA private key
+ */
public BigInteger getX();
}
diff --git a/libjava/java/security/interfaces/DSAPublicKey.java b/libjava/java/security/interfaces/DSAPublicKey.java
index a8bb885..6a2ad8f 100644
--- a/libjava/java/security/interfaces/DSAPublicKey.java
+++ b/libjava/java/security/interfaces/DSAPublicKey.java
@@ -1,27 +1,45 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* DSAPublicKey.java -- A Digital Signature Algorithm public key
+ Copyright (C) 1998, 2000 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
-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.
+ * This interface models a Digital Signature Algorithm (DSA) public key
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
*/
-
public interface DSAPublicKey extends DSAKey, PublicKey
{
- public static final long serialVersionUID = 1234526332779022332L;
-
+ /**
+ * This method returns the value of the DSA public key
+ */
public BigInteger getY();
}
diff --git a/libjava/java/security/interfaces/RSAKey.java b/libjava/java/security/interfaces/RSAKey.java
new file mode 100644
index 0000000..1233f95
--- /dev/null
+++ b/libjava/java/security/interfaces/RSAKey.java
@@ -0,0 +1,44 @@
+/* RSAKey.java --- A generic RSA Key interface
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.security.interfaces;
+
+/**
+ A generic RSA Key interface for public and private keys
+
+ @since JDK 1.3
+
+ @author Mark Benvenuto
+ */
+public interface RSAKey
+{
+ /**
+ Generates a modulus.
+
+ @returns a modulus
+ */
+ public java.math.BigInteger getModulus();
+}
diff --git a/libjava/java/security/interfaces/RSAPrivateCrtKey.java b/libjava/java/security/interfaces/RSAPrivateCrtKey.java
index cca294a..7e895dc 100644
--- a/libjava/java/security/interfaces/RSAPrivateCrtKey.java
+++ b/libjava/java/security/interfaces/RSAPrivateCrtKey.java
@@ -1,30 +1,82 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* RSAPrivateCrtKey.java -- An RSA private key in CRT format
+ Copyright (C) 1998 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
-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.
+ * This interface provides access to information about an RSA private
+ * key in Chinese Remainder Theorem (CRT) format.
+ *
+ * @version 0.0
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
*/
-
-// 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();
+ /**
+ * Returns the public exponent for this key
+ *
+ * @return The public exponent for this key
+ */
+ public abstract BigInteger getPublicExponent();
+
+ /**
+ * Returns the primeP value
+ *
+ * @return The primeP value
+ */
+ public abstract BigInteger getPrimeP();
+
+ /**
+ * Returns the primeQ value
+ *
+ * @return The primeQ value
+ */
+ public abstract BigInteger getPrimeQ();
+
+ /**
+ * Returns the primeExponentP
+ *
+ * @return The primeExponentP
+ */
+ public abstract BigInteger getPrimeExponentP();
+
+ /**
+ * Returns the primeExponentQ
+ *
+ * @return The primeExponentQ
+ */
+ public abstract BigInteger getPrimeExponentQ();
+
+ /**
+ * Returns the CRT coefficient
+ *
+ * @return The CRT coefficient
+ */
+ public abstract BigInteger getCrtCoefficient();
}
diff --git a/libjava/java/security/interfaces/RSAPrivateKey.java b/libjava/java/security/interfaces/RSAPrivateKey.java
index 4c16b05..f474795 100644
--- a/libjava/java/security/interfaces/RSAPrivateKey.java
+++ b/libjava/java/security/interfaces/RSAPrivateKey.java
@@ -1,27 +1,47 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* RSAPrivateKey.java -- An RSA private key
+ Copyright (C) 1998, 1999 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
-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.
+ * This interface provides access to information about an RSA private key.
+ *
+ * @version 0.1
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
*/
-
-// JDK1.2
-public interface RSAPrivateKey extends PrivateKey
+public interface RSAPrivateKey extends PrivateKey, RSAKey
{
- public BigInteger getModulus();
- public BigInteger getPrivateExponent();
+ /**
+ * Returns the private exponent value for this key
+ *
+ * @return The private exponent value for this key
+ */
+ public abstract BigInteger getPrivateExponent();
}
diff --git a/libjava/java/security/interfaces/RSAPublicKey.java b/libjava/java/security/interfaces/RSAPublicKey.java
index 0bee88d..51a555e 100644
--- a/libjava/java/security/interfaces/RSAPublicKey.java
+++ b/libjava/java/security/interfaces/RSAPublicKey.java
@@ -1,27 +1,47 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* RSAPublicKey.java -- An RSA public key
+ Copyright (C) 1998, 1999 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
-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.
+ * This interface provides access to information about an RSA public key.
+ *
+ * @version 0.1
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
*/
-
-// JDK1.2
-public interface RSAPublicKey extends PublicKey
+public interface RSAPublicKey extends PublicKey, RSAKey
{
- public BigInteger getModulus();
- public BigInteger getPublicExponent();
+ /**
+ * Returns the public exponent value for this key
+ *
+ * @return The public exponent value for this key
+ */
+ public abstract BigInteger getPublicExponent();
}
diff --git a/libjava/java/security/spec/AlgorithmParameterSpec.java b/libjava/java/security/spec/AlgorithmParameterSpec.java
index 5781623..63f5314 100644
--- a/libjava/java/security/spec/AlgorithmParameterSpec.java
+++ b/libjava/java/security/spec/AlgorithmParameterSpec.java
@@ -1,25 +1,41 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* AlgorithmParameterSpec.java --- Algorithm Parameter Spec Interface
+ Copyright (C) 1999 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+
package java.security.spec;
/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
+ A transparent interface for Algorithm Parameter Specifications.
+ It contains no member functions. It is used to group
+ algorithm parameter classes.
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-// JDK1.2
-public interface AlgorithmParameterSpec
+ @since JDK 1.2
+
+ @author Mark Benvenuto
+*/
+public abstract interface AlgorithmParameterSpec
{
- // This interface contains no methods or constants. Its only purpose is
- // to group (and provide type safety for) all key specifications.
}
diff --git a/libjava/java/security/spec/DSAParameterSpec.java b/libjava/java/security/spec/DSAParameterSpec.java
new file mode 100644
index 0000000..b904089
--- /dev/null
+++ b/libjava/java/security/spec/DSAParameterSpec.java
@@ -0,0 +1,89 @@
+/* DSAParameterSpec.java --- DSA Parameter Specificaton class
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+
+package java.security.spec;
+import java.security.interfaces.DSAParams;
+import java.math.BigInteger;
+
+/**
+ DSA Parameter class Specification. Used to maintain the DSA
+ Parameters.
+
+ @since JDK 1.2
+
+ @author Mark Benvenuto
+*/
+public class DSAParameterSpec extends Object implements AlgorithmParameterSpec, DSAParams
+{
+ private BigInteger p = null;
+ private BigInteger q = null;
+ private BigInteger g = null;
+
+ /**
+ Constructs a new DSAParameterSpec with the specified p, q, and g.
+
+ @param p the prime
+ @param q the sub-prime
+ @param g the base
+ */
+ public DSAParameterSpec(BigInteger p, BigInteger q, BigInteger g)
+ {
+ this.p = p;
+ this.q = q;
+ this.g = g;
+ }
+ /**
+ Returns p for the DSA algorithm.
+
+ @return Returns the requested BigInteger
+ */
+ public BigInteger getP()
+ {
+ return this.q;
+ }
+
+ /**
+ Returns p for the DSA algorithm.
+
+ @return Returns the requested BigInteger
+ */
+ public BigInteger getQ()
+ {
+ return this.q;
+ }
+
+ /**
+ Returns g for the DSA algorithm.
+
+ @return Returns the requested BigInteger
+ */
+ public BigInteger getG()
+ {
+ return this.g;
+ }
+
+}
diff --git a/libjava/java/security/spec/DSAPrivateKeySpec.java b/libjava/java/security/spec/DSAPrivateKeySpec.java
new file mode 100644
index 0000000..ee31b96
--- /dev/null
+++ b/libjava/java/security/spec/DSAPrivateKeySpec.java
@@ -0,0 +1,102 @@
+/* DSAPrivateKeySpec.java --- DSA Private Key Specificaton class
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+
+package java.security.spec;
+import java.math.BigInteger;
+
+/**
+ DSA Private Key class Specification. Used to maintain the DSA
+ Private Keys.
+
+ @since JDK 1.2
+
+ @author Mark Benvenuto
+*/
+public class DSAPrivateKeySpec extends Object implements KeySpec
+{
+ private BigInteger x = null;
+ private BigInteger p = null;
+ private BigInteger q = null;
+ private BigInteger g = null;
+
+ /**
+ Constructs a new DSAPrivateKeySpec with the specified x, p, q, and g.
+
+ @param x the private key
+ @param p the prime
+ @param q the sub-prime
+ @param g the base
+ */
+ public DSAPrivateKeySpec(BigInteger x, BigInteger p, BigInteger q, BigInteger g)
+ {
+ this.x = x;
+ this.p = p;
+ this.q = q;
+ this.g = g;
+ }
+
+ /**
+ Returns private key x for the DSA algorithm.
+
+ @return Returns the requested BigInteger
+ */
+ public BigInteger getX()
+ {
+ return this.x;
+ }
+
+ /**
+ Returns p for the DSA algorithm.
+
+ @return Returns the requested BigInteger
+ */
+ public BigInteger getP()
+ {
+ return this.q;
+ }
+
+ /**
+ Returns p for the DSA algorithm.
+
+ @return Returns the requested BigInteger
+ */
+ public BigInteger getQ()
+ {
+ return this.q;
+ }
+
+ /**
+ Returns g for the DSA algorithm.
+
+ @return Returns the requested BigInteger
+ */
+ public BigInteger getG()
+ {
+ return this.g;
+ }
+
+}
diff --git a/libjava/java/security/spec/DSAPublicKeySpec.java b/libjava/java/security/spec/DSAPublicKeySpec.java
new file mode 100644
index 0000000..d1fd237
--- /dev/null
+++ b/libjava/java/security/spec/DSAPublicKeySpec.java
@@ -0,0 +1,102 @@
+/* DSAPublicKeySpec.java --- DSA Public Key Specificaton class
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+
+package java.security.spec;
+import java.math.BigInteger;
+
+/**
+ DSA Public Key class Specification. Used to maintain the DSA
+ Public Keys.
+
+ @since JDK 1.2
+
+ @author Mark Benvenuto
+*/
+public class DSAPublicKeySpec extends Object implements KeySpec
+{
+ private BigInteger y = null;
+ private BigInteger p = null;
+ private BigInteger q = null;
+ private BigInteger g = null;
+
+ /**
+ Constructs a new DSAPublicKeySpec with the specified y, p, q, and g.
+
+ @param y the public key
+ @param p the prime
+ @param q the sub-prime
+ @param g the base
+ */
+ public DSAPublicKeySpec(BigInteger x, BigInteger p, BigInteger q, BigInteger g)
+ {
+ this.y = y;
+ this.p = p;
+ this.q = q;
+ this.g = g;
+ }
+
+ /**
+ Returns public key y for the DSA algorithm.
+
+ @return Returns the requested BigInteger
+ */
+ public BigInteger getY()
+ {
+ return this.y;
+ }
+
+ /**
+ Returns p for the DSA algorithm.
+
+ @return Returns the requested BigInteger
+ */
+ public BigInteger getP()
+ {
+ return this.q;
+ }
+
+ /**
+ Returns p for the DSA algorithm.
+
+ @return Returns the requested BigInteger
+ */
+ public BigInteger getQ()
+ {
+ return this.q;
+ }
+
+ /**
+ Returns g for the DSA algorithm.
+
+ @return Returns the requested BigInteger
+ */
+ public BigInteger getG()
+ {
+ return this.g;
+ }
+
+}
diff --git a/libjava/java/security/spec/EncodedKeySpec.java b/libjava/java/security/spec/EncodedKeySpec.java
new file mode 100644
index 0000000..d0a83f8
--- /dev/null
+++ b/libjava/java/security/spec/EncodedKeySpec.java
@@ -0,0 +1,74 @@
+/* EncodedKeySpec.java --- Encoded Key Specificaton class
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+
+package java.security.spec;
+
+/**
+ Encoded Key Specification class which is used to store
+ byte encoded keys.
+
+ @since JDK 1.2
+
+ @author Mark Benvenuto
+*/
+public abstract class EncodedKeySpec
+{
+
+ private byte[] encodedKey;
+
+ /**
+ Constructs a new EncodedKeySpec with the specified encoded key.
+
+ @param encodedKey A key to store
+ */
+ public EncodedKeySpec(byte[] encodedKey)
+ {
+ this.encodedKey = encodedKey;
+ }
+
+ /**
+ Gets the encoded key in byte format.
+
+ @returns the encoded key
+ */
+ public byte[] getEncoded()
+ {
+ return this.encodedKey;
+ }
+
+ /**
+ Returns the name of the key format used.
+
+ This name is the format such as "PKCS#8" or "X.509" which
+ if it matches a Key class name of the same type can be
+ transformed using the apporiate KeyFactory.
+
+ @return a string representing the name
+ */
+ public abstract String getFormat();
+
+}
diff --git a/libjava/java/security/spec/InvalidKeySpecException.java b/libjava/java/security/spec/InvalidKeySpecException.java
index 632fd25..15fa883 100644
--- a/libjava/java/security/spec/InvalidKeySpecException.java
+++ b/libjava/java/security/spec/InvalidKeySpecException.java
@@ -1,33 +1,59 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* InvalidKeySpecException.java --- Invalid KeySpec Exception
+ Copyright (C) 1999 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
-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.
- */
+ Exception for an invalid key specification.
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
+ @since JDK 1.2
-// JDK1.2
-public class InvalidKeySpecException extends GeneralSecurityException
+ @author Mark Benvenuto
+*/
+public class InvalidKeySpecException extends GeneralSecurityException
{
- public InvalidKeySpecException()
+
+ /**
+ Constructs an InvalidKeySpecException without a message string.
+ */
+ public InvalidKeySpecException()
{
super();
}
+ /**
+ Constructs an InvalidKeySpecException with a message string.
+
+ @param msg A message to display with exception
+ */
public InvalidKeySpecException(String msg)
{
- super(msg);
+ super( msg );
}
+
}
diff --git a/libjava/java/security/spec/InvalidParameterSpecException.java b/libjava/java/security/spec/InvalidParameterSpecException.java
index 1e2aff5..f3e8792 100644
--- a/libjava/java/security/spec/InvalidParameterSpecException.java
+++ b/libjava/java/security/spec/InvalidParameterSpecException.java
@@ -1,33 +1,59 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* InvalidParameterSpecException.java --- Invalid ParameterSpec Exception
+ Copyright (C) 1999 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
-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.
- */
+ Exception for an invalid algorithm specification.
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
+ @since JDK 1.2
-// JDK1.2
+ @author Mark Benvenuto
+*/
public class InvalidParameterSpecException extends GeneralSecurityException
{
- public InvalidParameterSpecException()
+
+ /**
+ Constructs an InvalidParameterSpecException without a message string.
+ */
+ public InvalidParameterSpecException()
{
super();
}
- public InvalidParameterSpecException(String msg)
+ /**
+ Constructs an InvalidParameterSpecException with a message string.
+
+ @param msg A message to display with exception
+ */
+ public InvalidParameterSpecException(String msg)
{
- super(msg);
+ super( msg );
}
+
}
diff --git a/libjava/java/security/spec/KeySpec.java b/libjava/java/security/spec/KeySpec.java
index 75e50f9..6c74dc5 100644
--- a/libjava/java/security/spec/KeySpec.java
+++ b/libjava/java/security/spec/KeySpec.java
@@ -1,25 +1,41 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* KeySpec.java --- Key Specification interface
+ Copyright (C) 1999 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+
package java.security.spec;
/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
+ A transparent interface for Key Specifications.
+ It contains no member functions. It is used to group
+ key classes.
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-// JDK1.2
-public interface KeySpec
+ @since JDK 1.2
+
+ @author Mark Benvenuto
+*/
+public abstract interface KeySpec
{
- // This interface contains no methods or constants. Its only purpose is
- // to group (and provide type safety for) all key specifications.
}
diff --git a/libjava/java/security/spec/PKCS8EncodedKeySpec.java b/libjava/java/security/spec/PKCS8EncodedKeySpec.java
new file mode 100644
index 0000000..c2c0084
--- /dev/null
+++ b/libjava/java/security/spec/PKCS8EncodedKeySpec.java
@@ -0,0 +1,70 @@
+/* PKCS8EncodedKeySpec.java --- PKCS8 Encoded Key Specificaton class
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+
+package java.security.spec;
+
+/**
+ PKCS8 Encoded Key Specification class which is used to store
+ "PKCS#8" byte encoded keys.
+
+ @since JDK 1.2
+
+ @author Mark Benvenuto
+*/
+public class PKCS8EncodedKeySpec extends EncodedKeySpec
+{
+ /**
+ Constructs a new PKCS8EncodedKeySpec with the specified encoded key.
+
+ @param encodedKey A key to store, assumed to be "PKCS#8"
+ */
+ public PKCS8EncodedKeySpec(byte[] encodedKey)
+ {
+ super( encodedKey );
+ }
+
+ /**
+ Gets the encoded key in byte format.
+
+ @returns the encoded key
+*/
+ public byte[] getEncoded()
+ {
+ return super.getEncoded();
+ }
+
+ /**
+ Returns the name of the key format used which is "PKCS#8"
+
+ @return a string representing the name
+*/
+ public String getFormat()
+ {
+ return "PKCS#8";
+ }
+
+}
diff --git a/libjava/java/security/spec/RSAKeyGenParameterSpec.java b/libjava/java/security/spec/RSAKeyGenParameterSpec.java
new file mode 100644
index 0000000..1d9d932
--- /dev/null
+++ b/libjava/java/security/spec/RSAKeyGenParameterSpec.java
@@ -0,0 +1,86 @@
+/* RSAKeyGenParameterSpec.java --- RSA Key Generator Parameter Spec Class
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+
+package java.security.spec;
+import java.math.BigInteger;
+
+/**
+ This class generates a set of RSA Key parameters used in the generation
+ of RSA keys.
+
+ @since JDK 1.3
+
+ @author Mark Benvenuto
+*/
+public class RSAKeyGenParameterSpec implements AlgorithmParameterSpec
+{
+ private int keysize;
+ private BigInteger publicExponent;
+
+ /**
+ Public Exponent F0 = 3
+ */
+ public static final BigInteger F0 = new BigInteger("3");
+
+ /**
+ Public Exponent F4 = 3
+ */
+ public static final BigInteger F4 = new BigInteger("65537");
+
+ /**
+ Create a new RSAKeyGenParameterSpec to store the RSA key's keysize
+ and public exponent
+
+ @param keysize Modulus size of key in bits
+ @param publicExponent - the exponent
+ */
+ public RSAKeyGenParameterSpec(int keysize, BigInteger publicExponent)
+ {
+ this.keysize = keysize;
+ this.publicExponent = publicExponent;
+ }
+
+ /**
+ Return the size of the key.
+
+ @return the size of the key.
+ */
+ public int getKeysize()
+ {
+ return keysize;
+ }
+
+ /**
+ Return the public exponent.
+
+ @return the public exponent.
+ */
+ public BigInteger getPublicExponent()
+ {
+ return publicExponent;
+ }
+}
diff --git a/libjava/java/security/spec/RSAPrivateCrtKeySpec.java b/libjava/java/security/spec/RSAPrivateCrtKeySpec.java
index 6a31163..53813c6 100644
--- a/libjava/java/security/spec/RSAPrivateCrtKeySpec.java
+++ b/libjava/java/security/spec/RSAPrivateCrtKeySpec.java
@@ -1,23 +1,140 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* RSAPrivateCrtKeySpec.java --- RSA Private Certificate Key Specificaton class
+ Copyright (C) 1999 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+
package java.security.spec;
+import java.math.BigInteger;
/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 7, 2000.
- */
+ RSA Private Certificate Key class Specification. Used to
+ maintain the RSA Private Certificate Keys with the
+ <I>Chinese Remainder Theorem</I>(CRT) as specified by PKCS#1.
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Stubbed.
- */
-
-// JDK1.2
+ @since JDK 1.2
+
+ @author Mark Benvenuto
+*/
public class RSAPrivateCrtKeySpec extends RSAPrivateKeySpec
{
+ private BigInteger publicExponent;
+ private BigInteger primeP;
+ private BigInteger primeQ;
+ private BigInteger primeExponentP;
+ private BigInteger primeExponentQ;
+ private BigInteger crtCoefficient;
+
+ /**
+ Constructs a new RSAPrivateKeySpec with the specified
+ variables.
+
+ @param modulus the RSA modulus
+ @param publicExponent the public key exponent
+ @param privateExponent the private key exponent
+ @param primeP the prime P
+ @param primeQ the prime Q
+ @param primeExponentP the prime exponent P
+ @param primeExponentQ the prime exponent P
+ @param crtCoefficient the CRT coefficient
+ */
+ public RSAPrivateCrtKeySpec(BigInteger modulus,
+ BigInteger publicExponent,
+ BigInteger privateExponent,
+ BigInteger primeP,
+ BigInteger primeQ,
+ BigInteger primeExponentP,
+ BigInteger primeExponentQ,
+ BigInteger crtCoefficient)
+ {
+ super( modulus, privateExponent);
+ this.publicExponent = publicExponent;
+ this.primeP = primeP;
+ this.primeQ = primeQ;
+ this.primeExponentP = primeExponentP;
+ this.primeExponentQ = primeExponentQ;
+ this.crtCoefficient = crtCoefficient;
+ }
+
+ /**
+ Gets the RSA public exponent.
+
+ @return the RSA public exponent
+ */
+ public BigInteger getPublicExponent()
+ {
+ return this.publicExponent;
+ }
+
+ /**
+ Gets the RSA prime P.
+
+ @return the RSA prime P
+ */
+ public BigInteger getPrimeP()
+ {
+ return this.primeP;
+ }
+
+ /**
+ Gets the RSA prime Q.
+
+ @return the RSA prime Q
+ */
+ public BigInteger getPrimeQ()
+ {
+ return this.primeQ;
+ }
+
+ /**
+ Gets the RSA prime exponent P.
+
+ @return the RSA prime exponent P
+ */
+ public BigInteger getPrimeExponentP()
+ {
+ return this.primeExponentP;
+ }
+
+ /**
+ Gets the RSA prime exponent P.
+
+ @return the RSA prime exponent Q
+ */
+ public BigInteger getPrimeExponentQ()
+ {
+ return this.primeExponentQ;
+ }
+
+ /**
+ Gets the RSA CRT coefficient.
+
+ @return the RSA CRT coefficient
+ */
+ public BigInteger getCrtCoefficient()
+ {
+ return this.crtCoefficient;
+ }
+
}
diff --git a/libjava/java/security/spec/RSAPrivateKeySpec.java b/libjava/java/security/spec/RSAPrivateKeySpec.java
index 4f38a2d..a502950 100644
--- a/libjava/java/security/spec/RSAPrivateKeySpec.java
+++ b/libjava/java/security/spec/RSAPrivateKeySpec.java
@@ -1,23 +1,77 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* RSAPrivateKeySpec.java --- RSA Private Key Specificaton class
+ Copyright (C) 1999 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+
package java.security.spec;
+import java.math.BigInteger;
/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 7, 2000.
- */
+ RSA Private Key class Specification. Used to maintain the RSA
+ Private Keys.
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Stubbed.
- */
-
-// JDK1.2
+ @since JDK 1.2
+
+ @author Mark Benvenuto
+*/
public class RSAPrivateKeySpec implements KeySpec
{
+ private BigInteger modulus;
+ private BigInteger privateExponent;
+
+ /**
+ Constructs a new RSAPrivateKeySpec with the specified
+ modulus and privateExponent.
+
+ @param modulus the RSA modulus
+ @param privateExponent the private key exponent
+ */
+ public RSAPrivateKeySpec(BigInteger modulus, BigInteger privateExponent)
+ {
+ this.modulus = modulus;
+ this.privateExponent = privateExponent;
+ }
+
+ /**
+ Gets the RSA modulus.
+
+ @return the RSA modulus
+ */
+ public BigInteger getModulus()
+ {
+ return this.modulus;
+ }
+
+ /**
+ Gets the RSA private exponent.
+
+ @return the RSA private exponent
+ */
+ public BigInteger getPrivateExponent()
+ {
+ return this.privateExponent;
+ }
+
}
diff --git a/libjava/java/security/spec/RSAPublicKeySpec.java b/libjava/java/security/spec/RSAPublicKeySpec.java
index 0bdcd22..0024a08 100644
--- a/libjava/java/security/spec/RSAPublicKeySpec.java
+++ b/libjava/java/security/spec/RSAPublicKeySpec.java
@@ -1,23 +1,77 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* RSAPublicKeySpec.java --- RSA Public Key Specificaton class
+ Copyright (C) 1999 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+
package java.security.spec;
+import java.math.BigInteger;
/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 10, 2000.
- */
+ RSA Public Key class Specification. Used to maintain the RSA
+ Public Keys.
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Stubbed.
- */
-
-// JDK1.2
+ @since JDK 1.2
+
+ @author Mark Benvenuto
+*/
public class RSAPublicKeySpec implements KeySpec
{
+ private BigInteger modulus;
+ private BigInteger publicExponent;
+
+ /**
+ Constructs a new RSAPublicKeySpec with the specified
+ modulus and publicExponent.
+
+ @param modulus the RSA modulus
+ @param publicExponent the public key exponent
+ */
+ public RSAPublicKeySpec(BigInteger modulus, BigInteger publicExponent)
+ {
+ this.modulus = modulus;
+ this.publicExponent = publicExponent;
+ }
+
+ /**
+ Gets the RSA modulus.
+
+ @return the RSA modulus
+ */
+ public BigInteger getModulus()
+ {
+ return this.modulus;
+ }
+
+ /**
+ Gets the RSA public exponent.
+
+ @return the RSA public exponent
+ */
+ public BigInteger getPublicExponent()
+ {
+ return this.publicExponent;
+ }
+
}
diff --git a/libjava/java/security/spec/X509EncodedKeySpec.java b/libjava/java/security/spec/X509EncodedKeySpec.java
new file mode 100644
index 0000000..165b543
--- /dev/null
+++ b/libjava/java/security/spec/X509EncodedKeySpec.java
@@ -0,0 +1,71 @@
+/* X509EncodedKeySpec.java --- X.509 Encoded Key Specificaton class
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+
+package java.security.spec;
+
+/**
+ X.509 Encoded Key Specification class which is used to store
+ "X.509" byte encoded keys.
+
+ @since JDK 1.2
+
+ @author Mark Benvenuto
+*/
+public class X509EncodedKeySpec extends EncodedKeySpec
+{
+
+ /**
+ Constructs a new X509EncodedKeySpec with the specified encoded key.
+
+ @param encodedKey A key to store, assumed to be "X.509"
+ */
+ public X509EncodedKeySpec(byte[] encodedKey)
+ {
+ super( encodedKey );
+ }
+
+ /**
+ Gets the encoded key in byte format.
+
+ @returns the encoded key
+ */
+ public byte[] getEncoded()
+ {
+ return super.getEncoded();
+ }
+
+ /**
+ Returns the name of the key format used which is "X.509"
+
+ @return a string representing the name
+ */
+ public String getFormat()
+ {
+ return "X.509";
+ }
+
+}