irssibot.user
Class User

java.lang.Object
  |
  +--irssibot.user.User

public class User
extends java.lang.Object

Represents a user in bot's userbase. Instances of ServerConnection keep a list of User objects.

Version:
$Name: $ $Revision: 1.5 $
Author:
Matti Dahlbom
See Also:
ServerConnection

Field Summary
private  java.util.Hashtable channels
           
private  boolean dynamic
           
private  java.util.Vector hosts
           
private  boolean isGlobalAdmin
           
private static long loginExpirationTime
           
private  Host loginHost
          This is the host that a dynamic user had when doing login.
private  long loginTime
           
private  java.lang.String name
           
private  java.lang.String password
           
 
Constructor Summary
User(java.lang.String name, java.lang.String globalFlags)
           
 
Method Summary
 boolean addChannelInfo(UserChannelInfo channelInfo)
          tries to add UserChannelInfo to channels hash table.
 void addHost(Host host)
          adds a single hostmask to user
 void addHosts(java.util.Vector maskStrings)
          Takes a Vector of Strings representings host masks as argument, and store the hosts into another Vector as Host objects.
private  void checkHosts()
          Look through hostmasks.
 boolean delHost(Host host)
          Deletes a single hostmask from user.
 void doLogin(Host host)
          attempts to login a user with password.
 void doLogout()
          Attempts to login a user with password.
 java.lang.String getChannelFlags(java.lang.String channelName)
          returns the channel flags string for user on channel.
 UserChannelInfo getChannelInfo(java.lang.String channelName)
          finds and returns channel info or null if not specified.
 java.util.Hashtable getChannels()
          Contains UserChannelInfo objects with channel names as keys
 java.lang.String getGlobalFlags()
           
 java.util.Vector getHosts()
           
 Host getLoginHost()
           
 java.lang.String getName()
           
 int getNumChannels()
           
 java.lang.String getPassword()
           
 java.lang.String getXML()
          get User info dump as XML in the following form:
 boolean hasMatchingHost(Host host)
          Checks if user has a matching host.
 boolean isChanAdmin(java.lang.String channelName)
          checks if user has A flag for channel.
 boolean isDynamic()
           
 boolean isGlobalAdmin()
          checks if user is a global admin
 boolean isLoggedIn()
          Checks whether a user has logged in and that the logon has not expired.
 boolean isOp(java.lang.String channelName)
          Checks if user has o flag for channel.
 boolean isVoice(java.lang.String channelName)
          checks if user has v flag for channel.
 void processGlobalFlagsString(java.lang.String globalFlags)
          go through global flags string and turn on indicated global flags
 boolean removeChannelInfo(java.lang.String channelName)
          tries to remove a UserChannelInfo from channels hash table.
 void setPassword(java.lang.String password)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loginExpirationTime

private static final long loginExpirationTime
See Also:
Constant Field Values

name

private java.lang.String name

password

private java.lang.String password

loginHost

private Host loginHost
This is the host that a dynamic user had when doing login.


channels

private java.util.Hashtable channels

hosts

private java.util.Vector hosts

loginTime

private long loginTime

isGlobalAdmin

private boolean isGlobalAdmin

dynamic

private boolean dynamic
Constructor Detail

User

public User(java.lang.String name,
            java.lang.String globalFlags)
Method Detail

getChannels

public java.util.Hashtable getChannels()
Contains UserChannelInfo objects with channel names as keys


getHosts

public java.util.Vector getHosts()

getName

public java.lang.String getName()

getPassword

public java.lang.String getPassword()

getLoginHost

public Host getLoginHost()

isDynamic

public boolean isDynamic()

doLogin

public void doLogin(Host host)
attempts to login a user with password.


doLogout

public void doLogout()
Attempts to login a user with password.


isLoggedIn

public boolean isLoggedIn()
Checks whether a user has logged in and that the logon has not expired.

Returns:
  • true if logged in
  • false if expired/not logged in

checkHosts

private void checkHosts()
Look through hostmasks. If a host with wildcard * found, mark the user dynamic.


addHosts

public void addHosts(java.util.Vector maskStrings)
Takes a Vector of Strings representings host masks as argument, and store the hosts into another Vector as Host objects.

Parameters:
maskStrings - input hosts

delHost

public boolean delHost(Host host)
Deletes a single hostmask from user.

Parameters:
host - host to be deleted
Returns:
  • true if successful
  • false if not found

addHost

public void addHost(Host host)
adds a single hostmask to user

Parameters:
host - hostmask to add

getNumChannels

public int getNumChannels()

getGlobalFlags

public java.lang.String getGlobalFlags()

setPassword

public void setPassword(java.lang.String password)

hasMatchingHost

public boolean hasMatchingHost(Host host)
Checks if user has a matching host.

Parameters:
host - host to match against
Returns:
true if user has a matching host

getChannelFlags

public java.lang.String getChannelFlags(java.lang.String channelName)
returns the channel flags string for user on channel.

Parameters:
channelName - name of channel
Returns:
flags string

isOp

public boolean isOp(java.lang.String channelName)
Checks if user has o flag for channel. Dynamic users must be logged in.

Parameters:
channelName - name of channel
Returns:
true/false

isVoice

public boolean isVoice(java.lang.String channelName)
checks if user has v flag for channel. dyn users must be logged in.

Parameters:
channelName - name of channel
Returns:
true/false

isChanAdmin

public boolean isChanAdmin(java.lang.String channelName)
checks if user has A flag for channel. dyn users must be logged in.

Parameters:
channelName - name of channel
Returns:
true/false

isGlobalAdmin

public boolean isGlobalAdmin()
checks if user is a global admin

Returns:
true/false

getXML

public java.lang.String getXML()
get User info dump as XML in the following form:

mask1 mask2

Returns:
XML dump as string

removeChannelInfo

public boolean removeChannelInfo(java.lang.String channelName)
tries to remove a UserChannelInfo from channels hash table.

Parameters:
channelName - name of removed channel
Returns:
    true if successful
      false if no such channel info defined

addChannelInfo

public boolean addChannelInfo(UserChannelInfo channelInfo)
tries to add UserChannelInfo to channels hash table.

Parameters:
channelInfo - UserChannelInfo
Returns:
    false if channelInfo already exists in hash table
      true otherwise

getChannelInfo

public UserChannelInfo getChannelInfo(java.lang.String channelName)
finds and returns channel info or null if not specified.

Returns:
channel info

processGlobalFlagsString

public void processGlobalFlagsString(java.lang.String globalFlags)
go through global flags string and turn on indicated global flags

Parameters:
globalFlags - global flags string


IrssiBot (c) 2000-2002 Matti Dahlbom