Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Openfire
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Openfire
Commits
d84581d4
Commit
d84581d4
authored
Oct 23, 2017
by
Dave Cridland
Committed by
GitHub
Oct 23, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #895 from surevine/automated-setup
OF-1412 Add automated setup support on first run
parents
57944fa8
8bf8d5cb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
150 additions
and
29 deletions
+150
-29
XMPPServer.java
src/java/org/jivesoftware/openfire/XMPPServer.java
+150
-29
No files found.
src/java/org/jivesoftware/openfire/XMPPServer.java
View file @
d84581d4
...
@@ -50,6 +50,7 @@ import org.jivesoftware.openfire.session.RemoteSessionLocator;
...
@@ -50,6 +50,7 @@ import org.jivesoftware.openfire.session.RemoteSessionLocator;
import
org.jivesoftware.openfire.spi.*
;
import
org.jivesoftware.openfire.spi.*
;
import
org.jivesoftware.openfire.transport.TransportHandler
;
import
org.jivesoftware.openfire.transport.TransportHandler
;
import
org.jivesoftware.openfire.update.UpdateManager
;
import
org.jivesoftware.openfire.update.UpdateManager
;
import
org.jivesoftware.openfire.user.User
;
import
org.jivesoftware.openfire.user.UserManager
;
import
org.jivesoftware.openfire.user.UserManager
;
import
org.jivesoftware.openfire.vcard.VCardManager
;
import
org.jivesoftware.openfire.vcard.VCardManager
;
import
org.jivesoftware.util.*
;
import
org.jivesoftware.util.*
;
...
@@ -323,21 +324,123 @@ public class XMPPServer {
...
@@ -323,21 +324,123 @@ public class XMPPServer {
xmppServerInfo
=
new
XMPPServerInfoImpl
(
new
Date
());
xmppServerInfo
=
new
XMPPServerInfoImpl
(
new
Date
());
initialized
=
true
;
initialized
=
true
;
if
(
setupMode
&&
"true"
.
equals
(
JiveGlobals
.
getXMLProperty
(
"autosetup.run"
)))
{
this
.
runAutoSetup
();
JiveGlobals
.
deleteXMLProperty
(
"autosetup"
);
JiveGlobals
.
deleteProperty
(
"autosetup"
);
}
}
}
/**
void
runAutoSetup
()
{
* Finish the setup process. Because this method is meant to be called from inside
// steps from setup-datasource-standard.jsp
* the Admin console plugin, it spawns its own thread to do the work so that the
// do this first so that other changes persist
* class loader is correct.
if
(
"standard"
.
equals
(
JiveGlobals
.
getXMLProperty
(
"autosetup.database.mode"
)))
{
*/
JiveGlobals
.
setXMLProperty
(
"database.defaultProvider.driver"
,
JiveGlobals
.
getXMLProperty
(
"autosetup.database.defaultProvider.driver"
));
public
void
finishSetup
()
{
JiveGlobals
.
setXMLProperty
(
"database.defaultProvider.serverURL"
,
JiveGlobals
.
getXMLProperty
(
"autosetup.database.defaultProvider.serverURL"
));
if
(!
setupMode
)
{
JiveGlobals
.
setXMLProperty
(
"database.defaultProvider.username"
,
JiveGlobals
.
getXMLProperty
(
"autosetup.database.defaultProvider.username"
));
return
;
JiveGlobals
.
setXMLProperty
(
"database.defaultProvider.password"
,
JiveGlobals
.
getXMLProperty
(
"autosetup.database.defaultProvider.password"
));
int
minConnections
;
int
maxConnections
;
double
connectionTimeout
;
try
{
minConnections
=
Integer
.
parseInt
(
JiveGlobals
.
getXMLProperty
(
"database.defaultProvider.minConnections"
));
}
}
// Make sure that setup finished correctly.
catch
(
Exception
e
)
{
if
(
"true"
.
equals
(
JiveGlobals
.
getXMLProperty
(
"setup"
)))
{
minConnections
=
5
;
// Iterate through all the provided XML properties and set the ones that haven't
}
// already been touched by setup prior to this method being called.
try
{
maxConnections
=
Integer
.
parseInt
(
JiveGlobals
.
getXMLProperty
(
"database.defaultProvider.maxConnections"
));
}
catch
(
Exception
e
)
{
maxConnections
=
25
;
}
try
{
connectionTimeout
=
Double
.
parseDouble
(
JiveGlobals
.
getXMLProperty
(
"database.defaultProvider.connectionTimeout"
));
}
catch
(
Exception
e
)
{
connectionTimeout
=
1.0
;
}
JiveGlobals
.
setXMLProperty
(
"database.defaultProvider.minConnections"
,
Integer
.
toString
(
minConnections
));
JiveGlobals
.
setXMLProperty
(
"database.defaultProvider.maxConnections"
,
Integer
.
toString
(
maxConnections
));
JiveGlobals
.
setXMLProperty
(
"database.defaultProvider.connectionTimeout"
,
Double
.
toString
(
connectionTimeout
));
}
// mark setup as done, so that other things can be written to the DB
JiveGlobals
.
setXMLProperty
(
"setup"
,
"true"
);
// steps from index.jsp
String
localeCode
=
JiveGlobals
.
getXMLProperty
(
"autosetup.locale"
);
logger
.
warn
(
"Setting locale to"
+
localeCode
);
JiveGlobals
.
setLocale
(
LocaleUtils
.
localeCodeToLocale
(
localeCode
.
trim
()));
// steps from setup-host-settings.jsp
JiveGlobals
.
setXMLProperty
(
"xmpp.domain"
,
JiveGlobals
.
getXMLProperty
(
"autosetup.xmpp.domain"
));
JiveGlobals
.
setXMLProperty
(
"xmpp.fqdn"
,
JiveGlobals
.
getXMLProperty
(
"autosetup.xmpp.fqdn"
));
JiveGlobals
.
migrateProperty
(
"xmpp.domain"
);
JiveGlobals
.
migrateProperty
(
"xmpp.fqdn"
);
JiveGlobals
.
setProperty
(
"xmpp.socket.ssl.active"
,
JiveGlobals
.
getXMLProperty
(
"autosetup.xmpp.socket.ssl.active"
,
"true"
));
JiveGlobals
.
setProperty
(
"xmpp.auth.anonymous"
,
JiveGlobals
.
getXMLProperty
(
"autosetup.xmpp.auth.anonymous"
,
"false"
));
JiveGlobals
.
setupPropertyEncryptionAlgorithm
(
JiveGlobals
.
getXMLProperty
(
"autosetup.encryption.algorithm"
,
"Blowfish"
));
// or AES
JiveGlobals
.
setupPropertyEncryptionKey
(
JiveGlobals
.
getXMLProperty
(
"autosetup.encryption.key"
,
null
));
// steps from setup-profile-settings.jsp
if
(
"default"
.
equals
(
JiveGlobals
.
getXMLProperty
(
"autosetup.authprovider.mode"
,
"default"
)))
{
JiveGlobals
.
setXMLProperty
(
"connectionProvider.className"
,
"org.jivesoftware.database.DefaultConnectionProvider"
);
JiveGlobals
.
setProperty
(
"provider.auth.className"
,
JiveGlobals
.
getXMLProperty
(
"provider.auth.className"
,
org
.
jivesoftware
.
openfire
.
auth
.
DefaultAuthProvider
.
class
.
getName
()));
JiveGlobals
.
setProperty
(
"provider.user.className"
,
JiveGlobals
.
getXMLProperty
(
"provider.user.className"
,
org
.
jivesoftware
.
openfire
.
user
.
DefaultUserProvider
.
class
.
getName
()));
JiveGlobals
.
setProperty
(
"provider.group.className"
,
JiveGlobals
.
getXMLProperty
(
"provider.group.className"
,
org
.
jivesoftware
.
openfire
.
group
.
DefaultGroupProvider
.
class
.
getName
()));
JiveGlobals
.
setProperty
(
"provider.vcard.className"
,
JiveGlobals
.
getXMLProperty
(
"provider.vcard.className"
,
org
.
jivesoftware
.
openfire
.
vcard
.
DefaultVCardProvider
.
class
.
getName
()));
JiveGlobals
.
setProperty
(
"provider.lockout.className"
,
JiveGlobals
.
getXMLProperty
(
"provider.lockout.className"
,
org
.
jivesoftware
.
openfire
.
lockout
.
DefaultLockOutProvider
.
class
.
getName
()));
JiveGlobals
.
setProperty
(
"provider.securityAudit.className"
,
JiveGlobals
.
getXMLProperty
(
"provider.securityAudit.className"
,
org
.
jivesoftware
.
openfire
.
security
.
DefaultSecurityAuditProvider
.
class
.
getName
()));
JiveGlobals
.
setProperty
(
"provider.admin.className"
,
JiveGlobals
.
getXMLProperty
(
"provider.admin.className"
,
org
.
jivesoftware
.
openfire
.
admin
.
DefaultAdminProvider
.
class
.
getName
()));
// make configurable?
JiveGlobals
.
setProperty
(
"user.scramHashedPasswordOnly"
,
"true"
);
}
// steps from setup-admin-settings.jsp
try
{
User
adminUser
=
UserManager
.
getInstance
().
getUser
(
"admin"
);
adminUser
.
setPassword
(
JiveGlobals
.
getXMLProperty
(
"autosetup.admin.password"
));
adminUser
.
setEmail
(
JiveGlobals
.
getXMLProperty
(
"autosetup.admin.email"
));
Date
now
=
new
Date
();
adminUser
.
setCreationDate
(
now
);
adminUser
.
setModificationDate
(
now
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
logger
.
warn
(
"There was an unexpected error encountered when "
+
"setting the new admin information. Please check your error "
+
"logs and try to remedy the problem."
);
}
// finish setup
this
.
finalSetupSteps
();
setupMode
=
false
;
}
private
void
finalSetupSteps
()
{
for
(
String
propName
:
JiveGlobals
.
getXMLPropertyNames
())
{
for
(
String
propName
:
JiveGlobals
.
getXMLPropertyNames
())
{
if
(
JiveGlobals
.
getProperty
(
propName
)
==
null
)
{
if
(
JiveGlobals
.
getProperty
(
propName
)
==
null
)
{
JiveGlobals
.
setProperty
(
propName
,
JiveGlobals
.
getXMLProperty
(
propName
));
JiveGlobals
.
setProperty
(
propName
,
JiveGlobals
.
getXMLProperty
(
propName
));
...
@@ -367,6 +470,24 @@ public class XMPPServer {
...
@@ -367,6 +470,24 @@ public class XMPPServer {
// Initialize list of admins now (before we restart Jetty)
// Initialize list of admins now (before we restart Jetty)
AdminManager
.
getInstance
().
getAdminAccounts
();
AdminManager
.
getInstance
().
getAdminAccounts
();
}
/**
* Finish the setup process. Because this method is meant to be called from inside
* the Admin console plugin, it spawns its own thread to do the work so that the
* class loader is correct.
*/
public
void
finishSetup
()
{
if
(!
setupMode
)
{
return
;
}
this
.
finalSetupSteps
();
// Make sure that setup finished correctly.
if
(
"true"
.
equals
(
JiveGlobals
.
getXMLProperty
(
"setup"
)))
{
// Iterate through all the provided XML properties and set the ones that haven't
// already been touched by setup prior to this method being called.
Thread
finishSetup
=
new
Thread
()
{
Thread
finishSetup
=
new
Thread
()
{
@Override
@Override
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment