de.fhg.igd.atlas.lsp
Class LSPRequest

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byjava.util.ArrayList
              extended bycodec.asn1.ASN1AbstractCollection
                  extended bycodec.asn1.ASN1Sequence
                      extended byde.fhg.igd.atlas.lsp.LSPRequest
All Implemented Interfaces:
ASN1Collection, ASN1Type, Cloneable, Collection, List, RandomAccess, Resolver, Serializable

public class LSPRequest
extends ASN1Sequence
implements Resolver

Represents an LSP_Request structure of the Location Service Protocol (LSP). This class encapsulates a request of the LSP as message body with additional information about the corresponding message type and the used protocol version.

The ASN.1 structure of the request is as follows

 LSP_Request := SEQUENCE
 {
   version   INTEGER {lspVer1(1)} (lspVer1),
 
   requestType   INTEGER
   {
     lookup(1),
     registerPlain(2),
     registerEncrypted(3),
     registerEncoded(4),
     refresh(5),
     list(6),
     proxyInvalidate(7),
   },
 
   requestBody   ANY DEFINED BY requestType OPTIONAL
 }
 
The Location Service Client (LSClient) can create an instance of this class by calling the public constructor, encode it by calling getEncoded and send it to the Location Service Server (LSServer) or Location Service Proxy (LSProxy). The LSServer respectively the LSProxy can decode the received request by calling createRequest.

Version:
"$Id: LSPRequest.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Jan Peters
See Also:
LSPReply, LSPLookup, LSPRegisterPlain, LSPRegisterEncoded, LSPRegisterEncrypted, LSPRefresh, LSPList, LSPProxyInvalidate, Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.util.AbstractList
 
Field Summary
protected  ASN1Type body_
          The request body.
static int LIST
          Message type for a LSPList request.
static int LOOKUP
          Message type for a LSPLookup request.
static int PROXY_INVALIDATE
          Message type for a LSPProxyInvalidate request.
static int REFRESH
          Message type for a LSPRefresh request.
static int REGISTER_ENCODED
          Message type for a LSPRegisterEncoded request.
static int REGISTER_ENCRYPTED
          Message type for a LSPRegisterEncrypted request.
static int REGISTER_PLAIN
          Message type for a LSPRegisterPlain request.
protected  ASN1Integer type_
          The request type.
static int VERSION
          The current version of the Location Service Protocol supported by this class.
protected  ASN1Integer version_
          The version number of this request.
 
Fields inherited from class codec.asn1.ASN1AbstractCollection
 
Fields inherited from class java.util.ArrayList
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
private LSPRequest()
          Creates an instance ready for decoding.
  LSPRequest(int type, ASN1Type body)
          Creates an request instance of the given type with the given body.
 
Method Summary
static LSPRequest createRequest(byte[] code)
          Creates a new request from the given encoded request.
static LSPRequest createRequest(InputStream in, int limit)
          Creates a new request from the encoded request, which will be read from the specified input stream.
 ASN1Type getBody()
          Returns the request body.
 byte[] getEncoded()
          Returns the DER encoded request.
 int getType()
          Returns the request type.
 String getTypeString()
          Returns the string representation of the request type.
 int getVersion()
          Returns the request version.
 ASN1Type resolve(ASN1Type caller)
          Returns the supposed ASN1Type of the request body, corresponding to the current request type.
 String toString()
          Returns the string representation of this request.
 
Methods inherited from class codec.asn1.ASN1Sequence
getTag
 
Methods inherited from class codec.asn1.ASN1AbstractCollection
checkConstraints, decode, encode, getCollection, getConstraint, getTagClass, getValue, isExplicit, isOptional, isType, setConstraint, setExplicit, setOptional
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, remove, removeAll, retainAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList
 

Field Detail

VERSION

public static final int VERSION
The current version of the Location Service Protocol supported by this class.

See Also:
Constant Field Values

LOOKUP

public static final int LOOKUP
Message type for a LSPLookup request.

See Also:
Constant Field Values

REGISTER_PLAIN

