xmlBlaster 2.2.0 API

org.xmlBlaster.authentication
Class Authenticate

java.lang.Object
  extended by org.xmlBlaster.authentication.Authenticate
All Implemented Interfaces:
java.util.EventListener, I_RunlevelListener

public final class Authenticate
extends java.lang.Object
implements I_RunlevelListener

Authenticate a client via login.

The login method serves as a factory for a xmlBlaster.Server Reference


Field Summary
private  boolean acceptWrongSenderAddress
           
private  java.util.Set<I_ClientListener> clientListenerSet
          For listeners who want to be informed about login/logout
private  long counter
          Unique counter to generate IDs
private  ServerScope glob
           
private static java.util.logging.Logger log
           
private  java.util.Map<java.lang.String,SubjectInfo> loginNameSubjectInfoMap
          With this map you can find a client using his login name.
private  java.lang.String ME
           
private  PluginManager plgnLdr
           
private  java.util.Map<java.lang.String,SessionInfo> sessionInfoMap
          With this map you can find a client using a sessionId.
private  I_XmlBlaster xmlBlasterImpl
          The singleton handle for this xmlBlaster server
 
Constructor Summary
Authenticate(ServerScope global)
           
 
Method Summary
 void addClientListener(I_ClientListener l)
          Adds the specified client listener to receive login/logout events.
 void changeSecretSessionId(java.lang.String oldSessionId, java.lang.String newSessionId)
          Replace the old by the new session id
 SessionInfo check(java.lang.String secretSessionId)
          Use this method to check a clients authentication.
 ConnectReturnQosServer connect(ConnectQosServer xmlQos)
          Login to xmlBlaster.
 ConnectReturnQosServer connect(ConnectQosServer connectQos, java.lang.String forcedSecretSessionId)
          Login to xmlBlaster.
 void connectionState(java.lang.String secretSessionId, ConnectionStateEnum state)
          Helper method where protocol layers may report a lost connection (e.g.
private  java.lang.String createSessionId(java.lang.String loginName)
          Generate a unique (and secret) resource ID
 void disconnect(java.lang.String secretSessionId, java.lang.String qos_literal)
           
private  void fireClientEvent(SessionInfo sessionInfo, boolean login)
          Used to fire an event if a client does a login / logout
private  void firePreRemovedClientEvent(SessionInfo sessionInfo)
           
 java.lang.String getClientList()
          For JMX MBean: These are the login names returned, every client may be logged in multiple times which you can't see here
private  I_ClientListener[] getClientListenerArr()
          Returns a current snapshot of all ClientListeners
 ServerScope getGlobal()
           
 int getMaxClients()
          For JMX MBean: The maximum number of different users, the sessions may be higher
 int getMaxSubjects()
           
 java.lang.String getName()
          Enforced by I_RunlevelListener
 int getNumClients()
          For JMX MBean: The number of different users, the sessions may be higher
 int getNumSubjects()
           
private  SessionInfo getOrCreateSessionInfo(SessionName sessionName, ConnectQosServer connectQos)
          Blocks for existing SessionInfo until it is initialized.
 SubjectInfo getOrCreateSubjectInfoByName(SessionName subjectName, boolean returnLocked, I_Subject subjectCtx, CbQueueProperty prop)
          Access a subjectInfo with the unique login name.
 SessionInfo getSessionInfo(SessionName sessionName)
          Find a session by its login name and pubSessionId or return null if not found
private  SessionInfo getSessionInfo(java.lang.String secretSessionId)
          Access a sessionInfo with the unique secretSessionId.
 SessionInfo[] getSessionInfoArr()
          Returns a current snapshot of all sessions, never returns null.
 SessionInfo getSessionInfoByName(SessionName sessionName)
           
 java.util.Map getSessionInfoMap()
          Just to testing sync
 SubjectInfo[] getSubjectInfoArr()
          Get a current snapshot of all known subjects.
 SubjectInfo getSubjectInfoByName(SessionName subjectName)
          Access a subjectInfo with the unique login name
 java.lang.String getSubjectList()
          Access a list of login names e.g.
 java.lang.String[] getSubjects()
          Access a list of login names e.g.
 I_XmlBlaster getXmlBlaster()
          Access the xmlBlaster singleton.
 boolean isAcceptWrongSenderAddress(SessionInfo sessionInfo)
          Authorization check (TODO: generic approach)
private  boolean isKnownInSessionInfoMap(java.lang.String previousSecretSessionId)
           
 java.lang.String login(java.lang.String loginName, java.lang.String passwd, java.lang.String xmlQoS_literal, java.lang.String secretSessionId)
           
 void logout(java.lang.String secretSessionId)
          Logout of a client.
 void removeClientListener(I_ClientListener l)
          Removes the specified listener
(package private)  void removeLoginName(SubjectInfo subjectInfo)
          Remove a SubjectInfo instance.
private  void resetSessionInfo(SessionInfo sessionInfo, boolean clearQueue, boolean forceShutdownEvenIfEntriesExist, boolean isDisconnecting)
           
 void runlevelChange(int from, int to, boolean force)
          Invoked on run level change, see RunlevelManager.RUNLEVEL_HALTED and RunlevelManager.RUNLEVEL_RUNNING

Enforced by I_RunlevelListener

 boolean sessionExists(java.lang.String secretSessionId)
           
 void setAcceptWrongSenderAddress(boolean acceptWrongSenderAddress)
           
 java.lang.String toXml()
          Dump state of this object into a XML ASCII string.
 java.lang.String toXml(java.lang.String extraOffset)
          Dump state of this object into a XML ASCII string.
 SessionInfo unsecureCreateSession(ConnectQos connectQos)
          Use this to create a user and session for internal users only.
private  void updateConnectQos(SessionInfo sessionInfo, ConnectQosServer newConnectQos)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ME

private final java.lang.String ME

plgnLdr

private final PluginManager plgnLdr

counter

private long counter
Unique counter to generate IDs


glob

private final ServerScope glob

log

private static java.util.logging.Logger log

sessionInfoMap

private final java.util.Map<java.lang.String,SessionInfo> sessionInfoMap
With this map you can find a client using a sessionId. key = sessionId A unique identifier value = SessionInfo object, containing all data about a client


loginNameSubjectInfoMap

private final java.util.Map<java.lang.String,SubjectInfo> loginNameSubjectInfoMap
With this map you can find a client using his login name. key = loginName, the unique login name of a client value = SessionInfo object, containing all data about a client


clientListenerSet

private final java.util.Set<I_ClientListener> clientListenerSet
For listeners who want to be informed about login/logout


xmlBlasterImpl

private final I_XmlBlaster xmlBlasterImpl
The singleton handle for this xmlBlaster server


acceptWrongSenderAddress

private boolean acceptWrongSenderAddress
Constructor Detail

Authenticate

public Authenticate(ServerScope global)
             throws XmlBlasterException
Throws:
XmlBlasterException
Method Detail

getSessionInfoMap

public java.util.Map getSessionInfoMap()
Just to testing sync

Returns:

getGlobal

public ServerScope getGlobal()

getXmlBlaster

public I_XmlBlaster getXmlBlaster()
Access the xmlBlaster singleton.


login

public java.lang.String login(java.lang.String loginName,
                              java.lang.String passwd,
                              java.lang.String xmlQoS_literal,
                              java.lang.String secretSessionId)
                       throws XmlBlasterException
Throws:
XmlBlasterException

unsecureCreateSession

public SessionInfo unsecureCreateSession(ConnectQos connectQos)
                                  throws XmlBlasterException
Use this to create a user and session for internal users only. This method is a security risk never allow external code to call it (there is no passwd needed). Note that the security instances are created rawish, they are not registered with the Authentication server.

Throws:
XmlBlasterException

connect

public final ConnectReturnQosServer connect(ConnectQosServer xmlQos)
                                     throws XmlBlasterException
Login to xmlBlaster.

Throws:
XmlBlasterException

isKnownInSessionInfoMap

private boolean isKnownInSessionInfoMap(java.lang.String previousSecretSessionId)

connect

public final ConnectReturnQosServer connect(ConnectQosServer connectQos,
                                            java.lang.String forcedSecretSessionId)
                                     throws XmlBlasterException
Login to xmlBlaster. If no secretSessionId==null, the secretSessionId from xmlQoS_literal is used, if this is null as well, we generate one.

The given secretSessionId (in the qos) from the client could be from e.g. a2Blaster, and will be used here as is, the a2Blaster plugin verifies it. The extra parameter secretSessionId is the CORBA internal POA session id.

Parameters:
connectQos - The login/connect QoS, see ConnectQosServer.java
secretSessionId - The caller (here CORBA-POA protocol driver or SessionPersistencePlugin) may insist to you its own secretSessionId
Throws:
XmlBlasterException

disconnect

public final void disconnect(java.lang.String secretSessionId,
                             java.lang.String qos_literal)
                      throws XmlBlasterException
Throws:
XmlBlasterException

getOrCreateSubjectInfoByName

public final SubjectInfo getOrCreateSubjectInfoByName(SessionName subjectName,
                                                      boolean returnLocked,
                                                      I_Subject subjectCtx,
                                                      CbQueueProperty prop)
                                               throws XmlBlasterException
Access a subjectInfo with the unique login name.

If the client is yet unknown, there will be instantiated a dummy SubjectInfo object

Parameters:
returnLocked - true: The SubjectInfo is locked
prop - Can be null
Returns:
the SubjectInfo object, is never null
Throws:
the - SubjectInfo object is never locked in such a case
XmlBlasterException

removeLoginName

void removeLoginName(SubjectInfo subjectInfo)
Remove a SubjectInfo instance.


getNumSubjects

public int getNumSubjects()

getSubjectInfoByName

public final SubjectInfo getSubjectInfoByName(SessionName subjectName)
Access a subjectInfo with the unique login name

Returns:
the SubjectInfo object
null if not found

getSessionInfoByName

public final SessionInfo getSessionInfoByName(SessionName sessionName)

changeSecretSessionId

public final void changeSecretSessionId(java.lang.String oldSessionId,
                                        java.lang.String newSessionId)
                                 throws XmlBlasterException
Replace the old by the new session id

Throws:
XmlBlasterException

getSessionInfo

private final SessionInfo getSessionInfo(java.lang.String secretSessionId)
Access a sessionInfo with the unique secretSessionId.

Returns:
the SessionInfo object or null if not known

getSessionInfoArr

public final SessionInfo[] getSessionInfoArr()
Returns a current snapshot of all sessions, never returns null.


getSessionInfo

public final SessionInfo getSessionInfo(SessionName sessionName)
Find a session by its login name and pubSessionId or return null if not found


getOrCreateSessionInfo

private final SessionInfo getOrCreateSessionInfo(SessionName sessionName,
                                                 ConnectQosServer connectQos)
                                          throws XmlBlasterException
Blocks for existing SessionInfo until it is initialized. For new created SessionInfo you need to call sessionInfo.init()

Parameters:
sessionName -
connectQos -
Returns:
Throws:
XmlBlasterException

sessionExists

public boolean sessionExists(java.lang.String secretSessionId)

logout

public final void logout(java.lang.String secretSessionId)
                  throws XmlBlasterException
Logout of a client.

Throws:
XmlBlasterException - If client is unknown

resetSessionInfo

private void resetSessionInfo(SessionInfo sessionInfo,
                              boolean clearQueue,
                              boolean forceShutdownEvenIfEntriesExist,
                              boolean isDisconnecting)
                       throws XmlBlasterException
Parameters:
sessionInfo -
clearQueue - Shall the message queue of the client be destroyed as well on last session logout?
forceShutdownEvenIfEntriesExist - on last session
isDisconnecting - true if this method is invoked while explicitly disconnecting a session, false otherwise. It is used to determine if the session queue (callback queue) has to be cleared or not.
Throws:
XmlBlasterException

createSessionId

private java.lang.String createSessionId(java.lang.String loginName)
                                  throws XmlBlasterException
Generate a unique (and secret) resource ID

Parameters:
loginName -
Returns:
unique ID
Throws:
XmlBlasterException - random generator

getClientListenerArr

private final I_ClientListener[] getClientListenerArr()
Returns a current snapshot of all ClientListeners


firePreRemovedClientEvent

private void firePreRemovedClientEvent(SessionInfo sessionInfo)
                                throws XmlBlasterException
Throws:
XmlBlasterException

fireClientEvent

private void fireClientEvent(SessionInfo sessionInfo,
                             boolean login)
                      throws XmlBlasterException
Used to fire an event if a client does a login / logout

Throws:
XmlBlasterException

updateConnectQos

private void updateConnectQos(SessionInfo sessionInfo,
                              ConnectQosServer newConnectQos)
                       throws XmlBlasterException
Throws:
XmlBlasterException

check

public SessionInfo check(java.lang.String secretSessionId)
                  throws XmlBlasterException
Use this method to check a clients authentication.

This method is called from an invoked xmlBlaster-server method (like subscribe()), using the delivered secretSessionId

Returns:
SessionInfo - if the client is OK otherwise an exception is thrown (returns never null)
Throws:
XmlBlasterException - Access denied

addClientListener

public void addClientListener(I_ClientListener l)
Adds the specified client listener to receive login/logout events.

This listener needs to implement the I_ClientListener interface.


removeClientListener

public void removeClientListener(I_ClientListener l)
Removes the specified listener


getMaxSubjects

public int getMaxSubjects()

getSubjectInfoArr

public SubjectInfo[] getSubjectInfoArr()
Get a current snapshot of all known subjects.

Returns:
The subjects known

getSubjects

public java.lang.String[] getSubjects()
Access a list of login names e.g. "joe","jack","averell","william"

Returns:
An array of length 0 if no clients available

getSubjectList

public java.lang.String getSubjectList()
Access a list of login names e.g. "joe,jack,averell,william"

Returns:
An empty string if no clients available

getName

public java.lang.String getName()
Enforced by I_RunlevelListener

Specified by:
getName in interface I_RunlevelListener

connectionState

public void connectionState(java.lang.String secretSessionId,
                            ConnectionStateEnum state)
Helper method where protocol layers may report a lost connection (e.g. socket EOF).

The SessionInfo can than do an immediate ping() to trigger POLLING mode

See Also:
I_Authenticate.connectionState(String, ConnectionStateEnum)

runlevelChange

public void runlevelChange(int from,
                           int to,
                           boolean force)
                    throws XmlBlasterException
Invoked on run level change, see RunlevelManager.RUNLEVEL_HALTED and RunlevelManager.RUNLEVEL_RUNNING

Enforced by I_RunlevelListener

Specified by:
runlevelChange in interface I_RunlevelListener
Parameters:
from - The current runlevel
to - The runlevel we want to switch to
force - If true force the change even if messages are lost
Throws:
XmlBlasterException

toXml

public final java.lang.String toXml()
Dump state of this object into a XML ASCII string.

Returns:
internal state of Authenticate as a XML ASCII string

toXml

public final java.lang.String toXml(java.lang.String extraOffset)
Dump state of this object into a XML ASCII string.

Parameters:
extraOffset - indenting of tags for nice output
Returns:
internal state of Authenticate as a XML ASCII string

getNumClients

public int getNumClients()
For JMX MBean: The number of different users, the sessions may be higher


getMaxClients

public int getMaxClients()
For JMX MBean: The maximum number of different users, the sessions may be higher


getClientList

public java.lang.String getClientList()
For JMX MBean: These are the login names returned, every client may be logged in multiple times which you can't see here


isAcceptWrongSenderAddress

public boolean isAcceptWrongSenderAddress(SessionInfo sessionInfo)
Authorization check (TODO: generic approach)

Parameters:
sessionInfo - can be null to get the general setting
Returns:
true: We accept wrong sender address in PublishQos.getSender() (not myself)

setAcceptWrongSenderAddress

public void setAcceptWrongSenderAddress(boolean acceptWrongSenderAddress)
Parameters:
acceptWrongSenderAddress - the acceptWrongSenderAddress to set

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.