Commit 1466a1e9 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Initial port from enterprise edition.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/branches/openfire_3_5_2@10384 b35dd754-fafc-0310-a699-88a17e54d16e
parent 12ed88c4
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Client Control Plugin Changelog</title>
<style type="text/css">
BODY {
font-size : 100%;
}
BODY, TD, TH {
font-family : tahoma, verdana, arial, helvetica, sans-serif;
font-size : 0.8em;
}
H2 {
font-size : 10pt;
font-weight : bold;
padding-left : 1em;
}
A:hover {
text-decoration : none;
}
H1 {
font-family : tahoma, arial, helvetica, sans-serif;
font-size : 1.4em;
font-weight: bold;
border-bottom : 1px #ccc solid;
padding-bottom : 2px;
}
TT {
font-family : courier new;
font-weight : bold;
color : #060;
}
PRE {
font-family : courier new;
font-size : 100%;
}
</style>
</head>
<body>
<h1>
Client Control Plugin Changelog
</h1>
<p><b>1.0.0</b> -- May 13, 2008</p>
<ul>
<li>Functionality ported from Openfire Enterprise, now Open Source.</li>
</ul>
</body>
</html>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<!-- Main plugin class -->
<class>org.jivesoftware.openfire.plugin.ClientControlPlugin</class>
<!-- Plugin meta-data -->
<name>Client Control</name>
<description>Controls clients allowed to connect and available features</description>
<author>Jive Software</author>
<version>1.0.0</version>
<date>6/13/2008</date>
<minServerVersion>3.5.0</minServerVersion>
<databaseKey>clientcontrol</databaseKey>
<databaseVersion>0</databaseVersion>
<!-- UI extension -->
<adminconsole>
<tab id="tab-server">
<sidebar id="client" name="${admin.sidebar.client.name}" description="${admin.sidebar.client.description}">
<item id="client-features" name="${admin.item.client-features.name}"
url="client-features.jsp"
description="${admin.item.client-features.description}"/>
<item id="client-version" name="${admin.item.client-version.name}"
url="permitted-clients.jsp"
description="${admin.item.client-version.description}"/>
<item id="groupchat-bookmarks" name="${admin.item.groupchat-bookmarks.name}"
url="groupchat-bookmarks.jsp"
description="${admin.item.groupchat-bookmarks.description}"/>
<item id="url-bookmarks" name="${admin.item.url-bookmarks.name}"
url="url-bookmarks.jsp"
description="${admin.item.url-bookmarks.description}"/>
<item id="spark-version" name="${admin.item.spark-version.name}"
url="spark-form.jsp"
description="${admin.item.spark-version.description}"/>
<item id="spark-download" name="${admin.item.spark-download.name}"
url="spark-download.jsp"
description="${admin.item.spark-download.description}"/>
</sidebar>
</tab>
</adminconsole>
</plugin>
\ No newline at end of file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Client Control Plugin Readme</title>
<style type="text/css">
BODY {
font-size : 100%;
}
BODY, TD, TH {
font-family : tahoma, verdana, arial, helvetica, sans-serif;
font-size : 0.8em;
}
H2 {
font-size : 10pt;
font-weight : bold;
}
A:hover {
text-decoration : none;
}
H1 {
font-family : tahoma, arial, helvetica, sans-serif;
font-size : 1.4em;
font-weight: bold;
border-bottom : 1px #ccc solid;
padding-bottom : 2px;
}
TT {
font-family : courier new;
font-weight : bold;
color : #060;
}
PRE {
font-family : courier new;
font-size : 100%;
}
#datatable TH {
color : #fff;
background-color : #2A448C;
text-align : left;
}
#datatable TD {
background-color : #FAF6EF;
}
#datatable .name {
background-color : #DCE2F5;
}
</style>
</head>
<body>
<h1>
Client Control Plugin Readme
</h1>
<h2>Overview</h2>
<p>
The client control plugin allows to specify which XMPP clients are allowed to connect to the server; which
client features are enabled; manage groupchat and URL bookmarks and control which Spark version should be
used by clients.
</p>
<h2>Installation</h2>
<p>
Copy clientControl.jar into the plugins directory of your Openfire installation.
The plugin will then be automatically deployed. To upgrade to a new version,
copy the new clientControl.jar file over the existing file.
</p>
<h2>Upgrading from Enterprise</h2>
<p>
If you are upgrading from the Enterprise plugin, and wish to keep your old
bookmarks, you will need to manually run some database scripts to
perform the migration. Note, if you don't care about your previous
bookmarks, you don't have to worry about these steps.
</p>
<p>
First, you will need to shut down your Openfire server and remove the
enterprise plugin. To do this, perform the following steps:
<ol>
<li>Shut down your Openfire server</li>
<li>Remove the <b>enterprise.jar</b> file and the <b>enterprise</b> directory from the plugins directory in your Openfire install root</li>
<li>Install this plugin, <b>clientControl.jar</b> by copying it into the plugins directory.</li>
<li>At this point, you will need to start up Openfire and let it extract and install the <b>clientControl</b> plugin. You can watch for this to occur by looking under the Plugins tab in the Openfire admin console. Once it appears in the list, continue to the next step.</li>
<li>Shut the server back down again.</li>
<li>Go into your plugins/clientControl/database directory. There you will see
some scripts prefixed with <b>import_</b>. Log into your database, switch
to the Openfire's database as you configured during setup (you can find
this information in conf/openfire.xml if you don't remember it), and run
the script that matches the database you are using. Note that the embedded
database is hsqldb and you can use the script in bin/extra from the Openfire
install root (bin/extra/embedded-db-viewer.sh or
bin/extra/embedded-db-viewer.bat, depending on whether you are using Windows)
to access your embedded database.</li>
<li>Once the script has completed, you can start Openfire back up and all of your settings should be the way they were when you were running the Enterprise plugin.</li>
</ol>
</p>
</body>
</html>
-- $Revision$
-- $Date$
INSERT INTO jiveVersion (name, version) VALUES ('clientcontrol', 0);
CREATE TABLE ofBookmark (
bookmarkID INTEGER NOT NULL,
bookmarkType VARCHAR(50) NOT NULL,
bookmarkName VARCHAR(255) NOT NULL,
bookmarkValue VARCHAR(1024) NOT NULL,
isGlobal INTEGER NOT NULL,
CONSTRAINT ofBookmark_pk PRIMARY KEY (bookmarkID)
);
CREATE TABLE ofBookmarkPerm (
bookmarkID INTEGER NOT NULL,
bookmarkType INTEGER NOT NULL,
name VARCHAR(255) NOT NULL,
CONSTRAINT ofBookmarkPerm_pk PRIMARY KEY(bookmarkID, name, bookmarkType)
);
CREATE TABLE ofBookmarkProp (
bookmarkID INTEGER NOT NULL,
name VARCHAR(100) NOT NULL,
propValue LONG VARCHAR NOT NULL,
CONSTRAINT ofBookmarkProp_pk PRIMARY KEY (bookmarkID, name)
);
// $Revision$
// $Date$
INSERT INTO jiveVersion (name, version) VALUES ('clientcontrol', 0);
CREATE TABLE ofBookmark (
bookmarkID BIGINT NOT NULL,
bookmarkType VARCHAR(50) NOT NULL,
bookmarkName VARCHAR(255) NOT NULL,
bookmarkValue VARCHAR(1024) NOT NULL,
isGlobal INT NOT NULL,
CONSTRAINT ofBookmark_pk PRIMARY KEY (bookmarkID)
);
CREATE TABLE ofBookmarkPerm (
bookmarkID BIGINT NOT NULL,
bookmarkType INTEGER NOT NULL,
name VARCHAR(255) NOT NULL,
CONSTRAINT ofBookmarkPerm_pk PRIMARY KEY(bookmarkID, name, bookmarkType)
);
CREATE TABLE ofBookmarkProp (
bookmarkID BIGINT NOT NULL,
name VARCHAR(100) NOT NULL,
propValue LONGVARCHAR NOT NULL,
CONSTRAINT ofBookmarkProp_pk PRIMARY KEY (bookmarkID, name)
);
# $Revision$
# $Date$
INSERT INTO jiveVersion (name, version) VALUES ('clientcontrol', 0);
CREATE TABLE ofBookmark (
bookmarkID BIGINT NOT NULL,
bookmarkType VARCHAR(50) NOT NULL,
bookmarkName VARCHAR(255) NOT NULL,
bookmarkValue VARCHAR(255) NOT NULL,
isGlobal INT NOT NULL,
PRIMARY KEY (bookmarkID)
);
CREATE TABLE ofBookmarkPerm (
bookmarkID BIGINT NOT NULL,
bookmarkType TINYINT NOT NULL,
name VARCHAR(255) NOT NULL,
PRIMARY KEY(bookmarkID, name, bookmarkType)
);
CREATE TABLE ofBookmarkProp (
bookmarkID BIGINT NOT NULL,
name VARCHAR(100) NOT NULL,
propValue TEXT NOT NULL,
PRIMARY KEY (bookmarkID, name)
);
-- $Revision$
-- $Date$
INSERT INTO jiveVersion (name, version) VALUES ('clientcontrol', 0);
CREATE TABLE ofBookmark (
bookmarkID INTEGER NOT NULL,
bookmarkType VARCHAR2(50) NOT NULL,
bookmarkName VARCHAR2(255) NOT NULL,
bookmarkValue VARCHAR2(1024) NOT NULL,
isGlobal INT NOT NULL,
CONSTRAINT ofBookmark_pk PRIMARY KEY (bookmarkID)
);
CREATE TABLE ofBookmarkPerm (
bookmarkID INTEGER NOT NULL,
bookmarkType NUMBER(2) NOT NULL,
name VARCHAR2(255) NOT NULL,
CONSTRAINT ofBookmarkPerm_pk PRIMARY KEY(bookmarkID, name, bookmarkType)
);
CREATE TABLE ofBookmarkProp (
bookmarkID INTEGER NOT NULL,
name VARCHAR2(100) NOT NULL,
propValue LONG NOT NULL,
CONSTRAINT ofBookmarkProp_pk PRIMARY KEY (bookmarkID, name)
);
-- $Revision$
-- $Date$
INSERT INTO jiveVersion (name, version) VALUES ('clientcontrol', 0);
CREATE TABLE ofBookmark (
bookmarkID INTEGER NOT NULL,
bookmarkType VARCHAR(50) NOT NULL,
bookmarkName VARCHAR(255) NOT NULL,
bookmarkValue VARCHAR(1024) NOT NULL,
isGlobal INTEGER NOT NULL,
CONSTRAINT ofBookmark_pk PRIMARY KEY (bookmarkID)
);
CREATE TABLE ofBookmarkPerm (
bookmarkID INTEGER NOT NULL,
bookmarkType SMALLINT NOT NULL,
name VARCHAR(255) NOT NULL,
CONSTRAINT ofBookmarkPerm_pk PRIMARY KEY(bookmarkID, name, bookmarkType)
);
CREATE TABLE ofBookmarkProp (
bookmarkID INTEGER NOT NULL,
name VARCHAR(100) NOT NULL,
propValue TEXT NOT NULL,
CONSTRAINT ofBookmarkProp_pk PRIMARY KEY (bookmarkID, name)
);
/* $Revision$ */
/* $Date$ */
INSERT INTO jiveVersion (name, version) VALUES ('clientcontrol', 0);
CREATE TABLE ofBookmark (
bookmarkID BIGINT NOT NULL,
bookmarkType VARCHAR(50) NOT NULL,
bookmarkName NVARCHAR(255) NOT NULL,
bookmarkValue NVARCHAR(1024) NOT NULL,
isGlobal INT NOT NULL,
CONSTRAINT ofBookmark_pk PRIMARY KEY (bookmarkID)
);
CREATE TABLE ofBookmarkPerm (
bookmarkID BIGINT NOT NULL,
bookmarkType TINYINT NOT NULL,
name NVARCHAR(255) NOT NULL,
CONSTRAINT ofBookmarkPerm_pk PRIMARY KEY(bookmarkID, name, bookmarkType)
);
CREATE TABLE ofBookmarkProp (
bookmarkID BIGINT NOT NULL,
name NVARCHAR(100) NOT NULL,
propValue NTEXT NOT NULL,
CONSTRAINT ofBookmarkProp_pk PRIMARY KEY (bookmarkID, name)
);
TRUNCATE TABLE ofBookmark;
INSERT INTO ofBookmark
(bookmarkID, bookmarkType, bookmarkName, bookmarkValue, isGlobal)
SELECT bookmarkID, bookmarkType, bookmarkName, bookmarkValue, isGlobal
FROM entBookmark;
TRUNCATE TABLE ofBookmarkPerm;
INSERT INTO ofBookmarkPerm
(bookmarkID, bookmarkType, name)
SELECT bookmarkID, bookmarkType, name
FROM entBookmarkPerm;
TRUNCATE TABLE ofBookmarkProp;
INSERT INTO ofBookmarkProp
(bookmarkID, name, propValue)
SELECT bookmarkID, name, propValue
FROM entBookmarkProp;
\ No newline at end of file
TRUNCATE TABLE ofBookmark;
INSERT INTO ofBookmark
(bookmarkID, bookmarkType, bookmarkName, bookmarkValue, isGlobal)
SELECT bookmarkID, bookmarkType, bookmarkName, bookmarkValue, isGlobal
FROM entBookmark;
TRUNCATE TABLE ofBookmarkPerm;
INSERT INTO ofBookmarkPerm
(bookmarkID, bookmarkType, name)
SELECT bookmarkID, bookmarkType, name
FROM entBookmarkPerm;
TRUNCATE TABLE ofBookmarkProp;
INSERT INTO ofBookmarkProp
(bookmarkID, name, propValue)
SELECT bookmarkID, name, propValue
FROM entBookmarkProp;
\ No newline at end of file
TRUNCATE TABLE ofBookmark;
INSERT INTO ofBookmark
(bookmarkID, bookmarkType, bookmarkName, bookmarkValue, isGlobal)
SELECT bookmarkID, bookmarkType, bookmarkName, bookmarkValue, isGlobal
FROM entBookmark;
TRUNCATE TABLE ofBookmarkPerm;
INSERT INTO ofBookmarkPerm
(bookmarkID, bookmarkType, name)
SELECT bookmarkID, bookmarkType, name
FROM entBookmarkPerm;
TRUNCATE TABLE ofBookmarkProp;
INSERT INTO ofBookmarkProp
(bookmarkID, name, propValue)
SELECT bookmarkID, name, propValue
FROM entBookmarkProp;
\ No newline at end of file
TRUNCATE TABLE ofBookmark;
INSERT INTO ofBookmark
(bookmarkID, bookmarkType, bookmarkName, bookmarkValue, isGlobal)
SELECT bookmarkID, bookmarkType, bookmarkName, bookmarkValue, isGlobal
FROM entBookmark;
TRUNCATE TABLE ofBookmarkPerm;
INSERT INTO ofBookmarkPerm
(bookmarkID, bookmarkType, name)
SELECT bookmarkID, bookmarkType, name
FROM entBookmarkPerm;
TRUNCATE TABLE ofBookmarkProp;
INSERT INTO ofBookmarkProp
(bookmarkID, name, propValue)
SELECT bookmarkID, name, propValue
FROM entBookmarkProp;
commit;
TRUNCATE TABLE ofBookmark;
INSERT INTO ofBookmark
(bookmarkID, bookmarkType, bookmarkName, bookmarkValue, isGlobal)
SELECT bookmarkID, bookmarkType, bookmarkName, bookmarkValue, isGlobal
FROM entBookmark;
TRUNCATE TABLE ofBookmarkPerm;
INSERT INTO ofBookmarkPerm
(bookmarkID, bookmarkType, name)
SELECT bookmarkID, bookmarkType, name
FROM entBookmarkPerm;
TRUNCATE TABLE ofBookmarkProp;
INSERT INTO ofBookmarkProp
(bookmarkID, name, propValue)
SELECT bookmarkID, name, propValue
FROM entBookmarkProp;
\ No newline at end of file
TRUNCATE TABLE ofBookmark;
INSERT INTO ofBookmark
(bookmarkID, bookmarkType, bookmarkName, bookmarkValue, isGlobal)
SELECT bookmarkID, bookmarkType, bookmarkName, bookmarkValue, isGlobal
FROM entBookmark;
TRUNCATE TABLE ofBookmarkPerm;
INSERT INTO ofBookmarkPerm
(bookmarkID, bookmarkType, name)
SELECT bookmarkID, bookmarkType, name
FROM entBookmarkPerm;
TRUNCATE TABLE ofBookmarkProp;
INSERT INTO ofBookmarkProp
(bookmarkID, name, propValue)
SELECT bookmarkID, name, propValue
FROM entBookmarkProp;
\ No newline at end of file
/**
* Copyright (C) 2008 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution, or a commercial license
* agreement with Jive.
*/
package org.jivesoftware.openfire.plugin;
import org.jivesoftware.openfire.container.Plugin;
import org.jivesoftware.openfire.container.PluginManager;
import org.jivesoftware.openfire.plugin.spark.SparkManager;
import org.jivesoftware.openfire.plugin.spark.BookmarkInterceptor;
import org.jivesoftware.openfire.plugin.spark.TaskEngine;
import org.jivesoftware.openfire.plugin.spark.manager.SparkVersionManager;
import org.jivesoftware.openfire.plugin.spark.manager.FileTransferFilterManager;
import java.io.File;
/**
* Client control plugin.
*
* @author Matt Tucker
*/
public class ClientControlPlugin implements Plugin {
private PluginManager pluginManager;
private SparkManager sparkManager;
private BookmarkInterceptor bookmarkInterceptor;
private SparkVersionManager sparkVersionManager;
private FileTransferFilterManager fileTransferFilterManager;
private TaskEngine taskEngine;
/**
* Constructs a new client control plugin.
*/
public ClientControlPlugin() {
}
// Plugin Interface
public void initializePlugin(PluginManager manager, File pluginDirectory) {
pluginManager = manager;
taskEngine = TaskEngine.getInstance();
sparkManager = new SparkManager(taskEngine);
sparkManager.start();
// Create and start the bookmark interceptor, which adds server-managed bookmarks when
// a user requests their bookmark list.
bookmarkInterceptor = new BookmarkInterceptor();
bookmarkInterceptor.start();
// Create and start the Spark version manager
sparkVersionManager = new SparkVersionManager();
sparkVersionManager.start();
fileTransferFilterManager = new FileTransferFilterManager();
fileTransferFilterManager.start();
}
public FileTransferFilterManager getFileTransferFilterManager() {
return fileTransferFilterManager;
}
public void destroyPlugin() {
pluginManager = null;
if (sparkManager != null) {
sparkManager.stop();
sparkManager.shutdown();
sparkManager = null;
}
if (bookmarkInterceptor != null) {
bookmarkInterceptor.stop();
bookmarkInterceptor = null;
}
if (sparkVersionManager != null) {
sparkVersionManager.shutdown();
sparkVersionManager = null;
}
if (fileTransferFilterManager != null) {
fileTransferFilterManager.stop();
fileTransferFilterManager = null;
}
taskEngine.shutdown();
}
}
\ No newline at end of file
/**
* $Revision$
* $Date$
*
* Copyright (C) 1999-2005 Jive Software. All rights reserved.
* This software is the proprietary information of Jive Software. Use is subject to license terms.
*/
package org.jivesoftware.openfire.plugin.spark;
import org.dom4j.Element;
import org.jivesoftware.util.Log;
import org.jivesoftware.openfire.group.Group;
import org.jivesoftware.openfire.group.GroupManager;
import org.jivesoftware.openfire.group.GroupNotFoundException;
import org.jivesoftware.openfire.interceptor.InterceptorManager;
import org.jivesoftware.openfire.interceptor.PacketInterceptor;
import org.jivesoftware.openfire.interceptor.PacketRejectedException;
import org.jivesoftware.openfire.session.Session;
import org.jivesoftware.openfire.user.UserManager;
import org.jivesoftware.openfire.user.UserNotFoundException;
import org.xmpp.packet.IQ;
import org.xmpp.packet.JID;
import org.xmpp.packet.Packet;
import java.util.Collection;
import java.util.Iterator;
/**
* Intercepts Bookmark Storage requests and appends all server based Bookmarks to
* the result.
*
* @author Derek DeMoro
*/
public class BookmarkInterceptor implements PacketInterceptor {
/**
* Initializes the BookmarkInterceptor and needed Server instances.
*/
public BookmarkInterceptor() {
}
public void interceptPacket(Packet packet, Session session, boolean incoming, boolean processed) throws PacketRejectedException {
if (!processed && packet instanceof IQ && !incoming) {
// Check for the Bookmark Storage element and hand off to the Bookmark engine.
IQ iq = (IQ)packet;
Element childElement = iq.getChildElement();
if (childElement == null || iq.getType() != IQ.Type.result) {
return;
}
String namespace = childElement.getNamespaceURI();
if ("jabber:iq:private".equals(namespace)) {
// In private data, when a user is attempting to retrieve bookmark
// information, there will be a storage:bookmarks namespace.
Element storageElement = childElement.element("storage");
if (storageElement == null) {
return;
}
namespace = storageElement.getNamespaceURI();
if ("storage:bookmarks".equals(namespace)) {
// Append Server defined bookmarks for user.
JID toJID = iq.getTo();
addBookmarks(toJID, storageElement);
}
}
}
}
/**
* Add this interceptor to the interceptor manager.
*/
public void start() {
InterceptorManager.getInstance().addInterceptor(this);
}
/**
* Remove this interceptor from the interceptor manager.
*/
public void stop() {
InterceptorManager.getInstance().removeInterceptor(this);
}
/**
* Adds all server defined bookmarks to the users requested
* bookmarks.
*
* @param jid the jid of the user requesting the bookmark(s)
* @param storageElement the JEP-0048 compliant storage element.
*/
private void addBookmarks(JID jid, Element storageElement) {
final Collection<Bookmark> bookmarks = BookmarkManager.getBookmarks();
for (Bookmark bookmark : bookmarks) {
// Check to see if the bookmark should be appended for this
// particular user.
boolean addBookmarkForUser = bookmark.isGlobalBookmark() || isBookmarkForJID(jid, bookmark);
if (addBookmarkForUser) {
// Add bookmark element.
addBookmarkElement(jid, bookmark, storageElement);
}
}
}
/**
* True if the specified bookmark should be appended to the users list of
* bookmarks.
*
* @param jid the jid of the user.
* @param bookmark the bookmark.
* @return true if bookmark should be appended.
*/
private static boolean isBookmarkForJID(JID jid, Bookmark bookmark) {
String username = jid.getNode();
if (bookmark.getUsers().contains(username)) {
return true;
}
Collection<String> groups = bookmark.getGroups();
if (groups != null && !groups.isEmpty()) {
GroupManager groupManager = GroupManager.getInstance();
for (String groupName : groups) {
try {
Group group = groupManager.getGroup(groupName);
if (group.isUser(jid.getNode())) {
return true;
}
}
catch (GroupNotFoundException e) {
Log.debug(e);
}
}
}
return false;
}
/**
* Adds a Bookmark to the users defined list of bookmarks.
*
* @param jid the users jid.
* @param bookmark the bookmark to be added.
* @param element the storage element to append to.
*/
private void addBookmarkElement(JID jid, Bookmark bookmark, Element element) {
final UserManager userManager = UserManager.getInstance();
try {
userManager.getUser(jid.getNode());
}
catch (UserNotFoundException e) {
return;
}
// If this is a URL Bookmark, check to make sure we
// do not add duplicate bookmarks.
if (bookmark.getType() == Bookmark.Type.url) {
Element urlBookmarkElement = urlExists(element, bookmark.getValue());
if (urlBookmarkElement == null) {
urlBookmarkElement = element.addElement("url");
urlBookmarkElement.addAttribute("name", bookmark.getName());
urlBookmarkElement.addAttribute("url", bookmark.getValue());
// Add an RSS attribute to the bookmark if it's defined. RSS isn't an
// official part of the Bookmark JEP, but we define it as a logical
// extension.
boolean rss = Boolean.valueOf(bookmark.getProperty("rss"));
if (rss) {
urlBookmarkElement.addAttribute("rss", Boolean.toString(rss));
}
}
appendSharedElement(urlBookmarkElement);
}
// Otherwise it's a conference bookmark.
else {
try {
Element conferenceElement = conferenceExists(element, bookmark.getValue());
// If the conference bookmark does not exist, add it to the current
// reply.
if (conferenceElement == null) {
conferenceElement = element.addElement("conference");
conferenceElement.addAttribute("name", bookmark.getName());
boolean autojoin = Boolean.valueOf(bookmark.getProperty("autojoin"));
conferenceElement.addAttribute("autojoin", Boolean.toString(autojoin));
conferenceElement.addAttribute("jid", bookmark.getValue());
}
appendSharedElement(conferenceElement);
}
catch (Exception e) {
Log.error(e);
}
}
}
/**
* Adds the shared namespace element to indicate to clients that this bookmark is a shared bookmark.
*
* @param bookmarkElement the bookmark to add the shared element to.
*/
private static void appendSharedElement(Element bookmarkElement) {
bookmarkElement.addElement("shared_bookmark", "http://jivesoftware.com/jeps/bookmarks");
}
/**
* Checks if the bookmark has already been defined in the users private storage.
*
* @param element the private storage element.
* @param url the url to search for.
* @return true if the bookmark already exists.
*/
private static Element urlExists(Element element, String url) {
// Iterate through current elements to see if this url already exists.
// If one does not exist, then add the bookmark.
final Iterator urlBookmarks = element.elementIterator("url");
while (urlBookmarks.hasNext()) {
Element urlElement = (Element)urlBookmarks.next();
String urlValue = urlElement.attributeValue("url");
if (urlValue.equalsIgnoreCase(url)) {
return urlElement;
}
}
return null;
}
/**
* Checks if the conference bookmark has already been defined in the users private storage.
*
* @param element the private storage element.
* @param roomJID the JID of the room to find.
* @return true if the bookmark exists.
*/
private Element conferenceExists(Element element, String roomJID) {
// Iterate through current elements to see if the conference bookmark
// already exists.
final Iterator conferences = element.elementIterator("conference");
while (conferences.hasNext()) {
final Element conferenceElement = (Element)conferences.next();
String jidValue = conferenceElement.attributeValue("jid");
if (jidValue != null && roomJID != null && jidValue.equalsIgnoreCase(roomJID)) {
return conferenceElement;
}
}
return null;
}
}
/**
* $Revision$
* $Date$
*
* Copyright (C) 1999-2005 Jive Software. All rights reserved.
* This software is the proprietary information of Jive Software. Use is subject to license terms.
*/
package org.jivesoftware.openfire.plugin.spark;
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.NotFoundException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* Manages global bookmarks. Bookmarks are defined by
* <a href="http://www.jabber.org/jeps/jep-0048.html">JEP-0048</a>. Users can define and
* manage their own bookmarks. Global bookmarks add to a user's own bookmarks and are
* defined by system administrators to apply to all users, groups, or sets of users.
*
* @see Bookmark
* @author Derek DeMoro
*/
public class BookmarkManager {
private static final String DELETE_BOOKMARK = "DELETE FROM ofBookmark where bookmarkID=?";
private static final String SELECT_BOOKMARKS = "SELECT bookmarkID from ofBookmark";
/**
* Returns the specified bookmark.
*
* @param bookmarkID the ID of the bookmark.
* @return the bookmark.
* @throws NotFoundException if the bookmark could not be found or loaded.
*/
public Bookmark getBookmark(long bookmarkID) throws NotFoundException {
// TODO add caching
return new Bookmark(bookmarkID);
}
/**
* Returns all bookmarks.
*
* @return the collection of bookmarks.
*/
public static Collection<Bookmark> getBookmarks() {
// TODO: add caching.
List<Bookmark> bookmarks = new ArrayList<Bookmark>();
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(SELECT_BOOKMARKS);
rs = pstmt.executeQuery();
while (rs.next()) {
long bookmarkID = rs.getLong(1);
try {
Bookmark bookmark = new Bookmark(bookmarkID);
bookmarks.add(bookmark);
}
catch (NotFoundException nfe) {
Log.error(nfe);
}
}
}
catch (SQLException e) {
Log.error(e);
}
finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
}
return bookmarks;
}
/**
* Deletes a bookmark with the specified bookmark ID.
*
* @param bookmarkID the ID of the bookmark to remove from the database.
*/
public static void deleteBookmark(long bookmarkID) {
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(DELETE_BOOKMARK);
pstmt.setLong(1, bookmarkID);
pstmt.execute();
}
catch (SQLException e) {
Log.error(e);
}
finally {
DbConnectionManager.closeConnection(pstmt, con);
}
}
}
\ No newline at end of file
/**
* $RCSfile: $
* $Revision: $
* $Date: $
*
* Copyright (C) 2006 Jive Software. All rights reserved.
* This software is the proprietary information of Jive Software. Use is subject to license terms.
*/
package org.jivesoftware.openfire.plugin.spark.manager;
import org.jivesoftware.openfire.filetransfer.*;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.util.JiveGlobals;
/**
*
*/
public class FileTransferFilterManager {
/**
* The JiveProperty relating to whether or not file transfer is currently enabled. If file
* transfer is disabled all known file transfer related packets are blocked, it also goes
* with out saying that the file transfer proxy is then disabled.
*/
static final String JIVEPROPERTY_FILE_TRANSFER_ENABLED = "xmpp.filetransfer.enabled";
/**
* Whether or not the file transfer is enabled by default.
*/
static final boolean DEFAULT_IS_FILE_TRANSFER_ENABLED = true;
private org.jivesoftware.openfire.filetransfer.FileTransferManager manager;
private TransferInterceptor transferInterceptor;
public FileTransferFilterManager()
{
this.manager = XMPPServer.getInstance().getFileTransferManager();
this.transferInterceptor = new TransferInterceptor();
}
public void start() {
manager.addFileTransferInterceptor(transferInterceptor);
}
public void stop() {
manager.removeFileTransferInterceptor(transferInterceptor);
}
public void enableFileTransfer(boolean isEnabled) {
JiveGlobals.setProperty(JIVEPROPERTY_FILE_TRANSFER_ENABLED, Boolean.toString(isEnabled));
}
public boolean isFileTransferEnabled() {
return JiveGlobals.getBooleanProperty(JIVEPROPERTY_FILE_TRANSFER_ENABLED,
DEFAULT_IS_FILE_TRANSFER_ENABLED);
}
private class TransferInterceptor implements FileTransferInterceptor {
public void interceptFileTransfer(FileTransfer transfer, boolean isReady)
throws FileTransferRejectedException
{
if(!isFileTransferEnabled()) {
throw new FileTransferRejectedException();
}
}
}
}
\ No newline at end of file
<?xml version='1.0' encoding='ISO-8859-1'?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<!-- Servlets -->
<servlet>
<servlet-name>SparkDownload</servlet-name>
<servlet-class>org.jivesoftware.openfire.plugin.spark.manager.SparkDownloadServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Servlet mappings -->
<servlet-mapping>
<servlet-name>SparkDownload</servlet-name>
<url-pattern>/getspark</url-pattern>
</servlet-mapping>
</web-app>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment