directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r619239 [1/2] - in /directory/sandbox/slp/src: ./ main/ main/java/ main/java/org/ main/java/org/apache/ main/java/org/apache/directory/ main/java/org/apache/directory/server/ main/java/org/apache/directory/server/slp/ main/java/org/apache/d...
Date Thu, 07 Feb 2008 01:51:16 GMT
Author: akarasulu
Date: Wed Feb  6 17:51:14 2008
New Revision: 619239

URL: http://svn.apache.org/viewvc?rev=619239&view=rev
Log:
DIRSERVER-1127: Applying patch provided by Jan S. Rellermeyer for a ds backed slp implementation

Added:
    directory/sandbox/slp/src/
    directory/sandbox/slp/src/main/
    directory/sandbox/slp/src/main/java/
    directory/sandbox/slp/src/main/java/org/
    directory/sandbox/slp/src/main/java/org/apache/
    directory/sandbox/slp/src/main/java/org/apache/directory/
    directory/sandbox/slp/src/main/java/org/apache/directory/server/
    directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/
    directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/ServiceLocationException.java
    directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/ServiceType.java
    directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/ServiceURL.java
    directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/impl/
    directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/impl/AuthenticatedServiceURL.java
    directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/impl/AuthenticationBlock.java
    directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/
    directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/AbstractSLPMessage.java
    directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/AbstractSLPReplyMessage.java
    directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/AbstractSLPRequestMessage.java
    directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/AttributeReplyMessage.java
    directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/AttributeRequestMessage.java
    directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/DAAdvertisementMessage.java
    directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/ServiceAcknowledgementMessage.java
    directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/ServiceDeregistrationMessage.java
    directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/ServiceRegistrationMessage.java
    directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/ServiceReplyMessage.java
    directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/ServiceRequestMessage.java
    directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/ServiceTypeReplyMessage.java
    directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/ServiceTypeRequestMessage.java

Added: directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/ServiceLocationException.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/ServiceLocationException.java?rev=619239&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/ServiceLocationException.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/ServiceLocationException.java Wed Feb  6 17:51:14 2008
@@ -0,0 +1,312 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.slp;
+
+import java.io.Serializable;
+
+/**
+ * This exception is thrown whenever a part of the SLP framework causes an
+ * exception. The error code is a hint why the exception occured.
+ * 
+ * @author Jan S. Rellermeyer, ETH Zurich
+ */
+public class ServiceLocationException extends Exception implements Serializable {
+
+	/**
+	 * @serial for serialization.
+	 */
+	private static final long serialVersionUID = 5718658752610460537L;
+
+	/**
+	 * There is data for the service type in the scope in the AttrRqst or
+	 * SrvRqst, but not in the requested language.
+	 */
+	public static final short LANGUAGE_NOT_SUPPORTED = 1;
+
+	/**
+	 * The message fails to obey SLP syntax.
+	 */
+	public static final short PARSE_ERROR = 2;
+
+	/**
+	 * The SrvReg has problems -- e.g., a zero lifetime or an omitted Language
+	 * Tag.
+	 */
+	public static final short INVALID_REGISTRATION = 3;
+
+	/**
+	 * The SLP message did not include a scope in its scope-list supported by
+	 * the SA or DA.
+	 */
+	public static final short SCOPE_NOT_SUPPORTED = 4;
+
+	/**
+	 * The DA or SA receives a request for an unsupported SLP SPI.
+	 */
+	public static final short AUTHENTICATION_UNKNOWN = 5;
+
+	/**
+	 * The DA expected URL and ATTR authentication in the SrvReg and did not
+	 * receive it.
+	 */
+	public static final short AUTHENTICATION_ABSENT = 6;
+
+	/**
+	 * Unsupported version number in message header. INTERNAL_ERROR = 10: The DA
+	 * (or SA) is too sick to respond.
+	 */
+	public static final short AUTHENTICATION_FAILED = 7;
+
+	/**
+	 * The DA received a SrvReg without FRESH set, for an unregistered service
+	 * or with inconsistent Service Types.
+	 */
+	public static final short INVALID_UPDATE = 13;
+
+	/**
+	 * The DA rejected the update because it was within the minimal update
+	 * intervall.
+	 */
+	public static final short REFRESH_REJECTED = 15;
+
+	/**
+	 * The feature or extension is not implemented.
+	 */
+	public static final short NOT_IMPLEMENTED = 16;
+
+	/**
+	 * The initialization of the framework failed.
+	 */
+	public static final short NETWORK_INIT_FAILED = 17;
+
+	/**
+	 * The network timed out while the framework tried to send a message.
+	 */
+	public static final short NETWORK_TIMED_OUT = 18;
+
+	/**
+	 * The network encountered an error.
+	 */
+	public static final short NETWORK_ERROR = 19;
+
+	/**
+	 * The framework encountered an internal system error.
+	 */
+	public static final short INTERNAL_SYSTEM_ERROR = 20;
+
+	/**
+	 * The type was not well formed.
+	 */
+	public static final short TYPE_ERROR = 21;
+
+	/**
+	 * The framework encountered a buffer overflow.
+	 */
+	public static final short BUFFER_OVERFLOW = 22;
+
+	/**
+	 * the error code of this exception instance.
+	 */
+	private short errorCode;
+
+	/**
+	 * hidden constructor.
+	 */
+	public ServiceLocationException() {
+	}
+
+	/**
+	 * Create a new ServiceLocation instance.
+	 * 
+	 * @param errcode
+	 *            the error code, one of the statically defined.
+	 * @param message
+	 *            the message of the exception.
+	 */
+	public ServiceLocationException(final short errcode, final String message) {
+		super(message);
+		errorCode = errcode;
+	}
+
+	/**
+	 * Get the error code of the exception.
+	 * 
+	 * @return the error code.
+	 */
+	public final short getErrorCode() {
+		return errorCode;
+	}
+}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.slp;
+
+import java.io.Serializable;
+
+/**
+ * This exception is thrown whenever a part of the SLP framework causes an
+ * exception. The error code is a hint why the exception occured.
+ * 
+ * @author Jan S. Rellermeyer, ETH Zurich
+ */
+public class ServiceLocationException extends Exception implements Serializable {
+
+	/**
+	 * @serial for serialization.
+	 */
+	private static final long serialVersionUID = 5718658752610460537L;
+
+	/**
+	 * There is data for the service type in the scope in the AttrRqst or
+	 * SrvRqst, but not in the requested language.
+	 */
+	public static final short LANGUAGE_NOT_SUPPORTED = 1;
+
+	/**
+	 * The message fails to obey SLP syntax.
+	 */
+	public static final short PARSE_ERROR = 2;
+
+	/**
+	 * The SrvReg has problems -- e.g., a zero lifetime or an omitted Language
+	 * Tag.
+	 */
+	public static final short INVALID_REGISTRATION = 3;
+
+	/**
+	 * The SLP message did not include a scope in its scope-list supported by
+	 * the SA or DA.
+	 */
+	public static final short SCOPE_NOT_SUPPORTED = 4;
+
+	/**
+	 * The DA or SA receives a request for an unsupported SLP SPI.
+	 */
+	public static final short AUTHENTICATION_UNKNOWN = 5;
+
+	/**
+	 * The DA expected URL and ATTR authentication in the SrvReg and did not
+	 * receive it.
+	 */
+	public static final short AUTHENTICATION_ABSENT = 6;
+
+	/**
+	 * Unsupported version number in message header. INTERNAL_ERROR = 10: The DA
+	 * (or SA) is too sick to respond.
+	 */
+	public static final short AUTHENTICATION_FAILED = 7;
+
+	/**
+	 * The DA received a SrvReg without FRESH set, for an unregistered service
+	 * or with inconsistent Service Types.
+	 */
+	public static final short INVALID_UPDATE = 13;
+
+	/**
+	 * The DA rejected the update because it was within the minimal update
+	 * intervall.
+	 */
+	public static final short REFRESH_REJECTED = 15;
+
+	/**
+	 * The feature or extension is not implemented.
+	 */
+	public static final short NOT_IMPLEMENTED = 16;
+
+	/**
+	 * The initialization of the framework failed.
+	 */
+	public static final short NETWORK_INIT_FAILED = 17;
+
+	/**
+	 * The network timed out while the framework tried to send a message.
+	 */
+	public static final short NETWORK_TIMED_OUT = 18;
+
+	/**
+	 * The network encountered an error.
+	 */
+	public static final short NETWORK_ERROR = 19;
+
+	/**
+	 * The framework encountered an internal system error.
+	 */
+	public static final short INTERNAL_SYSTEM_ERROR = 20;
+
+	/**
+	 * The type was not well formed.
+	 */
+	public static final short TYPE_ERROR = 21;
+
+	/**
+	 * The framework encountered a buffer overflow.
+	 */
+	public static final short BUFFER_OVERFLOW = 22;
+
+	/**
+	 * the error code of this exception instance.
+	 */
+	private short errorCode;
+
+	/**
+	 * hidden constructor.
+	 */
+	public ServiceLocationException() {
+	}
+
+	/**
+	 * Create a new ServiceLocation instance.
+	 * 
+	 * @param errcode
+	 *            the error code, one of the statically defined.
+	 * @param message
+	 *            the message of the exception.
+	 */
+	public ServiceLocationException(final short errcode, final String message) {
+		super(message);
+		errorCode = errcode;
+	}
+
+	/**
+	 * Get the error code of the exception.
+	 * 
+	 * @return the error code.
+	 */
+	public final short getErrorCode() {
+		return errorCode;
+	}
+}

