Package tigase.xmpp
Class XMPPResourceConnection
java.lang.Object
tigase.xmpp.RepositoryAccess
tigase.xmpp.XMPPResourceConnection
- Direct Known Subclasses:
JabberIqPrivacy.OfflineResourceConnection
,SMResourceConnection
Describe class XMPPResourceConnection here.
Created: Wed Feb 8 22:30:37 2006
Created: Wed Feb 8 22:30:37 2006
- Author:
- Artur Hefczyc
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
ConstantPRESENCE_KEY
is a key in temporary session data where the last presence sent by the user to server is stored, either initial presence or off-line presence before disconnecting.Fields inherited from class tigase.xmpp.RepositoryAccess
authRepo, authState, domain, is_anonymous, NO_ACCESS_TO_REP_MSG, NOT_AUTHORIZED_MSG
-
Constructor Summary
ConstructorsConstructorDescriptionXMPPResourceConnection
(JID connectionId, UserRepository rep, AuthRepository authRepo, SessionManagerHandler loginHandler) -
Method Summary
Modifier and TypeMethodDescriptionvoid
authorizeJID
(BareJID jid, boolean anonymous) computeCommonSessionDataIfAbsent
(String key, Function<String, Object> valueFactory) Method checks if inparentSession
in session data there is value for passedkey
and returns it if exists.computeSessionDataIfAbsent
(String key, Function<String, Object> valueFactory) Method checks if in session data is value for passedkey
and returns it if exists.Method returns list of active connection for the sameXMPPSession
.JID[]
Method returns list of jids of all connections for the sameXMPPSession
(same user).long
final BareJID
Returns user JID but without resource part.Gets the value of connectionIdgetConnectionId
(boolean updateLastAccessed) getConnectionId
(JID jid) long
final JID
getjid()
Returns full user JID for this session without throwing theNotAuthorizedException
exception if session is not authorized yet and therefore user name and resource is not known yet.final JID
getJID()
Returns full user JID for this session or throwsNotAuthorizedException
if session is not authorized yet and therefore user name and resource is not known yet.long
Gets the value of lastAccessedlong
Returns last presence packet with the user presence status ornull
if the user has not yet sent an initial presence.int
Gets the value of resourcefinal Object
getSessionData
(String key) Retrieves session data.Gets the value of sessionIdfinal String
void
boolean
This method allows you test this session if it already has been authorized.boolean
boolean
isLocalDomain
(String outDomain, boolean includeComponents) boolean
boolean
Returns information whether this is a server (SessionManager) session or normal user session.boolean
boolean
boolean
protected void
login()
final void
logout()
void
putCommonSessionData
(String key, Object value) Method sets passed value under passed key in common sessionData kept in parentSessionputCommonSessionDataIfAbsent
(String key, Object value) Method sets passed value under passedkey
in commonsessionData
kept inparentSession
but only if there is no value for thiskey
alreadyfinal void
putSessionData
(String key, Object value) Saves given session data.putSessionDataIfAbsent
(String key, Object value) Method sets passed value under passedkey
insessionData
but only if there is no value for thiskey
alreadyvoid
void
removeParentSession
(XMPPSession parent) final void
removeSessionData
(String key) void
setConnectionId
(JID connectionId) Sets the value of connectionIdvoid
setDefLang
(String lang) void
setLastAccessed
(long argLastAccessed) Sets the value of lastAccessedvoid
setParentSession
(XMPPSession parent) void
setPresence
(Element packet) void
setPriority
(int priority) void
setResource
(String argResource) Sets the connection resourcevoid
setSessionId
(String argSessionId) Sets the value of sessionIdvoid
setTmpSession
(boolean tmp) void
toString()
unregister
(String name_param) Deprecated.Methods inherited from class tigase.xmpp.RepositoryAccess
addDataList, addOfflineDataList, addPublicDataList, changeRegistration, getAuthenticationToken, getAuthState, getData, getDataGroups, getDataKeys, getDataList, getDomain, getDomainAsJID, getOfflineData, getOfflineDataList, getPublicData, getPublicDataList, isAnonymous, removeData, removeDataGroup, removeOfflineData, removeOfflineDataGroup, removePublicData, removePublicDataGroup, setData, setDataList, setDomain, setOfflineData, setOfflineDataList, setPublicData, setPublicDataList, setRegistration
-
Field Details
-
ALL_RESOURCES_CAPS_KEY
- See Also:
-
ALL_RESOURCES_KEY
- See Also:
-
ALL_RESOURCES_PRIORITY_KEY
- See Also:
-
AUTHENTICATION_TIMEOUT_KEY
- See Also:
-
CLOSING_KEY
- See Also:
-
ERROR_KEY
- See Also:
-
CONNECTION_CHECK_TIMESTAMP_KEY
- See Also:
-
PRESENCE_KEY
ConstantPRESENCE_KEY
is a key in temporary session data where the last presence sent by the user to server is stored, either initial presence or off-line presence before disconnecting.- See Also:
-
-
Constructor Details
-
XMPPResourceConnection
public XMPPResourceConnection(JID connectionId, UserRepository rep, AuthRepository authRepo, SessionManagerHandler loginHandler)
-
-
Method Details
-
authorizeJID
- Throws:
TigaseStringprepException
-
computeCommonSessionDataIfAbsent
Method checks if inparentSession
in session data there is value for passedkey
and returns it if exists. If not then it uses passedvalueFactory
to generate value and sets it inparentSession
in session data under passedkey
and returns newly set value -
computeSessionDataIfAbsent
Method checks if in session data is value for passedkey
and returns it if exists. If not then it uses passedvalueFactory
to generate value and sets it in session data under passedkey
and returns newly set value -
getjid
Returns full user JID for this session without throwing theNotAuthorizedException
exception if session is not authorized yet and therefore user name and resource is not known yet. Please note this method is for logging using only to avoid excessive use of try/catch for debugging code. It may return null.- Returns:
- a
String
value of calculated user full JID for this session including resource name.
-
incPacketsCounter
public void incPacketsCounter() -
logout
- Overrides:
logout
in classRepositoryAccess
- Throws:
NotAuthorizedException
-
nextStanzaId
-
putCommonSessionData
Method sets passed value under passed key in common sessionData kept in parentSession -
putCommonSessionDataIfAbsent
Method sets passed value under passedkey
in commonsessionData
kept inparentSession
but only if there is no value for thiskey
already- Returns:
- previous value
-
putSessionData
Saves given session data. Data are saved to temporary storage only and are accessible during this session life only and only from this session instance.
AnyObject
can be stored and retrieved throughgetSessionData(...)
.
To access permanent storage to keep data between session instances you must use one ofget/setData...(...)
methods familly. They gives you access to hierachical permanent data base. Permanent data base however can be accessed after successuf authorization while session storage is availble all the time.- Parameters:
key
- aString
value of stored data key ID.value
- aObject
value of data stored in session.- See Also:
-
putSessionDataIfAbsent
Method sets passed value under passedkey
insessionData
but only if there is no value for thiskey
already- Returns:
- previous value
-
queryAuth
- Overrides:
queryAuth
in classRepositoryAccess
- Throws:
TigaseDBException
-
removeCommonSessionData
-
removeParentSession
-
removeSessionData
-
streamClosed
public void streamClosed() -
toString
-
getActiveSessions
Method returns list of active connection for the sameXMPPSession
.- Returns:
- a value of
List<XMPPResourceConnection>
- Throws:
NotAuthorizedException
-
getAllResourcesJIDs
Method returns list of jids of all connections for the sameXMPPSession
(same user).- Returns:
- a value of
JID[]
-
getAuthRepository
-
getAuthTime
public long getAuthTime() -
getBareJID
Description copied from class:RepositoryAccess
Returns user JID but without resource part. This is real user ID not session ID. To retrieve session ID - full JID refer togetJID()
method.
If session has not been authorized yet this method throwsNotAuthorizedException
.- Specified by:
getBareJID
in classRepositoryAccess
- Returns:
- a
String
value of user ID - this is user JID without resource part. To obtain full user JID please refer togetJID
method. - Throws:
NotAuthorizedException
- when this session has not been authorized yet and some parts of user JID are not known yet.
-
getCommonSessionData
-
getConnectionId
Gets the value of connectionId- Returns:
- the value of connectionId
- Throws:
NoConnectionIdException
-
getConnectionId
- Throws:
NoConnectionIdException
-
setConnectionId
Sets the value of connectionId- Parameters:
connectionId
- is aJID
-
getConnectionId
- Throws:
NoConnectionIdException
-
getCreationTime
public long getCreationTime() -
getDefLang
-
setDefLang
-
getJID
Returns full user JID for this session or throwsNotAuthorizedException
if session is not authorized yet and therefore user name and resource is not known yet.- Returns:
- a
String
value of calculated user full JID for this session including resource name. - Throws:
NotAuthorizedException
-
getLastAccessed
public long getLastAccessed()Gets the value of lastAccessed- Returns:
- the value of lastAccessed
-
setLastAccessed
public void setLastAccessed(long argLastAccessed) Sets the value of lastAccessed- Parameters:
argLastAccessed
- Value to assign to this.lastAccessed
-
getPacketsCounter
public long getPacketsCounter() -
getParentSession
-
setParentSession
- Throws:
TigaseStringprepException
-
getPresence
Returns last presence packet with the user presence status ornull
if the user has not yet sent an initial presence.- Returns:
- an
Element
with last presence status received from the user.
-
setPresence
-
getPriority
public int getPriority() -
setPriority
public void setPriority(int priority) -
getResource
Gets the value of resource- Returns:
- the value of resource
-
setResource
public void setResource(String argResource) throws NotAuthorizedException, TigaseStringprepException Sets the connection resource- Parameters:
argResource
- Value to assign to this.resource- Throws:
NotAuthorizedException
TigaseStringprepException
-
getSessionData
Retrieves session data. This method gives access to temporary session data only. You can retrieve earlier saved data giving key ID to receive needed value. Please seeputSessionData
description for more details.- Parameters:
key
- aString
value of stored data ID.- Returns:
- a
Object
value of data for given key. - See Also:
-
getSessionId
Gets the value of sessionId- Returns:
- the value of sessionId
-
setSessionId
Sets the value of sessionId- Parameters:
argSessionId
- Value to assign to this.sessionId
-
getSMComponentId
-
getUserName
- Specified by:
getUserName
in classRepositoryAccess
- Throws:
NotAuthorizedException
-
isAuthorized
public boolean isAuthorized()Description copied from class:RepositoryAccess
This method allows you test this session if it already has been authorized. Iftrue
is returned as method result it means session has already been authorized, iffalse
however session is still not authorized.- Overrides:
isAuthorized
in classRepositoryAccess
- Returns:
- a
boolean
value which informs whether this session has been already authorized or not.
-
isLocalDomain
-
isResourceSet
public boolean isResourceSet() -
isServerSession
public boolean isServerSession()Returns information whether this is a server (SessionManager) session or normal user session. The server session is used to handle packets addressed to the server itself (local domain name).- Returns:
- a
boolean
value oftrue
if this is the server session andfalse
otherwise.
-
isTmpSession
public boolean isTmpSession() -
setTmpSession
public void setTmpSession(boolean tmp) -
isUserId
- Throws:
NotAuthorizedException
-
unregister
@Deprecated public Authorization unregister(String name_param) throws NotAuthorizedException, TigaseDBException, TigaseStringprepException Deprecated.- Overrides:
unregister
in classRepositoryAccess
- Throws:
NotAuthorizedException
TigaseDBException
TigaseStringprepException
-
isEncrypted
public boolean isEncrypted() -
isTlsRequired
public boolean isTlsRequired() -
login
protected void login()- Specified by:
login
in classRepositoryAccess
-
JabberIqRegister.doRemoveAccount(Packet, Element, XMPPResourceConnection, Queue)