de.fhg.igd.atlas.core
Class ServerInfo

java.lang.Object
  extended byde.fhg.igd.atlas.core.ServerInfo

public class ServerInfo
extends Object

Encapsulates the functionality needed to map implicit names of mobile objects to a corresponding Location Service Server (LSServer), which is responsible for storing their current locations then.

The location service defines a plain infrastructure of different LSServer which can be described through the three properties prefix mask, distinguished name and URL. Moreover a certificate for each server is needed which supports encryption of Location Service Protocol (LSP) messages. To initialize these server properties a a LDAP server or a server configuration file is used.

The server on which the location of a certain mobile object will be registered depends on its implicit name in following manner:

An examples of an server configuration file follows now:

 ### LS-Server configuration file
 #
 # SeMoA Shell variables are available within this
 # configuration file as ${}.
 #


 # With PrefixBitLength you set the number of bits,
 # which are used to map implicit names to their corresponding LS-Server
 #
 #   PrefixBitLength = 3, means that the first three bits of an
 #                        implicit name (from the left) are used
 #                        to map it to its corresponding LS-Server
 #
 # In this case you need to specify 2^3=8 LS-Server.

 PrefixBitLength = 1


 # A new LS-Server is specified with following entries
 #
 #   x.ServerPrefix = up to 20 bytes long (hex), seperated by spaces
 #   x.ServerDN     = the distinguished name of the server
 #   x.ServerURL    = the url of the server (the potocol must be "lsp")
 #

 1.ServerPrefix = 00
 1.ServerDN     = CN=LSServer1,OU=SeMoA-NET,O=SeMoA,L=Darmstadt,ST=Hessen,C=DE
 1.ServerURL    = lsp://LSServer1.igd.fhg.de:50000

 2.ServerPrefix = 80
 2.ServerDN     = CN=LSServer2,OU=SeMoA-NET,O=SeMoA,L=Darmstadt,ST=Hessen,C=DE
 2.ServerURL    = lsp://LSServer2.igd.fhg.de:50000
 
An examples of an LDIF file for a LDAP server follows next. The entries have the same meaning as in the case of a configuration file.
 # Example of an ATLAS server configuration
 dn: cn=PrefixBitLength,ou=ATLAS,o=SeMoA,l=Darmstadt,st=Hessen,c=DE
 objectClass: prefixBitLength
 length: 1

 dn: cn=Atlas-Server-1,ou=ATLAS,o=SeMoA,l=Darmstadt,st=Hessen,c=DE
 objectClass: atlasServer
 labeledURI: lsp://lsserver1.igd.fhg.de:50000
 distinguishedName: CN=LSServer1,OU=SeMoA-NET,O=SeMoA,L=Darmstadt,ST=Hessen,C=DE
 description: Server1
 serverPrefix: 00

 dn: cn=Atlas-Server-2,ou=ATLAS,o=SeMoA,l=Darmstadt,st=Hessen,c=DE
 objectClass: atlasServer
 labeledURI: lsp://capricornus.igd.fhg.de:50000
 distinguishedName: CN=LSServer2,OU=SeMoA-NET,O=SeMoA,L=Darmstadt,ST=Hessen,C=DE
 description: Server2
 serverPrefix: 40
 

Version:
"$Id: ServerInfo.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Jan Peters
See Also:
CertFinder, LSClientService, LSPRequest

Field Summary
static byte[] BIT_MASK
          An array of bytes with following content, depending on the index (used to generate the serverPrefixBitMask_).
static int DATA_ENCIPHERMENT
          The key usage mask for data encipherment, which is used to find the right encryption key (see SERVER_KEY).
static int IMPLICIT_NAME_LENGTH
          The length of the implicit name (depends on the result of the hash algorithm, which is used to generate it).
static String LDAP_ATLAS_SERVER
          The prefix of the RDNs of the entries where the configuration data for each ATLAS server is stored.
static String LDAP_CONFIG_ROOT
          The root of the ATLAS configuration entries in the LDAP server.
static String LDAP_DN
          The name of the attribute where the distinguished name of an ATLAS server is stored.
static String LDAP_LENGTH
          The name of the attribute where the prefix bit length is stored.
static String LDAP_PREFIX_BIT_LENGTH
          The RDN of the entry where the prefix bit length is stored.
static String LDAP_SERVER_PREFIX
          The name of the attribute where the prefix of an ATLAS server is stored.
static String LDAP_URL
          The name of the attribute where the URL of an ATLAS server is stored.
protected  Name localDN_
          The distinguished name of a local server.
private static Logger log_
          The Logger instance for this class
static String SERVER_CODE_SUFFIX
          The common suffix of the server code properties in the server configuration file.
static String SERVER_DN_SUFFIX
          The common suffix of the server DN properties in the server configuration file.