Added: directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/ServiceType.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/ServiceType.java?rev=619239&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/ServiceType.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/ServiceType.java Wed Feb  6 17:51:14 2008
@@ -0,0 +1,500 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.slp;
+
+import java.io.Serializable;
+
+/**
+ * Implementation of the SLP ServiceType class defined in RFC 2614.
+ * 
+ * @author Jan S. Rellermeyer, IKS, ETH Zurich
+ * @author Patrick Callis, Solers Corp.
+ * @since 0.1
+ */
+public final class ServiceType implements Serializable {
+
+	/**
+	 * the serial UID.
+	 */
+	private static final long serialVersionUID = 1652247274399819356L;
+
+	/**
+	 * the type.
+	 */
+	private String type = new String();
+
+	/**
+	 * is it a service ?
+	 */
+	private boolean isService = false;
+
+	/**
+	 * is it abstract ?
+	 */
+	private boolean isAbstract = false;
+
+	/**
+	 * the concrete type.
+	 */
+	private String concreteType = new String();
+
+	/**
+	 * the principle type.
+	 */
+	private String principleType = new String();
+
+	/**
+	 * the abstract type.
+	 */
+	private String abstractType = new String();
+
+	/**
+	 * the naming authority.
+	 */
+	private String namingAuthority = new String();
+
+	/**
+	 * creates a new ServiceType instance.
+	 * 
+	 * @param serviceType
+	 *            the string representation of a ServiceType, e.g.
+	 * 
+	 * <pre>
+	 *      service:osgi:remote
+	 * </pre>
+	 */
+	public ServiceType(final String serviceType) {
+		type = serviceType;
+		if (type.startsWith("service:")) {
+			isService = true;
+
+			int principleStart = 8;
+			int principleEnd = type.indexOf(":", principleStart);
+
+			if (principleEnd != -1) {
+				isAbstract = true;
+				principleType = type.substring(principleStart, principleEnd);
+				abstractType = type.substring(0, principleEnd);
+				concreteType = type.substring(principleEnd + 1);
+			} else {
+				isAbstract = false;
+				principleType = type.substring(principleStart);
+				abstractType = "";
+				concreteType = "";
+			}
+
+			int namingStart = type.indexOf(".") + 1;
+			if (namingStart != 0) {
+				int namingEnd = type.indexOf(":", namingStart);
+				if (namingEnd == -1) {
+					namingAuthority = type.substring(namingStart);
+				} else {
+					namingAuthority = type.substring(namingStart, namingEnd);
+				}
+			} else {
+				namingAuthority = "";
+			}
+		}
+	}
+
+	/**
+	 * is the ServiceType instance a ServiceURL ?
+	 * 
+	 * @return true if this is the case.
+	 */
+	public boolean isServiceURL() {
+		return isService;
+	}
+
+	/**
+	 * is the ServiceType instance an abstract type ?
+	 * 
+	 * @return true if thie is the case.
+	 */
+	public boolean isAbstractType() {
+		return isAbstract;
+	}
+
+	/**
+	 * is the naming authority default (IANA) ?
+	 * 
+	 * @return true if this is the case.
+	 */
+	public boolean isNADefault() {
+		return namingAuthority.equals("");
+	}
+
+	/**
+	 * get the concrete type part of this ServiceType instance.
+	 * 
+	 * @return a String representing the concrete type.
+	 */
+	public String getConcreteTypeName() {
+		return concreteType;
+	}
+
+	/**
+	 * get the principle type part of this ServiceType instance.
+	 * 
+	 * @return a String representing the principle part.
+	 */
+	public String getPrincipleTypeName() {
+		return principleType;
+	}
+
+	/**
+	 * get the name of the abstract type of this ServiceType instance.
+	 * 
+	 * @return a String representing the abstract type.
+	 */
+	public String getAbstractTypeName() {
+		return abstractType;
+	}
+
+	/**
+	 * get the naming authority.
+	 * 
+	 * @return the naming authority.
+	 */
+	public String getNamingAuthority() {
+		return namingAuthority;
+	}
+
+	/**
+	 * check if two ServiceTypes are equal.
+	 * 
+	 * @param obj
+	 *            another ServiceType.
+	 * @return true if they equal.
+	 */
+	public boolean equals(final Object obj) {
+		if (!(obj instanceof ServiceType)) {
+			return false;
+		}
+		ServiceType t = (ServiceType) obj;
+		return (isService == t.isService && isAbstract == t.isAbstract
+				&& concreteType.equals(t.concreteType)
+				&& principleType.equals(t.principleType)
+				&& abstractType.equals(t.abstractType) && namingAuthority
+				.equals(t.namingAuthority));
+	}
+
+	/**
+	 * check if a ServiceType matches a ServiceURL or another ServiceType.
+	 * 
+	 * @param obj
+	 *            the object to be compared to.
+	 * @return true if this type matches the other object.
+	 */
+	public boolean matches(final Object obj) {
+		if (!(obj instanceof ServiceType)) {
+			return false;
+		}
+		ServiceType t = (ServiceType) obj;
+		if (!isAbstract) {
+			return equals(t);
+		} else {
+			return equals(t) || t.toString().equals(getAbstractTypeName());
+		}
+	}
+
+	/**
+	 * get a String representation of this ServiceType instance.
+	 * 
+	 * @return the String representation.
+	 */
+	public String toString() {
+		return type;
+	}
+
+	/**
+	 * get the hashCode of this ServiceType instance.
+	 * 
+	 * @return the int value of the hashCode.
+	 */
+	public int hashCode() {
+		int code = 0;
+
+		if (concreteType != null) {
+			code ^= (concreteType.hashCode());
+		}
+		if (principleType != null) {
+			code ^= (principleType.hashCode() << 8);
+		}
+		if (abstractType != null) {
+			code ^= (abstractType.hashCode() << 16);
+		}
+		if (namingAuthority != null) {
+			code ^= (namingAuthority.hashCode() << 24);
+		}
+		return code;
+	}
+
+}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.slp;
+
+import java.io.Serializable;
+
+/**
+ * Implementation of the SLP ServiceType class defined in RFC 2614.
+ * 
+ * @author Jan S. Rellermeyer, IKS, ETH Zurich
+ * @author Patrick Callis, Solers Corp.
+ * @since 0.1
+ */
+public final class ServiceType implements Serializable {
+
+	/**
+	 * the serial UID.
+	 */
+	private static final long serialVersionUID = 1652247274399819356L;
+
+	/**
+	 * the type.
+	 */
+	private String type = new String();
+
+	/**
+	 * is it a service ?
+	 */
+	private boolean isService = false;
+
+	/**
+	 * is it abstract ?
+	 */
+	private boolean isAbstract = false;
+
+	/**
+	 * the concrete type.
+	 */
+	private String concreteType = new String();
+
+	/**
+	 * the principle type.
+	 */
+	private String principleType = new String();
+
+	/**
+	 * the abstract type.
+	 */
+	private String abstractType = new String();
+
+	/**
+	 * the naming authority.
+	 */
+	private String namingAuthority = new String();
+
+	/**
+	 * creates a new ServiceType instance.
+	 * 
+	 * @param serviceType
+	 *            the string representation of a ServiceType, e.g.
+	 * 
+	 * <pre>
+	 *      service:osgi:remote
+	 * </pre>
+	 */
+	public ServiceType(final String serviceType) {
+		type = serviceType;
+		if (type.startsWith("service:")) {
+			isService = true;
+
+			int principleStart = 8;
+			int principleEnd = type.indexOf(":", principleStart);
+
+			if (principleEnd != -1) {
+				isAbstract = true;
+				principleType = type.substring(principleStart, principleEnd);
+				abstractType = type.substring(0, principleEnd);
+				concreteType = type.substring(principleEnd + 1);
+			} else {
+				isAbstract = false;
+				principleType = type.substring(principleStart);
+				abstractType = "";
+				concreteType = "";
+			}
+
+			int namingStart = type.indexOf(".") + 1;
+			if (namingStart != 0) {
+				int namingEnd = type.indexOf(":", namingStart);
+				if (namingEnd == -1) {
+					namingAuthority = type.substring(namingStart);
+				} else {
+					namingAuthority = type.substring(namingStart, namingEnd);
+				}
+			} else {
+				namingAuthority = "";
+			}
+		}
+	}
+
+	/**
+	 * is the ServiceType instance a ServiceURL ?
+	 * 
+	 * @return true if this is the case.
+	 */
+	public boolean isServiceURL() {
+		return isService;
+	}
+
+	/**
+	 * is the ServiceType instance an abstract type ?
+	 * 
+	 * @return true if thie is the case.
+	 */
+	public boolean isAbstractType() {
+		return isAbstract;
+	}
+
+	/**
+	 * is the naming authority default (IANA) ?
+	 * 
+	 * @return true if this is the case.
+	 */
+	public boolean isNADefault() {
+		return namingAuthority.equals("");
+	}
+
+	/**
+	 * get the concrete type part of this ServiceType instance.
+	 * 
+	 * @return a String representing the concrete type.
+	 */
+	public String getConcreteTypeName() {
+		return concreteType;
+	}
+
+	/**
+	 * get the principle type part of this ServiceType instance.
+	 * 
+	 * @return a String representing the principle part.
+	 */
+	public String getPrincipleTypeName() {
+		return principleType;
+	}
+
+	/**
+	 * get the name of the abstract type of this ServiceType instance.
+	 * 
+	 * @return a String representing the abstract type.
+	 */
+	public String getAbstractTypeName() {
+		return abstractType;
+	}
+
+	/**
+	 * get the naming authority.
+	 * 
+	 * @return the naming authority.
+	 */
+	public String getNamingAuthority() {
+		return namingAuthority;
+	}
+
+	/**
+	 * check if two ServiceTypes are equal.
+	 * 
+	 * @param obj
+	 *            another ServiceType.
+	 * @return true if they equal.
+	 */
+	public boolean equals(final Object obj) {
+		if (!(obj instanceof ServiceType)) {
+			return false;
+		}
+		ServiceType t = (ServiceType) obj;
+		return (isService == t.isService && isAbstract == t.isAbstract
+				&& concreteType.equals(t.concreteType)
+				&& principleType.equals(t.principleType)
+				&& abstractType.equals(t.abstractType) && namingAuthority
+				.equals(t.namingAuthority));
+	}
+
+	/**
+	 * check if a ServiceType matches a ServiceURL or another ServiceType.
+	 * 
+	 * @param obj
+	 *            the object to be compared to.
+	 * @return true if this type matches the other object.
+	 */
+	public boolean matches(final Object obj) {
+		if (!(obj instanceof ServiceType)) {
+			return false;
+		}
+		ServiceType t = (ServiceType) obj;
+		if (!isAbstract) {
+			return equals(t);
+		} else {
+			return equals(t) || t.toString().equals(getAbstractTypeName());
+		}
+	}
+
+	/**
+	 * get a String representation of this ServiceType instance.
+	 * 
+	 * @return the String representation.
+	 */
+	public String toString() {
+		return type;
+	}
+
+	/**
+	 * get the hashCode of this ServiceType instance.
+	 * 
+	 * @return the int value of the hashCode.
+	 */
+	public int hashCode() {
+		int code = 0;
+
+		if (concreteType != null) {
+			code ^= (concreteType.hashCode());
+		}
+		if (principleType != null) {
+			code ^= (principleType.hashCode() << 8);
+		}
+		if (abstractType != null) {
+			code ^= (abstractType.hashCode() << 16);
+		}
+		if (namingAuthority != null) {
+			code ^= (namingAuthority.hashCode() << 24);
+		}
+		return code;
+	}
+
+}

