Overview | Package | Class | Tree | Deprecated | Index | Help
| Openfire 3.9.3 Javadoc
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jivesoftware.openfire.clearspace
Class ClearspaceManager

    java.lang.Object
      org.jivesoftware.openfire.container.BasicModule
          org.jivesoftware.openfire.clearspace.ClearspaceManager

All Implemented Interfaces:
  ComponentEventListener, ExternalComponentManagerListener, Module, CertificateEventListener, PropertyEventListener

    public class ClearspaceManager

extends BasicModule
implements ExternalComponentManagerListener, ComponentEventListener, PropertyEventListener, CertificateEventListener

Centralized administration of Clearspace connections. The `getInstance()` method should be used to get an instance. The following properties configure this manager:

- clearspace.uri
- clearspace.sharedSecret

Author:
  Daniel Henninger

Nested Class Summary
`static class` | `ClearspaceManager.HttpType` Different kind of HTTP request types

Field Summary
`protected static String` | `CHAT_URL_PREFIX`
`static String` | `CLEARSPACE_COMPONENT`
`protected static String` | `IM_URL_PREFIX`
`static String` | `MUC_SUBDOMAIN`

Constructor Summary
`ClearspaceManager()` Constructs a new ClearspaceManager instance.
`ClearspaceManager(Map<String,String> properties)` Constructs a new ClearspaceManager instance.

Method Summary
`void` | `certificateCreated(KeyStore keyStore, String alias, X509Certificate cert)` Event triggered when a new certificate is created.
`void` | `certificateDeleted(KeyStore keyStore, String alias)` Event triggered when a certificate is being deleted from the keystore.
`void` | `certificateSigned(KeyStore keyStore, String alias, List<X509Certificate> certificates)` Event triggered when a certificate has been signed by a Certificate Authority.
`Boolean` | `checkAuthentication(String username, String password)` Check a username/password pair for valid authentication.
`void` | `componentAllowed(String subdomain, ExternalComponentConfiguration configuration)` Notification indicating that a new component was allowed to connect using a given configuration.
`void` | `componentBlocked(String subdomain)` Notification indicating that a component was blocked to connect to the server.
`void` | `componentConfigurationDeleted(String subdomain)` Notification indicating that the configuration of a component, that was either blocked or allowed to connect, is being deleted.
`void` | `componentInfoReceived(org.xmpp.packet.IQ iq)` The server has received a disco#info response from the component.
`void` | `componentRegistered(org.xmpp.packet.JID componentJID)` A component was registered with the Component Manager.
`void` | `componentSecretUpdated(String subdomain, String newSecret)` Notification indicating that the configuration of a component, that was either blocked or allowed to connect, is being deleted.
`void` | `componentUnregistered(org.xmpp.packet.JID componentJID)` A component was removed.
`boolean` | `configClearspace()`
`void` | `defaultSecretChanged(String newSecret)` Notification indicating that the default secret is being modified.
`org.dom4j.Element` | `executeRequest(ClearspaceManager.HttpType type, String urlSuffix)` Makes a rest request of either type GET or DELETE at the specified urlSuffix.
`org.dom4j.Element` | `executeRequest(ClearspaceManager.HttpType type, String urlSuffix, String xmlParams)` Makes a rest request of any type at the specified urlSuffix.
`String` | `generateNonce()` Generates a new nonce.
`String` | `getConnectionURI()` Returns the Clearspace service URI; e.g.
`protected long` | `getGroupID(String groupname)` Returns the Clearspace group id of the group.
`static ClearspaceManager` | `getInstance()` Provides singleton access to an instance of the ClearspaceManager class.
`String` | `getNonce()` Returns a nonce generated by Clearspace to be used in a SSO login.
`Map<String,String>` | `getProperties()`
`String` | `getSharedSecret()` Returns the password, configured in Clearspace, that Openfire will use to authenticate with Clearspace to perform it's integration.
`protected long` | `getUserID(org.xmpp.packet.JID user)` Returns the Clearspace user id the user by JID.
`protected long` | `getUserID(String username)` Returns the Clearspace user id the user by username.
`protected String` | `getUsernameByID(Long id)` Returns the Clearspace username of the user by id.
`boolean` | `isClearspaceConfigured()` Returns true if Clerspace was configured at least one time since Openfire startup.
`Boolean` | `isClearspaceConnected()` Returns true if Clearspce is connected to Openfire.
`static boolean` | `isEnabled()` Returns true if Clearspace is being used as the backend of Openfire.
`boolean` | `isFromClearspace(org.xmpp.packet.JID address)` Returns true if a given JID belongs to a known Clearspace component domain.
`Boolean` | `isOpenfireConnected()` Returns true if Openfire is connected to Clearspace.
`boolean` | `isValidNonce(String nonce)` Returns true if the nonce was generated usig `generateNonce` and if this is the first check for that nonce.
`void` | `permissionPolicyChanged(ExternalComponentManager.PermissionPolicy newPolicy)` Notification indicating that the permission policy is being modified.
`void` | `portChanged(int newPort)` Notification indicating that the port used by external components is being modified.
`void` | `propertyDeleted(String property, Map params)` A property was deleted.
`void` | `propertySet(String property, Map params)` A property was set.
`org.xmpp.packet.IQ` | `query(org.xmpp.packet.IQ packet, int timeout)` Sends an IQ packet to the Clearspace external component and returns the IQ packet returned by CS or `null` if no answer was received before the specified timeout.
`void` | `serviceEnabled(boolean enabled)` Notification indicating whether the service is being enabled or disabled.
`void` | `setConnectionURI(String uri)` Sets the URI of the Clearspace service; e.g., `https://localhost:80/clearspace`.
`void` | `setSharedSecret(String sharedSecret)` Sets the shared secret for the Clearspace service we're connecting to.
`void` | `start()` Starts the basic module.
`void` | `stop()` Stops the basic module.
`Throwable` | `testConnection()` Tests the web services connection with Clearspace given the manager's current configuration.
`void` | `xmlPropertyDeleted(String property, Map params)` An XML property was deleted.
`void` | `xmlPropertySet(String property, Map params)` An XML property was set.

