Commit a729a4e9 by Anthony Green Committed by Anthony Green

Attributes.java, [...]: Imported from Classpath.

Sat Aug 19 11:00:53 2000  Anthony Green  <green@redhat.com>

	* java/util/jar/Attributes.java, java/util/jar/JarEntry.java,
	java/util/jar/JarException.java, java/util/jar/JarFile.java,
	java/util/jar/JarInputStream.java,
	java/util/jar/JarOutputStream.java, java/util/jar/Manifest.java,
	java/util/Set.java, java/util/Map.java, java/util/Bucket.java,
	java/util/AbstractSet.java, java/util/BasicMapEntry.java,
	java/security/cert/CRL.java, java/security/cert/CRLException.java,
	java/security/cert/Certificate.java,
	java/security/cert/CertificateEncodingException.java,
	java/security/cert/CertificateException.java,
	java/security/cert/CertificateExpiredException.java,
	java/security/cert/CertificateFactory.java,
	java/security/cert/CertificateFactorySpi.java,
	java/security/cert/CertificateNotYetValidException.java,
	java/security/cert/CertificateParsingException.java,
	java/security/cert/X509CRL.java,
	java/security/cert/X509CRLEntry.java,
	java/security/cert/X509Certificate.java,
	java/security/cert/X509Extension.java: Imported from Classpath.
	* java/util/Hashtable.java: Imported from Classpath.

	* java/util/zip/ZipInputStream.java: Create stub for
	createZipEntry.

	* gcj/javaprims.h: Updated class list.

	* Makefile.in, gcj/Makefile.in: Rebuilt.
	* Makefile.am (ordinary_java_source_files): Add these new classes.