Added: directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/ServiceURL.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/ServiceURL.java?rev=619239&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/ServiceURL.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/ServiceURL.java Wed Feb  6 17:51:14 2008
@@ -0,0 +1,650 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.slp;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import org.apache.directory.server.slp.impl.AuthenticatedServiceURL;
+
+/**
+ * Implementation of the SLP ServiceURL class defined in RFC 2614.
+ * 
+ * @author Jan S. Rellermeyer, ETH Zürich
+ */
+public final class ServiceURL extends AuthenticatedServiceURL {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 9181946114021582389L;
+
+	/**
+	 * 
+	 */
+	public static final int NO_PORT = 0;
+
+	/**
+	 * 
+	 */
+	public static final int LIFETIME_NONE = 0;
+
+	/**
+	 * 
+	 */
+	public static final int LIFETIME_DEFAULT = 10800;
+
+	/**
+	 * 
+	 */
+	public static final int LIFETIME_MAXIMUM = 65535;
+
+	/**
+	 * 
+	 */
+	public static final int LIFETIME_PERMANENT = -1;
+
+	/**
+	 * 
+	 */
+	private String url = null;;
+
+	/**
+	 * 
+	 */
+	private int lifetime = 0;
+
+	/**
+	 * 
+	 */
+	private ServiceType type = null;
+
+	/**
+	 * 
+	 */
+	private String host = null;
+
+	/**
+	 * 
+	 */
+	private String protocol = null;
+
+	/**
+	 * 
+	 */
+	private int port = 0;
+
+	/**
+	 * 
+	 */
+	private String path = null;
+
+	/**
+	 * 
+	 * 
+	 */
+	private ServiceURL() {
+	}
+
+	/**
+	 * create a new ServiceURL instance from a String.
+	 * 
+	 * @param serviceURL
+	 *            the string representation of a ServiceURL like
+	 * 
+	 * <pre>
+	 *                 service::&quot;serviceType&quot;://&quot;addrspec&quot;
+	 * </pre>
+	 * 
+	 * where servicetype should be of the form abstractType:concreteType and
+	 * addrspec is the hostname or dotted decimal notation of the host's address
+	 * followed by an optional :portNumber. Example:
+	 * 
+	 * <pre>
+	 *                     service:osgi:remote://my.host.ch:9200
+	 * </pre>
+	 * 
+	 * @param lifeTime
+	 *            the lifetime of the ServiceURL in seconds.
+	 * @throws ServiceLocationException
+	 *             if the String is not parsable.
+	 */
+	public ServiceURL(final String serviceURL, final int lifeTime)
+			throws ServiceLocationException {
+		url = serviceURL;
+		lifetime = lifeTime;
+
+		try {
+			parse();
+		} catch (Exception ex) {
+			throw new ServiceLocationException(
+					ServiceLocationException.PARSE_ERROR,
+					"service url is malformed: [" + url + "]. ");
+		}
+	}
+
+	/**
+	 * parse the url string.
+	 * 
+	 */
+	private void parse() {
+		int pos1 = url.indexOf("://");
+		type = new ServiceType(url.substring(0, pos1++));
+
+		int pos2 = url.indexOf("://", pos1 + 1);
+		if (pos2 > -1) {
+			protocol = url.substring(pos1 + 2, pos2);
+			pos1 = pos2 + 1;
+		}
+
+		int hostEnd = url.indexOf(":", pos1 + 2);
+
+		int pathStart;
+		if (hostEnd == -1) {
+			port = NO_PORT;
+			pathStart = hostEnd = url.indexOf("/", pos1 + 2);
+		} else {
+			pathStart = url.indexOf("/", hostEnd + 1);
+			if (pathStart == -1) {
+				port = Integer.parseInt(url.substring(hostEnd + 1));
+			} else {
+				port = Integer.parseInt(url.substring(hostEnd + 1, pathStart));
+			}
+		}
+
+		if (hostEnd == -1) {
+			host = url.substring(pos1 + 2);
+		} else {
+			host = url.substring(pos1 + 2, hostEnd);
+		}
+
+		if (pathStart == -1) {
+			path = "";
+		} else {
+			path = url.substring(pathStart);
+		}
+	}
+
+	/**
+	 * Check if two instances are equal.
+	 * 
+	 * @inheritDoc java.lang.Object.equals(Object)
+	 * @param obj
+	 *            the object to compare to.
+	 * @return true if the instances are equal.
+	 */
+	public boolean equals(final Object obj) {
+		if (obj instanceof ServiceURL) {
+			final ServiceURL u = (ServiceURL) obj;
+			return (type.equals(u.type)
+					&& host.equals(u.host)
+					&& port == u.port
+					&& ((protocol == null && u.protocol == null) || protocol
+							.equals(u.protocol)) && path.equals(u.path));
+		}
+		return false;
+	}
+
+	/**
+	 * Check if a ServiceURL matches another ServiceURL or a ServiceType. In the
+	 * first case, the method performs an equality check with equals(Object
+	 * obj), for ServiceTypes, the ServiceType part of the ServiceURL is checked
+	 * against the given ServiceType.
+	 * 
+	 * @param obj
+	 *            a ServiceURL or ServiceType. All other objects will return
+	 *            false.
+	 * @return true if the match succeeds.
+	 */
+	public boolean matches(final Object obj) {
+		if (obj instanceof ServiceURL) {
+			return equals(obj);
+		} else if (obj instanceof ServiceType) {
+			return type.matches(obj);
+		}
+		return false;
+	}
+
+	/**
+	 * get a String representation of the ServiceURL.
+	 * 
+	 * @return the String representation.
+	 */
+	public String toString() {
+		return type.toString() + "://"
+				+ (protocol != null ? protocol + "://" : "") + host
+				+ (port != NO_PORT ? (":" + port) : "") + path;
+	}
+
+	/**
+	 * get the hashCode of the ServiceURL instance.
+	 * 
+	 * @return the hashCode.
+	 */
+	public int hashCode() {
+		return url.hashCode();
+	}
+
+	/**
+	 * get the service type.
+	 * 
+	 * @return the service type.
+	 */
+	public ServiceType getServiceType() {
+		return type;
+	}
+
+	/**
+	 * get the transport method.
+	 * 
+	 * @return the transport method. IP returns empty string.
+	 * @deprecated
+	 */
+	public String getTransport() {
+		return "";
+	}
+
+	/**
+	 * get the protocol.
+	 * 
+	 * @return the protocol, if specified. Otherwise, returns null.
+	 */
+	public String getProtocol() {
+		return protocol;
+	}
+
+	/**
+	 * get the host.
+	 * 
+	 * @return the host.
+	 */
+	public String getHost() {
+		return host;
+	}
+
+	/**
+	 * get the port.
+	 * 
+	 * @return the port.
+	 */
+	public int getPort() {
+		return port;
+	}
+
+	/**
+	 * get the URL path.
+	 * 
+	 * @return the URL path.
+	 */
+	public String getURLPath() {
+		return path;
+	}
+
+	/**
+	 * get the lifetime.
+	 * 
+	 * @return the lifetime.
+	 */
+	public int getLifetime() {
+		return lifetime;
+	}
+
+	/**
+	 * get the byte representation of the ServiceURL instance.
+	 * 
+	 * @throws IOException
+	 * @throws IOException
+	 *             if an internal processing error occurs.
+	 */
+	public void writeTo(DataOutputStream out) throws IOException {
+		out.write(0);
+		out.writeShort((short) lifetime);
+		out.writeUTF(toString());
+		// writeAuthBlock(out);
+	}
+
+	public int getLength() {
+		return 1 + 2 + 2 + toString().length(); // + getAuthBlockLength();
+	}
+}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.slp;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import org.apache.directory.server.slp.impl.AuthenticatedServiceURL;
+
+/**
+ * Implementation of the SLP ServiceURL class defined in RFC 2614.
+ * 
+ * @author Jan S. Rellermeyer, ETH Zürich
+ */
+public final class ServiceURL extends AuthenticatedServiceURL {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 9181946114021582389L;
+
+	/**
+	 * 
+	 */
+	public static final int NO_PORT = 0;
+
+	/**
+	 * 
+	 */
+	public static final int LIFETIME_NONE = 0;
+
+	/**
+	 * 
+	 */
+	public static final int LIFETIME_DEFAULT = 10800;
+
+	/**
+	 * 
+	 */
+	public static final int LIFETIME_MAXIMUM = 65535;
+
+	/**
+	 * 
+	 */
+	public static final int LIFETIME_PERMANENT = -1;
+
+	/**
+	 * 
+	 */
+	private String url = null;;
+
+	/**
+	 * 
+	 */
+	private int lifetime = 0;
+
+	/**
+	 * 
+	 */
+	private ServiceType type = null;
+
+	/**
+	 * 
+	 */
+	private String host = null;
+
+	/**
+	 * 
+	 */
+	private String protocol = null;
+
+	/**
+	 * 
+	 */
+	private int port = 0;
+
+	/**
+	 * 
+	 */
+	private String path = null;
+
+	/**
+	 * 
+	 * 
+	 */
+	private ServiceURL() {
+	}
+
+	/**
+	 * create a new ServiceURL instance from a String.
+	 * 
+	 * @param serviceURL
+	 *            the string representation of a ServiceURL like
+	 * 
+	 * <pre>
+	 *                 service::&quot;serviceType&quot;://&quot;addrspec&quot;
+	 * </pre>
+	 * 
+	 * where servicetype should be of the form abstractType:concreteType and
+	 * addrspec is the hostname or dotted decimal notation of the host's address
+	 * followed by an optional :portNumber. Example:
+	 * 
+	 * <pre>
+	 *                     service:osgi:remote://my.host.ch:9200
+	 * </pre>
+	 * 
+	 * @param lifeTime
+	 *            the lifetime of the ServiceURL in seconds.
+	 * @throws ServiceLocationException
+	 *             if the String is not parsable.
+	 */
+	public ServiceURL(final String serviceURL, final int lifeTime)
+			throws ServiceLocationException {
+		url = serviceURL;
+		lifetime = lifeTime;
+
+		try {
+			parse();
+		} catch (Exception ex) {
+			throw new ServiceLocationException(
+					ServiceLocationException.PARSE_ERROR,
+					"service url is malformed: [" + url + "]. ");
+		}
+	}
+
+	/**
+	 * parse the url string.
+	 * 
+	 */
+	private void parse() {
+		int pos1 = url.indexOf("://");
+		type = new ServiceType(url.substring(0, pos1++));
+
+		int pos2 = url.indexOf("://", pos1 + 1);
+		if (pos2 > -1) {
+			protocol = url.substring(pos1 + 2, pos2);
+			pos1 = pos2 + 1;
+		}
+
+		int hostEnd = url.indexOf(":", pos1 + 2);
+
+		int pathStart;
+		if (hostEnd == -1) {
+			port = NO_PORT;
+			pathStart = hostEnd = url.indexOf("/", pos1 + 2);
+		} else {
+			pathStart = url.indexOf("/", hostEnd + 1);
+			if (pathStart == -1) {
+				port = Integer.parseInt(url.substring(hostEnd + 1));
+			} else {
+				port = Integer.parseInt(url.substring(hostEnd + 1, pathStart));
+			}
+		}
+
+		if (hostEnd == -1) {
+			host = url.substring(pos1 + 2);
+		} else {
+			host = url.substring(pos1 + 2, hostEnd);
+		}
+
+		if (pathStart == -1) {
+			path = "";
+		} else {
+			path = url.substring(pathStart);
+		}
+	}
+
+	/**
+	 * Check if two instances are equal.
+	 * 
+	 * @inheritDoc java.lang.Object.equals(Object)
+	 * @param obj
+	 *            the object to compare to.
+	 * @return true if the instances are equal.
+	 */
+	public boolean equals(final Object obj) {
+		if (obj instanceof ServiceURL) {
+			final ServiceURL u = (ServiceURL) obj;
+			return (type.equals(u.type)
+					&& host.equals(u.host)
+					&& port == u.port
+					&& ((protocol == null && u.protocol == null) || protocol
+							.equals(u.protocol)) && path.equals(u.path));
+		}
+		return false;
+	}
+
+	/**
+	 * Check if a ServiceURL matches another ServiceURL or a ServiceType. In the
+	 * first case, the method performs an equality check with equals(Object
+	 * obj), for ServiceTypes, the ServiceType part of the ServiceURL is checked
+	 * against the given ServiceType.
+	 * 
+	 * @param obj
+	 *            a ServiceURL or ServiceType. All other objects will return
+	 *            false.
+	 * @return true if the match succeeds.
+	 */
+	public boolean matches(final Object obj) {
+		if (obj instanceof ServiceURL) {
+			return equals(obj);
+		} else if (obj instanceof ServiceType) {
+			return type.matches(obj);
+		}
+		return false;
+	}
+
+	/**
+	 * get a String representation of the ServiceURL.
+	 * 
+	 * @return the String representation.
+	 */
+	public String toString() {
+		return type.toString() + "://"
+				+ (protocol != null ? protocol + "://" : "") + host
+				+ (port != NO_PORT ? (":" + port) : "") + path;
+	}
+
+	/**
+	 * get the hashCode of the ServiceURL instance.
+	 * 
+	 * @return the hashCode.
+	 */
+	public int hashCode() {
+		return url.hashCode();
+	}
+
+	/**
+	 * get the service type.
+	 * 
+	 * @return the service type.
+	 */
+	public ServiceType getServiceType() {
+		return type;
+	}
+
+	/**
+	 * get the transport method.
+	 * 
+	 * @return the transport method. IP returns empty string.
+	 * @deprecated
+	 */
+	public String getTransport() {
+		return "";
+	}
+
+	/**
+	 * get the protocol.
+	 * 
+	 * @return the protocol, if specified. Otherwise, returns null.
+	 */
+	public String getProtocol() {
+		return protocol;
+	}
+
+	/**
+	 * get the host.
+	 * 
+	 * @return the host.
+	 */
+	public String getHost() {
+		return host;
+	}
+
+	/**
+	 * get the port.
+	 * 
+	 * @return the port.
+	 */
+	public int getPort() {
+		return port;
+	}
+
+	/**
+	 * get the URL path.
+	 * 
+	 * @return the URL path.
+	 */
+	public String getURLPath() {
+		return path;
+	}
+
+	/**
+	 * get the lifetime.
+	 * 
+	 * @return the lifetime.
+	 */
+	public int getLifetime() {
+		return lifetime;
+	}
+
+	/**
+	 * get the byte representation of the ServiceURL instance.
+	 * 
+	 * @throws IOException
+	 * @throws IOException
+	 *             if an internal processing error occurs.
+	 */
+	public void writeTo(DataOutputStream out) throws IOException {
+		out.write(0);
+		out.writeShort((short) lifetime);
+		out.writeUTF(toString());
+		// writeAuthBlock(out);
+	}
+
+	public int getLength() {
+		return 1 + 2 + 2 + toString().length(); // + getAuthBlockLength();
+	}
+}

