tigase.xmpp

## Class XMPPResourceConnection

- java.lang.Object
- - tigase.xmpp.RepositoryAccess
  - - tigase.xmpp.XMPPResourceConnection

- Direct Known Subclasses:
    SMResourceConnection

      public class XMPPResourceConnection
      extends RepositoryAccess

  Describe class XMPPResourceConnection here. Created: Wed Feb 8 22:30:37 2006
  Version:
    $Rev$
  Author:
    Artur Hefczyc

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `ALL_RESOURCES_CAPS_KEY` Field description
    `static String` | `ALL_RESOURCES_KEY` Field description
    `static String` | `ALL_RESOURCES_PRIORITY_KEY` Field description
    `static String` | `AUTHENTICATION_TIMEOUT_KEY` Field description
    `static String` | `CLOSING_KEY` Field description
    `static String` | `ERROR_KEY` Field description
    `static String` | `PRESENCE_KEY` Constant `PRESENCE_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

    Constructors
    Constructor and Description
    `XMPPResourceConnection(tigase.xmpp.JID connectionId, UserRepository rep, AuthRepository authRepo, SessionManagerHandler loginHandler)` Creates a new `XMPPResourceConnection` instance.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `authorizeJID(tigase.xmpp.BareJID jid, boolean anonymous)` Method description
    `List<XMPPResourceConnection>` | `getActiveSessions()` Method description
    `tigase.xmpp.JID[]` | `getAllResourcesJIDs()` Method description
    `AuthRepository` | `getAuthRepository()` Method description
    `long` | `getAuthTime()` Method description
    `tigase.xmpp.BareJID` | `getBareJID()` Returns user JID but without resource part.
    `Object` | `getCommonSessionData(String key)`
    `tigase.xmpp.JID` | `getConnectionId()` Gets the value of connectionId
    `tigase.xmpp.JID` | `getConnectionId(tigase.xmpp.JID jid)` Method description
    `long` | `getCreationTime()` Method description
    `String` | `getDefLang()` Method description
    `tigase.xmpp.JID` | `getjid()` Returns full user JID for this session without throwing the `NotAuthorizedException` exception if session is not authorized yet and therefore user name and resource is not known yet.
    `tigase.xmpp.JID` | `getJID()` Returns full user JID for this session or throws `NotAuthorizedException` if session is not authorized yet and therefore user name and resource is not known yet.
    `long` | `getLastAccessed()` Gets the value of lastAccessed
    `long` | `getPacketsCounter()` Method description
    `XMPPSession` | `getParentSession()` Method description
    `tigase.xml.Element` | `getPresence()` Returns last presence packet with the user presence status or `null` if the user has not yet sent an initial presence.
    `int` | `getPriority()` Method description
    `String` | `getResource()` Gets the value of resource
    `Object` | `getSessionData(String key)` Retrieves session data.
    `String` | `getSessionId()` Gets the value of sessionId
    `tigase.xmpp.JID` | `getSMComponentId()` Method description
    `tigase.xmpp.BareJID` | `getUserId()` Deprecated.
    `String` | `getUserName()` Method description
    `void` | `incPacketsCounter()` Method description
    `boolean` | `isAuthorized()` Method description
    `boolean` | `isEncrypted()`
    `boolean` | `isLocalDomain(String outDomain, boolean includeComponents)` Method description
    `boolean` | `isResourceSet()` Method description
    `boolean` | `isServerSession()` Returns information whether this is a server (SessionManager) session or normal user session.
    `boolean` | `isTlsRequired()`
    `boolean` | `isTmpSession()` Method description
    `boolean` | `isUserId(tigase.xmpp.BareJID bareJID)` Method description
    `protected void` | `login()` Method description
    `Authorization` | `loginDigest(String user, String digest, String id, String alg)` Deprecated.
    `Authorization` | `loginOther(Map<String,Object> props)` Deprecated.
    `Authorization` | `loginPlain(String user, String password)` Deprecated.
    `void` | `logout()` Method description
    `String` | `nextStanzaId()` Method description
    `void` | `putCommonSessionData(String key, Object value)` Method description
    `void` | `putSessionData(String key, Object value)` Saves given session data.
    `void` | `queryAuth(Map<String,Object> authProps)` Method description
    `Object` | `removeCommonSessionData(String key)` Method description
    `void` | `removeParentSession(XMPPSession parent)` Method description
    `void` | `removeSessionData(String key)` Method description
    `void` | `setConnectionId(tigase.xmpp.JID connectionId)` Sets the value of connectionId
    `void` | `setDefLang(String lang)` Method description
    `void` | `setLastAccessed(long argLastAccessed)` Sets the value of lastAccessed
    `void` | `setParentSession(XMPPSession parent)` Method description
    `void` | `setPresence(tigase.xml.Element packet)` Method description
    `void` | `setPriority(int priority)` Method description
    `void` | `setResource(String argResource)` Sets the connection resource
    `void` | `setSessionId(String argSessionId)` Sets the value of sessionId
    `void` | `setTmpSession(boolean tmp)` Method description
    `void` | `streamClosed()` Method description
    `String` | `toString()` Method description
    `Authorization` | `unregister(String name_param)` Method description

    - ### Methods inherited from class tigase.xmpp.RepositoryAccess

      `addDataList, addOfflineDataList, addPublicDataList, getAuthenticationToken, getAuthState, getData, getDataGroups, getDataKeys, getDataList, getDomain, getDomainAsJID, getOfflineData, getOfflineDataList, getPublicData, getPublicDataList, isAnonymous, loginDigest, loginPlain, loginToken, register, register, removeData, removeDataGroup, removeOfflineData, removeOfflineDataGroup, removePublicData, removePublicDataGroup, setData, setDataList, setDomain, setOfflineData, setOfflineDataList, setPublicData, setPublicDataList`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### ALL_RESOURCES_CAPS_KEY

          public static final String ALL_RESOURCES_CAPS_KEY

      Field description
      See Also:
        Constant Field Values

    - #### ALL_RESOURCES_KEY

          public static final String ALL_RESOURCES_KEY

      Field description
      See Also:
        Constant Field Values

    - #### ALL_RESOURCES_PRIORITY_KEY

          public static final String ALL_RESOURCES_PRIORITY_KEY

      Field description
      See Also:
        Constant Field Values

    - #### AUTHENTICATION_TIMEOUT_KEY

          public static final String AUTHENTICATION_TIMEOUT_KEY

      Field description
      See Also:
        Constant Field Values

    - #### CLOSING_KEY

          public static final String CLOSING_KEY

      Field description
      See Also:
        Constant Field Values

    - #### ERROR_KEY

          public static final String ERROR_KEY

      Field description
      See Also:
        Constant Field Values

    - #### PRESENCE_KEY

          public static final String PRESENCE_KEY

      Constant `PRESENCE_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:
        Constant Field Values

  - ### Constructor Detail

    - #### XMPPResourceConnection

          public XMPPResourceConnection(tigase.xmpp.JID connectionId,
                                UserRepository rep,
                                AuthRepository authRepo,
                                SessionManagerHandler loginHandler)

      Creates a new `XMPPResourceConnection` instance.
      Parameters:
        `connectionId` -
        `rep` -
        `authRepo` -
        `loginHandler` -

  - ### Method Detail

    - #### authorizeJID

          public void authorizeJID(tigase.xmpp.BareJID jid,
                          boolean anonymous)

      Method description
      Parameters:
        `jid` -
        `anonymous` -

    - #### getjid

          public final tigase.xmpp.JID getjid()

      Returns full user JID for this session without throwing the `NotAuthorizedException` 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()

      Method description

    - #### loginDigest

          @Deprecated
          public final Authorization loginDigest(String user,
                                             String digest,
                                             String id,
                                             String alg)
                                          throws NotAuthorizedException,
                                                 AuthorizationException,
                                                 TigaseDBException,
                                                 tigase.util.TigaseStringprepException

      Deprecated.
      Method description
      Parameters:
        `user` -
        `digest` -
        `id` -
        `alg` -
      Returns:
        a value of `Authorization`
      Throws:
        `AuthorizationException`
        `NotAuthorizedException`
        `TigaseDBException`
        `tigase.util.TigaseStringprepException`

    - #### loginOther

          @Deprecated
          public final Authorization loginOther(Map<String,Object> props)
                                         throws NotAuthorizedException,
                                                AuthorizationException,
                                                TigaseDBException

      Deprecated.
      Method description
      Overrides:
        `loginOther` in class `RepositoryAccess`
      Parameters:
        `props` -
      Returns:
        a value of `Authorization`
      Throws:
        `AuthorizationException`
        `NotAuthorizedException`
        `TigaseDBException`

    - #### loginPlain

          @Deprecated
          public final Authorization loginPlain(String user,
                                            String password)
                                         throws NotAuthorizedException,
                                                AuthorizationException,
                                                TigaseDBException,
                                                tigase.util.TigaseStringprepException

      Deprecated.
      Method description
      Parameters:
        `user` -
        `password` -
      Returns:
        a value of `Authorization`
      Throws:
        `AuthorizationException`
        `NotAuthorizedException`
        `TigaseDBException`
        `tigase.util.TigaseStringprepException`

    - #### logout

          public final void logout()
                            throws NotAuthorizedException

      Method description
      Overrides:
        `logout` in class `RepositoryAccess`
      Throws:
        `NotAuthorizedException`

    - #### nextStanzaId

          public String nextStanzaId()

      Method description
      Returns:
        a value of `String`

    - #### putCommonSessionData

          public void putCommonSessionData(String key,
                                  Object value)

      Method description
      Parameters:
        `key` -
        `value` -

    - #### putSessionData

          public final void putSessionData(String key,
                            Object value)

      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.
      Any `Object` can be stored and retrieved through `getSessionData(...)`.
      To access permanent storage to keep data between session instances you must use one of `get/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` - a `String` value of stored data key ID.
        `value` - a `Object` value of data stored in session.
      See Also:
        `getSessionData(String)`

    - #### queryAuth

          public void queryAuth(Map<String,Object> authProps)
                         throws TigaseDBException

      Method description
      Overrides:
        `queryAuth` in class `RepositoryAccess`
      Parameters:
        `authProps` -
      Throws:
        `TigaseDBException`

    - #### removeCommonSessionData

          public Object removeCommonSessionData(String key)

      Method description
      Parameters:
        `key` -
      Returns:
        a value of `Object`

    - #### removeParentSession

          public void removeParentSession(XMPPSession parent)

      Method description
      Parameters:
        `parent` -

    - #### removeSessionData

          public final void removeSessionData(String key)

      Method description
      Parameters:
        `key` -

    - #### streamClosed

          public void streamClosed()

      Method description

    - #### toString

          public String toString()

      Method description
      Overrides:
        `toString` in class `Object`
      Returns:
        a value of `String`

    - #### unregister

          public Authorization unregister(String name_param)
                                   throws NotAuthorizedException,
                                          TigaseDBException,
                                          tigase.util.TigaseStringprepException

      Method description
      Overrides:
        `unregister` in class `RepositoryAccess`
      Parameters:
        `name_param` -
      Returns:
        a value of `Authorization`
      Throws:
        `NotAuthorizedException`
        `TigaseDBException`
        `tigase.util.TigaseStringprepException`

    - #### getActiveSessions

          public List<XMPPResourceConnection> getActiveSessions()
                                                         throws NotAuthorizedException

      Method description
      Returns:
        a value of `List`
      Throws:
        `NotAuthorizedException`

    - #### getAllResourcesJIDs

          public tigase.xmpp.JID[] getAllResourcesJIDs()

      Method description
      Returns:
        a value of `JID[]`

    - #### getAuthRepository

          public AuthRepository getAuthRepository()

      Method description
      Returns:
        a value of `AuthRepository`

    - #### getAuthTime

          public long getAuthTime()

      Method description
      Returns:
        a value of `long`

    - #### getBareJID

          public final tigase.xmpp.BareJID getBareJID()
                                               throws NotAuthorizedException

      Returns user JID but without resource part. This is real user ID not session ID. To retrieve session ID - full JID refer to `getJID()` method.
      If session has not been authorized yet this method throws `NotAuthorizedException`.
      Specified by:
        `getBareJID` in class `RepositoryAccess`
      Returns:
        a `String` value of user ID - this is user JID without resource part. To obtain full user JID please refer to `getJID` method.
      Throws:
        `NotAuthorizedException` - when this session has not been authorized yet and some parts of user JID are not known yet.
      See Also:
        `getJID()`

    - #### getCommonSessionData

          public Object getCommonSessionData(String key)

      Parameters:
        `key` -
      Returns:
        a value of `Object`

    - #### getConnectionId

          public tigase.xmpp.JID getConnectionId()
                                          throws NoConnectionIdException

      Gets the value of connectionId
      Returns:
        the value of connectionId
      Throws:
        `NoConnectionIdException`

    - #### getConnectionId

          public tigase.xmpp.JID getConnectionId(tigase.xmpp.JID jid)
                                          throws NoConnectionIdException

      Method description
      Parameters:
        `jid` -
      Returns:
        a value of `JID`
      Throws:
        `NoConnectionIdException`

    - #### getCreationTime

          public long getCreationTime()

      Method description
      Returns:
        a value of `long`

    - #### getDefLang

          public String getDefLang()

      Method description
      Returns:
        a value of `String`

    - #### getJID

          public final tigase.xmpp.JID getJID()
                                       throws NotAuthorizedException

      Returns full user JID for this session or throws `NotAuthorizedException` 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

    - #### getPacketsCounter

          public long getPacketsCounter()

      Method description
      Returns:
        a value of `long`

    - #### getParentSession

          public XMPPSession getParentSession()

      Method description
      Returns:
        a value of `XMPPSession`

    - #### getPresence

          public tigase.xml.Element getPresence()

      Returns last presence packet with the user presence status or `null` if the user has not yet sent an initial presence.
      Returns:
        an `Element` with last presence status received from the user.

    - #### getPriority

          public int getPriority()

      Method description
      Returns:
        a value of `int`

    - #### getResource

          public String getResource()

      Gets the value of resource
      Returns:
        the value of resource

    - #### getSessionData

          public final Object getSessionData(String key)

      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 see `putSessionData` description for more details.
      Parameters:
        `key` - a `String` value of stored data ID.
      Returns:
        a `Object` value of data for given key.
      See Also:
        `putSessionData(String, Object)`

    - #### getSessionId

          public String getSessionId()

      Gets the value of sessionId
      Returns:
        the value of sessionId

    - #### getSMComponentId

          public tigase.xmpp.JID getSMComponentId()

      Method description
      Returns:
        a value of `JID`

    - #### getUserId

          @Deprecated
          public tigase.xmpp.BareJID getUserId()
                                        throws NotAuthorizedException

      Deprecated.
      To get the user bare JID please use `getBareJID` method, to check the whether the user with given BareJID is owner of the session please use method `isUserId(...)`. From now one the user session may handle more than a single userId, hence getting just userId is not enough to check whether the user Id belongs to the session.
      Returns:
        a value of `BareJID`
      Throws:
        `NotAuthorizedException`

    - #### getUserName

          public final String getUserName()
                                   throws NotAuthorizedException

      Method description
      Specified by:
        `getUserName` in class `RepositoryAccess`
      Returns:
        a value of `String`
      Throws:
        `NotAuthorizedException`

    - #### isAuthorized

          public boolean isAuthorized()

      Method description
      Overrides:
        `isAuthorized` in class `RepositoryAccess`
      Returns:
        a value of `boolean`

    - #### isLocalDomain

          public boolean isLocalDomain(String outDomain,
                              boolean includeComponents)

      Method description
      Parameters:
        `outDomain` -
        `includeComponents` -
      Returns:
        a value of `boolean`

    - #### isResourceSet

          public boolean isResourceSet()

      Method description
      Returns:
        a value of `boolean`

    - #### 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 of `true` if this is the server session and `false` otherwise.

    - #### isTmpSession

          public boolean isTmpSession()

      Method description
      Returns:
        a value of `boolean`

    - #### isUserId

          public boolean isUserId(tigase.xmpp.BareJID bareJID)
                           throws NotAuthorizedException

      Method description
      Parameters:
        `bareJID` -
      Returns:
        a value of `boolean`
      Throws:
        `NotAuthorizedException`

    - #### setConnectionId

          public void setConnectionId(tigase.xmpp.JID connectionId)

      Sets the value of connectionId
      Parameters:
        `connectionId` - is a `JID`

    - #### setDefLang

          public void setDefLang(String lang)

      Method description
      Parameters:
        `lang` -

    - #### setLastAccessed

          public void setLastAccessed(long argLastAccessed)

      Sets the value of lastAccessed
      Parameters:
        `argLastAccessed` - Value to assign to this.lastAccessed

    - #### setParentSession

          public void setParentSession(XMPPSession parent)
                                throws tigase.util.TigaseStringprepException

      Method description
      Parameters:
        `parent` -
      Throws:
        `tigase.util.TigaseStringprepException`

    - #### setPresence

          public void setPresence(tigase.xml.Element packet)

      Method description
      Parameters:
        `packet` -

    - #### setPriority

          public void setPriority(int priority)

      Method description
      Parameters:
        `priority` -

    - #### setResource

          public void setResource(String argResource)
                           throws NotAuthorizedException,
                                  tigase.util.TigaseStringprepException

      Sets the connection resource
      Parameters:
        `argResource` - Value to assign to this.resource
      Throws:
        `NotAuthorizedException`
        `tigase.util.TigaseStringprepException`

    - #### setSessionId

          public void setSessionId(String argSessionId)

      Sets the value of sessionId
      Parameters:
        `argSessionId` - Value to assign to this.sessionId

    - #### setTmpSession

          public void setTmpSession(boolean tmp)

      Method description
      Parameters:
        `tmp` - is a `boolean`

    - #### login

          protected void login()

      Method description
      Specified by:
        `login` in class `RepositoryAccess`

    - #### isEncrypted

          public boolean isEncrypted()

    - #### isTlsRequired

          public boolean isTlsRequired()

Copyright © 2014 "Tigase, Inc.". All rights reserved.