Methods inherited from class org.jivesoftware.openfire.container.BasicModule
`destroy, getName, initialize`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### IM_URL_PREFIX

    protected static final String IM_URL_PREFIX

See Also:
  Constant Field Values

### CHAT_URL_PREFIX

    protected static final String CHAT_URL_PREFIX

See Also:
  Constant Field Values

### MUC_SUBDOMAIN

    public static final String MUC_SUBDOMAIN

See Also:
  Constant Field Values

### CLEARSPACE_COMPONENT

    public static final String CLEARSPACE_COMPONENT

See Also:
  Constant Field Values

Constructor Detail

### ClearspaceManager

    public ClearspaceManager(Map<String,String> properties)

  Constructs a new ClearspaceManager instance. Typically, `getInstance()` should be called instead of this method. ClearspaceManager instances should only be created directly for testing purposes.

  Parameters:
    `properties` - the Map that contains properties used by the Clearspace manager, such as Clearspace host and shared secret.

### ClearspaceManager

    public ClearspaceManager()

  Constructs a new ClearspaceManager instance. Typically, `getInstance()` should be called instead of this method. ClearspaceManager instances should only be created directly for testing purposes.

Method Detail

### getInstance

    public static ClearspaceManager getInstance()

  Provides singleton access to an instance of the ClearspaceManager class.

  Returns:
    an ClearspaceManager instance.

### checkAuthentication

    public Boolean checkAuthentication(String username,
                                       String password)

  Check a username/password pair for valid authentication.

  Parameters:
    `username` - Username to authenticate against.
    `password` - Password to use for authentication.
  Returns:
    True or false of the authentication succeeded.