Added: directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/impl/AuthenticatedServiceURL.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/impl/AuthenticatedServiceURL.java?rev=619239&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/impl/AuthenticatedServiceURL.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/impl/AuthenticatedServiceURL.java Wed Feb  6 17:51:14 2008
@@ -0,0 +1,204 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.slp.impl;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.apache.directory.server.slp.ServiceLocationException;
+
+/**
+ * Authentication support for service URLs.
+ * 
+ * @author Jan S. Rellermeyer, ETH Zurich
+ */
+public class AuthenticatedServiceURL {
+
+	/**
+	 * the authentication blocks.
+	 */
+	private AuthenticationBlock[] authBlocks;
+
+	/**
+	 * set the authentication blocks.
+	 * 
+	 * @param authBlocks
+	 *            the authentication blocks.
+	 */
+	public void setAuthBlocks(final AuthenticationBlock[] authBlocks) {
+		this.authBlocks = authBlocks;
+	}
+
+	public AuthenticationBlock[] getAuthBlocks() {
+		return authBlocks;
+	}
+
+	public void verify() throws ServiceLocationException {
+		if (authBlocks.length == 0) {
+			return;
+		}
+		for (int i = 0; i < authBlocks.length; i++) {
+			byte[] data = getAuthData(authBlocks[i].getSpi(), authBlocks[i]
+					.getTimestamp());
+			if (authBlocks[i].verify(data)) {
+				return;
+			}
+		}
+		// TODO: improve
+		throw new ServiceLocationException(
+				ServiceLocationException.AUTHENTICATION_FAILED, "");
+	}
+
+	/**
+	 * get the byte representation of the authentication data.
+	 * 
+	 * @param spi
+	 *            the SPI string as defined in RFC 2608
+	 * @param timestamp
+	 *            a timestamp as defined in RFC 2608
+	 * @return a byte array.
+	 * @throws ServiceLocationException
+	 *             in case of internal errors.
+	 */
+	private byte[] getAuthData(final String spi, final int timestamp)
+			throws ServiceLocationException {
+		try {
+			final ByteArrayOutputStream bos = new ByteArrayOutputStream();
+			final DataOutputStream dos = new DataOutputStream(bos);
+
+			byte[] temp = spi.getBytes();
+			dos.writeShort(temp.length);
+			dos.write(temp);
+			temp = toString().getBytes();
+			dos.writeShort(temp.length);
+			dos.write(temp);
+			dos.writeInt(timestamp);
+			return bos.toByteArray();
+		} catch (IOException ioe) {
+			throw new ServiceLocationException(
+					ServiceLocationException.INTERNAL_SYSTEM_ERROR, ioe
+							.getMessage());
+		}
+	}
+
+}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.slp.impl;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.apache.directory.server.slp.ServiceLocationException;
+
+/**
+ * Authentication support for service URLs.
+ * 
+ * @author Jan S. Rellermeyer, ETH Zurich
+ */
+public class AuthenticatedServiceURL {
+
+	/**
+	 * the authentication blocks.
+	 */
+	private AuthenticationBlock[] authBlocks;
+
+	/**
+	 * set the authentication blocks.
+	 * 
+	 * @param authBlocks
+	 *            the authentication blocks.
+	 */
+	public void setAuthBlocks(final AuthenticationBlock[] authBlocks) {
+		this.authBlocks = authBlocks;
+	}
+
+	public AuthenticationBlock[] getAuthBlocks() {
+		return authBlocks;
+	}
+
+	public void verify() throws ServiceLocationException {
+		if (authBlocks.length == 0) {
+			return;
+		}
+		for (int i = 0; i < authBlocks.length; i++) {
+			byte[] data = getAuthData(authBlocks[i].getSpi(), authBlocks[i]
+					.getTimestamp());
+			if (authBlocks[i].verify(data)) {
+				return;
+			}
+		}
+		// TODO: improve
+		throw new ServiceLocationException(
+				ServiceLocationException.AUTHENTICATION_FAILED, "");
+	}
+
+	/**
+	 * get the byte representation of the authentication data.
+	 * 
+	 * @param spi
+	 *            the SPI string as defined in RFC 2608
+	 * @param timestamp
+	 *            a timestamp as defined in RFC 2608
+	 * @return a byte array.
+	 * @throws ServiceLocationException
+	 *             in case of internal errors.
+	 */
+	private byte[] getAuthData(final String spi, final int timestamp)
+			throws ServiceLocationException {
+		try {
+			final ByteArrayOutputStream bos = new ByteArrayOutputStream();
+			final DataOutputStream dos = new DataOutputStream(bos);
+
+			byte[] temp = spi.getBytes();
+			dos.writeShort(temp.length);
+			dos.write(temp);
+			temp = toString().getBytes();
+			dos.writeShort(temp.length);
+			dos.write(temp);
+			dos.writeInt(timestamp);
+			return bos.toByteArray();
+		} catch (IOException ioe) {
+			throw new ServiceLocationException(
+					ServiceLocationException.INTERNAL_SYSTEM_ERROR, ioe
+							.getMessage());
+		}
+	}
+
+}

