You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by rj...@apache.org on 2009/06/09 14:00:32 UTC
svn commit: r782968 [1/7] - in /directory/sandbox/slp: ./
src/main/java/org/apache/directory/slp/
src/main/java/org/apache/directory/slp/codec/
src/main/java/org/apache/directory/slp/extensions/
src/main/java/org/apache/directory/slp/impl/ src/main/jav...
Author: rjan
Date: Tue Jun 9 12:00:29 2009
New Revision: 782968
URL: http://svn.apache.org/viewvc?rev=782968&view=rev
Log:
checkin of the new version developed by me and my student Lorenz Breu.
Added:
directory/sandbox/slp/src/main/java/org/apache/directory/slp/
directory/sandbox/slp/src/main/java/org/apache/directory/slp/Advertiser.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/AttributeReplyFuture.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/AuthenticatedServiceURL.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/DirectoryAgent.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/Locator.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/OpaqueValue.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/ReplyFuture.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/SLPAttribute.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/Service.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceLocationEnumeration.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceLocationException.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceReplyFuture.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceStore.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceType.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceURL.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/
directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/AbstractSLPMessageCodec.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/AttributeReplyMessageCodec.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/AttributeRequestMessageCodec.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/DAAdvertisementMessageCodec.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/SLPProtocolCodecFactory.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceAcknowledgementMessageCodec.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceDeregistrationMessageCodec.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceRegistrationMessageCodec.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceReplyMessageCodec.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceRequestMessageCodec.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceTypeReplyMessageCodec.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceTypeRequestMessageCodec.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/
directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/AbstractExtension.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/AttributeListExtension.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/SelectExtension.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/SortExtension.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/UnsupportedExtension.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/Activator.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/AdvertiserImpl.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/AttributeReplyFutureImpl.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/AuthenticatedServiceURL.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/AuthenticationBlock.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/LocatorImpl.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/NonThreadedReplyFuture.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/OSGiPlatformAbstraction.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/PlatformAbstraction.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/SLPAttributeImpl.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/SLPConfiguration.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/SLPCore.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/SLPDaemon.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/SLPDaemonImpl.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/SLPHandler.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/SLPUtils.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/ServiceLocationEnumerationImpl.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/ServiceReplyFutureImpl.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/ThreadedReplyFuture.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/da/
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/da/DirectoryAgentDaemon.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/da/DirectoryAgentDaemonImpl.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/da/DirectoryAgentImpl.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/da/SimpleServiceStore.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/filter/
directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/filter/Filter.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/messages/
directory/sandbox/slp/src/main/java/org/apache/directory/slp/messages/AbstractSLPMessage.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/messages/AbstractSLPReplyMessage.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/messages/AbstractSLPRequestMessage.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/messages/AttributeReplyMessage.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/messages/AttributeRequestMessage.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/messages/DAAdvertisementMessage.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/messages/ServiceAcknowledgementMessage.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/messages/ServiceDeregistrationMessage.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/messages/ServiceRegistrationMessage.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/messages/ServiceReplyMessage.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/messages/ServiceRequestMessage.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/messages/ServiceTypeReplyMessage.java (with props)
directory/sandbox/slp/src/main/java/org/apache/directory/slp/messages/ServiceTypeRequestMessage.java (with props)
directory/sandbox/slp/src/test/java/org/apache/directory/slp/
directory/sandbox/slp/src/test/java/org/apache/directory/slp/messages/
- copied from r782966, directory/sandbox/slp/src/test/java/org/apache/directory/server/slp/messages/
directory/sandbox/slp/src/test/java/org/apache/directory/slp/messages/MessageTest.java.disabled
- copied, changed from r782966, directory/sandbox/slp/src/test/java/org/apache/directory/server/slp/messages/MessageTest.java
Removed:
directory/sandbox/slp/src/test/java/org/apache/directory/slp/messages/MessageTest.java
Modified:
directory/sandbox/slp/pom.xml
Modified: directory/sandbox/slp/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/pom.xml?rev=782968&r1=782967&r2=782968&view=diff
==============================================================================
--- directory/sandbox/slp/pom.xml (original)
+++ directory/sandbox/slp/pom.xml Tue Jun 9 12:00:29 2009
@@ -36,31 +36,32 @@
<dependencies>
<dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi</artifactId>
+ <version>3.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.mina</groupId>
- <artifactId>mina-core</artifactId>
- <version>1.0.8</version>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ <scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.4.3</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <version>1.4.3</version>
+ <groupId>org.apache.mina</groupId>
+ <artifactId>mina-core</artifactId>
+ <version>2.0.0-RC1-SNAPSHOT</version>
</dependency>
<dependency>
- <groupId>backport-util-concurrent</groupId>
- <artifactId>backport-util-concurrent
- </artifactId>
- <version>3.0</version>
+ <groupId>org.apache.mina</groupId>
+ <artifactId>mina-transport-apr</artifactId>
+ <version>2.0.0-RC1-SNAPSHOT</version>
</dependency>
</dependencies>
Added: directory/sandbox/slp/src/main/java/org/apache/directory/slp/Advertiser.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/Advertiser.java?rev=782968&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/Advertiser.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/Advertiser.java Tue Jun 9 12:00:29 2009
@@ -0,0 +1,169 @@
+/*
+ * 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.slp;
+
+import java.util.Dictionary;
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * Advertiser implements the SA properties of SLP. Services can be registered
+ * and unregistered. The SLP framework handles DA discovery.
+ *
+ * @author Jan S. Rellermeyer
+ */
+public interface Advertiser {
+
+ /**
+ * Returns the locale of this Advertiser instance.
+ *
+ * @return the current Locale.
+ */
+ Locale getLocale();
+
+ /**
+ * Get the locale of this instance.
+ *
+ * @param locale
+ * the Locale.
+ * @see Advertiser#getLocale()
+ */
+ void setLocale(final Locale locale);
+
+ /**
+ * Register a service with the SLP framework. The service will be registered
+ * with all known DAs that support the default scope and with the local SA
+ * registry for multicast discovery.
+ *
+ * @param url
+ * the <code>ServiceURL</code> of the service.
+ * @param attributes
+ * a <code>Dictionary</code> of attributes for the service. RFC
+ * 2614 proposes a <code>Vector</code> of attribute-value-pairs
+ * here but the <code>Dictionary</code> makes this
+ * implementation more close to <code>OSGi</code>.
+ * @throws ServiceLocationException
+ * in case that the registration failed for any reason.
+ */
+ void register(ServiceURL url, Dictionary attributes)
+ throws ServiceLocationException;
+
+ /**
+ * Register a service with the SLP framework. The service will be registered
+ * with all known DAs that support at least one of the given scopes and with
+ * the local SA registry for multicast discovery.
+ *
+ * @param url
+ * the ServiceURL of the service.
+ * @param scopes
+ * a <code>List</code> of scope names as <code>Strings</code>.
+ * @param attributes
+ * a <code>Dictionary</code> of attributes for the service. RFC
+ * 2614 proposes a <code>Vector</code> of attribute-value-pairs
+ * here but the <code>Dictionary</code> makes this
+ * implementation more close to <code>OSGi</code>
+ * @throws ServiceLocationException
+ * in case that the registration failed for any reason.
+ */
+ void register(ServiceURL url, List<String> scopes, Dictionary attributes)
+ throws ServiceLocationException;
+
+
+
+ /**
+ * update an existing registration using scopes.
+ * This will replace all attributes that are already registered and add those that are not.
+ * If security is enabled, this will fail.
+ *
+ * @param url
+ * the ServiceURL of the service.
+ * @param scopes
+ * a List of scopes.
+ * @param attributes
+ * a Dictionary of attributes.
+ * @throws ServiceLocationException
+ * if the registration has failed for any reason.
+ * @see Advertiser#register(ServiceURL, List, Dictionary)
+ */
+ public void update(ServiceURL url, List<String> scopes, Dictionary attributes)
+ throws ServiceLocationException;
+
+
+ /**
+ * Unregister a service with the SLP framework. The service will be
+ * unregistered with all known DAs in the scopes that it was registered in.
+ *
+ * @param url
+ * the <code>ServiceURL</code> of the service.
+ * @throws ServiceLocationException
+ * in case that the deregistration failed for any reason.
+ */
+ void deregister(ServiceURL url) throws ServiceLocationException;
+
+ /**
+ * deregister a service in some scopes.
+ *
+ * @param url
+ * the ServiceURL of the service.
+ * @param scopes
+ * the scopes.
+ * @throws ServiceLocationException
+ * if the deregistration has failed for any reason.
+ * @see Advertiser#deregister(ServiceURL, List)
+ * @since 0.7.1
+ */
+ void deregister(final ServiceURL url, final List<String> scopes)
+ throws ServiceLocationException;
+
+ /**
+ * <b>Not yet implemented.</b> Add attributes to an already registered
+ * service. Allows incremental registration.
+ *
+ * @param url
+ * the <code>ServiceURL</code> of the service.
+ * @param attributes
+ * the attributes to be added.
+ * @throws ServiceLocationException
+ * whenever called.
+ */
+ void addAttributes(ServiceURL url, Dictionary attributes)
+ throws ServiceLocationException;
+
+ /**
+ * <b>Not yet implemented.</b> Remove attributes to an already registered
+ * service. Allows incremental registration.
+ *
+ * @param url
+ * the <code>ServiceURL</code> of the service.
+ * @param attributeIds
+ * the attributes to be removed.
+ * @throws ServiceLocationException
+ * whenever called.
+ */
+ void deleteAttributes(ServiceURL url, Dictionary attributeIds)
+ throws ServiceLocationException;
+
+
+ /**
+ * Shut down the SA (SLPCore remains initialized, but no messages are handled by the SA)
+ */
+ public void shutdown();
+
+}
Propchange: directory/sandbox/slp/src/main/java/org/apache/directory/slp/Advertiser.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: directory/sandbox/slp/src/main/java/org/apache/directory/slp/AttributeReplyFuture.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/AttributeReplyFuture.java?rev=782968&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/AttributeReplyFuture.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/AttributeReplyFuture.java Tue Jun 9 12:00:29 2009
@@ -0,0 +1,49 @@
+/*
+ * 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.slp;
+
+import java.util.List;
+
+/**
+ *
+ * @author Lorenz Breu
+ */
+public interface AttributeReplyFuture extends ReplyFuture{
+
+ /**
+ * Get the contents of the next attribute reply as a List of SLPAttributes, blocks if there are none available at the time
+ *
+ * @return
+ * A List of SLPAttributes.
+ */
+ public SLPAttribute nextAttribute();
+
+
+ /**
+ * Block and get the result of the complete SLP request/reply process as a List of SLPAttributes
+ *
+ * @return
+ * A List of SLPAttributes.
+ */
+ public List<SLPAttribute> getResultAttributes();
+
+
+
+}
Propchange: directory/sandbox/slp/src/main/java/org/apache/directory/slp/AttributeReplyFuture.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: directory/sandbox/slp/src/main/java/org/apache/directory/slp/AuthenticatedServiceURL.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/AuthenticatedServiceURL.java?rev=782968&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/AuthenticatedServiceURL.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/AuthenticatedServiceURL.java Tue Jun 9 12:00:29 2009
@@ -0,0 +1,190 @@
+/* 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.slp;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.directory.slp.ServiceLocationException;
+import org.apache.directory.slp.impl.AuthenticationBlock;
+import org.apache.directory.slp.impl.SLPUtils;
+
+
+/**
+ * Authentication support for service URLs.
+ *
+ * @author Jan S. Rellermeyer
+ */
+public class AuthenticatedServiceURL {
+
+ /**
+ * The lifetime of the ServiceURL i.e., how long authentication remains valid.
+ */
+int lifetime = 0;
+
+ /**
+ * the authentication blocks.
+ */
+ private AuthenticationBlock[] authBlocks;
+
+ /**
+ * set the authentication blocks.
+ *
+ * @param authBlocks
+ * the authentication blocks.
+ */
+ public void setAuthBlocks(final AuthenticationBlock[] authBlocks) {
+ this.authBlocks = authBlocks;
+ }
+
+ /**
+ * Returns the Authentication Blocks of this service url
+ *
+ * @return
+ * array of <code>AuthenticationBlock</code>
+ */
+public AuthenticationBlock[] getAuthBlocks() {
+ return authBlocks;
+ }
+
+
+
+
+ /**
+ * verify the authentication blocks.
+ *
+ * Copied over to the MINA port from the original jSLP implementation, untested
+ */
+ 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());
+ }
+ }
+
+ /**
+ * sign the ServiceURL.
+ *
+ * @param spiList
+ * the List of SPIs
+ * @throws ServiceLocationException
+ * in case of IO errors.
+ */
+ public final void sign(final List spiList)
+ throws ServiceLocationException {
+ authBlocks = new AuthenticationBlock[spiList.size()];
+ for (int k = 0; k < spiList.size(); k++) {
+ int timestamp = SLPUtils.getTimestamp();
+ timestamp += lifetime;
+
+ String spi = (String) spiList.get(k);
+ byte[] data = getAuthData(spi, timestamp);
+ byte[] sig;
+ try {
+ sig = AuthenticationBlock.sign(spi,data);
+ } catch (Exception e) {
+ //SLPCore.platform.logError(e.getMessage(), e.fillInStackTrace());
+ throw new ServiceLocationException(
+ ServiceLocationException.AUTHENTICATION_FAILED,
+ "Could not sign data");
+ }
+ authBlocks[k] = new AuthenticationBlock(timestamp,spi,sig);
+
+ }
+ }
+
+ /**
+ * sign the ServiceURL.
+ *
+ * Copied over to the MINA port from the original jSLP implementation, untested
+ *
+ * Type mismatch between the original jSLP (all Lists) and the MINA codecs (all String[])
+ * required this overload.
+ *
+ * @param spiList
+ * the String[] of SPIs
+ * @throws ServiceLocationException
+ * in case of IO errors.
+ */
+ public final void sign (final String[] spiList) throws ServiceLocationException{
+ authBlocks = new AuthenticationBlock[spiList.length];
+ for (int k = 0; k< spiList.length;k++){
+ int timestamp = SLPUtils.getTimestamp();
+ timestamp += lifetime;
+
+ String spi = (String) spiList[k];
+ byte[] data = getAuthData(spi, timestamp);
+ byte[] sig;
+ try {
+ sig = AuthenticationBlock.sign(spi,data);
+ } catch (Exception e) {
+ //SLPCore.platform.logError(e.getMessage(), e.fillInStackTrace());
+ throw new ServiceLocationException(
+ ServiceLocationException.AUTHENTICATION_FAILED,
+ "Could not sign data");
+ }
+ authBlocks[k] = new AuthenticationBlock(timestamp,spi,sig);
+ }
+ }
+
+
+}
\ No newline at end of file
Propchange: directory/sandbox/slp/src/main/java/org/apache/directory/slp/AuthenticatedServiceURL.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: directory/sandbox/slp/src/main/java/org/apache/directory/slp/DirectoryAgent.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/DirectoryAgent.java?rev=782968&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/DirectoryAgent.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/DirectoryAgent.java Tue Jun 9 12:00:29 2009
@@ -0,0 +1,150 @@
+/*
+ * 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.slp;
+
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.directory.slp.messages.ServiceDeregistrationMessage;
+import org.apache.directory.slp.messages.ServiceRegistrationMessage;
+
+/**
+ * External interface of the jSLP Directory Agent.
+ *
+ * @author Lorenz Breu
+ *
+ */
+public interface DirectoryAgent {
+
+
+ /**
+ * list all services currently managed by this DA
+ *
+ * @return
+ * List of Services registered on this DA
+ */
+ public List<Service> listServices();
+
+ /**
+ * Shut the DA down by sending out a DAADVERT with statelessBoottimestamp of 0 and deregistering it from the jSLP core
+ */
+ public void shutdown();
+
+ /**
+ * Register a service with the DA.
+ *
+ * @param reg
+ * The ServiceRegistrationMessage received that contains the Service information
+ * @throws ServiceLocationException
+ */
+ public void registerService(ServiceRegistrationMessage reg) throws ServiceLocationException;
+
+
+
+ /**
+ * Register a service with the DA.
+ *
+ * @param service
+ * The Service to be registered.
+ * @throws ServiceLocationException
+ */
+ public void registerService(Service service) throws ServiceLocationException;
+
+
+
+ /**
+ * Parses a static registration file in which services are registered as in OpenSLP 1.x and 2.x:
+ *
+ * #comment
+ * ;comment
+ * service-url,language-tag,lifetime,[service-type]<newline>
+ * "scopes="[scope-list]<newline>
+ * [attrid]"="val1<newline>
+ * [attrid]"="val1,val2,val3<newline>
+ * <newline>
+ *
+ * @param file
+ * The file which contains the static registrations in the format listed above
+ */
+ public void registerServicesFromFile(File file);
+
+ /**
+ * Exports all services in the service store to a static registration file with the following format
+ * identical to OpenSLP 1.x and 2.x
+ *
+ * @param path
+ * The string to the path where the file is located. If no file is located there, one will be created.
+ * @param append
+ * Set to true if an existing file is to be appended to, or false if an existing file is to be overwritten
+ */
+ public void exportServicesToFile(String path, boolean append);
+
+ /**
+ * Deregister a service from the DA.
+ *
+ * @param dereg
+ * The ServiceDeregistrationMessage received that contains the Service information
+ * @throws ServiceLocationException
+ */
+ public void deregisterService(ServiceDeregistrationMessage dereg) throws ServiceLocationException;
+
+
+
+
+
+
+ /**
+ * Deregeister a service from the DA.
+ *
+ * @param service
+ * @throws ServiceLocationException
+ */
+ public void deregisterService(Service service) throws ServiceLocationException;
+
+
+ /**
+ * Set the backend for service storage. Set flush to false if existing services are to be kept.
+ *
+ * @param store
+ * The ServiceStore to use
+ * @param flush
+ * true: create a fresh service store, no existing entries are kept.
+ * false: Keep existing registrations
+ * @throws ServiceLocationException
+ */
+ public void setServiceStore(ServiceStore store, boolean flush) throws ServiceLocationException;
+
+
+ /**
+ * Returns the attribute type registry of the DA. ServiceStore implementations should keep track of attribute types and
+ * are encouraged to use a mapping of <abstract_service_type>.<attribute_name> -> Integer using the types staticaly provided by the ServiceStore interface.
+ *
+ * The result is a copy of the data in the registry and does not provide write access to the actual registry.
+ *
+ *
+ * @return
+ * A <code>Map</code> representing the mapping of attributes to types (Integer, String, Boolean, Opaque, Keyword)
+ * @throws ServiceLocationException
+ * If a ServiceStore implementation does not support this feature
+ */
+ public Map<String, Integer> getAttributeTypes() throws ServiceLocationException;
+
+}
Propchange: directory/sandbox/slp/src/main/java/org/apache/directory/slp/DirectoryAgent.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: directory/sandbox/slp/src/main/java/org/apache/directory/slp/Locator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/Locator.java?rev=782968&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/Locator.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/Locator.java Tue Jun 9 12:00:29 2009
@@ -0,0 +1,164 @@
+/*
+ * 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.slp;
+
+import java.util.List;
+import java.util.Locale;
+
+//import com.sun.slamd.stat.CategoricalTracker;
+
+/**
+ * Locator implements the UA properties of SLP. Services can be discovered by
+ * type or by URL, attributes of discovered services can be retrieved and
+ * service types can be listed.
+ *
+ * @author Jan S. Rellermeyer, Systems Group, ETH Zurich
+ * @since 0.1
+ */
+public interface Locator {
+ /**
+ * Returns the locale of this Locator instance.
+ *
+ * @return the current Locale.
+ */
+ Locale getLocale();
+
+ /**
+ * Get the locale of this instance.
+ *
+ * @param locale
+ * the Locale.
+ * @see Advertiser#getLocale()
+ */
+ void setLocale(final Locale locale);
+
+ /**
+ * Find all services types that are currently
+ * registered in the network.
+ *
+ * @param namingAuthority
+ * the naming authority for the service type. If omitted,
+ * ALL Service Types are returned, regardless of Naming Authority.
+ * With the empty <code>String</code> (""), <code>IANA</code> will be assumed.
+ * @param scopes
+ * a <code>List</code> of scopes in that service types are to
+ * be discovered.
+ * @return a ReplyFuture with the discovered ServiceTypes.
+ * @throws ServiceLocationException
+ * whenever called.
+ */
+ ReplyFuture findServiceTypes(String namingAuthority,
+ List<String> scopes) throws ServiceLocationException;
+
+ /**
+ * Find all services that match a certain service type.
+ *
+ * @param type
+ * the ServiceType.
+ * @param scopes
+ * A <code>List</code> of scope <code>Strings</code>, RFC
+ * 2614 uses <code>Vector</code> here but jSLP prefers the
+ * Collection Framework.
+ * @param searchFilter
+ * an RFC 1960 compliant <code>String</code> of a LDAP filter.
+ * RFC 2614 proposes the newer RFC 2254 style filters that adds
+ * support for extensible matches.
+ * @return a ReplyFuture with the <code>ServiceURLs</code>
+ * of the found services.
+ * @throws ServiceLocationException
+ * in case of an exception in the underlying framework.
+ * @throws InvalidSyntaxException
+ */
+ ServiceReplyFuture findServices(ServiceType type, List<String> scopes,
+ String searchFilter) throws ServiceLocationException, IllegalArgumentException;
+
+ /**
+ * Find all services that match a ServiceURL.
+ *
+ * @param url
+ * the ServiceURL.
+ * @param scopes
+ * A <code>List</code> of scopes <code>Strings</code>, RFC
+ * 2614 uses <code>Vector</code> here but jSLP prefers the
+ * Collection Framework.
+ * @param attributeIds
+ * A List of attribute-value-pairs like
+ *
+ * <pre>
+ * (key = value)
+ * </pre>
+ *
+ * that must match. If null, no attribute constraints are applied.
+ * @return a RepyFuture with the <code>ServiceURLs</code>
+ * of the found services.
+ * @throws ServiceLocationException
+ * in case of an exception in the underlying framework.
+ */
+ AttributeReplyFuture findAttributes(ServiceURL url, List<String> scopes,
+ List attributeIds) throws ServiceLocationException;
+
+ /**
+ * Find all services that match a ServiceType.
+ *
+ * @param type
+ * the ServiceType.
+ * @param scopes
+ * A <code>List</code> of scope <code>Strings</code>, RFC
+ * 2614 uses <code>Vector</code> here but jSLP prefers the
+ * Collection Framework.
+ * @param attributeIds
+ * A List of attribute-value-pairs like
+ *
+ * <pre>
+ * (key = value)
+ * </pre>
+ *
+ * that must match. If null, no attribute constraints are applied.
+ * @return a ReplyFuture with the ServiceURLs of the found
+ * services.
+ * @throws ServiceLocationException
+ * in case of an exception in the underlying framework.
+ */
+ AttributeReplyFuture findAttributes(ServiceType type, List<String> scopes,
+ List attributeIds) throws ServiceLocationException;
+
+
+ /**
+ * Start the Acceptors in the core and have them listen on the SLP_PORT.
+ *
+ * By default a Locator will not be listening on the SLP_PORT in order to allow a UA to be
+ * used by non-root users. Therefor the UA will not receive DAADVERTS and the like sent as
+ * multicast packets to the SLP_PORT.
+ *
+ * @throws ServiceLocationException
+ * in case the MINA framework could no tbe initialized on the SLP_PORT (e.g. as non-root on the default port 427)
+ */
+ public void listenOnSLPPort() throws ServiceLocationException;
+
+ public boolean isUseAttributeListExtension();
+
+ public void setUseAttributeListExtension(boolean useAttributeListExtension);
+
+ //FOR BENCHMARKING, REMOVE!!
+ //TODO: REMOVE!!
+ //public void addDATracker(CategoricalTracker daTracker);
+
+ //public void forceDAs(String[] das);
+}
Propchange: directory/sandbox/slp/src/main/java/org/apache/directory/slp/Locator.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: directory/sandbox/slp/src/main/java/org/apache/directory/slp/OpaqueValue.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/OpaqueValue.java?rev=782968&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/OpaqueValue.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/OpaqueValue.java Tue Jun 9 12:00:29 2009
@@ -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.slp;
+
+import java.util.StringTokenizer;
+
+/**
+ * A wrapper used for the SLP Opaque attribute type. Provides access to the String representation
+ * as well as the raw bytes. Also provides equality, comparison and toString methods
+ *
+ * @author Lorenz Breu
+ *
+ */
+public class OpaqueValue implements Comparable<OpaqueValue>{
+
+ private String opaqueString;
+
+ private Byte[] opaqueBytes;
+
+
+
+
+ /**
+ * Create a new OpaqueValue with a String representing an opaque attribute in SLP.
+ *
+ * @param opaque
+ * A String representing an SLP opaque type i.e., starting with "\FF" (or "\\FF" in actual Java notation)
+ */
+ public OpaqueValue(String opaque){
+ opaqueString = opaque.toUpperCase();
+ opaqueBytes = opaqueStringToByteArray(opaque);
+ }
+
+ /**
+ * Create a new OpaqueValue with raw bytes.
+ *
+ * @param bytes
+ * The raw bytes as <code>byte[]</code>
+ */
+ public OpaqueValue(byte[] bytes){
+ opaqueString = byteArrayToOpaqueString(bytes);
+ Byte[] ba = new Byte[bytes.length];
+ for (int i = 0; i < ba.length; i++){
+ ba[i] = bytes[i];
+ }
+ opaqueBytes = ba;
+ }
+
+ /**
+ * Create a new OpaqueValue with raw bytes.
+ *
+ * @param bytes
+ * The raw bytes as <code>Byte[]</code>
+ */
+ public OpaqueValue(Byte[] bytes){
+ opaqueString = byteArrayToOpaqueString(bytes);
+ opaqueBytes = bytes;
+ }
+
+
+
+
+ /**
+ * Converts a Byte array to its corresponding SLP string representation
+ *
+ * @param ba
+ * The raw bytes as <code>Byte[]</code>
+ * @return
+ * The SLP string representation without the leading "\FF" if it is not explicitly present in the byte array
+ */
+ public static String byteArrayToOpaqueString(Byte[] ba){
+ String result = "";
+ for (Byte b : ba){
+ result+="\\"+byteToHex(b);
+ }
+ return result;
+ }
+
+
+ /**
+ * Converts a byte array to its corresponding SLP string representation
+ *
+ * @param bar
+ * The raw bytes as <code>byte[]</code>
+ * @return
+ * The SLP string representation without adding the leading "\FF" if it is not explicitly present in the byte array
+ */
+ public static String byteArrayToOpaqueString(byte[] bar){
+ Byte[] ba = new Byte[bar.length];
+ for (int i = 0; i < ba.length; i++){
+ ba[i] = bar[i];
+ }
+ String result = "";
+ for (Byte b : ba){
+ result+="\\"+byteToHex(b);
+ }
+ return result;
+ }
+
+
+
+ /**
+ * Converts an SLP string representing an opaque value to its corresponding Byte[]
+ *
+ * @param os
+ * The SLP string representation
+ *
+ * @return
+ * The raw bytes as <code>Byte[]</code>
+ */
+ public static Byte[] opaqueStringToByteArray(String os){
+ StringTokenizer tokenizer = new StringTokenizer(os,"\\");
+ Byte[] result = new Byte[tokenizer.countTokens()];
+ int i = 0;
+ while (tokenizer.hasMoreTokens()){
+ result[i++] = (byte) Integer.parseInt(tokenizer.nextToken(),16);
+ }
+ return result;
+ }
+
+
+
+ /**
+ * Converts a single byte to its hexadecimal string representation.
+ * Examples: 1->"01", 12->"0C", 255->"FF", ...
+ *
+ * @param b
+ * The single byte
+ * @return
+ * Hexadecimal value as a string (no leading "0x")
+ */
+ public static String byteToHex(byte b){
+ String result = Integer.toHexString(b);
+ if (result.length()>2){
+ result = result.substring(result.length()-2);
+ } else if (result.length()==1){
+ result = "0"+result;
+ }
+ return result.toUpperCase();
+
+ }
+
+
+ /**
+ * Converts a hexadecimal string representation to a byte.
+ *
+ * @param h
+ * The string representation of a byte e.g. "FF"
+ * @return
+ * The Byte that value represents
+ */
+ public static Byte hexToByte(String h){
+ return (byte) Integer.parseInt(h,16);
+ }
+
+ /**
+ * Returns the raw byte contents of this value
+ *
+ * @return
+ * The raw bytes as <code>Byte[]</code>
+ */
+ public Byte[] getOpaqueBytes() {
+ return opaqueBytes;
+ }
+
+
+ /**
+ * Set the raw byte contents of this value
+ *
+ * @param opaqueBytes
+ * The raw bytes as <code>Byte[]</code>
+ */
+ public void setOpaqueBytes(Byte[] opaqueBytes) {
+ this.opaqueBytes = opaqueBytes;
+ }
+
+ /**
+ * Returns the SLP string representation of the raw byte contents of this value
+ *
+ * @return
+ * SLP String representing the raw byte value
+ */
+ public String getOpaqueString() {
+ return opaqueString;
+ }
+
+ /**
+ * Sets the SLP string representation of the raw byte contents of this value
+ *
+ * @param opaqueString
+ * SLP String representing the raw byte value
+ */
+ public void setOpaqueString(String opaqueString) {
+ this.opaqueString = opaqueString;
+ }
+
+ /**
+ * Returns the SLP string representation of the raw byte contents of this value
+ *
+ * @return
+ * SLP String representing the raw byte value
+ */
+ public String toString(){
+ return opaqueString;
+ }
+
+
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(OpaqueValue o) {
+ if (o.getOpaqueString().equals(opaqueString)){
+ return 0;
+ }
+
+ if (o.getOpaqueBytes().length>opaqueBytes.length){
+ return -1;
+ }
+ return 1;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj){
+ if (obj instanceof OpaqueValue){
+ OpaqueValue ov = (OpaqueValue) obj;
+ return opaqueString.equals(ov.getOpaqueString());
+ }
+ if (obj instanceof String){
+ String os = (String) obj;
+ return opaqueString.equals(os.toUpperCase());
+ }
+ if (obj instanceof Byte[]){
+ Byte[] ba = (Byte[]) obj;
+ return equals(ba);
+ }
+ return false;
+ }
+
+ /**
+ * Override of the equals() method to check if this OpaqueValue equals another.
+ *
+ * @param ov
+ * The other OpaqueValue this one is to be compared to
+ * @return
+ * True on equality, else false
+ */
+ public boolean equals(OpaqueValue ov){
+ return opaqueString.equals(ov.getOpaqueString());
+ }
+
+ /**
+ * Override of the equals() method to check if this OpaqueValue equals an SLP representation of an opaque value.
+ *
+ * @param os
+ * The string representation of the opaque value this one is to be compared to
+ * @return
+ * True on equality, else false
+ */
+ public boolean equals(String os){
+ return os.toUpperCase().equals(opaqueString);
+ }
+
+ /**
+ * Override of the equals() method to check if this OpaqueValue equals raw Byte data
+ *
+ * @param ba
+ * The raw bytes as <code>Byte[]</code> of the opaque value this one is to be compared to
+ * @return
+ * True on equality, else false
+ */
+ public boolean equals(Byte[] ba){
+ return byteArrayToOpaqueString(ba).equals(byteArrayToOpaqueString(opaqueBytes));
+ }
+
+ /**
+ * Override of the equals() method to check if this OpaqueValue equals raw byte data
+ *
+ * @param bar
+ * The raw bytes as <code>byte[]</code> of the opaque value this one is to be compared to
+ * @return
+ * True on equality, else false
+ */
+ public boolean equals(byte[] bar){
+ Byte[] ba = new Byte[bar.length];
+ for (int i = 0; i < ba.length; i++){
+ ba[i] = bar[i];
+ }
+ return byteArrayToOpaqueString(ba).equals(byteArrayToOpaqueString(opaqueBytes));
+ }
+
+}
Propchange: directory/sandbox/slp/src/main/java/org/apache/directory/slp/OpaqueValue.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: directory/sandbox/slp/src/main/java/org/apache/directory/slp/ReplyFuture.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/ReplyFuture.java?rev=782968&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/ReplyFuture.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/ReplyFuture.java Tue Jun 9 12:00:29 2009
@@ -0,0 +1,98 @@
+/*
+ * 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.slp;
+
+import java.util.List;
+
+import org.apache.directory.slp.ServiceLocationEnumeration;
+import org.apache.directory.slp.messages.AbstractSLPReplyMessage;
+
+
+/**
+ * The future returned when performing SLP lookups. It can be accessed while results still come in using next(),
+ * or after all results have arrived using getResult().
+ *
+ * @author Lorenz Breu
+ *
+ */
+public interface ReplyFuture extends ServiceLocationEnumeration {
+
+
+
+
+ /**
+ * Adds the result of an SLP reply message to the list of responses and the sender of the
+ * reply to the list of responders, if the error code is 0.
+ *
+ * @param reply
+ * An AbstractSLPReplyMessage obtained through unicast or multicast
+ */
+ public void add(AbstractSLPReplyMessage reply);
+
+ /**
+ * Close the future.
+ * If the override flag is set, the future will be closed directly.
+ * If override is false, then the defined scopes will be removed from the list of unhandled scopes
+ * and the future will be closed only if no scopes remain unhandled. Else it will remain open.
+ *
+ * @param scopes
+ * The scopes to mark as done.
+ * @param override
+ * Set to true if the future should be closed even if scopes remain unhandled (e.g. timeout)
+ */
+ public void setDone(String[] scopes, boolean override);
+
+
+
+
+ /**
+ * Returns the status of the future.
+ *
+ * @return
+ * True if done, false if results can still be added.
+ */
+ public boolean isDone();
+
+ /**
+ * Blocking call that waits until the future is marked as "done" before returning all available responses.
+ *
+ * @return
+ * A list of all results obtained during the unicast or multicast SLP operation in the form of Strings.
+ */
+ public List<String> getResult();
+
+
+ /**
+ * Returns the sources of all reply messages with error code 0 passed on to this future.
+ *
+ * @return
+ * Array of IP addresses as Strings in dot notation of the sources of reply messages.
+ */
+ public String[] getResponders();
+
+
+
+}
+
+
+
+
+
+
Propchange: directory/sandbox/slp/src/main/java/org/apache/directory/slp/ReplyFuture.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: directory/sandbox/slp/src/main/java/org/apache/directory/slp/SLPAttribute.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/SLPAttribute.java?rev=782968&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/SLPAttribute.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/SLPAttribute.java Tue Jun 9 12:00:29 2009
@@ -0,0 +1,66 @@
+/*
+ * 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.slp;
+
+/**
+ * A wrapper around the SLP attributes. Used by the Locator for attribute requests.
+ * As jSLP does not enforce or use service templates, situations may occur when attribute
+ * requests lead to inconsistent answers. This wrapper prevents this by keeping track
+ * of name and type of a specific attribute.
+ *
+ * @author Lorenz Breu
+ *
+ */
+public interface SLPAttribute {
+
+ /**
+ * The types of the corresponding SLP attributes
+ */
+ public static final int STRING_AT = 1;
+ public static final int INTEGER_AT = 2;
+ public static final int BOOLEAN_AT = 3;
+ public static final int OPAQUE_AT = 4;
+ public static final int KEYWORD_AT = 5;
+
+ public static final String STRING_AT_STRING = "String";
+ public static final String INTEGER_AT_STRING = "Integer";
+ public static final String BOOLEAN_AT_STRING = "Boolean";
+ public static final String OPAQUE_AT_STRING = "Opaque";
+ public static final String KEYWORD_AT_STRING = "Keyword";
+
+
+ public int getType();
+
+ public String getTypeString();
+
+ public String getName();
+
+ public Boolean[] getBooleanValues();
+
+ public String[] getStringValues();
+
+ public Integer[] getIntegerValues();
+
+ public OpaqueValue[] getOpaqueValues();
+
+ public int count();
+
+ public boolean isKeyword();
+}
Propchange: directory/sandbox/slp/src/main/java/org/apache/directory/slp/SLPAttribute.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: directory/sandbox/slp/src/main/java/org/apache/directory/slp/Service.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/Service.java?rev=782968&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/Service.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/Service.java Tue Jun 9 12:00:29 2009
@@ -0,0 +1,277 @@
+/*
+ * 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.slp;
+
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.List;
+
+import org.apache.directory.slp.impl.AuthenticationBlock;
+import org.apache.directory.slp.impl.SLPUtils;
+import org.apache.directory.slp.messages.ServiceRegistrationMessage;
+
+/**
+ * Encapsulates the internal information about registered services.
+ *
+ * @author Jan S. Rellermeyer
+ */
+public class Service {
+
+ /**
+ * the service URL.
+ */
+ private ServiceURL url;
+
+ /**
+ * the service attributes.
+ */
+ Dictionary<String,Object> attributes;
+
+ /**
+ * The attribute list as it is received, must be stored and given back in this way when an SPI is included, as DAs are not to
+ * sign reply messages, only pass on authentication information as received.
+ */
+ String verbatimAttributeList = "";
+
+
+ /**
+ * the service attribute authentication blocks.
+ */
+ private AuthenticationBlock[] authenticationBlocks;
+
+
+ /**
+ * the scopes this service is intended for.
+ */
+ private List<String> scopes;
+
+
+ /**
+ * Added to support replication on Cirrostratus
+ */
+ public Service(){
+
+ }
+
+ /**
+ * creates a new Service instance by parsing a registration message.
+ *
+ * @param sreg
+ * the service registration message.
+ */
+ public Service(final ServiceRegistrationMessage sreg) {
+
+ // TODO: support localized registrations ...
+ url = sreg.getServiceURL();
+ attributes = SLPUtils.stringArrayToDict(sreg.getAttrList());
+ scopes = new ArrayList<String>();
+ for (String scope : sreg.getScopes()){
+ scopes.add(scope.toLowerCase().trim());
+ }
+ authenticationBlocks = sreg.getAuthBlocks();
+ verbatimAttributeList = sreg.getVerbatimAttributeList();
+ }
+
+ /**
+ * creates a new Service instance from a ServiceURL hsing default scope.
+ *
+ * @param url
+ * the service url for this Service instance.
+ */
+ public Service(ServiceURL url){
+ this.url = url;
+ scopes = new ArrayList<String>();
+ scopes.add("default");
+ }
+
+
+ /**
+ * @param obj
+ * Object to compare.
+ * @return <code>true</code> if the object is of type <code>Service</code>
+ * and the two services have a matching serviceURL and equal
+ * properties.
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(final Object obj) {
+ if (obj instanceof Service) {
+ Service service = (Service) obj;
+ return attributes.equals(service.attributes)
+ && url.equals(service.url);
+ }
+ return false;
+ }
+
+
+
+
+// public boolean equals(final Object obj) {
+// if (obj instanceof Service) {
+// Service service = (Service) obj;
+// return url.equals(service.url);
+// }
+// return false;
+// }
+
+
+
+
+ /**
+ * get the hash code.
+ *
+ * @return the hash code.
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ return url.hashCode();
+ }
+
+
+ /**
+ * get the ServiceURL of this Service
+ *
+ * @return the ServiceURL
+ */
+ public ServiceURL getURL(){
+ return url;
+ }
+
+ /**
+ * Get the attributes as a Dictionary mapping attribute name (String) to values (Integer, Boolean, String, OpaqueValue or array of the aforementioned)
+ *
+ * @return The attributes as Dictionary String->Object
+ */
+ public Dictionary<String,Object> getAttributes(){
+ return attributes;
+ }
+
+ /**
+ * Set the Service's attributes, overwriting any existing attributes
+ * jSLP expects the values to be of type String, Integer, Boolean or OpaqueValue or an array of these types.
+ *
+ * @param attr
+ * The attributes as a Dictionary String->Object.
+ */
+ public void setAttributes(Dictionary<String,Object> attr){
+ attributes = attr;
+ }
+
+ /**
+ * Gets the attributes but converts all values to their string representation
+ *
+ * @return
+ * The attributes as a Dictionary String->String
+ */
+ public Dictionary<String,String> getAttributesAsStringDict(){
+ if (attributes==null){
+ return new Hashtable<String,String>();
+ }
+ Enumeration keys = attributes.keys();
+ Dictionary<String,String> result = new Hashtable<String,String>();
+ while (keys.hasMoreElements()){
+ Object key = keys.nextElement();
+ Object value = attributes.get(key);
+ String combined="";
+ if (value instanceof Object[]){
+ Object[] valueArray = (Object[]) value;
+ combined = valueArray[0].toString();
+ for (int i=1;i<valueArray.length;i++){
+ combined = combined + ", "+valueArray[i].toString().trim();
+ }
+ value=combined;
+ }
+ result.put(key.toString(),value.toString());
+ }
+ return result;
+ }
+
+ /**
+ * Get the scopes as a List
+ *
+ * @return
+ * The scopes
+ */
+ public List<String> getScopes(){
+ return scopes;
+ }
+
+ /**
+ * Sets the scope list
+ *
+ * @param scopes
+ * The scopes as a List of String
+ */
+ public void setScopes(List<String> scopes){
+ this.scopes = scopes;
+ }
+
+ /**
+ * Get the authentication blocks
+ *
+ * @return
+ * The Authentication Blocks as an array
+ */
+ public AuthenticationBlock[] getAuthBlocks(){
+ return authenticationBlocks;
+ }
+
+ /**
+ * Set the authentication blocks
+ *
+ * @param blocks
+ * The Authentication Blocks as an array
+ */
+ public void setAuthBlocks(AuthenticationBlock[] blocks){
+ authenticationBlocks = blocks;
+ }
+
+ /**
+ * Get the verbatim attribute list as it arrives in a registration message.
+ * Required for DAs as they do not sign the replies but simply pass on authentication information as received
+ *
+ * @return
+ * String representation of the attributes as arrived in the registration
+ */
+ public String getVerbatimAttributeList(){
+ return verbatimAttributeList;
+ }
+
+ /**
+ * Set the verbatim attribute list as it arrives in a registration message.
+ * Required for DAs as they do not sign the replies but simply pass on authentication information as received
+ *
+ * @param v
+ * String representation of the attributes as arrived in the registration
+ */
+ public void setVerbatimAttributeList(String v){
+ verbatimAttributeList=v;
+ }
+
+ /**
+ * get a string representation.
+ *
+ * @return a string.
+ */
+ public String toString() {
+ return url.toString();
+ }
+}
Propchange: directory/sandbox/slp/src/main/java/org/apache/directory/slp/Service.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceLocationEnumeration.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceLocationEnumeration.java?rev=782968&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceLocationEnumeration.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceLocationEnumeration.java Tue Jun 9 12:00:29 2009
@@ -0,0 +1,39 @@
+/*
+ * 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.slp;
+
+import java.util.Enumeration;
+
+/**
+ * An enumeration over results of request messages as defined in RFC 2614.
+ *
+ * @author Jan S. Rellermeyer
+ */
+public interface ServiceLocationEnumeration extends Enumeration {
+
+ /**
+ * get the next result of a request.
+ *
+ * @return the next <code>Object</code>
+ * @throws ServiceLocationException
+ * if there is no more result.
+ */
+ Object next() throws ServiceLocationException;
+}
Propchange: directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceLocationEnumeration.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceLocationException.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceLocationException.java?rev=782968&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceLocationException.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceLocationException.java Tue Jun 9 12:00:29 2009
@@ -0,0 +1,164 @@
+/*
+ * 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.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
+ */
+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;
+
+
+ /**
+ * DA or SA received a request with a mandatory but unsupported extension
+ */
+ public static final short OPTION_NOT_UNDERSTOOD = 12;
+
+
+ /**
+ * 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.
+ */
+ private 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;
+ }
+}
Propchange: directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceLocationException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceReplyFuture.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceReplyFuture.java?rev=782968&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceReplyFuture.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceReplyFuture.java Tue Jun 9 12:00:29 2009
@@ -0,0 +1,52 @@
+/*
+ * 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.slp;
+
+import java.util.List;
+
+/**
+ * The reply future returned by service lookups. Provides access to the results not only
+ * as Strings but also as Service objects.
+ *
+ * If the Attribute List Extension is used, the attributes in the returned Service objects are set, else they remain null.
+ *
+ * @author Lorenz Breu
+ */
+public interface ServiceReplyFuture extends ReplyFuture{
+
+ /**
+ * Get the next Service object returned by the SLP request process. Blocks until a Service is available
+ * or the process times out (e.g. MCC).
+ *
+ * @return
+ * The next Service object
+ */
+ public Service nextService();
+
+ /**
+ * Get the complete List of Service objects returned by the SLP request process.
+ * Blocks until the process times out (e.g. end of MCC).
+ *
+ * @return
+ * List of Service objects
+ */
+ public List<Service> getResultServices();
+
+}
Propchange: directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceReplyFuture.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceStore.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceStore.java?rev=782968&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceStore.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceStore.java Tue Jun 9 12:00:29 2009
@@ -0,0 +1,190 @@
+/*
+ * 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.slp;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The interface that backends of the DA have to implement. Provides methods
+ * to store and retrieve services, attributes and service types.
+ * Implementations of this interface are encouraged to keep track of attribute types
+ * for abstract service types to enforce consistency.
+ *
+ * @author Lorenz Breu
+ *
+ */
+public interface ServiceStore {
+
+
+ /**
+ * The types of the corresponding SLP attributes
+ */
+ public static final int STRING_AT = 1;
+ public static final int INTEGER_AT = 2;
+ public static final int BOOLEAN_AT = 3;
+ public static final int OPAQUE_AT = 4;
+ public static final int KEYWORD_AT = 5;
+
+ /**
+ * Fetches a list of all services currently registered with this DA
+ *
+ * @return
+ * List<Service>: all services
+ * @throws ServiceLocationException
+ */
+ public List<Service> listServices() throws ServiceLocationException;
+
+ /**
+ * Stores a service in the backend. Should throw a ServiceLocationException if the service already exists.
+ *
+ * @param service
+ * The service to store
+ * @throws ServiceLocationException
+ */
+ public void storeService(Service service) throws ServiceLocationException;
+
+ /**
+ * Get attributes of registered services.
+ *
+ * @param service
+ * Can be either a full service url (e.g. "service:osgi://gantenbein:123") in which case only attributes of thsi specific service are returned.
+ * Alternatively a service type can also be used (e.g. "service:osgi") in which case attributes of all services that match that service type are returned.
+ *
+ * @param tagList
+ * If this list is empty or null, all attributes are returned, otherwise only the ones in this list are returned.
+ *
+ * @param scopeList
+ * The scopes in which to search for matching services
+ *
+ * @return
+ * An array of attributes in the form "(attribute=value)"
+ */
+ public String[] getAttributes(String service, String[] tagList, String[] scopeList);
+
+ /**
+ * Get service types of services registered with this DA
+ *
+ * @param scopes
+ * The scopes in which to search
+ *
+ * @param namingAuthority
+ * The naming authority defining the service types. can be "" or null, in which case all service types are returned.
+ *
+ * @return
+ * An array of available service types
+ */
+ public ServiceType[] getServiceTypes(String[] scopes, String namingAuthority);
+
+ /**
+ * Get services that match the specified predicate/filter-string of the specified service type
+ *
+ * @param serviceType
+ * The service type of the services to be looked up
+ *
+ * @param attributeFilter
+ * The predicate to be used when searching, e.g. (attribute=foo)
+ *
+ * @return
+ * List of services that match the given type and predicate
+ *
+ * @throws ServiceLocationException
+ */
+ public List<Service> getServices(String serviceType, String attributeFilter) throws ServiceLocationException;
+
+ /**
+ * Get services that match the specified predicate/filter-string of the specified service type and in addition are in at least one of the specified scopes.
+ *
+ * @param serviceType
+ * The service type of the services to be looked up
+ *
+ * @param attributeFilter
+ * The predicate to be used when searching, e.g. (attribute=foo)
+ *
+ * @param scopes
+ * An array of scopes. A service must be in at least one of these scopes to be found.
+ * If null or empty, services in all scopes are returned.
+ *
+ * @return
+ * List of services that match the given type and predicate
+ *
+ * @throws ServiceLocationException
+ */
+ public List<Service> getServices(String serviceType, String attributeFilter, String[] scopes) throws ServiceLocationException;
+
+ /**
+ * Fetch a specific service identified with the unique service URL.
+ *
+ * @param serviceUrl
+ * The service url (e.g. "service:osgi://gantenbein:123" of the requested service.
+ *
+ * @return
+ * The service if it is found, null else.
+ *
+ * @throws ServiceLocationException
+ */
+ public Service getService(String serviceUrl) throws ServiceLocationException;
+
+ /**
+ * Remove a specific service identified by its unique service url from the service store.
+ *
+ * @param serviceurl
+ * The service url (e.g. "service:osgi://gantenbein:123" of the requested service.
+ *
+ * @throws ServiceLocationException
+ */
+ public void deleteService(String serviceurl) throws ServiceLocationException;
+
+ /**
+ * Checks if a service with that service url is in the service store.
+ *
+ * @param service
+ * The service url (as a string) of the requested service, e.g. "service:osgi://gantenbein:123"
+ *
+ * @return
+ * TRUE if the service was found, FALSE else
+ */
+ public boolean containsService(String service);
+
+ /**
+ * Remove all services from the store. Should be done at startup if an implementation keeps registered services in persistent storage.
+ */
+ public void clear();
+
+
+ /**
+ * Perform any cleanup steps necessary. Normally the SLP service is killed, so this may never be called...
+ */
+ public void shutdown();
+
+ /**
+ * Returns the attribute type registry of the ServiceStore. Implementations should keep track of attribute types and
+ * are encouraged to use a mapping of <abstract_service_type>.<attribute_name> -> Integer using the types staticaly provided by the ServiceStore interface.
+ *
+ * The result is a copy of the data in the registry and does not provide write access to the actual registry.
+ *
+ *
+ * @return
+ * A <code>Map</code> representing the mapping of attributes to types (Integer, String, Boolean, Opaque, Keyword)
+ * @throws ServiceLocationException
+ * If a ServiceStore implementation does not support this feature
+ */
+ public Map<String, Integer> getAttributeTypes() throws ServiceLocationException;
+}
Propchange: directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceStore.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceType.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceType.java?rev=782968&view=auto
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceType.java (added)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceType.java Tue Jun 9 12:00:29 2009
@@ -0,0 +1,270 @@
+/* modified version by Jan S. Rellermeyer, ETH Zurich
+ * Copyright 2005-2007 Systems Group, ETH Zurich. All rights reserved.
+ *
+ * based on the Java SLP implementation by Solers Corporation
+ * Copyright 2003 Solers Corporation. All rights reserved.
+ *
+ * Modification and use of this SLP API software and associated documentation
+ * ("Software") is permitted provided that the conditions specified in the
+ * LICENSE.txt file included within this distribution are met.
+ *
+ * Author of the original class: Patrick Callis
+ */
+package org.apache.directory.slp;
+
+import java.io.Serializable;
+
+/**
+ * Implementation of the SLP ServiceType class defined in RFC 2614.
+ *
+ * @author Jan S. Rellermeyer, Systems Group, 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.equals("service") || type.equals("service:")){
+ // quick fix by Lorenz to make service: an abstract service type for searches...
+ isService = true;
+ isAbstract = true;
+ abstractType = "service";
+ concreteType = "";
+ principleType = "";
+
+ } else {
+ if (type.startsWith("service:")) {
+ isService = true;
+
+ int principleStart = 8;
+ int principleEnd = type.indexOf(":", principleStart);
+
+ if (principleEnd != -1) {
+ isAbstract = false;
+ principleType = type.substring(principleStart, principleEnd);
+ abstractType = type.substring(0, principleEnd);
+ concreteType = type.substring(principleEnd + 1);
+ } else {
+ isAbstract = true;
+ principleType = type.substring(principleStart);
+ // added by lorenz, seems like a service of type service:printer should return abstract type printer as well
+ abstractType=type.substring(principleStart);
+ //abstractType = "";
+ concreteType = "";
+ }
+
+ int namingStart = type.indexOf(".") + 1;
+ if (namingStart != 0) {
+ int namingEnd = type.indexOf(":", namingStart);
+ String na = "";
+ if (namingEnd == -1) {
+ na = type.substring(namingStart);
+ } else {
+ na = type.substring(namingStart, namingEnd);
+ }
+ // 1954772: isNADefault returns false for "IANA"
+ if("IANA".equalsIgnoreCase(na)) {
+ namingAuthority = "";
+ // remove "iana" from type so toString() is consistent
+ type = type.substring(0, namingStart - 1) + type.substring(namingStart + 4, type.length());
+ } else {
+ namingAuthority = na;
+ }
+ } 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 "".equals(namingAuthority);
+ }
+
+ /**
+ * 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;
+
+ if (!isAbstract && t.isAbstract){
+ return toString().startsWith(t.toString());
+ }
+
+
+ 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;
+ }
+
+}
Propchange: directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceType.java
------------------------------------------------------------------------------
svn:mime-type = text/plain