Commit 087ddec9 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Allowed to specify wildcards for external component configurations. JM-1367

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@10410 b35dd754-fafc-0310-a699-88a17e54d16e
parent f8d0551c
...@@ -134,6 +134,7 @@ CREATE TABLE ofVersion ( ...@@ -134,6 +134,7 @@ CREATE TABLE ofVersion (
CREATE TABLE ofExtComponentConf ( CREATE TABLE ofExtComponentConf (
subdomain VARCHAR(255) NOT NULL, subdomain VARCHAR(255) NOT NULL,
wildcard INTEGER NOT NULL,
secret VARCHAR(255), secret VARCHAR(255),
permission VARCHAR(10) NOT NULL, permission VARCHAR(10) NOT NULL,
CONSTRAINT ofExtComponentConf_pk PRIMARY KEY (subdomain) CONSTRAINT ofExtComponentConf_pk PRIMARY KEY (subdomain)
...@@ -385,7 +386,7 @@ INSERT INTO ofID (idType, id) VALUES (19, 1); ...@@ -385,7 +386,7 @@ INSERT INTO ofID (idType, id) VALUES (19, 1);
INSERT INTO ofID (idType, id) VALUES (23, 1); INSERT INTO ofID (idType, id) VALUES (23, 1);
INSERT INTO ofID (idType, id) VALUES (26, 1); INSERT INTO ofID (idType, id) VALUES (26, 1);
INSERT INTO ofVersion (name, version) VALUES ('openfire', 19); INSERT INTO ofVersion (name, version) VALUES ('openfire', 20);
-- Entry for admin user -- Entry for admin user
INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate) INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate)
......
...@@ -133,6 +133,7 @@ CREATE TABLE ofVersion ( ...@@ -133,6 +133,7 @@ CREATE TABLE ofVersion (
CREATE TABLE ofExtComponentConf ( CREATE TABLE ofExtComponentConf (
subdomain VARCHAR(255) NOT NULL, subdomain VARCHAR(255) NOT NULL,
wildcard INTEGER NOT NULL,
secret VARCHAR(255), secret VARCHAR(255),
permission VARCHAR(10) NOT NULL, permission VARCHAR(10) NOT NULL,
CONSTRAINT ofExtComponentConf_pk PRIMARY KEY (subdomain) CONSTRAINT ofExtComponentConf_pk PRIMARY KEY (subdomain)
...@@ -371,7 +372,7 @@ INSERT INTO ofID (idType, id) VALUES (19, 1); ...@@ -371,7 +372,7 @@ INSERT INTO ofID (idType, id) VALUES (19, 1);
INSERT INTO ofID (idType, id) VALUES (23, 1); INSERT INTO ofID (idType, id) VALUES (23, 1);
INSERT INTO ofID (idType, id) VALUES (26, 1); INSERT INTO ofID (idType, id) VALUES (26, 1);
INSERT INTO ofVersion (name, version) VALUES ('openfire', 19); INSERT INTO ofVersion (name, version) VALUES ('openfire', 20);
// Entry for admin user // Entry for admin user
INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate) INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate)
......
...@@ -122,6 +122,7 @@ CREATE TABLE ofVersion ( ...@@ -122,6 +122,7 @@ CREATE TABLE ofVersion (
CREATE TABLE ofExtComponentConf ( CREATE TABLE ofExtComponentConf (
subdomain VARCHAR(255) NOT NULL, subdomain VARCHAR(255) NOT NULL,
wildcard TINYINT NOT NULL,
secret VARCHAR(255), secret VARCHAR(255),
permission VARCHAR(10) NOT NULL, permission VARCHAR(10) NOT NULL,
PRIMARY KEY (subdomain) PRIMARY KEY (subdomain)
...@@ -360,7 +361,7 @@ INSERT INTO ofID (idType, id) VALUES (19, 1); ...@@ -360,7 +361,7 @@ INSERT INTO ofID (idType, id) VALUES (19, 1);
INSERT INTO ofID (idType, id) VALUES (23, 1); INSERT INTO ofID (idType, id) VALUES (23, 1);
INSERT INTO ofID (idType, id) VALUES (26, 1); INSERT INTO ofID (idType, id) VALUES (26, 1);
INSERT INTO ofVersion (name, version) VALUES ('openfire', 19); INSERT INTO ofVersion (name, version) VALUES ('openfire', 20);
# Entry for admin user # Entry for admin user
INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate) INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate)
......
...@@ -130,6 +130,7 @@ CREATE TABLE ofVersion ( ...@@ -130,6 +130,7 @@ CREATE TABLE ofVersion (
CREATE TABLE ofExtComponentConf ( CREATE TABLE ofExtComponentConf (
subdomain VARCHAR2(255) NOT NULL, subdomain VARCHAR2(255) NOT NULL,
wildcard INTEGER NOT NULL,
secret VARCHAR2(255), secret VARCHAR2(255),
permission VARCHAR2(10) NOT NULL, permission VARCHAR2(10) NOT NULL,
CONSTRAINT ofExtComponentConf_pk PRIMARY KEY (subdomain) CONSTRAINT ofExtComponentConf_pk PRIMARY KEY (subdomain)
...@@ -368,7 +369,7 @@ INSERT INTO ofID (idType, id) VALUES (19, 1); ...@@ -368,7 +369,7 @@ INSERT INTO ofID (idType, id) VALUES (19, 1);
INSERT INTO ofID (idType, id) VALUES (23, 1); INSERT INTO ofID (idType, id) VALUES (23, 1);
INSERT INTO ofID (idType, id) VALUES (26, 1); INSERT INTO ofID (idType, id) VALUES (26, 1);
INSERT INTO ofVersion (name, version) VALUES ('openfire', 19); INSERT INTO ofVersion (name, version) VALUES ('openfire', 20);
-- Entry for admin user -- Entry for admin user
INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate) INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate)
......
...@@ -138,6 +138,7 @@ CREATE TABLE ofVersion ( ...@@ -138,6 +138,7 @@ CREATE TABLE ofVersion (
CREATE TABLE ofExtComponentConf ( CREATE TABLE ofExtComponentConf (
subdomain VARCHAR(255) NOT NULL, subdomain VARCHAR(255) NOT NULL,
wildcard INTEGER NOT NULL,
secret VARCHAR(255), secret VARCHAR(255),
permission VARCHAR(10) NOT NULL, permission VARCHAR(10) NOT NULL,
CONSTRAINT ofExtComponentConf_pk PRIMARY KEY (subdomain) CONSTRAINT ofExtComponentConf_pk PRIMARY KEY (subdomain)
...@@ -376,7 +377,7 @@ INSERT INTO ofID (idType, id) VALUES (19, 1); ...@@ -376,7 +377,7 @@ INSERT INTO ofID (idType, id) VALUES (19, 1);
INSERT INTO ofID (idType, id) VALUES (23, 1); INSERT INTO ofID (idType, id) VALUES (23, 1);
INSERT INTO ofID (idType, id) VALUES (26, 1); INSERT INTO ofID (idType, id) VALUES (26, 1);
INSERT INTO ofVersion (name, version) VALUES ('openfire', 19); INSERT INTO ofVersion (name, version) VALUES ('openfire', 20);
-- Entry for admin user -- Entry for admin user
INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate) INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate)
......
...@@ -136,6 +136,7 @@ CREATE TABLE ofVersion ( ...@@ -136,6 +136,7 @@ CREATE TABLE ofVersion (
CREATE TABLE ofExtComponentConf ( CREATE TABLE ofExtComponentConf (
subdomain NVARCHAR(255) NOT NULL, subdomain NVARCHAR(255) NOT NULL,
wildcard INT NOT NULL,
secret NVARCHAR(255), secret NVARCHAR(255),
permission NVARCHAR(10) NOT NULL, permission NVARCHAR(10) NOT NULL,
CONSTRAINT ofExtComponentConf_pk PRIMARY KEY (subdomain) CONSTRAINT ofExtComponentConf_pk PRIMARY KEY (subdomain)
...@@ -374,7 +375,7 @@ INSERT INTO ofID (idType, id) VALUES (19, 1); ...@@ -374,7 +375,7 @@ INSERT INTO ofID (idType, id) VALUES (19, 1);
INSERT INTO ofID (idType, id) VALUES (23, 1); INSERT INTO ofID (idType, id) VALUES (23, 1);
INSERT INTO ofID (idType, id) VALUES (26, 1); INSERT INTO ofID (idType, id) VALUES (26, 1);
INSERT INTO ofVersion (name, version) VALUES ('openfire', 19); INSERT INTO ofVersion (name, version) VALUES ('openfire', 20);
/* Entry for admin user */ /* Entry for admin user */
INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate) INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate)
......
...@@ -136,6 +136,7 @@ CREATE TABLE ofVersion ( ...@@ -136,6 +136,7 @@ CREATE TABLE ofVersion (
CREATE TABLE ofExtComponentConf ( CREATE TABLE ofExtComponentConf (
subdomain NVARCHAR(255) NOT NULL, subdomain NVARCHAR(255) NOT NULL,
wildcard INT NOT NULL,
secret NVARCHAR(255) NULL, secret NVARCHAR(255) NULL,
permission NVARCHAR(10) NOT NULL, permission NVARCHAR(10) NOT NULL,
CONSTRAINT ofExtComponentConf_pk PRIMARY KEY (subdomain) CONSTRAINT ofExtComponentConf_pk PRIMARY KEY (subdomain)
...@@ -374,7 +375,7 @@ INSERT INTO ofID (idType, id) VALUES (19, 1); ...@@ -374,7 +375,7 @@ INSERT INTO ofID (idType, id) VALUES (19, 1);
INSERT INTO ofID (idType, id) VALUES (23, 1); INSERT INTO ofID (idType, id) VALUES (23, 1);
INSERT INTO ofID (idType, id) VALUES (26, 1); INSERT INTO ofID (idType, id) VALUES (26, 1);
INSERT INTO ofVersion (name, version) VALUES ('openfire', 19); INSERT INTO ofVersion (name, version) VALUES ('openfire', 20);
/* Entry for admin user */ /* Entry for admin user */
INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate) INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate)
......
-- add wildcard column to ofExtComponentConf
ALTER TABLE ofExtComponentConf ADD COLUMN wildcard INTEGER DEFAULT 0 NOT NULL;
-- Update version
UPDATE ofVersion SET version = 20 WHERE name = 'openfire';
\ No newline at end of file
// add wildcard column to ofExtComponentConf
ALTER TABLE ofExtComponentConf ADD COLUMN wildcard INTEGER DEFAULT 0 NOT NULL;
// Update version
UPDATE ofVersion SET version = 20 WHERE name = 'openfire';
\ No newline at end of file
# add wildcard column to ofExtComponentConf
ALTER TABLE ofExtComponentConf ADD COLUMN wildcard TINYINT NOT NULL DEFAULT 0;
# Update version
UPDATE ofVersion SET version = 20 WHERE name = 'openfire';
-- add wildcard column to ofExtComponentConf
ALTER TABLE ofExtComponentConf ADD wildcard INTEGER DEFAULT 0 NOT NULL;
-- Update version
UPDATE ofVersion SET version = 20 WHERE name = 'openfire';
COMMIT;
\ No newline at end of file
-- add wildcard column to ofExtComponentConf
ALTER TABLE ofExtComponentConf ADD COLUMN wildcard INTEGER DEFAULT 0 NOT NULL;
-- Update version
UPDATE ofVersion SET version = 20 WHERE name = 'openfire';
/* add wildcard column to ofExtComponentConf */
ALTER TABLE ofExtComponentConf ADD wildcard INT DEFAULT 0 NOT NULL;
/* Update version */
UPDATE ofVersion SET version = 20 WHERE name = 'openfire';
/* add wildcard column to ofExtComponentConf */
ALTER TABLE ofExtComponentConf ADD COLUMN wildcard INT DEFAULT 0 NOT NULL;
/* Update version */
UPDATE ofVersion SET version = 20 WHERE name = 'openfire';
...@@ -47,7 +47,7 @@ public class SchemaManager { ...@@ -47,7 +47,7 @@ public class SchemaManager {
/** /**
* Current Openfire database schema version. * Current Openfire database schema version.
*/ */
private static final int DATABASE_VERSION = 19; private static final int DATABASE_VERSION = 20;
/** /**
* Creates a new Schema manager. * Creates a new Schema manager.
......
...@@ -424,7 +424,7 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM ...@@ -424,7 +424,7 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM
*/ */
public void setSharedSecret(String sharedSecret) { public void setSharedSecret(String sharedSecret) {
// Set new password for external component // Set new password for external component
ExternalComponentConfiguration configuration = new ExternalComponentConfiguration("clearspace", ExternalComponentConfiguration configuration = new ExternalComponentConfiguration("clearspace", true,
ExternalComponentConfiguration.Permission.allowed, sharedSecret); ExternalComponentConfiguration.Permission.allowed, sharedSecret);
try { try {
ExternalComponentManager.allowAccess(configuration); ExternalComponentManager.allowAccess(configuration);
......
...@@ -11,13 +11,19 @@ package org.jivesoftware.openfire.component; ...@@ -11,13 +11,19 @@ package org.jivesoftware.openfire.component;
public class ExternalComponentConfiguration { public class ExternalComponentConfiguration {
private String subdomain; private String subdomain;
/**
* Flag that indicates if components whose domain starts with the subdomain of this configuration
* should use this configuration.
*/
private boolean wildcard;
private Permission permission; private Permission permission;
private String secret; private String secret;
public ExternalComponentConfiguration(String subdomain, Permission permission, String secret) { public ExternalComponentConfiguration(String subdomain, boolean wildcard, Permission permission, String secret) {
this.subdomain = subdomain; this.subdomain = subdomain;
this.wildcard = wildcard;
this.permission = permission; this.permission = permission;
this.secret = secret; this.secret = secret;
} }
...@@ -26,6 +32,10 @@ public class ExternalComponentConfiguration { ...@@ -26,6 +32,10 @@ public class ExternalComponentConfiguration {
return subdomain; return subdomain;
} }
public boolean isWildcard() {
return wildcard;
}
public Permission getPermission() { public Permission getPermission() {
return permission; return permission;
} }
......
...@@ -130,7 +130,7 @@ ...@@ -130,7 +130,7 @@
if (errors.isEmpty()) { if (errors.isEmpty()) {
// Remove the hostname if the user is not sending just the subdomain // Remove the hostname if the user is not sending just the subdomain
subdomain = subdomain.replace("." + serverName, ""); subdomain = subdomain.replace("." + serverName, "");
ExternalComponentConfiguration configuration = new ExternalComponentConfiguration(subdomain, ExternalComponentConfiguration configuration = new ExternalComponentConfiguration(subdomain, false,
ExternalComponentConfiguration.Permission.allowed, secret); ExternalComponentConfiguration.Permission.allowed, secret);
try { try {
ExternalComponentManager.allowAccess(configuration); ExternalComponentManager.allowAccess(configuration);
......
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