Added: directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/impl/AuthenticationBlock.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/impl/AuthenticationBlock.java?rev=619239&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/impl/AuthenticationBlock.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/impl/AuthenticationBlock.java Wed Feb  6 17:51:14 2008
@@ -0,0 +1,144 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.slp.impl;
+
+/**
+ * Authentication block.
+ * 
+ * @author Jan S. Rellermeyer, ETH Zurich
+ * 
+ */
+public class AuthenticationBlock {
+
+	/**
+	 * the BSD code for DSA.
+	 */
+	public static final short BSD_DSA = 0x0002;
+
+	/**
+	 * the timestamp.
+	 */
+	private int timestamp;
+
+	/**
+	 * the signature.
+	 */
+	private byte[] sig = null;
+
+	/**
+	 * the SPI.
+	 */
+	private String spi = null;
+
+	public AuthenticationBlock(final int timestamp, final String spi,
+			final byte[] sig) {
+		this.timestamp = timestamp;
+		this.spi = spi;
+		this.sig = sig;
+	}
+
+	public int getTimestamp() {
+		return timestamp;
+	}
+
+	public String getSpi() {
+		return spi;
+	}
+
+	public boolean verify(byte[] data2) {
+		return false;
+	}
+
+	public byte[] getSig() {
+		return sig;
+	}
+}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.slp.impl;
+
+/**
+ * Authentication block.
+ * 
+ * @author Jan S. Rellermeyer, ETH Zurich
+ * 
+ */
+public class AuthenticationBlock {
+
+	/**
+	 * the BSD code for DSA.
+	 */
+	public static final short BSD_DSA = 0x0002;
+
+	/**
+	 * the timestamp.
+	 */
+	private int timestamp;
+
+	/**
+	 * the signature.
+	 */
+	private byte[] sig = null;
+
+	/**
+	 * the SPI.
+	 */
+	private String spi = null;
+
+	public AuthenticationBlock(final int timestamp, final String spi,
+			final byte[] sig) {
+		this.timestamp = timestamp;
+		this.spi = spi;
+		this.sig = sig;
+	}
+
+	public int getTimestamp() {
+		return timestamp;
+	}
+
+	public String getSpi() {
+		return spi;
+	}
+
+	public boolean verify(byte[] data2) {
+		return false;
+	}
+
+	public byte[] getSig() {
+		return sig;
+	}
+}