public static final int REGISTER_PLAIN
Message type for a LSPRegisterPlain request.

See Also:
Constant Field Values

REGISTER_ENCRYPTED

public static final int REGISTER_ENCRYPTED
Message type for a LSPRegisterEncrypted request.

See Also:
Constant Field Values

REGISTER_ENCODED

public static final int REGISTER_ENCODED
Message type for a LSPRegisterEncoded request.

See Also:
Constant Field Values

REFRESH

public static final int REFRESH
Message type for a LSPRefresh request.

See Also:
Constant Field Values

LIST

public static final int LIST
Message type for a LSPList request.

See Also:
Constant Field Values

PROXY_INVALIDATE

public static final int PROXY_INVALIDATE
Message type for a LSPProxyInvalidate request.

See Also:
Constant Field Values

version_

protected ASN1Integer version_
The version number of this request.


type_

protected ASN1Integer type_
The request type.


body_

protected ASN1Type body_
The request body.

Constructor Detail

LSPRequest

private LSPRequest()
Creates an instance ready for decoding. This can only be built within the createRequest method to decode a given encoded request.


LSPRequest

public LSPRequest(int type,
                  ASN1Type body)
           throws InvalidMessageTypeException,
                  NullPointerException
Creates an request instance of the given type with the given body.

Parameters:
type - The request type.
body - The request body
Throws:
InvalidMessageTypeException - if the given request type is not supported (RuntimeException).
NullPointerException - if body is null (RuntimeException).
Method Detail

createRequest

public static LSPRequest createRequest(byte[] code)
                                throws CorruptedCodeException,
                                       WrongProtocolVersionException,
                                       InvalidMessageTypeException,
                                       IllegalStateException,
                                       NullPointerException
Creates a new request from the given encoded request.

Parameters:
code - The encoded request.
Returns:
The decoded request.
Throws:
CorruptedCodeException - if the code is bad.
WrongProtocolVersionException - if the protocol version does not match with the expected one (RuntimeException).
InvalidMessageTypeException - if the message type of the request is not supported (RuntimeException).
IllegalStateException - if an error occurs while decoding with DERDecoder (RuntimeException).
NullPointerException - if code is null (RuntimeException).

createRequest

public static LSPRequest createRequest(InputStream in,
                                       int limit)
                                throws CorruptedCodeException,
                                       WrongProtocolVersionException,
                                       InvalidMessageTypeException,
                                       IllegalStateException,
                                       NullPointerException
Creates a new request from the encoded request, which will be read from the specified input stream. If the encoded request is longer than the specified limit of bytes, an IllegalStateException will be thrown.

Returns:
The decoded request.
Throws:
CorruptedCodeException - if the code is bad.
WrongProtocolVersionException - if the protocol version does not match with the expected one (RuntimeException).
InvalidMessageTypeException - if the message type of the request is not supported (RuntimeException).
IllegalStateException - if an error occurs while decoding with DERDecoder (RuntimeException).
NullPointerException - if code is null (RuntimeException).

resolve

public ASN1Type resolve(ASN1Type caller)
                 throws ResolverException
Returns the supposed ASN1Type of the request body, corresponding to the current request type.

Specified by:
resolve in interface Resolver
Parameters:
caller - The caller of this method.
Returns:
The ASN1Type of the request body.
Throws:
ResoverException - if the current request type is not supported.
ResolverException

getVersion

public int getVersion()
Returns the request version.

Returns:
The request version.

getType

public int getType()
Returns the request type.

Returns:
The request type.

getBody

public ASN1Type getBody()
Returns the request body.

Returns:
The request body.

getEncoded

public byte[] getEncoded()
                  throws IllegalStateException
Returns the DER encoded request.

Returns:
The encoded request.
Throws:
IllegalStateException - if an exception occures during ASN1 encoding (RuntimeException).

getTypeString

public String getTypeString()
Returns the string representation of the request type.

Returns:
The string representation.

toString

public String toString()
Returns the string representation of this request. This is done in following manner
 ASN1StructureName {
 Property  : Value
 }
 

Returns:
The string representation.


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.