### testConnection

    public Throwable testConnection()

  Tests the web services connection with Clearspace given the manager's current configuration.

  Returns:
    The exception or null if connection test was successful.

### isOpenfireConnected

    public Boolean isOpenfireConnected()

  Returns true if Openfire is connected to Clearspace. This method may delay some time since it has to ping Clearspace to know if Openfire is able to connect to it.

  Returns:
    true if Openfire is connected to Clearspace.

### isClearspaceConnected

    public Boolean isClearspaceConnected()

  Returns true if Clearspce is connected to Openfire.

  Returns:
    true if Clearspce is connected to Openfire.

### getProperties

    public Map<String,String> getProperties()

### getConnectionURI

    public String getConnectionURI()

  Returns the Clearspace service URI; e.g. `https://localhost:80/clearspace`. This value is stored as the Jive Property `clearspace.uri`.

  Returns:
    the Clearspace service URI.

### setConnectionURI

    public void setConnectionURI(String uri)

  Sets the URI of the Clearspace service; e.g., `https://localhost:80/clearspace`. This value is stored as the Jive Property `clearspace.uri`.

  Parameters:
    `uri` - the Clearspace service URI.

### getSharedSecret

    public String getSharedSecret()

  Returns the password, configured in Clearspace, that Openfire will use to authenticate with Clearspace to perform it's integration.

  Returns:
    the password Openfire will use to authenticate with Clearspace.

### setSharedSecret

    public void setSharedSecret(String sharedSecret)

  Sets the shared secret for the Clearspace service we're connecting to.

  Parameters:
    `sharedSecret` - the password configured in Clearspace to authenticate Openfire.

### isEnabled

    public static boolean isEnabled()

  Returns true if Clearspace is being used as the backend of Openfire. When integrated with Clearspace then users and groups will be pulled out from Clearspace. User authentication will also rely on Clearspace.

  Returns:
    true if Clearspace is being used as the backend of Openfire.

### start

    public void start()
               throws IllegalStateException

  Description copied from class: `BasicModule`

  Starts the basic module.

  Inheriting classes that choose to override this method MUST call this start() method before accessing BasicModule resources.

  Specified by:
    `start` in interface `Module`
  Overrides:
    `start` in class `BasicModule`
  Throws:
    `IllegalStateException` - If start is called before initialize successfully returns

### stop

    public void stop()

  Description copied from class: `BasicModule`

  Stops the basic module.

  Inheriting classes that choose to override this method MUST call this stop() method before accessing BasicModule resources.

  Specified by:
    `stop` in interface `Module`
  Overrides:
    `stop` in class `BasicModule`

### configClearspace

    public boolean configClearspace()

### isClearspaceConfigured

    public boolean isClearspaceConfigured()

  Returns true if Clerspace was configured at least one time since Openfire startup.

  Returns:
    true if Clerspace was configured at least one time since Openfire startup.

### serviceEnabled

    public void serviceEnabled(boolean enabled)
                        throws ModificationNotAllowedException

  Description copied from interface: `ExternalComponentManagerListener`
  Notification indicating whether the service is being enabled or disabled. The listener may throw an exception to not allow the change from taking place.

  Specified by:
    `serviceEnabled` in interface `ExternalComponentManagerListener`
  Parameters:
    `enabled` - true if the service is being enabled.
  Throws:
    `ModificationNotAllowedException` - if the operation was denied.

### portChanged

    public void portChanged(int newPort)
                     throws ModificationNotAllowedException

  Description copied from interface: `ExternalComponentManagerListener`
  Notification indicating that the port used by external components is being modified. The listener may throw an exception to not allow the change from taking place.

  Specified by:
    `portChanged` in interface `ExternalComponentManagerListener`
  Parameters:
    `newPort` - new default secret being set.
  Throws:
    `ModificationNotAllowedException` - if the operation was denied.