Added: directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/AbstractSLPMessage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/AbstractSLPMessage.java?rev=619239&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/AbstractSLPMessage.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/AbstractSLPMessage.java Wed Feb  6 17:51:14 2008
@@ -0,0 +1,196 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.slp.messages;
+
+import java.util.Locale;
+
+/**
+ * abstract base class for all SLP messages.
+ * 
+ * @author Jan S. Rellermeyer, ETH Zurich
+ * 
+ */
+public abstract class AbstractSLPMessage {
+
+	protected static final String[] EMPTY = new String[0];
+
+	protected final byte funcID;
+
+	protected short xid;
+
+	protected boolean multicast;
+
+	protected boolean tcp;
+
+	// TODO: take the default locale here...
+	protected Locale locale = new Locale("en");
+
+	AbstractSLPMessage(final byte funcID) {
+		this.funcID = funcID;
+	}
+
+	public final byte getFuncID() {
+		return funcID;
+	}
+
+	public final short getXid() {
+		return xid;
+	}
+
+	public final void setXid(final short xid) {
+		this.xid = xid;
+	}
+
+	public final boolean isMulticast() {
+		return multicast;
+	}
+
+	public final void setMulticast(final boolean multicast) {
+		this.multicast = multicast;
+	}
+
+	public final boolean isTcp() {
+		return tcp;
+	}
+
+	public final void setTcp(final boolean tcp) {
+		this.tcp = tcp;
+	}
+
+	public final Locale getLocale() {
+		return locale;
+	}
+
+	public final void setLocale(final Locale locale) {
+		if (locale != null) {
+			this.locale = locale;
+		} else {
+			// TODO: set default
+		}
+	}
+
+	public String getHeaderString() {
+		final StringBuffer buffer = new StringBuffer();
+		buffer.append("xid=" + xid);
+		buffer.append(", locale=" + locale);
+		return buffer.toString();
+	}
+
+	public abstract String toString();
+
+}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.slp.messages;
+
+import java.util.Locale;
+
+/**
+ * abstract base class for all SLP messages.
+ * 
+ * @author Jan S. Rellermeyer, ETH Zurich
+ * 
+ */
+public abstract class AbstractSLPMessage {
+
+	protected static final String[] EMPTY = new String[0];
+
+	protected final byte funcID;
+
+	protected short xid;
+
+	protected boolean multicast;
+
+	protected boolean tcp;
+
+	// TODO: take the default locale here...
+	protected Locale locale = new Locale("en");
+
+	AbstractSLPMessage(final byte funcID) {
+		this.funcID = funcID;
+	}
+
+	public final byte getFuncID() {
+		return funcID;
+	}
+
+	public final short getXid() {
+		return xid;
+	}
+
+	public final void setXid(final short xid) {
+		this.xid = xid;
+	}
+
+	public final boolean isMulticast() {
+		return multicast;
+	}
+
+	public final void setMulticast(final boolean multicast) {
+		this.multicast = multicast;
+	}
+
+	public final boolean isTcp() {
+		return tcp;
+	}
+
+	public final void setTcp(final boolean tcp) {
+		this.tcp = tcp;
+	}
+
+	public final Locale getLocale() {
+		return locale;
+	}
+
+	public final void setLocale(final Locale locale) {
+		if (locale != null) {
+			this.locale = locale;
+		} else {
+			// TODO: set default
+		}
+	}
+
+	public String getHeaderString() {
+		final StringBuffer buffer = new StringBuffer();
+		buffer.append("xid=" + xid);
+		buffer.append(", locale=" + locale);
+		return buffer.toString();
+	}
+
+	public abstract String toString();
+
+}

Added: directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/AbstractSLPReplyMessage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/AbstractSLPReplyMessage.java?rev=619239&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/AbstractSLPReplyMessage.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/AbstractSLPReplyMessage.java Wed Feb  6 17:51:14 2008
@@ -0,0 +1,108 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.slp.messages;
+
+/**
+ * abstract base class for all ReplyMessages.
+ * 
+ * @author Jan S. Rellermeyer, ETH Zürich
+ */
+public abstract class AbstractSLPReplyMessage extends AbstractSLPMessage {
+
+	/**
+	 * the error code that is returned.
+	 */
+	private short errorCode;
+
+	AbstractSLPReplyMessage(byte funcID) {
+		super(funcID);
+	}
+
+	public void setErrorCode(final short errorCode) {
+		this.errorCode = errorCode;
+	}
+
+	public short getErrorCode() {
+		return errorCode;
+	}
+
+	public final String getHeaderString() {
+		final StringBuffer buffer = new StringBuffer();
+		buffer.append(super.getHeaderString());
+		buffer.append(", errorCode=");
+		buffer.append(errorCode);
+		return buffer.toString();
+	}
+
+}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.slp.messages;
+
+/**
+ * abstract base class for all ReplyMessages.
+ * 
+ * @author Jan S. Rellermeyer, ETH Zürich
+ */
+public abstract class AbstractSLPReplyMessage extends AbstractSLPMessage {
+
+	/**
+	 * the error code that is returned.
+	 */
+	private short errorCode;
+
+	AbstractSLPReplyMessage(byte funcID) {
+		super(funcID);
+	}
+
+	public void setErrorCode(final short errorCode) {
+		this.errorCode = errorCode;
+	}
+
+	public short getErrorCode() {
+		return errorCode;
+	}
+
+	public final String getHeaderString() {
+		final StringBuffer buffer = new StringBuffer();
+		buffer.append(super.getHeaderString());
+		buffer.append(", errorCode=");
+		buffer.append(errorCode);
+		return buffer.toString();
+	}
+
+}