static String SERVER_KEY
          The alias of the server key, which is used to encrypt LSP messages (see LSPRegisterEncrypted)
static String SERVER_PREFIX_BIT_LENGTH
          The name for the server prefix bit length property in the server configuration file.
static String SERVER_URL_SUFFIX
          The common suffix of the server URL properties in the server configuration file.
protected  SortedMap serverDN_
          The sorted map of initialized server DNs (see SERVER_DN_SUFFIX).
protected  int serverPrefixBitLength_
          The length of the server prefix counted in bits (see SERVER_PREFIX_BIT_LENGTH).
protected  byte[] serverPrefixBitMask_
          The server prefix bit mask (see BIT_MASK).
protected  SortedMap serverURL_
          The sorted map of initialized server URLs (see SERVER_URL_SUFFIX).
 
Constructor Summary
ServerInfo()
          Creates an instance of this class.
 
Method Summary
 LSServerService getLocalServer()
          Tries to locate a local LSServerService interface
 X509Certificate getServerCert(byte[] implicitName)
          Returns the server certificate of the LSServer corresponding to the given implicitName.
 Principal getServerDN(byte[] implicitName)
          Returns the server DN of the LSServer corresponding to the given implicitName.
 byte[] getServerPrefix(byte[] implicitName)
          Returns the server prefix of the LSServer corresponding to the given implicitName.
protected  byte[] getServerPrefixBitMask(int length)
          Generates the server prefix bit mask for the given server prefix bit length (see SERVER_PREFIX_BIT_LENGTH and BIT_MASK).
 URL getServerURL(byte[] implicitName)
          Returns the server URL of the LSServer corresponding to the given implicitName.
 boolean isLocal(byte[] implicitName)
          Checks if the LSServer corresponding to the given implicitName is a local server.
protected  boolean loadServerMappings(String filename)
          Parses the server configuration file of the given filename and replaces the current server settings with the new ones, if the file contains valid data and the constraints have been fulfilled.
protected  boolean loadServerMappings(URL ldapurl)
          Retrieves the server settings from the LDAP server with the given ldapurl and replaces the current server settings with the new ones, if the file contains valid data and the constraints have been fulfilled.
protected  boolean setServerPrefixLength(int length)
          Sets the server prefix bit length and generates the serverPrefixBitMask_ (see SERVER_PREFIX_BIT_LENGTH and BIT_MASK).
 String toString()
          Returns the string representation of this instance.
 String toStringServer()
          Returns the string representation of all initialized LSServer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log_

private static Logger log_
The Logger instance for this class


LDAP_CONFIG_ROOT

public static final String LDAP_CONFIG_ROOT
The root of the ATLAS configuration entries in the LDAP server.

See Also:
Constant Field Values

LDAP_PREFIX_BIT_LENGTH

public static final String LDAP_PREFIX_BIT_LENGTH
The RDN of the entry where the prefix bit length is stored.

See Also:
Constant Field Values

LDAP_LENGTH

public static final String LDAP_LENGTH
The name of the attribute where the prefix bit length is stored.

See Also:
Constant Field Values

LDAP_ATLAS_SERVER

public static final String LDAP_ATLAS_SERVER
The prefix of the RDNs of the entries where the configuration data for each ATLAS server is stored.

See Also:
Constant Field Values

LDAP_SERVER_PREFIX

public static final String LDAP_SERVER_PREFIX
The name of the attribute where the prefix of an ATLAS server is stored.

See Also:
Constant Field Values

LDAP_DN

public static final String LDAP_DN
The name of the attribute where the distinguished name of an ATLAS server is stored.

See Also:
Constant Field Values

LDAP_URL

public static final String LDAP_URL
The name of the attribute where the URL of an ATLAS server is stored.

See Also:
Constant Field Values

SERVER_KEY

public static final String SERVER_KEY
The alias of the server key, which is used to encrypt LSP messages (see LSPRegisterEncrypted)

See Also:
Constant Field Values

DATA_ENCIPHERMENT

public static final int DATA_ENCIPHERMENT
The key usage mask for data encipherment, which is used to find the right encryption key (see SERVER_KEY).

See Also:
Constant Field Values

BIT_MASK

public static final byte[] BIT_MASK
An array of bytes with following content, depending on the index (used to generate the serverPrefixBitMask_).
 BIT_MASK[i] = [ i times 1 | (8-i) times 0 ]
 


IMPLICIT_NAME_LENGTH

public static final int IMPLICIT_NAME_LENGTH
The length of the implicit name (depends on the result of the hash algorithm, which is used to generate it).

See Also:
Constant Field Values

SERVER_PREFIX_BIT_LENGTH

public static final String SERVER_PREFIX_BIT_LENGTH
The name for the server prefix bit length property in the server configuration file. This property is used to determine the number of bits within the implicit names, which are relevant for the mapping between implicit names and the LSServer.