### defaultSecretChanged

    public void defaultSecretChanged(String newSecret)
                              throws ModificationNotAllowedException

  Description copied from interface: `ExternalComponentManagerListener`
  Notification indicating that the default secret is being modified. The listener may throw an exception to not allow the change from taking place.

  Specified by:
    `defaultSecretChanged` in interface `ExternalComponentManagerListener`
  Parameters:
    `newSecret` - new default secret being set.
  Throws:
    `ModificationNotAllowedException` - if the operation was denied.

### permissionPolicyChanged

    public void permissionPolicyChanged(ExternalComponentManager.PermissionPolicy newPolicy)
                                 throws ModificationNotAllowedException

  Description copied from interface: `ExternalComponentManagerListener`
  Notification indicating that the permission policy is being modified. See `ExternalComponentManager.PermissionPolicy` for more information. The listener may throw an exception to not allow the change from taking place.

  Specified by:
    `permissionPolicyChanged` in interface `ExternalComponentManagerListener`
  Parameters:
    `newPolicy` - new permission policy being set.
  Throws:
    `ModificationNotAllowedException` - if the operation was denied.

### componentAllowed

    public void componentAllowed(String subdomain,
                                 ExternalComponentConfiguration configuration)
                          throws ModificationNotAllowedException

  Description copied from interface: `ExternalComponentManagerListener`
  Notification indicating that a new component was allowed to connect using a given configuration. The listener may throw an exception to not allow the change from taking place.

  Specified by:
    `componentAllowed` in interface `ExternalComponentManagerListener`
  Parameters:
    `subdomain` - subdomain of the added component.
    `configuration` - configuration for the external component.
  Throws:
    `ModificationNotAllowedException` - if the operation was denied.

### componentBlocked

    public void componentBlocked(String subdomain)
                          throws ModificationNotAllowedException

  Description copied from interface: `ExternalComponentManagerListener`
  Notification indicating that a component was blocked to connect to the server. The listener may throw an exception to not allow the change from taking place.

  Specified by:
    `componentBlocked` in interface `ExternalComponentManagerListener`
  Parameters:
    `subdomain` - subdomain of the blocked component.
  Throws:
    `ModificationNotAllowedException` - if the operation was denied.

### componentSecretUpdated

    public void componentSecretUpdated(String subdomain,
                                       String newSecret)
                                throws ModificationNotAllowedException

  Description copied from interface: `ExternalComponentManagerListener`
  Notification indicating that the configuration of a component, that was either blocked or allowed to connect, is being deleted. The listener may throw an exception to not allow the change from taking place.

  Specified by:
    `componentSecretUpdated` in interface `ExternalComponentManagerListener`
  Parameters:
    `subdomain` - subdomain of the component.
    `newSecret` - new secret being set for the component.
  Throws:
    `ModificationNotAllowedException` - if the operation was denied.

### componentConfigurationDeleted

    public void componentConfigurationDeleted(String subdomain)
                                       throws ModificationNotAllowedException

  Description copied from interface: `ExternalComponentManagerListener`
  Notification indicating that the configuration of a component, that was either blocked or allowed to connect, is being deleted. The listener may throw an exception to not allow the change from taking place.

  Specified by:
    `componentConfigurationDeleted` in interface `ExternalComponentManagerListener`
  Parameters:
    `subdomain` - subdomain of the component.
  Throws:
    `ModificationNotAllowedException` - if the operation was denied.

### executeRequest

    public org.dom4j.Element executeRequest(ClearspaceManager.HttpType type,
                                            String urlSuffix)
                                     throws ConnectionException,
                                            Exception

  Makes a rest request of either type GET or DELETE at the specified urlSuffix. The urlSuffix should be of the form /userService/users. If CS throws an exception it handled and transalated to a Openfire exception if possible. This is done using the check fault method that has an exception mapping from CS to OF. If no mapping is found then it throws a `Exception` with the message of the CS exception.

  Parameters:
    `type` - Must be GET or DELETE
    `urlSuffix` - The url suffix of the rest request
  Returns:
    The response as a xml doc.
  Throws:
    `ConnectionException` - Thrown if there are issues perfoming the request.
    `Exception` - Thrown if the response from Clearspace contains an exception.