Added: directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/AbstractSLPRequestMessage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/AbstractSLPRequestMessage.java?rev=619239&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/AbstractSLPRequestMessage.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/AbstractSLPRequestMessage.java Wed Feb  6 17:51:14 2008
@@ -0,0 +1,148 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.slp.messages;
+
+import java.util.Arrays;
+
+/**
+ * Abstract base class for all request messages.
+ * 
+ * @author Jan S. Rellermeyer, ETH Zürich
+ */
+public abstract class AbstractSLPRequestMessage extends AbstractSLPMessage {
+
+	/**
+	 * the list of previous responders. If a peer receives a request message and
+	 * is already in the previous responder list, it will silently drop the
+	 * message.
+	 */
+	protected String[] prevResponders = EMPTY;
+
+	/**
+	 * a list of scopes that will be included.
+	 */
+	protected String[] scopes = new String[] { "default" };
+
+	AbstractSLPRequestMessage(byte funcID) {
+		super(funcID);
+	}
+
+	public final void setPrevResponders(final String[] responders) {
+		this.prevResponders = responders;
+	}
+
+	public final String[] getPrevResponders() {
+		return prevResponders;
+	}
+
+	public final void setScopes(final String[] scopes) {
+		if (scopes != null) {
+			this.scopes = scopes;
+		}
+	}
+
+	public final String[] getScopes() {
+		return scopes;
+	}
+
+	public final String getHeaderString() {
+		final StringBuffer buffer = new StringBuffer();
+		buffer.append(super.getHeaderString());
+		buffer.append(", prevResponders=");
+		buffer.append(Arrays.asList(prevResponders));
+		buffer.append(", scopes=");
+		buffer.append(Arrays.asList(scopes));
+		return buffer.toString();
+	}
+}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.slp.messages;
+
+import java.util.Arrays;
+
+/**
+ * Abstract base class for all request messages.
+ * 
+ * @author Jan S. Rellermeyer, ETH Zürich
+ */
+public abstract class AbstractSLPRequestMessage extends AbstractSLPMessage {
+
+	/**
+	 * the list of previous responders. If a peer receives a request message and
+	 * is already in the previous responder list, it will silently drop the
+	 * message.
+	 */
+	protected String[] prevResponders = EMPTY;
+
+	/**
+	 * a list of scopes that will be included.
+	 */
+	protected String[] scopes = new String[] { "default" };
+
+	AbstractSLPRequestMessage(byte funcID) {
+		super(funcID);
+	}
+
+	public final void setPrevResponders(final String[] responders) {
+		this.prevResponders = responders;
+	}
+
+	public final String[] getPrevResponders() {
+		return prevResponders;
+	}
+
+	public final void setScopes(final String[] scopes) {
+		if (scopes != null) {
+			this.scopes = scopes;
+		}
+	}
+
+	public final String[] getScopes() {
+		return scopes;
+	}
+
+	public final String getHeaderString() {
+		final StringBuffer buffer = new StringBuffer();
+		buffer.append(super.getHeaderString());
+		buffer.append(", prevResponders=");
+		buffer.append(Arrays.asList(prevResponders));
+		buffer.append(", scopes=");
+		buffer.append(Arrays.asList(scopes));
+		return buffer.toString();
+	}
+}

Added: directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/AttributeReplyMessage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/AttributeReplyMessage.java?rev=619239&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/AttributeReplyMessage.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/AttributeReplyMessage.java Wed Feb  6 17:51:14 2008
@@ -0,0 +1,160 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.slp.messages;
+
+import java.util.Arrays;
+import org.apache.directory.server.slp.impl.AuthenticationBlock;
+
+/**
+ * abstract base class for all reply messages.
+ * 
+ * @author Jan S. Rellermeyer, ETH Zurich
+ * 
+ */
+public final class AttributeReplyMessage extends AbstractSLPReplyMessage {
+
+	/**
+	 * the message funcID values according to RFC 2608, Attribute Reply = 7.
+	 */
+	public static final byte FUNC_ID = 7;
+
+	public static final String TYPE = "ATTRRPLY";
+
+	private String[] attributes;
+
+	private AuthenticationBlock[] authBlocks;
+
+	public AttributeReplyMessage() {
+		super(FUNC_ID);
+	}
+
+	public void setAttributes(final String[] attributes) {
+		this.attributes = attributes;
+	}
+
+	public String[] getAttributes() {
+		return attributes;
+	}
+
+	public void setAuthBlocks(final AuthenticationBlock[] authBlocks) {
+		this.authBlocks = authBlocks;
+	}
+
+	public AuthenticationBlock[] getAuthBlocks() {
+		return authBlocks;
+	}
+
+	public void verify() {
+		// TODO Auto-generated method stub
+
+	}
+
+	public String toString() {
+		StringBuffer buffer = new StringBuffer();
+		buffer.append(TYPE);
+		buffer.append(" [");
+		buffer.append(getHeaderString());
+		buffer.append(", attrCount=" + attributes.length);
+		buffer.append(", attributes=" + Arrays.asList(attributes));
+		buffer.append("]");
+		return buffer.toString();
+	}
+
+}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.slp.messages;
+
+import java.util.Arrays;
+import org.apache.directory.server.slp.impl.AuthenticationBlock;
+
+/**
+ * abstract base class for all reply messages.
+ * 
+ * @author Jan S. Rellermeyer, ETH Zurich
+ * 
+ */
+public final class AttributeReplyMessage extends AbstractSLPReplyMessage {
+
+	/**
+	 * the message funcID values according to RFC 2608, Attribute Reply = 7.
+	 */
+	public static final byte FUNC_ID = 7;
+
+	public static final String TYPE = "ATTRRPLY";
+
+	private String[] attributes;
+
+	private AuthenticationBlock[] authBlocks;
+
+	public AttributeReplyMessage() {
+		super(FUNC_ID);
+	}
+
+	public void setAttributes(final String[] attributes) {
+		this.attributes = attributes;
+	}
+
+	public String[] getAttributes() {
+		return attributes;
+	}
+
+	public void setAuthBlocks(final AuthenticationBlock[] authBlocks) {
+		this.authBlocks = authBlocks;
+	}
+
+	public AuthenticationBlock[] getAuthBlocks() {
+		return authBlocks;
+	}
+
+	public void verify() {
+		// TODO Auto-generated method stub
+
+	}
+
+	public String toString() {
+		StringBuffer buffer = new StringBuffer();
+		buffer.append(TYPE);
+		buffer.append(" [");
+		buffer.append(getHeaderString());
+		buffer.append(", attrCount=" + attributes.length);
+		buffer.append(", attributes=" + Arrays.asList(attributes));
+		buffer.append("]");
+		return buffer.toString();
+	}
+
+}

Added: directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/AttributeRequestMessage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/AttributeRequestMessage.java?rev=619239&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/AttributeRequestMessage.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/AttributeRequestMessage.java Wed Feb  6 17:51:14 2008
@@ -0,0 +1,174 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.slp.messages;
+
+import java.util.Arrays;
+
+import org.apache.directory.server.slp.ServiceURL;
+
+/**
+ * Attribute request message (ATTRRQST).
+ * 
+ * @author Jan S. Rellermeyer, ETH Zurich
+ * 
+ */
+public final class AttributeRequestMessage extends AbstractSLPRequestMessage {
+
+	/**
+	 * the message funcID values according to RFC 2608, Attribute Request = 6.
+	 */
+	public static final byte FUNC_ID = 6;
+
+	public static final String TYPE = "ATTRRQST";
+
+	private ServiceURL url;
+
+	private String[] tags = EMPTY;
+
+	private String[] spis = EMPTY;
+
+	public AttributeRequestMessage() {
+		super(FUNC_ID);
+	}
+
+	public void setServiceURL(final ServiceURL url) {
+		this.url = url;
+	}
+
+	public ServiceURL getServiceUrl() {
+		return url;
+	}
+
+	public void setTags(final String[] tags) {
+		this.tags = tags;
+	}
+
+	public String[] getTags() {
+		return tags;
+	}
+
+	public void setSpis(final String[] spis) {
+		this.spis = spis;
+	}
+
+	public String[] getSpis() {
+		return spis;
+	}
+
+	public String toString() {
+		StringBuffer buffer = new StringBuffer();
+		buffer.append(TYPE);
+		buffer.append(" [");
+		buffer.append(getHeaderString());
+		buffer.append(", url=" + url);
+		buffer.append(", tags=" + Arrays.asList(tags));
+		buffer.append(", spis=" + Arrays.asList(spis));
+		buffer.append("]");
+		return buffer.toString();
+	}
+
+}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.slp.messages;
+
+import java.util.Arrays;
+
+import org.apache.directory.server.slp.ServiceURL;
+
+/**
+ * Attribute request message (ATTRRQST).
+ * 
+ * @author Jan S. Rellermeyer, ETH Zurich
+ * 
+ */
+public final class AttributeRequestMessage extends AbstractSLPRequestMessage {
+
+	/**
+	 * the message funcID values according to RFC 2608, Attribute Request = 6.
+	 */
+	public static final byte FUNC_ID = 6;
+
+	public static final String TYPE = "ATTRRQST";
+
+	private ServiceURL url;
+
+	private String[] tags = EMPTY;
+
+	private String[] spis = EMPTY;
+
+	public AttributeRequestMessage() {
+		super(FUNC_ID);
+	}
+
+	public void setServiceURL(final ServiceURL url) {
+		this.url = url;
+	}
+
+	public ServiceURL getServiceUrl() {
+		return url;
+	}
+
+	public void setTags(final String[] tags) {
+		this.tags = tags;
+	}
+
+	public String[] getTags() {
+		return tags;
+	}
+
+	public void setSpis(final String[] spis) {
+		this.spis = spis;
+	}
+
+	public String[] getSpis() {
+		return spis;
+	}
+
+	public String toString() {
+		StringBuffer buffer = new StringBuffer();
+		buffer.append(TYPE);
+		buffer.append(" [");
+		buffer.append(getHeaderString());
+		buffer.append(", url=" + url);
+		buffer.append(", tags=" + Arrays.asList(tags));
+		buffer.append(", spis=" + Arrays.asList(spis));
+		buffer.append("]");
+		return buffer.toString();
+	}
+
+}

