diff options
author | Mark Wielaard <mark@gcc.gnu.org> | 2006-05-18 17:29:21 +0000 |
---|---|---|
committer | Mark Wielaard <mark@gcc.gnu.org> | 2006-05-18 17:29:21 +0000 |
commit | 4f9533c7722fa07511a94d005227961f4a4dec23 (patch) | |
tree | 9f9c470de62ee62fba1331a396450d728d2b1fad /libjava/classpath/javax/naming | |
parent | eaec4980e139903ae9b274d1abcf3a13946603a8 (diff) | |
download | gcc-4f9533c7722fa07511a94d005227961f4a4dec23.zip gcc-4f9533c7722fa07511a94d005227961f4a4dec23.tar.gz gcc-4f9533c7722fa07511a94d005227961f4a4dec23.tar.bz2 |
Imported GNU Classpath 0.90
Imported GNU Classpath 0.90
* scripts/makemake.tcl: LocaleData.java moved to gnu/java/locale.
* sources.am: Regenerated.
* gcj/javaprims.h: Regenerated.
* Makefile.in: Regenerated.
* gcj/Makefile.in: Regenerated.
* include/Makefile.in: Regenerated.
* testsuite/Makefile.in: Regenerated.
* gnu/java/lang/VMInstrumentationImpl.java: New override.
* gnu/java/net/local/LocalSocketImpl.java: Likewise.
* gnu/classpath/jdwp/VMMethod.java: Likewise.
* gnu/classpath/jdwp/VMVirtualMachine.java: Update to latest
interface.
* java/lang/Thread.java: Add UncaughtExceptionHandler.
* java/lang/reflect/Method.java: Implements GenericDeclaration and
isSynthetic(),
* java/lang/reflect/Field.java: Likewise.
* java/lang/reflect/Constructor.java
* java/lang/Class.java: Implements Type, GenericDeclaration,
getSimpleName() and getEnclosing*() methods.
* java/lang/Class.h: Add new public methods.
* java/lang/Math.java: Add signum(), ulp() and log10().
* java/lang/natMath.cc (log10): New function.
* java/security/VMSecureRandom.java: New override.
* java/util/logging/Logger.java: Updated to latest classpath
version.
* java/util/logging/LogManager.java: New override.
From-SVN: r113887
Diffstat (limited to 'libjava/classpath/javax/naming')
7 files changed, 456 insertions, 13 deletions
diff --git a/libjava/classpath/javax/naming/Binding.java b/libjava/classpath/javax/naming/Binding.java index 9d6608a..a34f8b3 100644 --- a/libjava/classpath/javax/naming/Binding.java +++ b/libjava/classpath/javax/naming/Binding.java @@ -39,31 +39,73 @@ exception statement from your version. */ package javax.naming; /** + * <code>Binding</code> represents the name-object mapping of a + * binding in a context. + * <p> + * Bindings are mappings of a name to an object and this class is used to + * specify such mappings. The bindings of a context are retrieved by the + * <code>Context#listBindings()</code> methods. + * </p> + * * @author Tom Tromey (tromey@redhat.com) - * @date May 16, 2001 + * @since 1.3 */ public class Binding extends NameClassPair { private static final long serialVersionUID = 8839217842691845890L; + /** + * Constructs an instance with the given name and object. + * + * @param name the name of the binding relative to the target context + * (may not be <code>null</code>) + * @param obj the bound object + */ public Binding (String name, Object obj) { super (name, null); boundObj = obj; } + /** + * Constructs an instance with the given name and object and a + * flag indicating if the name is relative to the target context. + * + * @param name the name of the binding relative to the target context + * (may not be <code>null</code>) + * @param obj the bound object + * @param isRelative flag indicating if the name is relative or not + */ public Binding (String name, Object obj, boolean isRelative) { super (name, null, isRelative); boundObj = obj; } + /** + * Constructs an instance with the given name, classname and object. + * + * @param name the name of the binding relative to the target context + * (may not be <code>null</code>) + * @param className the classname to set (maybe <code>null</code>) + * @param obj the bound object + */ public Binding (String name, String className, Object obj) { super (name, className); boundObj = obj; } + /** + * Constructs an instance with the given name, classname, object and a + * flag indicating if the name is relative to the target context. + * + * @param name the name of the binding relative to the target context + * (may not be <code>null</code>) + * @param className the classname to set (maybe <code>null</code>) + * @param isRelative flag indicating if the name is relative or not + * @param obj the bound object + */ public Binding (String name, String className, Object obj, boolean isRelative) { @@ -71,6 +113,15 @@ public class Binding extends NameClassPair boundObj = obj; } + /** + * Returns the classname of the bound object. + * <p> + * Returns the classname if set explicitly. If not and the bound object is + * not <code>null</code> the classname of the bound object is used. + * </p> + * + * @return The fully qualified classname (may be <code>null</code>). + */ public String getClassName () { String r = super.getClassName (); @@ -79,16 +130,29 @@ public class Binding extends NameClassPair return boundObj == null ? null : boundObj.getClass ().getName (); } + /** + * Returns the bound object of this binding. + * @return The bound object (maybe <code>null</code>). + */ public Object getObject () { return boundObj; } + /** + * Sets the bound object of this binding. + * @param obj the bound object. + */ public void setObject (Object obj) { boundObj = obj; } + /** + * Returns the string representation. + * @return The string as given by the NameClassPair superclass plus + * the bound objects string representation seperated by a colon. + */ public String toString () { // Format specified by the documentation. diff --git a/libjava/classpath/javax/naming/CompositeName.java b/libjava/classpath/javax/naming/CompositeName.java index 61adcf1..6f3466c 100644 --- a/libjava/classpath/javax/naming/CompositeName.java +++ b/libjava/classpath/javax/naming/CompositeName.java @@ -1,5 +1,5 @@ /* CompositeName.java -- - Copyright (C) 2001, 2005 Free Software Foundation, Inc. + Copyright (C) 2001, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,6 +38,9 @@ exception statement from your version. */ package javax.naming; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Enumeration; import java.util.NoSuchElementException; @@ -45,10 +48,6 @@ import java.util.Vector; /** * @author Tom Tromey (tromey@redhat.com) - * @date May 16, 2001 - * - * FIXME: must write readObject and writeObject to conform to - * serialization spec. */ public class CompositeName implements Name, Cloneable, Serializable { @@ -316,6 +315,22 @@ public class CompositeName implements Name, Cloneable, Serializable } return result.toString (); } + + private void readObject(ObjectInputStream s) + throws IOException, ClassNotFoundException + { + int size = s.readInt(); + elts = new Vector(size); + for (int i = 0; i < size; i++) + elts.add(s.readObject()); + } + + private void writeObject(ObjectOutputStream s) throws IOException + { + s.writeInt(elts.size()); + for (int i = 0; i < elts.size(); i++) + s.writeObject(elts.get(i)); + } private transient Vector elts; } diff --git a/libjava/classpath/javax/naming/NameClassPair.java b/libjava/classpath/javax/naming/NameClassPair.java index 127730a..7925d45 100644 --- a/libjava/classpath/javax/naming/NameClassPair.java +++ b/libjava/classpath/javax/naming/NameClassPair.java @@ -41,18 +41,43 @@ package javax.naming; import java.io.Serializable; /** + * <code>NameClassPair</code> represents the name-classname mapping pair + * of a binding in a context. + * <p> + * Bindings are mappings of a name to an object and this class is used to + * specify the mapping of the name to the class type of the bound object. + * As classname the fully qualified classname is used. + * </p> + * * @author Tom Tromey (tromey@redhat.com) - * @date May 16, 2001 + * @since 1.3 */ public class NameClassPair implements Serializable { private static final long serialVersionUID = 5620776610160863339L; + /** + * Constructs an instance with the given name and classname. + * + * @param name the name of the binding relative to the target context + * (may not be <code>null</code>) + * @param className the name of the class. If <code>null</code> the bound + * object is also <code>null</code> + */ public NameClassPair (String name, String className) { this (name, className, true); } + /** + * Constructs an instance with the given name and classname and a + * flag indicating if the name is relative to the target context. + * + * @param name the name of the binding (may not be <code>null</code>) + * @param className the name of the class. If <code>null</code> the bound + * object is also <code>null</code> + * @param isRelative flag indicating if the name is relative or not + */ public NameClassPair (String name, String className, boolean isRelative) { this.name = name; @@ -60,36 +85,105 @@ public class NameClassPair implements Serializable this.isRel = isRelative; } + /** + * Returns the classname of the binding. + * @return The fully qualified classname or <code>null</code> if the + * bound object is null. + */ public String getClassName () { return className; } + /** + * Returns the name of the binding. + * @return The name. + */ public String getName () { return name; } + /** + * Checks whether the name is relative to the target context or not. + * @return <code>true</code> if the name is relative, + * <code>false</code> otherwise. + */ public boolean isRelative () { return isRel; } + /** + * Sets the classname of the bound object. + * @param name the classname to set (maybe <code>null</code>) + */ public void setClassName (String name) { this.className = name; } + /** + * Sets the name of the binding. + * @param name the name to set + */ public void setName (String name) { this.name = name; } + /** + * Sets if the name is relative to the target context. + * @param r <code>true</code> to mark as relative + */ public void setRelative (boolean r) { this.isRel = r; } + + /** + * Sets the full name for this binding. Setting the full name by this + * method is the only way to initialize full names of bindings if + * supported by a specific naming system. + * + * @param fullName the full name of this binding. If not set or set to + * <code>null</code> the <code>getNameInNamespace()</code> method will + * throw an exception + * + * @see #getNameInNamespace() + * + * @since 1.5 + */ + public void setNameInNamespace(String fullName) + { + this.fullName = fullName; + } + + /** + * Returns the full name for this binding. The full name of a binding is + * defined as the absolute name in its own namespace and is not valid + * outside. + * + * @return The full name in the bindings namespace. + * @throws UnsupportedOperationException if no full name is applicable in + * the specific naming system. + * + * @see Context#getNameInNamespace() + * + * @since 1.5 + */ + public String getNameInNamespace() + { + if (this.fullName == null) + throw new UnsupportedOperationException(); + + return this.fullName; + } + /** + * Returns the string representation. + * @return The string <code>getName() + ":" + getClassName()</code>. + */ public String toString () { // Specified by class documentation. @@ -100,4 +194,5 @@ public class NameClassPair implements Serializable private String name; private String className; private boolean isRel; + private String fullName; } diff --git a/libjava/classpath/javax/naming/directory/BasicAttribute.java b/libjava/classpath/javax/naming/directory/BasicAttribute.java index 0470365..c641979 100644 --- a/libjava/classpath/javax/naming/directory/BasicAttribute.java +++ b/libjava/classpath/javax/naming/directory/BasicAttribute.java @@ -1,5 +1,5 @@ /* BasicAttribute.java -- - Copyright (C) 2000, 2001, 2004 Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2004, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,6 +38,9 @@ exception statement from your version. */ package javax.naming.directory; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; import java.util.NoSuchElementException; import java.util.Vector; @@ -48,6 +51,7 @@ import javax.naming.OperationNotSupportedException; /** * @author Tom Tromey (tromey@redhat.com) * @date June 20, 2001 + * @since 1.3 */ public class BasicAttribute implements Attribute { @@ -297,11 +301,29 @@ public class BasicAttribute implements Attribute return one.equals (two); } + + private void readObject(ObjectInputStream s) + throws IOException, ClassNotFoundException + { + s.defaultReadObject(); + int size = s.readInt(); + values = new Vector(size); + for (int i=0; i < size; i++) + values.add(s.readObject()); + } + private void writeObject(ObjectOutputStream s) throws IOException + { + s.defaultWriteObject(); + s.writeInt(values.size()); + for (int i=0; i < values.size(); i++) + s.writeObject(values.get(i)); + } + // Used when enumerating this attribute. private class BasicAttributeEnumeration implements NamingEnumeration { - int where = -1; + int where = 0; public BasicAttributeEnumeration () { @@ -328,10 +350,9 @@ public class BasicAttribute implements Attribute public Object nextElement () throws NoSuchElementException { - if (where + 1 >= values.size ()) + if (where == values.size ()) throw new NoSuchElementException ("no more elements"); - ++where; - return values.get (where); + return values.get (where++); } } } diff --git a/libjava/classpath/javax/naming/directory/BasicAttributes.java b/libjava/classpath/javax/naming/directory/BasicAttributes.java index 37ec195..9318fbb 100644 --- a/libjava/classpath/javax/naming/directory/BasicAttributes.java +++ b/libjava/classpath/javax/naming/directory/BasicAttributes.java @@ -1,5 +1,5 @@ /* BasicAttributes.java -- - Copyright (C) 2000, 2001, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,6 +38,9 @@ exception statement from your version. */ package javax.naming.directory; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; import java.util.NoSuchElementException; import java.util.Vector; @@ -196,6 +199,24 @@ public class BasicAttributes implements Attributes // Package-private to avoid a trampoline. transient Vector attributes; + private void readObject(ObjectInputStream s) throws IOException, + ClassNotFoundException + { + s.defaultReadObject(); + int size = s.readInt(); + attributes = new Vector(size); + for (int i = 0; i < size; i++) + attributes.add(s.readObject()); + } + + private void writeObject(ObjectOutputStream s) throws IOException + { + s.defaultWriteObject(); + s.writeInt(attributes.size()); + for (int i = 0; i < attributes.size(); i++) + s.writeObject(attributes.get(i)); + } + // Used when enumerating. private class BasicAttributesEnumeration implements NamingEnumeration { diff --git a/libjava/classpath/javax/naming/ldap/StartTlsRequest.java b/libjava/classpath/javax/naming/ldap/StartTlsRequest.java new file mode 100644 index 0000000..b0a30b5 --- /dev/null +++ b/libjava/classpath/javax/naming/ldap/StartTlsRequest.java @@ -0,0 +1,108 @@ +/* StartTlsRequest.java -- extended ldap TLS request + Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.ldap; + +import java.util.Iterator; + +import gnu.classpath.ServiceFactory; + +import javax.naming.NamingException; + +/** + * @since 1.4 + */ +public class StartTlsRequest + implements ExtendedRequest +{ + private static final long serialVersionUID = 4441679576360753397L; + + /** + * The assigned object identifier for this response. + */ + public static final String OID = "1.3.6.1.4.1.1466.20037"; + + /** + * Create a new instance. + */ + public StartTlsRequest() + { + } + + /** + * Return the response identifier. This is simply the value + * of the {@link #OID} field. + */ + public String getID() + { + return OID; + } + + /** + * Return the encoded value. This implementation always returns null. + */ + public byte[] getEncodedValue() + { + return null; + } + + /** + * Create a new extended reponse object, using the standard service + * provider approach to load a provider. The provider will be a subclass + * of StartTlsRequest with a no-argument constructor. The key is + * "javax.naming.ldap.StartTlsRequest". + * @param id the identifier, must be {@link #OID} or null + * @param berValue ignored + * @param offset ignored + * @param length ignored + * @throws NamingException if there is a problem creating the response + */ + public ExtendedResponse createExtendedResponse(String id, byte[] berValue, + int offset, int length) + throws NamingException + { + if (id != null && ! OID.equals(id)) + throw new NamingException("incorrect id: was \"" + id + + "\", but expected: \"" + OID + "\""); + Iterator it = ServiceFactory.lookupProviders(StartTlsRequest.class); + if (it.hasNext()) + return (ExtendedResponse) it.next(); + throw new NamingException("couldn't find provider for " + + "javax.naming.ldap.StartTlsRequest"); + } +} diff --git a/libjava/classpath/javax/naming/ldap/StartTlsResponse.java b/libjava/classpath/javax/naming/ldap/StartTlsResponse.java new file mode 100644 index 0000000..68cd5bf --- /dev/null +++ b/libjava/classpath/javax/naming/ldap/StartTlsResponse.java @@ -0,0 +1,119 @@ +/* StartTlsResponse.java -- extended ldap TLS response + Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.ldap; + +import java.io.IOException; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLSession; +import javax.net.ssl.SSLSocketFactory; + +/** + * @since 1.4 + */ +public abstract class StartTlsResponse + implements ExtendedResponse +{ + private static final long serialVersionUID = 8372842182579276418L; + + /** + * The assigned object identifier for this response. + */ + public static final String OID = "1.3.6.1.4.1.1466.20037"; + + /** + * Create a new instance. + */ + protected StartTlsResponse() + { + } + + /** + * Return the response identifier. This is simply the value + * of the {@link #OID} field. + */ + public String getID() + { + return OID; + } + + /** + * Return the encoded value. This implementation always returns null. + */ + public byte[] getEncodedValue() + { + return null; + } + + /** + * Set the list of cipher suites to use. + * @param cipherSuites the list of suites + * @see SSLSocketFactory#getSupportedCipherSuites() + */ + public abstract void setEnabledCipherSuites(String[] cipherSuites); + + /** + * Set the hostname verifier to use. This must be called before + * {@link #negotiate()}. + * @param verifier the hostname verifier + */ + public abstract void setHostnameVerifier(HostnameVerifier verifier); + + /** + * Negotiate the TLS session using the default SSL socket factory. + * @return the SSL session + * @throws IOException if communication fails for some reason + */ + public abstract SSLSession negotiate() throws IOException; + + /** + * Negotiate the TLS session using the supplied SSL socket factory. + * @param factory the socket factory to use + * @return the SSL session + * @throws IOException if communication fails for some reason + */ + public abstract SSLSession negotiate(SSLSocketFactory factory) + throws IOException; + + /** + * Close the connection. + * @throws IOException if communication fails for some reason + */ + public abstract void close() throws IOException; +} |