### executeRequest

    public org.dom4j.Element executeRequest(ClearspaceManager.HttpType type,
                                            String urlSuffix,
                                            String xmlParams)
                                     throws ConnectionException,
                                            Exception

  Makes a rest request of any type at the specified urlSuffix. The urlSuffix should be of the form /userService/users. If CS throws an exception it handled and transalated to a Openfire exception if possible. This is done using the check fault method that tries to throw the best maching exception.

  Parameters:
    `type` - Must be GET or DELETE
    `urlSuffix` - The url suffix of the rest request
    `xmlParams` - The xml with the request params, must be null if type is GET or DELETE only
  Returns:
    The response as a xml doc.
  Throws:
    `ConnectionException` - Thrown if there are issues perfoming the request.
    `Exception` - Thrown if the response from Clearspace contains an exception.

### getUserID

    protected long getUserID(String username)
                      throws UserNotFoundException

  Returns the Clearspace user id the user by username.

  Parameters:
    `username` - Username to retrieve ID of.
  Returns:
    The ID number of the user in Clearspace.
  Throws:
    `UserNotFoundException` - If the user was not found.

### getUserID

    protected long getUserID(org.xmpp.packet.JID user)
                      throws UserNotFoundException

  Returns the Clearspace user id the user by JID.

  Parameters:
    `user` - JID of user to retrieve ID of.
  Returns:
    The ID number of the user in Clearspace.
  Throws:
    `UserNotFoundException` - If the user was not found.

### getUsernameByID

    protected String getUsernameByID(Long id)
                              throws UserNotFoundException

  Returns the Clearspace username of the user by id.

  Parameters:
    `id` - ID to retrieve Username of.
  Returns:
    The username of the user in Clearspace.
  Throws:
    `UserNotFoundException` - If the user was not found.

### getGroupID

    protected long getGroupID(String groupname)
                       throws GroupNotFoundException

  Returns the Clearspace group id of the group.

  Parameters:
    `groupname` - Name of the group to retrieve ID of.
  Returns:
    The ID number of the group in Clearspace.
  Throws:
    `GroupNotFoundException` - If the group was not found.

### isFromClearspace

    public boolean isFromClearspace(org.xmpp.packet.JID address)

  Returns true if a given JID belongs to a known Clearspace component domain.

  Parameters:
    `address` - Address to check.
  Returns:
    True if the specified address is a Clearspace component.

### query

    public org.xmpp.packet.IQ query(org.xmpp.packet.IQ packet,
                                    int timeout)

  Sends an IQ packet to the Clearspace external component and returns the IQ packet returned by CS or `null` if no answer was received before the specified timeout.

  Parameters:
    `packet` - IQ packet to send.
    `timeout` - milliseconds to wait before timing out.
  Returns:
    IQ packet returned by Clearspace responsing the packet we sent.

### componentRegistered

    public void componentRegistered(org.xmpp.packet.JID componentJID)

  Description copied from interface: `ComponentEventListener`
  A component was registered with the Component Manager. At this point the component has been intialized and started. XMPP entities can exchange packets with the component. However, the component is still not listed as a disco#items of the server since the component has not answered the disco#info request sent by the server.

  Specified by:
    `componentRegistered` in interface `ComponentEventListener`
  Parameters:
    `componentJID` - address where the component can be located (e.g. search.myserver.com)

### componentUnregistered

    public void componentUnregistered(org.xmpp.packet.JID componentJID)

  Description copied from interface: `ComponentEventListener`
  A component was removed. This means that no other cluster node has this component and this was the last connection of the component.

  Specified by:
    `componentUnregistered` in interface `ComponentEventListener`
  Parameters:
    `componentJID` - address where the component was located (e.g. search.myserver.com)