Added: directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/DAAdvertisementMessage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/DAAdvertisementMessage.java?rev=619239&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/DAAdvertisementMessage.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/DAAdvertisementMessage.java Wed Feb  6 17:51:14 2008
@@ -0,0 +1,242 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.slp.messages;
+
+import java.util.Arrays;
+import org.apache.directory.server.slp.ServiceURL;
+import org.apache.directory.server.slp.impl.AuthenticationBlock;
+
+/**
+ * Directory Agent Advertisement Message (DAADVERT).
+ * 
+ * @author Jan S. Rellermeyer, ETH Zurich
+ * 
+ */
+public class DAAdvertisementMessage extends AbstractSLPReplyMessage {
+
+	/**
+	 * the message funcID values according to RFC 2608, DA Advertisement = 8.
+	 */
+	public static final byte FUNC_ID = 8;
+
+	public static final String TYPE = "DAADVERT";
+
+	private int bootTimestamp;
+
+	private ServiceURL serviceURL;
+
+	private String[] scopes = EMPTY;
+
+	private String[] attributes = EMPTY;
+
+	private String[] spis = EMPTY;
+
+	private AuthenticationBlock[] authBlocks = new AuthenticationBlock[0];
+
+	public DAAdvertisementMessage() {
+		super(FUNC_ID);
+	}
+
+	public void setStatelessBootTimestamp(int bootTimestamp) {
+		this.bootTimestamp = bootTimestamp;
+	}
+
+	public int getStatelessBootTimestamp() {
+		return bootTimestamp;
+	}
+
+	public void setServiceURL(ServiceURL serviceURL) {
+		this.serviceURL = serviceURL;
+	}
+
+	public ServiceURL getServiceURL() {
+		return serviceURL;
+	}
+
+	public void setScopes(String[] scopes) {
+		this.scopes = scopes;
+	}
+
+	public String[] getScopes() {
+		return scopes;
+	}
+
+	public void setAttributes(String[] attributes) {
+		this.attributes = attributes;
+	}
+
+	public String[] getAttributes() {
+		return attributes;
+	}
+
+	public void setSPIs(String[] spis) {
+		this.spis = spis;
+	}
+
+	public String[] getSPIs() {
+		return spis;
+	}
+
+	public void setAuthBlocks(AuthenticationBlock[] authBlocks) {
+		this.authBlocks = authBlocks;
+	}
+
+	public AuthenticationBlock[] getAuthBlocks() {
+		return authBlocks;
+	}
+
+	public String toString() {
+		StringBuffer buffer = new StringBuffer();
+		buffer.append(TYPE);
+		buffer.append(" [");
+		buffer.append(getHeaderString());
+		buffer.append(", url=" + serviceURL);
+		buffer.append(", scopes=");
+		buffer.append(Arrays.asList(scopes));
+		buffer.append(", attributes=");
+		buffer.append(Arrays.asList(attributes));
+		buffer.append(", spis=");
+		buffer.append(Arrays.asList(spis));
+		buffer.append("]");
+		return buffer.toString();
+	}
+
+}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.slp.messages;
+
+import java.util.Arrays;
+import org.apache.directory.server.slp.ServiceURL;
+import org.apache.directory.server.slp.impl.AuthenticationBlock;
+
+/**
+ * Directory Agent Advertisement Message (DAADVERT).
+ * 
+ * @author Jan S. Rellermeyer, ETH Zurich
+ * 
+ */
+public class DAAdvertisementMessage extends AbstractSLPReplyMessage {
+
+	/**
+	 * the message funcID values according to RFC 2608, DA Advertisement = 8.
+	 */
+	public static final byte FUNC_ID = 8;
+
+	public static final String TYPE = "DAADVERT";
+
+	private int bootTimestamp;
+
+	private ServiceURL serviceURL;
+
+	private String[] scopes = EMPTY;
+
+	private String[] attributes = EMPTY;
+
+	private String[] spis = EMPTY;
+
+	private AuthenticationBlock[] authBlocks = new AuthenticationBlock[0];
+
+	public DAAdvertisementMessage() {
+		super(FUNC_ID);
+	}
+
+	public void setStatelessBootTimestamp(int bootTimestamp) {
+		this.bootTimestamp = bootTimestamp;
+	}
+
+	public int getStatelessBootTimestamp() {
+		return bootTimestamp;
+	}
+
+	public void setServiceURL(ServiceURL serviceURL) {
+		this.serviceURL = serviceURL;
+	}
+
+	public ServiceURL getServiceURL() {
+		return serviceURL;
+	}
+
+	public void setScopes(String[] scopes) {
+		this.scopes = scopes;
+	}
+
+	public String[] getScopes() {
+		return scopes;
+	}
+
+	public void setAttributes(String[] attributes) {
+		this.attributes = attributes;
+	}
+
+	public String[] getAttributes() {
+		return attributes;
+	}
+
+	public void setSPIs(String[] spis) {
+		this.spis = spis;
+	}
+
+	public String[] getSPIs() {
+		return spis;
+	}
+
+	public void setAuthBlocks(AuthenticationBlock[] authBlocks) {
+		this.authBlocks = authBlocks;
+	}
+
+	public AuthenticationBlock[] getAuthBlocks() {
+		return authBlocks;
+	}
+
+	public String toString() {
+		StringBuffer buffer = new StringBuffer();
+		buffer.append(TYPE);
+		buffer.append(" [");
+		buffer.append(getHeaderString());
+		buffer.append(", url=" + serviceURL);
+		buffer.append(", scopes=");
+		buffer.append(Arrays.asList(scopes));
+		buffer.append(", attributes=");
+		buffer.append(Arrays.asList(attributes));
+		buffer.append(", spis=");
+		buffer.append(Arrays.asList(spis));
+		buffer.append("]");
+		return buffer.toString();
+	}
+
+}

Added: directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/ServiceAcknowledgementMessage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/ServiceAcknowledgementMessage.java?rev=619239&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/ServiceAcknowledgementMessage.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/server/slp/messages/ServiceAcknowledgementMessage.java Wed Feb  6 17:51:14 2008
@@ -0,0 +1,104 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.slp.messages;
+
+/**
+ * Service Acknowledgement Message (SRVACK).
+ * 
+ * @author Jan S. Rellermeyer, ETH Zurich
+ * 
+ */
+public class ServiceAcknowledgementMessage extends AbstractSLPReplyMessage {
+
+	/**
+	 * the message funcID values according to RFC 2608, Service Acknowledgement =
+	 * 5.
+	 */
+	public static final byte FUNC_ID = 5;
+
+	public static final String TYPE = "SRVACK";
+
+	public ServiceAcknowledgementMessage() {
+		super(FUNC_ID);
+	}
+
+	public String toString() {
+		StringBuffer buffer = new StringBuffer();
+		buffer.append(TYPE);
+		buffer.append(" [");
+		buffer.append(getHeaderString());
+		buffer.append(", errorCode=" + getErrorCode());
+		buffer.append("]");
+		return buffer.toString();
+	}
+
+}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.slp.messages;
+
+/**
+ * Service Acknowledgement Message (SRVACK).
+ * 
+ * @author Jan S. Rellermeyer, ETH Zurich
+ * 
+ */
+public class ServiceAcknowledgementMessage extends AbstractSLPReplyMessage {
+
+	/**
+	 * the message funcID values according to RFC 2608, Service Acknowledgement =
+	 * 5.
+	 */
+	public static final byte FUNC_ID = 5;
+
+	public static final String TYPE = "SRVACK";
+
+	public ServiceAcknowledgementMessage() {
+		super(FUNC_ID);
+	}
+
+	public String toString() {
+		StringBuffer buffer = new StringBuffer();
+		buffer.append(TYPE);
+		buffer.append(" [");
+		buffer.append(getHeaderString());
+		buffer.append(", errorCode=" + getErrorCode());
+		buffer.append("]");
+		return buffer.toString();
+	}
+
+}



Mime
View raw message