FTP-Server API

server
Class Conf

java.lang.Object
  |
  +--server.Conf

public class Conf
extends Object

The configuration file setup.conf is read though this class. The class contains a number of servicemethods to fetch different values through the configurationfile.


Method Summary
static void addObserver(ConfObserver co)
           
static void addUser(String name, String login, String pass)
          Adds a new user to the 'Users' tag.
static void banAddress(InetAddress address)
          Banns an IP-address, by writing it into the configurationfile.
static XMLTag[] concat(XMLTag[] newArr, XMLTag[] oldArr)
          Concatinates to arrays of XMLTags. oldArr will be first in the new array, and newArr last.
static String[] getActiveCommands()
          Gets all active commands.
static String getCheckIniterval()
          How often the server should check the clients for beeing passive
static int getCommandUsage(String name)
           
static XMLTag[] getDirectoriesFromUser(XMLTag user)
          All directories tags for a user and its usergroups.
static XMLTag[] getGroups()
          Looks for usergroups in 'Users.Usergroup'
static Conf getInstance()
          Returns a singleton of this class.
static int getLineCapacity()
          The maxupload of the server.
static int getMaxUsers()
          The maximum number of uses on the server.
static int[] getPassivPorts()
          The initerval of ports, that may be used by passiv filetransfer.
static XMLTag getRoot()
          Returns the entire "root" of the server.
static String getServerIP()
          The ip, that is informed the client by a 'pasv' command.
static int getServerPort()
          The port the server is configured to start up on.
static int getSession()
          Gets the sessionnumber on the server.
static String getUserOption(XMLTag t, String option)
          Seeks out an users option.
static XMLTag[] getUsers()
          Searches for users i in both 'Users.User' and 'Users.Usergroup'.
static boolean isBanned(Socket client)
          Finds out if the IP, that this socket is connected to is banned.
static boolean isBanned(String ipAddress)
          Finds out if the IP address, that is passed is banned from this server.
static boolean IsIntelligenceActive()
          Is server intelligence for kicking and banning clients turned on?
static void reload()
          Discards the current state of the configurationfile [setup.xml], and reads the old configuration into the servers memory.
static boolean removeObserver(ConfObserver co)
           
static void save()
          Saves the configurationfiles current state onto the harddrive.
static void setActiveCommands(String[] commands)
          Sets the active commands.
static void setCheckIniterval(String time)
          Sets the how often the server should check the clients for beeing passive
static void setCommandUsage(String name, int val)
           
static void setIntelligenceActive(boolean active)
          Sets server intelligence for kicking and banning active
static void setSession(int seNr)
          Sets the value in the 'Memory.sessions'
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addObserver

public static void addObserver(ConfObserver co)

removeObserver

public static boolean removeObserver(ConfObserver co)

getRoot

public static XMLTag getRoot()
Returns the entire "root" of the server. Amongst other things, the tag contains the Server-Tag.

Returns:
root.

getCheckIniterval

public static String getCheckIniterval()
How often the server should check the clients for beeing passive

Returns:
00:05:00 if no tag is found (the tag is also added i this case)

setCheckIniterval

public static void setCheckIniterval(String time)
Sets the how often the server should check the clients for beeing passive

Parameters:
time - eg. 00:05:00

IsIntelligenceActive

public static boolean IsIntelligenceActive()
Is server intelligence for kicking and banning clients turned on?

Returns:
false if no tag is found (the tag is also added i this case)

setIntelligenceActive

public static void setIntelligenceActive(boolean active)
Sets server intelligence for kicking and banning active

Parameters:
active - on/off

getCommandUsage

public static int getCommandUsage(String name)
                           throws Exception
Exception

setCommandUsage

public static void setCommandUsage(String name,
                                   int val)

getActiveCommands

public static String[] getActiveCommands()
Gets all active commands. These commands are the ones the client must use if he does not want to be kicked when serverintelligence is turned on.

Returns:
String[] {List, Retr, ect...}

setActiveCommands

public static void setActiveCommands(String[] commands)
Sets the active commands. These commands are the ones the client must use if he does not want to be kicked when serverintelligence is turned on.

Parameters:
commands - String[] {List, Retr, ect...}

getUsers

public static XMLTag[] getUsers()
Searches for users i in both 'Users.User' and 'Users.Usergroup'.

Returns:
all the servers users

getGroups

public static XMLTag[] getGroups()
Looks for usergroups in 'Users.Usergroup'

Returns:
all usergroups on the server.

concat

public static XMLTag[] concat(XMLTag[] newArr,
                              XMLTag[] oldArr)
Concatinates to arrays of XMLTags. oldArr will be first in the new array, and newArr last.

Parameters:
newArr - The new array, that should be added to the old array
oldArr - the old array
Returns:
The to arrays concatinated to a single array.

addUser

public static void addUser(String name,
                           String login,
                           String pass)
Adds a new user to the 'Users' tag.

Parameters:
name - The users name (for reference use)
login - loginnavn
pass - password

getServerPort

public static int getServerPort()
The port the server is configured to start up on.

Returns:
Configured port, or 21 if not port is found.

getSession

public static int getSession()
Gets the sessionnumber on the server. If the session number isn't found, 0 are returned, and the tag 'Memory' with option 'sessions' 0 are added to the setup.conf file

Returns:
sessionnumber or 0.

setSession

public static void setSession(int seNr)
Sets the value in the 'Memory.sessions'

Parameters:
seNr - sessionnumber.

getServerIP

public static String getServerIP()
The ip, that is informed the client by a 'pasv' command.

Returns:
ip / null if not found

getPassivPorts

public static int[] getPassivPorts()
The initerval of ports, that may be used by passiv filetransfer. If nothing is found the initerval 1025-65536 is returned (both ports included)

Returns:
{startport,endport}

getMaxUsers

public static int getMaxUsers()
The maximum number of uses on the server.

Returns:
10.000 if nothing is found.

getUserOption

public static String getUserOption(XMLTag t,
                                   String option)
Seeks out an users option. If it isn't found, the search goes on in the 'Usergroup', and then in the 'Server' tag

Parameters:
t - The users tag
option - The option that is seeked after
Returns:
An empty string ("") if nothing else is found.

getDirectoriesFromUser

public static XMLTag[] getDirectoriesFromUser(XMLTag user)
All directories tags for a user and its usergroups. The users own directories are first in the returned array!

Parameters:
user - the users tag
Returns:
if nothing is found, XMLTag[0] are returned...

isBanned

public static boolean isBanned(Socket client)
Finds out if the IP, that this socket is connected to is banned.

Parameters:
client - Socket to client
Returns:
true, if banned!

isBanned

public static boolean isBanned(String ipAddress)
Finds out if the IP address, that is passed is banned from this server.

Parameters:
ipAddress - fx. 127.0.0.1
Returns:
true, if banned!

banAddress

public static void banAddress(InetAddress address)
Banns an IP-address, by writing it into the configurationfile.

Parameters:
address - The IP-address!

getLineCapacity

public static int getLineCapacity()
The maxupload of the server. Used for grahical purposes only!

Returns:
liniekapacity or 100.000 KB if not found

save

public static void save()
Saves the configurationfiles current state onto the harddrive.


reload

public static void reload()
Discards the current state of the configurationfile [setup.xml], and reads the old configuration into the servers memory. All changes that have not been saved are lost!


getInstance

public static Conf getInstance()
Returns a singleton of this class. Actually this isn't necessary, as all methods in the class are declared static.

Returns:
Conf instans.

FTP-Server API