### componentInfoReceived

    public void componentInfoReceived(org.xmpp.packet.IQ iq)

  Description copied from interface: `ComponentEventListener`
  The server has received a disco#info response from the component. Once a component is registered with the server, the server will send a disco#info request to the component to discover if service discover is supported by the component. This event is triggered when the server received the response of the component.

  Specified by:
    `componentInfoReceived` in interface `ComponentEventListener`
  Parameters:
    `iq` - the IQ packet with the disco#info sent by the component.

### getNonce

    public String getNonce()

  Returns a nonce generated by Clearspace to be used in a SSO login.

  Returns:
    a unique nonce.

### generateNonce

    public String generateNonce()

  Generates a new nonce. The `isValidNonce` method will return true when using nonces generated by this method.

  Returns:
    a unique nonce

### isValidNonce

    public boolean isValidNonce(String nonce)

  Returns true if the nonce was generated usig `generateNonce` and if this is the first check for that nonce.

  Parameters:
    `nonce` - the nonce to be checked
  Returns:
    true if the nonce if the nonce was generated and this is the first check for that nonce

### propertySet

    public void propertySet(String property,
                            Map params)

  Description copied from interface: `PropertyEventListener`
  A property was set. The parameter map `params` will contain the the value of the property under the key `value`.

  Specified by:
    `propertySet` in interface `PropertyEventListener`
  Parameters:
    `property` - the name of the property.
    `params` - event parameters.

### propertyDeleted

    public void propertyDeleted(String property,
                                Map params)

  Description copied from interface: `PropertyEventListener`
  A property was deleted.

  Specified by:
    `propertyDeleted` in interface `PropertyEventListener`
  Parameters:
    `property` - the name of the property deleted.
    `params` - event parameters.

### xmlPropertySet

    public void xmlPropertySet(String property,
                               Map params)

  Description copied from interface: `PropertyEventListener`
  An XML property was set. The parameter map `params` will contain the the value of the property under the key `value`.

  Specified by:
    `xmlPropertySet` in interface `PropertyEventListener`
  Parameters:
    `property` - the name of the property.
    `params` - event parameters.

### xmlPropertyDeleted

    public void xmlPropertyDeleted(String property,
                                   Map params)

  Description copied from interface: `PropertyEventListener`
  An XML property was deleted.

  Specified by:
    `xmlPropertyDeleted` in interface `PropertyEventListener`
  Parameters:
    `property` - the name of the property.
    `params` - event parameters.

### certificateCreated

    public void certificateCreated(KeyStore keyStore,
                                   String alias,
                                   X509Certificate cert)

  Description copied from interface: `CertificateEventListener`
  Event triggered when a new certificate is created.

  Specified by:
    `certificateCreated` in interface `CertificateEventListener`
  Parameters:
    `keyStore` - key store where the certificate has been added.
    `alias` - the alias of the certificate in the keystore.
    `cert` - the new certificate created.

### certificateDeleted

    public void certificateDeleted(KeyStore keyStore,
                                   String alias)

  Description copied from interface: `CertificateEventListener`
  Event triggered when a certificate is being deleted from the keystore.

  Specified by:
    `certificateDeleted` in interface `CertificateEventListener`
  Parameters:
    `keyStore` - key store where the certificate is being deleted.
    `alias` - the alias of the certificate in the keystore.

### certificateSigned

    public void certificateSigned(KeyStore keyStore,
                                  String alias,
                                  List<X509Certificate> certificates)

  Description copied from interface: `CertificateEventListener`
  Event triggered when a certificate has been signed by a Certificate Authority.

  Specified by:
    `certificateSigned` in interface `CertificateEventListener`
  Parameters:
    `keyStore` - key store where the certificate is stored.
    `alias` - the alias of the certificate in the keystore.
    `certificates` - chain of certificates. First certificate in the list is the certificate being signed and last certificate in the list is the root certificate.

Overview | Package | Class | Tree | Deprecated | Index | Help
| Openfire 3.9.3 Javadoc
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2008 Jive Software.