Following constraint has to be fulfilled:

 0 <= serverPrefixBitLength <= IMPLICIT_NAME_LENGTH
 

See Also:
Constant Field Values

SERVER_CODE_SUFFIX

public static final String SERVER_CODE_SUFFIX
The common suffix of the server code properties in the server configuration file. These properties contain a bit mask, which is used to map implicit names to the LSServer.

See Also:
Constant Field Values

SERVER_DN_SUFFIX

public static final String SERVER_DN_SUFFIX
The common suffix of the server DN properties in the server configuration file. These properties contain the distinguished name of the LSServer, which are used to obtain the corresponding encryption keys and certificates of the servers.

See Also:
Constant Field Values

SERVER_URL_SUFFIX

public static final String SERVER_URL_SUFFIX
The common suffix of the server URL properties in the server configuration file. These properties contain the URL of the LSServer, which is used as communication port for the Location Service Protocol.

See Also:
Constant Field Values

serverPrefixBitLength_

protected int serverPrefixBitLength_
The length of the server prefix counted in bits (see SERVER_PREFIX_BIT_LENGTH).


serverPrefixBitMask_

protected byte[] serverPrefixBitMask_
The server prefix bit mask (see BIT_MASK).


serverURL_

protected SortedMap serverURL_
The sorted map of initialized server URLs (see SERVER_URL_SUFFIX).


serverDN_

protected SortedMap serverDN_
The sorted map of initialized server DNs (see SERVER_DN_SUFFIX).


localDN_

protected Name localDN_
The distinguished name of a local server.

Constructor Detail

ServerInfo

public ServerInfo()
Creates an instance of this class. To initialize the server URLs (serverURL_) and server DNs (serverDN_), loadServerMappings() has to be called.

Method Detail

loadServerMappings

protected boolean loadServerMappings(URL ldapurl)
Retrieves the server settings from the LDAP server with the given ldapurl and replaces the current server settings with the new ones, if the file contains valid data and the constraints have been fulfilled.

Parameters:
ldapurl - The URL of the LDAP server with the server configuration data.
Returns:
true if server setting have been initialized successfully; false otherwise.

loadServerMappings

protected boolean loadServerMappings(String filename)
Parses the server configuration file of the given filename and replaces the current server settings with the new ones, if the file contains valid data and the constraints have been fulfilled.

Parameters:
filename - The name of the server configuration file.
Returns:
true if server setting have been initialized successfully; false otherwise.

setServerPrefixLength

protected boolean setServerPrefixLength(int length)
Sets the server prefix bit length and generates the serverPrefixBitMask_ (see SERVER_PREFIX_BIT_LENGTH and BIT_MASK).

Parameters:
length - The server prefix bit length.
Returns:
true if length is valid; false otherwise.

getServerPrefixBitMask

protected byte[] getServerPrefixBitMask(int length)
Generates the server prefix bit mask for the given server prefix bit length (see SERVER_PREFIX_BIT_LENGTH and BIT_MASK).

Parameters:
length - The server prefix bit length.
Returns:
The server prefix bit mask or null if length is not valid.

getServerPrefix

public byte[] getServerPrefix(byte[] implicitName)
                       throws IllegalArgumentException
Returns the server prefix of the LSServer corresponding to the given implicitName.

Parameters:
implicitName - The implicit name.
Returns:
The server prefix.
Throws:
IllegalArgumentException - if the implicitName does not have the right length.

getServerDN

public Principal getServerDN(byte[] implicitName)
Returns the server DN of the LSServer corresponding to the given implicitName.

Parameters:
implicitName - The implicit name.
Returns:
The server DN or null if an error occured.

getServerURL

public URL getServerURL(byte[] implicitName)
Returns the server URL of the LSServer corresponding to the given implicitName.

Parameters:
implicitName - The implicit name.
Returns:
The server DN or null if an error occured.

getServerCert

public X509Certificate getServerCert(byte[] implicitName)
Returns the server certificate of the LSServer corresponding to the given implicitName.

Parameters:
implicitName - The implicit name.
Returns:
The server DN or null if an error occured.

isLocal

public boolean isLocal(byte[] implicitName)
Checks if the LSServer corresponding to the given implicitName is a local server. This is done by comparing the local DN with the server DN (It is possible that the LSServer runs within another SeMoA-Platform: isLocal returns true, but getLocalServer returns null).

Parameters:
implicitName - The implicit name.
Returns:
true if the LSServer corresponding to implicitNameis a local server; false otherwise.

getLocalServer

public LSServerService getLocalServer()
Tries to locate a local LSServerService interface

Returns:
The LSServerService interface if found; null otherwise.

toStringServer

public String toStringServer()
Returns the string representation of all initialized LSServer.

Returns:
The string representation.

toString

public String toString()
Returns the string representation of this instance.

Returns:
The string representation.


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.