From-SVN: r35809
parent e76d9acb
Sat Aug 19 11:00:53 2000 Anthony Green <green@redhat.com>
* java/util/jar/Attributes.java, java/util/jar/JarEntry.java,
java/util/jar/JarException.java, java/util/jar/JarFile.java,
java/util/jar/JarInputStream.java,
java/util/jar/JarOutputStream.java, java/util/jar/Manifest.java,
java/util/Set.java, java/util/Map.java, java/util/Bucket.java,
java/util/AbstractSet.java, java/util/BasicMapEntry.java,
java/security/cert/CRL.java, java/security/cert/CRLException.java,
java/security/cert/Certificate.java,
java/security/cert/CertificateEncodingException.java,
java/security/cert/CertificateException.java,
java/security/cert/CertificateExpiredException.java,
java/security/cert/CertificateFactory.java,
java/security/cert/CertificateFactorySpi.java,
java/security/cert/CertificateNotYetValidException.java,
java/security/cert/CertificateParsingException.java,
java/security/cert/X509CRL.java,
java/security/cert/X509CRLEntry.java,
java/security/cert/X509Certificate.java,
java/security/cert/X509Extension.java: Imported from Classpath.
* java/util/Hashtable.java: Imported from Classpath.
* java/util/zip/ZipInputStream.java: Create stub for
createZipEntry.
* gcj/javaprims.h: Updated class list.
* Makefile.in, gcj/Makefile.in: Rebuilt.
* Makefile.am (ordinary_java_source_files): Add these new classes.
2000-08-16 Rolf W. Rasmussen <rolfwr@ii.uib.no>
* gnu/gcj/awt/ComponentDataBlitOp.java: New file.
......
......@@ -129,7 +129,7 @@ DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
TAR = gtar
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
......@@ -198,7 +198,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 \
......
......@@ -214,9 +214,13 @@ extern "Java"
class AbstractCollection;
class AbstractList;
class AbstractList$SubList;
class AbstractSet;
class Arrays;
class Arrays$ListImpl;
class BasicMapEntry;
class BitSet;
class Bucket;
class Bucket$Node;
class Calendar;
class Collection;
class Comparator;
......@@ -229,13 +233,18 @@ extern "Java"
class EventObject;
class GregorianCalendar;
class Hashtable;
class HashtableEntry;
class HashtableEnumeration;
class Hashtable$HashtableCollection;
class Hashtable$HashtableEntry;
class Hashtable$HashtableEnumeration;
class Hashtable$HashtableIterator;
class Hashtable$HashtableSet;
class Iterator;
class List;
class ListIterator;
class ListResourceBundle;
class Locale;
class Map;
class Map$Entry;
class MissingResourceException;
class NoSuchElementException;
class Observable;
......@@ -244,6 +253,7 @@ extern "Java"
class PropertyResourceBundle;
class Random;
class ResourceBundle;
class Set;
class SimpleTimeZone;
class Stack;
class StringTokenizer;
......@@ -253,9 +263,14 @@ extern "Java"
class VectorEnumeration;
namespace jar
{
class Attributes;
class JarEntry;
class JarException;
class JarFile;
class JarFile$JarEnumeration;
class JarInputStream;
class JarOutputStream;
class Manifest;
};
namespace zip
......@@ -282,6 +297,92 @@ extern "Java"
};
};
};
namespace java
{
namespace io
{
class BlockDataException;
class BufferedInputStream;
class BufferedOutputStream;
class BufferedReader;
class BufferedWriter;
class ByteArrayInputStream;
class ByteArrayOutputStream;
class CharArrayReader;
class CharArrayWriter;
class CharConversionException;
class DataInput;
class DataInputStream;
class DataOutput;
class DataOutputStream;
class EOFException;
class Externalizable;
class File;
class FileDescriptor;
class FileInputStream;
class FileNotFoundException;
class FileOutputStream;
class FileReader;
class FileWriter;
class FilenameFilter;
class FilterInputStream;
class FilterOutputStream;
class FilterReader;
class FilterWriter;
class IOException;
class InputStream;
class InputStreamReader;
class InterfaceComparator;
class InterruptedIOException;
class InvalidClassException;
class InvalidObjectException;
class LineNumberInputStream;
class LineNumberReader;
class MemberComparator;
class NotActiveException;
class NotSerializableException;
class ObjectInput;
class ObjectInputStream;
class ObjectInputStream$GetField;
class ObjectInputValidation;
class ObjectOutput;
class ObjectOutputStream;
class ObjectOutputStream$PutField;
class ObjectStreamClass;
class ObjectStreamConstants;
class ObjectStreamException;
class ObjectStreamField;
class OptionalDataException;
class OutputStream;
class OutputStreamWriter;
class PipedInputStream;
class PipedOutputStream;
class PipedReader;
class PipedWriter;
class PrintStream;
class PrintWriter;
class PushbackInputStream;
class PushbackReader;
class RandomAccessFile;
class Reader;
class Replaceable;
class Resolvable;
class SequenceInputStream;
class Serializable;
class SerializablePermission;
class StreamCorruptedException;
class StreamTokenizer;
class StringBufferInputStream;
class StringReader;
class StringWriter;
class SyncFailedException;
class UTFDataFormatException;
class UnsupportedEncodingException;
class ValidatorAndPriority;
class WriteAbortedException;
class Writer;
};
};
};
typedef struct java::lang::Object* jobject;
......
......@@ -128,7 +128,7 @@ DIST_COMMON = ./stamp-h.in Makefile.am Makefile.in config.h.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
TAR = gtar
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
......@@ -225,7 +225,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 \
......
/* CRL.java --- Certificate Revocation List
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.cert;
/**
Certificate Revocation List class for managing CRLs that
have different formats but the same general use. They
all serve as lists of revoked certificates and can
be queried for a given certificate.
Specialized CRLs extend this class.
@author Mark Benvenuto
@since JDK 1.2
*/
public abstract class CRL
{
private String type;
/**
Creates a new CRL for the specified type. An example
is "X.509".
@param type the standard name for the CRL type.
*/
protected CRL(String type)
{
this.type = type;
}
/**
Returns the CRL type.
@return a string representing the CRL type
*/
public final String getType()
{
return type;
}
/**
Returns a string representing the CRL.
@return a string representing the CRL.
*/
public abstract String toString();
/**
Determines whether or not the specified Certificate
is revoked.
@param cert A certificate to check if it is revoked
@return true if the certificate is revoked,
false otherwise.
*/
public abstract boolean isRevoked(Certificate cert);
}
/* CRLException.java --- Certificate Revocation List Exception
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.cert;
import java.security.GeneralSecurityException;
/**
Exception for a Certificate Revocation List.
@since JDK 1.2
@author Mark Benvenuto
*/
public class CRLException extends GeneralSecurityException
{
/**
Constructs an CRLExceptionwithout a message string.
*/
public CRLException()
{
super();
}
/**
Constructs an CRLException with a message string.
@param msg A message to display with exception
*/
public CRLException(String msg)
{
super( msg );
}
}
/* Certificate.java --- Certificate 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.cert;
import java.security.PublicKey;
import java.security.NoSuchAlgorithmException;
import java.security.InvalidKeyException;
import java.security.NoSuchProviderException;
import java.security.SignatureException;
import java.io.ObjectInputStream;
import java.io.ByteArrayInputStream;
import java.io.ObjectStreamException;
/**
The Certificate class is an abstract class used to manage
identity certificates. An identity certificate is a
combination of a principal and a public key which is
certified by another principal. This is the puprose of
Certificate Authorities (CA).
This class is used to manage different types of certificates
but have important common puposes. Different types of
certificates like X.509 and OpenPGP share general certificate
functions (like encoding and verifying) and information like
public keys.
X.509, OpenPGP, and SDSI can be implemented by subclassing this
class even though they differ in storage methods and information
stored.
@since JDK 1.2
@author Mark Benvenuto
*/
public abstract class Certificate
{
private String type;
/**
Constructs a new certificate of the specified type. An example
is "X.509".
@param type a valid standard name for a certificate.
*/
protected Certificate(String type)
{
this.type = type;
}
/**
Returns the Certificate type.
@return a string representing the Certificate type
*/
public final String getType()
{
return type;
}
/**
Compares this Certificate to other. It checks if the
object if instanceOf Certificate and then checks if
the encoded form matches.
@param other An Object to test for equality
@return true if equal, false otherwise
*/
public boolean equals(Object other)
{
if( other instanceof Certificate ) {
try {
Certificate x = (Certificate) other;
if( getEncoded().length != x.getEncoded().length )
return false;
byte b1[] = getEncoded();
byte b2[] = x.getEncoded();
for( int i = 0; i < b1.length; i++ )
if( b1[i] != b2[i] )
return false;
} catch( CertificateEncodingException cee ) {
return false;
}
return true;
}
return false;
}
/**
Returns a hash code for this Certificate in its encoded
form.
@return A hash code of this class
*/
public int hashCode()
{
return super.hashCode();
}
/**
Gets the DER ASN.1 encoded format for this Certificate.
It assumes each certificate has only one encoding format.
Ex: X.509 is encoded as ASN.1 DER
@return byte array containg encoded form
@throws CertificateEncodingException if an error occurs
*/
public abstract byte[] getEncoded() throws CertificateEncodingException;
/**
Verifies that this Certificate was properly signed with the
PublicKey that corresponds to its private key.
@param key PublicKey to verify with
@throws CertificateException encoding error
@throws NoSuchAlgorithmException unsupported algorithm
@throws InvalidKeyException incorrect key
@throws NoSuchProviderException no provider
@throws SignatureException signature error
*/
public abstract void verify(PublicKey key)
throws CertificateException,
NoSuchAlgorithmException,
InvalidKeyException,
NoSuchProviderException,
SignatureException;
/**
Verifies that this Certificate was properly signed with the
PublicKey that corresponds to its private key and uses
the signature engine provided by the provider.
@param key PublicKey to verify with
@param sigProvider Provider to use for signature algorithm
@throws CertificateException encoding error
@throws NoSuchAlgorithmException unsupported algorithm
@throws InvalidKeyException incorrect key
@throws NoSuchProviderException incorrect provider
@throws SignatureException signature error
*/
public abstract void verify(PublicKey key,
String sigProvider)
throws CertificateException,
NoSuchAlgorithmException,
InvalidKeyException,
NoSuchProviderException,
SignatureException;
/**
Returns a string representing the Certificate.
@return a string representing the Certificate.
*/
public abstract String toString();
/**
Returns the public key stored in the Certificate.
@return The public key
*/
public abstract PublicKey getPublicKey();
/* INNER CLASS */
/**
Certificate.CertificateRep is an inner class used to provide an alternate
storage mechanism for serialized Certificates.
*/
protected static class CertificateRep implements java.io.Serializable
{
private String type;
private byte[] data;
/**
Create an alternate Certificate class to store a serialized Certificate
@param type the name of certificate type
@param data the certificate data
*/
protected CertificateRep(String type,
byte[] data)
{
this.type = type;
this.data = data;
}
/**
Return the stored Certificate
@return the stored certificate
@throws ObjectStreamException if certificate cannot be resolved
*/
protected Object readResolve()
throws ObjectStreamException
{
try {
return new ObjectInputStream( new ByteArrayInputStream( data ) ).readObject();
} catch ( Exception e ) {
e.printStackTrace();
throw new RuntimeException ( e.toString() );
}
}
}
}
/* CertificateEncodingException.java --- Certificate Encoding Exception
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.cert;
/**
Exception for a Certificate Encoding.
@since JDK 1.2
@author Mark Benvenuto
*/
public class CertificateEncodingException extends CertificateException
{
/**
Constructs an CertificateEncodingException without a message string.
*/
public CertificateEncodingException()
{
super();
}
/**
Constructs an CertificateEncodingException with a message string.
@param msg A message to display with exception
*/
public CertificateEncodingException(String msg)
{
super( msg );
}
}
/* CertificateException.java --- Certificate Exception
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.cert;
import java.security.GeneralSecurityException;
/**
Exception for a Certificate.
@since JDK 1.2
@author Mark Benvenuto
*/
public class CertificateException extends GeneralSecurityException
{
/**
Constructs an CertificateException without a message string.
*/
public CertificateException()
{
super();
}
/**
Constructs an CertificateException with a message string.
@param msg A message to display with exception
*/
public CertificateException(String msg)
{
super( msg );
}
}
/* CertificateExpiredException.java --- Certificate Expired Exception
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.cert;
/**
Exception for a Certificate Expiring.
@since JDK 1.2
@author Mark Benvenuto
*/
public class CertificateExpiredException extends CertificateException
{
/**
Constructs an CertificateExpiredException without a message string.
*/
public CertificateExpiredException()
{
super();
}
/**
Constructs an CertificateExpiredException with a message string.
@param msg A message to display with exception
*/
public CertificateExpiredException(String msg)
{
super( msg );
}
}
/* CertificateFactory.java --- Certificate 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.cert;
import java.security.NoSuchProviderException;
import java.security.Provider;
import java.security.Security;
import java.io.InputStream;
import java.util.Collection;
/**
This class implments the CertificateFactory class interface
used to generate certificates and certificate revocation
list (CRL) objects from their encodings.
A certifcate factory for X.509 returns certificates of the
java.security.cert.X509Certificate class, and CRLs of the
java.security.cert.X509CRL class.
@since JDK 1.2
@author Mark Benvenuto
*/
public class CertificateFactory
{
private CertificateFactorySpi certFacSpi;
private Provider provider;
private String type;
/**
Creates an instance of CertificateFactory
@param certFacSpi A CertificateFactory engine to use
@param provider A provider to use
@param type The type of Certificate
*/
protected CertificateFactory(CertificateFactorySpi certFacSpi, Provider provider, String type)
{
this.certFacSpi = certFacSpi;
this.provider = provider;
this.type = type;
}
/**
Gets an instance of the CertificateFactory class representing
the specified certificate factory. If the type is not
found then, it throws CertificateException.
@param type the type of certificate to choose
@return a CertificateFactory repesenting the desired type
@throws CertificateException if the type of certificate is not implemented by providers
*/
public static final CertificateFactory getInstance(String type) throws CertificateException
{
Provider[] p = Security.getProviders ();
for (int i = 0; i < p.length; i++)
{
String classname = p[i].getProperty ("CertificateFactory." + type);
if (classname != null)
return getInstance (classname, type, p[i]);
}
throw new CertificateException(type);
}
/**
Gets an instance of the CertificateFactory class representing
the specified certificate factory 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 CertificateFactory repesenting the desired type
@throws CertificateException if the type of certificate is not implemented by providers
@throws NoSuchProviderException if the provider is not found
*/
public static final CertificateFactory getInstance(String type, String provider)
throws CertificateException, NoSuchProviderException
{
Provider p = Security.getProvider(provider);
if( p == null)
throw new NoSuchProviderException();
return getInstance (p.getProperty ("CertificateFactory." + type),
type, p);
}
private static CertificateFactory getInstance (String classname,
String type,
Provider provider)
throws CertificateException
{
try {
return new CertificateFactory( (CertificateFactorySpi)Class.forName( classname ).newInstance(), provider, type );
} catch( ClassNotFoundException cnfe) {
throw new CertificateException("Class not found");
} catch( InstantiationException ie) {
throw new CertificateException("Class instantiation failed");
} catch( IllegalAccessException iae) {
throw new CertificateException("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 certificate supported
@return A string with the type of certificate
*/
public final String getType()
{
return type;
}
/**
Generates a Certificate based on the encoded data read
from the InputStream.
The input stream must contain only one certificate.
If there exists a specialized certificate class for the
certificate format handled by the certificate factory
then the return Ceritificate should be a typecast of it.
Ex: A X.509 CertificateFactory should return X509Certificate.
For X.509 certificates, the certificate in inStream must be
DER encoded and supplied in binary or printable (Base64)
encoding. If the certificate is in Base64 encoding, it must be
bounded by -----BEGINCERTIFICATE-----, and
-----END CERTIFICATE-----.
@param inStream an input stream containing the certificate data
@return a certificate initialized with InputStream data.
@throws CertificateException Certificate parsing error
*/
public final Certificate generateCertificate(InputStream inStream)
throws CertificateException
{
return certFacSpi.engineGenerateCertificate( inStream );
}
/**
Returns a collection of certificates that were read from the
input stream. It may be empty, have only one, or have
multiple certificates.
For a X.509 certificate factory, the stream may contain a
single DER encoded certificate or a PKCS#7 certificate
chain. This is a PKCS#7 <I>SignedData</I> object with the
most significant field being <I>certificates</I>. If no
CRLs are present, then an empty collection is returned.
@param inStream an input stream containing the certificates
@return a collection of certificates initialized with
the InputStream data.
@throws CertificateException Certificate parsing error
*/
public final Collection generateCertificates(InputStream inStream)
throws CertificateException
{
return certFacSpi.engineGenerateCertificates( inStream );
}
/**
Generates a CRL based on the encoded data read
from the InputStream.
The input stream must contain only one CRL.
If there exists a specialized CRL class for the
CRL format handled by the certificate factory
then the return CRL should be a typecast of it.
Ex: A X.509 CertificateFactory should return X509CRL.
@param inStream an input stream containing the CRL data
@return a CRL initialized with InputStream data.
@throws CRLException CRL parsing error
*/
public final CRL generateCRL(InputStream inStream)
throws CRLException
{
return certFacSpi.engineGenerateCRL( inStream );
}
/**
Generates CRLs based on the encoded data read
from the InputStream.
For a X.509 certificate factory, the stream may contain a
single DER encoded CRL or a PKCS#7 CRL set. This is a
PKCS#7 <I>SignedData</I> object with the most significant
field being <I>crls</I>. If no CRLs are present, then an
empty collection is returned.
@param inStream an input stream containing the CRLs
@return a collection of CRLs initialized with
the InputStream data.
@throws CRLException CRL parsing error
*/
public final Collection generateCRLs(InputStream inStream)
throws CRLException
{
return certFacSpi.engineGenerateCRLs( inStream );
}
}
/* CertificateFactorySpi.java --- Certificate 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.cert;
import java.io.InputStream;
import java.util.Collection;
/**
CertificateFactorySpi is the abstract class Service Provider
Interface (SPI) for the CertificateFactory class. A provider
must implment all the abstract methods if they wish to
supply a certificate factory for a particular certificate
type. Ex: X.509
Certificate factories are used to generate certificates and
certificate revocation lists (CRL) from their encoding.
@since JDK 1.2
@author Mark Benvenuto
*/
public abstract class CertificateFactorySpi
{
/**
Constructs a new CertificateFactorySpi
*/
public CertificateFactorySpi()
{}
/**
Generates a Certificate based on the encoded data read
from the InputStream.
The input stream must contain only one certificate.
If there exists a specialized certificate class for the
certificate format handled by the certificate factory
then the return Ceritificate should be a typecast of it.
Ex: A X.509 CertificateFactory should return X509Certificate.
For X.509 certificates, the certificate in inStream must be
DER encoded and supplied in binary or printable (Base64)
encoding. If the certificate is in Base64 encoding, it must be
bounded by -----BEGINCERTIFICATE-----, and
-----END CERTIFICATE-----.
@param inStream an input stream containing the certificate data
@return a certificate initialized with InputStream data.
@throws CertificateException Certificate parsing error
*/
public abstract Certificate engineGenerateCertificate(InputStream inStream)
throws CertificateException;
/**
Returns a collection of certificates that were read from the
input stream. It may be empty, have only one, or have
multiple certificates.
For a X.509 certificate factory, the stream may contain a
single DER encoded certificate or a PKCS#7 certificate
chain. This is a PKCS#7 <I>SignedData</I> object with the
most significant field being <I>certificates</I>. If no
CRLs are present, then an empty collection is returned.
@param inStream an input stream containing the certificates
@return a collection of certificates initialized with
the InputStream data.
@throws CertificateException Certificate parsing error
*/
public abstract Collection engineGenerateCertificates(InputStream inStream)
throws CertificateException;
/**
Generates a CRL based on the encoded data read
from the InputStream.
The input stream must contain only one CRL.
If there exists a specialized CRL class for the
CRL format handled by the certificate factory
then the return CRL should be a typecast of it.
Ex: A X.509 CertificateFactory should return X509CRL.
@param inStream an input stream containing the CRL data
@return a CRL initialized with InputStream data.
@throws CRLException CRL parsing error
*/
public abstract CRL engineGenerateCRL(InputStream inStream)
throws CRLException;
/**
Generates CRLs based on the encoded data read
from the InputStream.
For a X.509 certificate factory, the stream may contain a
single DER encoded CRL or a PKCS#7 CRL set. This is a
PKCS#7 <I>SignedData</I> object with the most significant
field being <I>crls</I>. If no CRLs are present, then an
empty collection is returned.
@param inStream an input stream containing the CRLs
@return a collection of CRLs initialized with
the InputStream data.
@throws CRLException CRL parsing error
*/
public abstract Collection engineGenerateCRLs(InputStream inStream)
throws CRLException;
}
/* CertificateNotYetValidException.java --- Certificate Not Yet Valid Exception
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.cert;
/**
Exception for a Certificate being not yet valid.
@since JDK 1.2
@author Mark Benvenuto
*/
public class CertificateNotYetValidException extends CertificateException
{
/**
Constructs an CertificateNotYetValidException without a message string.
*/
public CertificateNotYetValidException()
{
super();
}
/**
Constructs an CertificateNotYetValidException with a message string.
@param msg A message to display with exception
*/
public CertificateNotYetValidException(String msg)
{
super( msg );
}
}
/* CertificateParsingException.java --- Certificate Parsing Exception
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.cert;
/**
Exception for a Certificate Parsing.
@since JDK 1.2
@author Mark Benvenuto
*/
public class CertificateParsingException extends CertificateException
{
/**
Constructs an CertificateParsingException without a message string.
*/
public CertificateParsingException()
{
super();
}
/**
Constructs an CertificateParsingException with a message string.
@param msg A message to display with exception
*/
public CertificateParsingException(String msg)
{
super( msg );
}
}
/* X509CRLEntry.java --- X.509 Certificate Revocation List Entry
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.cert;
import java.math.BigInteger;
import java.util.Date;
/**
Abstract class for entries in the CRL (Certificate Revocation
List). The ASN.1 definition for <I>revokedCertificates</I> is
revokedCertificates SEQUENCE OF SEQUENCE {
userCertificate CertificateSerialNumber,
revocationDate Time,
crlEntryExtensions Extensions OPTIONAL
-- if present, shall be v2
} OPTIONAL,
CertificateSerialNumber ::= INTEGER
Time ::= CHOICE {
utcTime UTCTime,
generalTime GeneralizedTime }
Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
Extension ::= SEQUENCE {
extnID OBJECT IDENTIFIER,
critical BOOLEAN DEFAULT FALSE,
extnValue OCTET STRING }
For more information consult rfc2459.
@author Mark Benvenuto
@since JDK 1.2
*/
public abstract class X509CRLEntry implements X509Extension
{
/**
Creates a new X509CRLEntry
*/
public X509CRLEntry()
{}
/**
Compares this X509CRLEntry to other. It checks if the
object if instanceOf X509CRLEntry and then checks if
the encoded form( the inner SEQUENCE) matches.
@param other An Object to test for equality
@return true if equal, false otherwise
*/
public boolean equals(Object other)
{
if( other instanceof X509CRLEntry ) {
try {
X509CRLEntry xe = (X509CRLEntry) other;
if( getEncoded().length != xe.getEncoded().length )
return false;
byte b1[] = getEncoded();
byte b2[] = xe.getEncoded();
for( int i = 0; i < b1.length; i++ )
if( b1[i] != b2[i] )
return false;
} catch( CRLException crle ) {
return false;
}
return true;
}
return false;
}
/**
Returns a hash code for this X509CRLEntry in its encoded
form.
@return A hash code of this class
*/
public int hashCode()
{
return super.hashCode();
}
/**
Gets the DER ASN.1 encoded format for this CRL Entry,
the inner SEQUENCE.
@return byte array containg encoded form
@throws CRLException if an error occurs
*/
public abstract byte[] getEncoded() throws CRLException;
/**
Gets the serial number for <I>userCertificate</I> in
this X509CRLEntry.
@return the serial number for this X509CRLEntry.
*/
public abstract BigInteger getSerialNumber();
/**
Gets the revocation date in <I>revocationDate</I> for
this X509CRLEntry.
@return the revocation date for this X509CRLEntry.
*/
public abstract Date getRevocationDate();
/**
Checks if this X509CRLEntry has extensions.
@return true if it has extensions, false otherwise
*/
public abstract boolean hasExtensions();
/**
Returns a string that represents this X509CRLEntry.
@return a string representing this X509CRLEntry.
*/
public abstract String toString();
}
/* X509Extension.java --- X.509 Extension
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.cert;
import java.util.Set;
/**
Public abstract interface for the X.509 Extension.
This is used for X.509 v3 Certificates and CRL v2 (Certificate
Revocation Lists) for managing attributes assoicated with
Certificates, for managing the hierarchy of certificates,
and for managing the distribution of CRL. This extension
format is used to define private extensions.
Each extensions for a certificate or CRL must be marked
either critical or non-critical. If the certificate/CRL
system encounters a critical extension not recognized then
it must reject the certificate. A non-critical extension
may be just ignored if not recognized.
The ASN.1 definition for this class is:
Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
Extension ::= SEQUENCE {
extnId OBJECT IDENTIFIER,
critical BOOLEAN DEFAULT FALSE,
extnValue OCTET STRING
-- contains a DER encoding of a value
-- of the type registered for use with
-- the extnId object identifier value
}
@author Mark Benvenuto
@since JDK 1.2
*/
public abstract interface X509Extension
{
/**
Returns true if the certificate contains a critical extension
that is not supported.
@return true if has unsupported extension, false otherwise
*/
public boolean hasUnsupportedCriticalExtension();
/**
Returns a set of the CRITICAL extension OIDs from the
certificate/CRL that the object implementing this interface
manages.
@return A Set containing the OIDs. If there are no CRITICAL
extensions or extensions at all this returns null.
*/
public Set getCriticalExtensionOIDs();
/**
Returns a set of the NON-CRITICAL extension OIDs from the
certificate/CRL that the object implementing this interface
manages.
@return A Set containing the OIDs. If there are no NON-CRITICAL
extensions or extensions at all this returns null.
*/
public Set getNonCriticalExtensionOIDs();
/**
Returns the DER encoded OCTET string for the specified
extension value identified by a OID. The OID is a string
of number seperated by periods. Ex: 12.23.45.67
*/
public byte[] getExtensionValue(String oid);
}
/* AbstractSet.java -- Abstract implementation of most of Set
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.util;
/**
* An abstract implementation of Set to make it easier to create your own
* implementations. In order to create a Set, subclass AbstractSet and
* implement the same methods that are required for AbstractCollection
* (although these methods must of course meet the requirements that Set puts
* on them - specifically, no element may be in the set more than once). This
* class simply provides implementations of equals() and hashCode() to fulfil
* the requirements placed on them by the Set interface.
*/
public abstract class AbstractSet extends AbstractCollection implements Set {
/**
* Tests whether the given object is equal to this Set. This implementation
* first checks whether this set <em>is</em> the given object, and returns
* true if so. Otherwise, if o is a Set and is the same size as this one, it
* returns the result of calling containsAll on the given Set. Otherwise, it
* returns false.
*
* @param o the Object to be tested for equality with this Set
* @return true if the given object is equal to this Set
*/
public boolean equals(Object o) {
if (o == this) {
return true;
} else if (o instanceof Set && ((Set)o).size() == size()) {
throw new Error ("FIXME: compiler error - AbstractSet.equals");
/* FIXME: this is the correct implementation, but a compiler
error prevents us from building it.
return containsAll((Collection)o); */
} else {
return false;
}
}
/**
* Returns a hash code for this Set. The hash code of a Set is the sum of the
* hash codes of all its elements, except that the hash code of null is
* defined to be zero. This implementation obtains an Iterator over the Set,
* and sums the results.
*
* @return a hash code for this Set
*/
public int hashCode() {
int hash = 0;
Iterator i = iterator();
while (i.hasNext()) {
try {
hash += i.next().hashCode();
} catch (NullPointerException e) {
}
}
return hash;
}
}
/* BasicMapEntry.java -- a class providing a plain-vanilla implementation of
the Map.Entry interface; could be used anywhere in java.util
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.util;
/**
* a class which implements Map.Entry
*
* @author Jon Zeppieri
* @version $Revision: 1.3 $
* @modified $Id: BasicMapEntry.java,v 1.3 2000/03/15 21:59:07 rao Exp $
*/
class BasicMapEntry implements Map.Entry
{
/** the key */
Object key;
/** the value */
Object value;
/**
* construct a new BasicMapEntry with the given key and value
*
* @param newKey the key of this Entry
* @param newValue the value of this Entry
*/
BasicMapEntry(Object newKey, Object newValue)
{
key = newKey;
value = newValue;
}
/**
* returns true if <pre>o</pre> is a Map.Entry and
* <pre>
* (((o.getKey == null) ? (key == null) :
* o.getKey().equals(key)) &&
* ((o.getValue() == null) ? (value == null) :
* o.getValue().equals(value)))
* </pre>
*
* NOTE: the calls to getKey() and getValue() in this implementation
* are <i>NOT</i> superfluous and should not be removed. They insure
* that subclasses such as HashMapEntry work correctly
*
* @param o the Object being tested for equality
*/
public boolean equals(Object o)
{
Map.Entry tester;
Object oTestingKey, oTestingValue;
Object oKey, oValue;
if (o instanceof Map.Entry)
{
tester = (Map.Entry) o;
oKey = getKey();
oValue = getValue();
oTestingKey = tester.getKey();
oTestingValue = tester.getValue();
return (((oTestingKey == null) ? (oKey == null) :
oTestingKey.equals(oKey)) &&
((oTestingValue == null) ? (oValue == null) :
oTestingValue.equals(oValue)));
}
return false;
}
/** returns the key */
public Object getKey()
{
return key;
}
/** returns the value */
public Object getValue()
{
return value;
}
/** the hashCode() for a Map.Entry is
* <pre>
* ((getKey() == null) ? 0 : getKey().hashCode()) ^
* ((getValue() == null) ? 0 : getValue().hashCode());
* </pre>
*
* NOTE: the calls to getKey() and getValue() in this implementation
* are <i>NOT</i> superfluous and should not be removed. They insure
* that subclasses such as HashMapEntry work correctly
*/
public int hashCode()
{
Object oKey = getKey();
Object oValue = getValue();
return ((oKey == null) ? 0 : oKey.hashCode()) ^
((oValue == null) ? 0 : oValue.hashCode());
}
/**
* sets the value of this Map.Entry
*
* @param newValue the new value of this Map.Entry
*/
public Object setValue(Object newValue)
throws java.lang.UnsupportedOperationException, ClassCastException,
IllegalArgumentException, NullPointerException
{
Object oVal = value;
value = newValue;
return oVal;
}
}
/* Bucket.java -- a class providing a hash-bucket data structure
(a lightweight linked list)
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.util;
/**
* a class representing a simple, lightweight linked-list, using Node
* objects as its linked nodes; this is used by Hashtable and HashMap
*
* @author Jon Zeppieri
* @version $Revision: 1.3 $
* @modified $Id: Bucket.java,v 1.3 2000/03/15 21:59:08 rao Exp $
*/
class Bucket
{
/** the first node of the lined list, originally null */
Node first;
/** trivial constructor for a Bucket */
Bucket()
{
}
/** add this key / value pair to the list
*
* @param newNode a Node object to be added to this list
* @return the old value mapped to the key if there was one,
* otherwise null.
*/
Object add(Node newNode)
{
Object oKey;
Object oTestKey = newNode.getKey();
Node it = first;
Node prev = null;
if (it == null) // if the list is empty (the ideal case), we make a new single-node list
{
first = newNode;
return null;
}
else // otherwise try to find where this key already exists in the list,
{// and if it does, replace the value with the new one (and return the old one)
while (it != null)
{
oKey = it.getKey();
if ((oKey == null) ? (oTestKey == null) :
oKey.equals(oTestKey))
{
Object oldValue = it.value;
it.value = newNode.getValue();
return oldValue;
}
prev = it;
it = it.next;
}
prev.next = newNode; // otherwise, just stick this at the
return null; // end of the list
}
}
/**
* remove a Map.Entry in this list with the supplied key and return its value,
* if it exists, else return null
*
* @param key the key we are looking for in this list
*/
Object removeByKey(Object key)
{
Object oEntryKey;
Node prev = null;
Node it = first;
while (it != null)
{
oEntryKey = it.getKey();
if ((oEntryKey == null) ? (key == null) : oEntryKey.equals(key))
{
if (prev == null) // we are removing the first element
first = it.next;
else
prev.next = it.next;
return it.getValue();
}
else
{
prev = it;
it = it.next;
}
}
return null;
}
/**
* return the value which the supplied key maps to, if it maps to anything in this list,
* otherwise, return null
*
* @param key the key mapping to a value that we are looking for
*/
Object getValueByKey(Object key)
{
Node entry = getEntryByKey(key);
return (entry == null) ? null : entry.getValue();
}
/**
* return the Map.Entry which the supplied key is a part of, if such a Map.Entry exists,
* null otherwise
*
* this method is important for HashMap, which can hold null values and the null key
*
* @param key the key for which we are finding the corresponding Map.Entry
*/
Node getEntryByKey(Object key)
{
Object oEntryKey;
Node it = first;
while (it != null)
{
oEntryKey = it.getKey();
if ((oEntryKey == null) ? (key == null) : oEntryKey.equals(key))
return it;
it = it.next;
}
return null;
}
/**
* return true if this list has a Map.Entry whose value equals() the supplied value
*
* @param value the value we are looking to match in this list
*/
boolean containsValue(Object value)
{
Object oEntryValue;
Node it = first;
while (it != null)
{
oEntryValue = it.getValue();
if ((oEntryValue == null) ? (value == null) : oEntryValue.equals(value))
return true;
it = it.next;
}
return false;
}
// INNSER CLASSES ----------------------------------------------------------
/**
* a class represnting a node in our lightweight linked-list
* that we use for hash buckets; a Node object contains a Map.Entry as its
* <pre>value</pre> property and a reference (possibly, even hopefully, null)
* to another Node as its <pre>next</pre> property.
*
* There <i>is</i> a reason for not using a highly generic "LinkedNode" type
* class: we want to eliminate runtime typechecks.
*
* @author Jon Zeppieri
* @version $Revision: 1.3 $
* @modified $Id: Bucket.java,v 1.3 2000/03/15 21:59:08 rao Exp $
*/
static class Node extends BasicMapEntry implements Map.Entry
{
/** a reference to the next node in the linked list */
Node next;
/** non-trivial contructor -- sets the <pre>value</pre> of the Bucket upon instantiation */
Node(Object key, Object value)
{
super(key, value);
}
}
// EOF ------------------------------------------------------------------------
}
/* Map.java -- An object that maps keys to values
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. */
// TO DO:
// ~ Doc comments for everything.
package java.util;
public interface Map
{
public void clear();
public boolean containsKey(Object key);
public boolean containsValue(Object value);
public Set entrySet();
public boolean equals(Object o);
public Object get(Object key);
public Object put(Object key, Object value);
public int hashCode();
public boolean isEmpty();
public Set keySet();
public void putAll(Map m);
public Object remove(Object o);
public int size();
public Collection values();
public static interface Entry {
public Object getKey();
public Object getValue();
public Object setValue(Object value);
public int hashCode();
public boolean equals(Object o);
}
}
/* Set.java -- A collection that prohibits duplicates
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. */
// TO DO:
// ~ Doc comments for everything.
package java.util;
public interface Set extends Collection {
boolean add(Object o);
boolean addAll(Collection c);
void clear();
boolean contains(Object o);
boolean containsAll(Collection c);
boolean equals(Object o);
int hashCode();
boolean isEmpty();
Iterator iterator();
boolean remove(Object o);
boolean removeAll(Collection c);
boolean retainAll(Collection c);
int size();
Object[] toArray();
}
/* Copyright (C) 1999 Free Software Foundation
/* JarEntry.java - Represents an entry in a jar file
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.util.jar;
import java.util.zip.*;
import java.io.IOException;
import java.security.cert.Certificate;
import java.util.zip.ZipEntry;
/**
* Does not implement the security and manifest methods.
* Extension to a ZipEntry that contains manifest attributes and certificates.
* Both the Atrributes and the Certificates can be null when not set.
* Note that the <code>getCertificates()</code> method only returns a
* valid value after all of the data of the entry has been read.
* <p>
* There are no public methods to set the attributes or certificate of an
* Entru. Only JarEntries created by the classes in <code>java.util.jar</code>
* will have these properties set.
*
* @author Kresten Krab Thorup <krab@gnu.org>
* @date August 10, 1999.
* @since 1.2
* @author Mark Wielaard (mark@klomp.org)
*/
public class JarEntry extends ZipEntry {
// (Packge local) fields
Attributes attr;
Certificate certs[];
// Constructors
/**
* Creates a new JarEntry with the specified name and no attributes or
* or certificates. Calls <code>super(name)</code> so all other (zip)entry
* fields are null or -1.
*
* @param name the name of the new jar entry
* @exception NullPointerException when the supplied name is null
* @exception IllegalArgumentException when the supplied name is longer
* than 65535 bytes
*/
public JarEntry(String name) throws NullPointerException,
IllegalArgumentException {
super(name);
attr = null;
certs = null;
}
public class JarEntry extends ZipEntry
{
ZipEntry zip;
/**
* Creates a new JarEntry with the specified ZipEntry as template for
* all properties of the entry. Both attributes and certificates will be
* null.
*
* @param entry the ZipEntry whose fields should be copied
*/
public JarEntry(ZipEntry entry) {
super(entry);
attr = null;
certs = null;
}
public JarEntry (ZipEntry ent)
{
super (ent);
}
/**
* Creates a new JarEntry with the specified JarEntry as template for
* all properties of the entry.
*
* @param entry the jarEntry whose fields should be copied
*/
public JarEntry(JarEntry entry) {
super(entry);
try {
attr = entry.getAttributes();
} catch(IOException _) {}
certs = entry.getCertificates();
}
public JarEntry (JarEntry ent)
{
super (ent);
}
// Methods
public JarEntry (String name)
{
super (name);
}
/**
* Returns a copy of the Attributes set for this entry.
* When no Attributes are set in the manifest null is returned.
*
* @return a copy of the Attributes set for this entry
* @exception IOException This will never be thrown. It is here for
* binary compatibility.
*/
public Attributes getAttributes() throws IOException {
if (attr != null) {
return (Attributes) attr.clone();
} else {
return null;
}
}
/**
* Returns a copy of the certificates set for this entry.
* When no certificates are set or when not all data of this entry has
* been read null is returned.
* <p>
* To make sure that this call returns a valid value you must read all
* data from the JarInputStream for this entry.
* When you don't need the data for an entry but want to know the
* certificates that are set for the entry then you can skip all data by
* calling <code>skip(entry.getSize())</code> on the JarInputStream for
* the entry.
*
* @return a copy of the certificates set for this entry
*/
public Certificate[] getCertificates() {
if (certs != null) {
return (Certificate []) certs.clone();
} else {
return null;
}
}
}
/* Attributes.java -- exception thrown to indicate an problem with a jar file
Copyright (C) 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.util.jar;
import java.util.zip.ZipException;
/**
* This exception is thrown to indicate an problem with a jar file.
* It can be constructed with or without a descriptive message of the problem.
* <p>
* Note that none of the methods in the java.util.jar package actually declare
* to throw this exception, most just declare that they throw an IOException
* which is super class of JarException.
*
* @since 1.2
* @author Mark Wielaard (mark@klomp.org)
*/
public class JarException extends ZipException {
// Constructors
/**
* Create a new JarException without a descriptive error message.
*/
public JarException() {
super();
}
/**
* Create a new JarException with a descriptive error message indicating
* what went wrong. This message can later be retrieved by calling the
* <code>getMessage()</code> method.
* @see java.lang.Throwable@getMessage()
*
* @param message The descriptive error message
*/
public JarException(String message) {
super(message);
}
}
/* Copyright (C) 1999 Free Software Foundation
/* JarInputStream.java - InputStream for reading jar files
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.util.jar;
import java.util.zip.*;
import java.io.InputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
/**
* Does not implement any of the security. Just a place holder, so
* that I can implement URLClassLoader.
* InputStream for reading jar files.
* XXX - verification of the signatures in the Manifest file is not yet
* implemented.
*
* @author Kresten Krab Thorup <krab@gnu.org>
* @date August 10, 1999.
* @since 1.2
* @author Mark Wielaard (mark@klomp.org)
*/
public class JarInputStream extends ZipInputStream {
// Fields
/** The manifest for this file or null when there was no manifest. */
private Manifest manifest;
/** The first real JarEntry for this file. Used by readManifest() to store
an entry that isn't the manifest but that should be returned by
getNextEntry next time it is called. Null when no firstEntry was read
while searching for the manifest entry, or when it has already been
returned by getNextEntry(). */
private JarEntry firstEntry;
// Constructors
/**
* Creates a new JarInputStream and tries to read the manifest.
* If such a manifest is present the JarInputStream tries to verify all
* the entry signatures while reading.
*
* @param in InputStream to read the jar from
* @exception IOException when an error occurs when opening or reading
*/
public JarInputStream(InputStream in) throws IOException {
this(in, true);
}
/**
* Creates a new JarInputStream and tries to read the manifest.
* If such a manifest is present and verify is true, the JarInputStream
* tries to verify all the entry signatures while reading.
*
* @param in InputStream to read the jar from
* @param verify wheter or not to verify the manifest entries
* @exception IOException when an error occurs when opening or reading
*/
public JarInputStream(InputStream in, boolean verify) throws IOException {
super(in);
readManifest(verify);
}
public class JarInputStream extends ZipInputStream
{
public JarEntry getNextJarEntry () throws java.io.IOException
{
return new JarEntry (getNextEntry ());
// Methods
/**
* Set the manifest if found. Skips all entries that start with "META-INF/"
*
* @param verify when true (and a Manifest is found) checks the Manifest,
* when false no check is performed
* @exception IOException if an error occurs while reading
*/
private void readManifest(boolean verify) throws IOException {
firstEntry = (JarEntry) super.getNextEntry();
while ((firstEntry != null) &&
firstEntry.getName().startsWith("META-INF/")) {
if(firstEntry.getName().equals(JarFile.MANIFEST_NAME)) {
manifest = new Manifest(this);
}
firstEntry = (JarEntry) super.getNextEntry();
}
closeEntry();
if (verify) {
// XXX
}
}
/**
* Creates a JarEntry for a particular name and consults the manifest
* for the Attributes of the entry.
* Used by <code>ZipEntry.getNextEntry()</code>
*
* @param name the name of the new entry
*/
protected ZipEntry createZipEntry(String name) {
ZipEntry zipEntry = super.createZipEntry(name);
JarEntry jarEntry = new JarEntry(zipEntry);
if (manifest != null) {
jarEntry.attr = manifest.getAttributes(name);
}
return jarEntry;
}
/**
* Returns the Manifest for the jar file or null if there was no Manifest.
*/
public Manifest getManifest() {
return manifest;
}
public JarInputStream (java.io.InputStream is)
{
super(is);
}
/**
* Returns the next entry or null when there are no more entries.
* Does actually return a JarEntry, if you don't want to cast it yourself
* use <code>getNextJarEntry()</code>. Does not return any entries found
* at the beginning of the ZipFile that are special
* (those that start with "META-INF/").
*
* @exception IOException if an IO error occurs when reading the entry
*/
public ZipEntry getNextEntry() throws IOException {
ZipEntry entry;
if (firstEntry != null) {
entry = firstEntry;
firstEntry = null;
} else {
entry = super.getNextEntry();
}
return entry;
}
/**
* Returns the next jar entry or null when there are no more entries.
*
* @exception IOException if an IO error occurs when reading the entry
*/
public JarEntry getNextJarEntry() throws IOException {
return (JarEntry)getNextEntry();
}
/**
* XXX
*
* @param buf XXX
* @param off XXX
* @param len XXX
* @return XXX
* @exception IOException XXX
*/
public int read(byte[] buf, int off, int len) throws IOException {
// XXX if (verify) {}
return super.read(buf, off, len);
}
}
/* JarOutputStream.java - OutputStream for writing jar files
Copyright (C) 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.util.jar;
import java.io.OutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
* OutputStream for writing jar files.
* A special ZipOutputStream that can take JarEntries and can have a optional
* Manifest as first entry.
*
* @author Mark Wielaard (mark@klomp.org)
*/
public class JarOutputStream extends ZipOutputStream {
// Constructors
/**
* Creates a new JarOutputStream without a manifest entry.
*
* @param out the stream to create the new jar on
* @exception IOException if something unexpected happend
*/
public JarOutputStream(OutputStream out) throws IOException {
this(out, null);
}
/**
* Creates a new JarOutputStream with a manifest entry.
* The manifest will be the first entry in the jar.
*
* @param out the stream to create the new jar on
* @param man the manifest that should be put in the jar file or null
* for no manifest entry
* @exception IOException if something unexpected happend
*/
public JarOutputStream(OutputStream out, Manifest man) throws IOException {
super(out);
if (man != null)
writeManifest(man);
}
// Methods
/**
* Writes the manifest to a new JarEntry in this JarOutputStream with as
* name JarFile.MANIFEST_NAME.
*
* @param manifest the non null manifest to be written
* @exception IOException if something unexpected happend
*/
private void writeManifest(Manifest manifest) throws IOException {
// Create a new Jar Entry for the Manifest
JarEntry entry = new JarEntry(JarFile.MANIFEST_NAME);
putNextEntry(entry);
manifest.write(this);
closeEntry();
}
/**
* Prepares the JarOutputStream for writing the next entry.
* This implementation just calls <code>super.putNextEntre()</code>.
*
* @param entry The information for the next entry
* @exception IOException when some unexpected I/O exception occured
*/
public void putNextEntry(ZipEntry entry) throws IOException {
super.putNextEntry(entry); // XXX
}
}
......@@ -123,6 +123,12 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants
}
}
protected ZipEntry createZipEntry (String name)
{
// FIXME - must figure out what this is supposed to do.
return null;
}
public int read (byte[] b, int off, int len) throws IOException
{
if (len > avail)
......
......@@ -137,7 +137,7 @@ DIST_COMMON = ChangeLog Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
TAR = gtar
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
......@@ -165,7 +165,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 \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment