Skip to content

Commit

Permalink
Fix compatibility issue with Openfire 4.9.0
Browse files Browse the repository at this point in the history
Replaced Openfire API usage that was deprecated in Openfire 4.8.0 and removed in 4.9.0.

This plugin is now compatible with Openfire 4.9.0 and requires 4.8.0 or later. No longer compatible with versions older than 4.8.0.

fixes #2
  • Loading branch information
guusdk committed Sep 11, 2024
1 parent 221ba3d commit 5660e56
Show file tree
Hide file tree
Showing 21 changed files with 29 additions and 22 deletions.
6 changes: 6 additions & 0 deletions changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
<h1>Onesocialweb Plugin Changelog
</h1>

<p><b>0.7.0</b> -- (tbd)</p>
<ul>
<li>Now requires Openfire 4.8.0</li>
<li>Fixes <a href="https://github.com/igniterealtime/openfire-galene-plugin/issues/6">issue #6</a>: Fix compatibility issue with Openfire 4.9.0</li>
</ul>

<p><b>0.6</b> -- April 1st, 2010</p>
<ul>
<li>First public release.</li>
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<url>http://onesocialweb.org</url>
<version>${pom.version}</version>
<date>${openfire-plugin.build.date}</date>
<minServerVersion>3.7.1</minServerVersion>
<minServerVersion>4.8.0</minServerVersion>
<licenseType>apache</licenseType>
</plugin>
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>plugins</artifactId>
<groupId>org.igniterealtime.openfire</groupId>
<version>4.7.1</version>
<version>4.8.0</version>
</parent>

<groupId>org.onesocialweb</groupId>
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<img src="https://igniterealtime.github.io/openfire-osw-plugin/onesocialweb.png" />

This is the revived onesocialweb project for Openfire 4.7.1+. It includes:
This is the revived onesocialweb project for Openfire 4.8.0+. It includes:

- the Openfire plugin
- the web client which can be accessed with https://your-server:7443/osw.
Expand Down
5 changes: 3 additions & 2 deletions src/java/org/onesocialweb/openfire/OswPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.onesocialweb.openfire;

import java.io.File;
import java.nio.file.Path;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.util.Hashtable;
Expand Down Expand Up @@ -208,7 +209,7 @@ private void setConnectionProperties() {
}
}

String logFile = JiveGlobals.getHomeDirectory() + "/logs/osw_openjpa.log";
Path logFile = JiveGlobals.getHomePath().resolve("logs").resolve("osw_openjpa.log");
String debugLevel = "INFO";

if (Log.isDebugEnabled()) {
Expand All @@ -221,7 +222,7 @@ private void setConnectionProperties() {
connProperties.put("openjpa.ConnectionUserName", username);
connProperties.put("openjpa.ConnectionPassword", password);

connProperties.put("openjpa.Log", "DefaultLevel=" + debugLevel + ", Tool=" + debugLevel + ", SQL=" + debugLevel + ", File=" + logFile);
connProperties.put("openjpa.Log", "DefaultLevel=" + debugLevel + ", Tool=" + debugLevel + ", SQL=" + debugLevel + ", File=" + logFile.toAbsolutePath());
connProperties.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
connProperties.put("openjpa.Multithreaded", "true");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ public void interceptPacket(Packet packet, Session session,
return;
}

// We only care for messaes to local users
// We only care for messages to local users
if (!server.isLocal(toJID)
|| !server.getUserManager().isRegisteredUser(toJID)) {
|| !server.getUserManager().isRegisteredUser(toJID, false)) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public IQ handleIQ(IQ packet) throws UnauthorizedException {
}

// Only a local user can delete an activity to his stream
if (!userManager.isRegisteredUser(sender.getNode())) {
if (!userManager.isRegisteredUser(sender, false)) {
IQ result = IQ.createResultIQ(packet);
result.setChildElement(packet.getChildElement().createCopy());
result.setError(PacketError.Condition.not_authorized);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public IQ handleIQ(IQ packet) throws UnauthorizedException {
}

// Only a local user can publish an activity to his stream
if (!userManager.isRegisteredUser(sender.getNode())) {
if (!userManager.isRegisteredUser(sender, false)) {
IQ result = IQ.createResultIQ(packet);
result.setChildElement(packet.getChildElement().createCopy());
result.setError(PacketError.Condition.not_authorized);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public IQ handleIQ(IQ packet) throws UnauthorizedException {

// A valid request is an IQ of type get, for a valid and local recipient
if (!(packet.getType().equals(IQ.Type.get) && target != null && target.getNode() != null
&& userManager.isRegisteredUser(target.getNode()))) {
&& userManager.isRegisteredUser(target, false))) {
IQ result = IQ.createResultIQ(packet);
result.setChildElement(packet.getChildElement().createCopy());
result.setError(PacketError.Condition.bad_request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public IQ handleIQ(IQ packet) throws UnauthorizedException {

// A valid request is an IQ of type set, for a valid and local recipient
if (!(packet.getType().equals(IQ.Type.set) && recipient != null && recipient.getNode() != null
&& userManager.isRegisteredUser(recipient.getNode()))) {
&& userManager.isRegisteredUser(recipient, false))) {
IQ result = IQ.createResultIQ(packet);
result.setChildElement(packet.getChildElement().createCopy());
result.setError(PacketError.Condition.bad_request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public IQ handleIQ(IQ packet) throws UnauthorizedException {

// A valid request is an IQ of type get, for a valid and local recipient
if (!(packet.getType().equals(IQ.Type.get) && recipient != null && recipient.getNode() != null
&& userManager.isRegisteredUser(recipient.getNode()))) {
&& userManager.isRegisteredUser(recipient, false))) {
IQ result = IQ.createResultIQ(packet);
result.setChildElement(packet.getChildElement().createCopy());
result.setError(PacketError.Condition.bad_request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public IQ handleIQ(IQ packet) throws UnauthorizedException {

// A valid request is an IQ of type get, for a valid and local recipient
if (!(packet.getType().equals(IQ.Type.get) && recipient != null && recipient.getNode() != null
&& userManager.isRegisteredUser(recipient.getNode()))) {
&& userManager.isRegisteredUser(recipient, false))) {
IQ result = IQ.createResultIQ(packet);
result.setChildElement(packet.getChildElement().createCopy());
result.setError(PacketError.Condition.bad_request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public IQ handleIQ(IQ packet) throws UnauthorizedException {

// A valid request is an IQ of type set, for a valid and local recipient
if (!(packet.getType().equals(IQ.Type.set) && recipient != null && recipient.getNode() != null
&& userManager.isRegisteredUser(recipient.getNode()))) {
&& userManager.isRegisteredUser(recipient, false))) {
IQ result = IQ.createResultIQ(packet);
result.setChildElement(packet.getChildElement().createCopy());
result.setError(PacketError.Condition.bad_request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public IQ handleIQ(IQ packet) throws UnauthorizedException {
}

// Only a local user can publish an activity to his stream
if (!userManager.isRegisteredUser(sender.getNode())) {
if (!userManager.isRegisteredUser(sender, false)) {
IQ result = IQ.createResultIQ(packet);
result.setChildElement(packet.getChildElement().createCopy());
result.setError(PacketError.Condition.not_authorized);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public IQ handleIQ(IQ packet) throws UnauthorizedException {
}

// Only a local user has an inbox
if (!userManager.isRegisteredUser(sender.getNode())) {
if (!userManager.isRegisteredUser(sender, false)) {
IQ result = IQ.createResultIQ(packet);
result.setChildElement(packet.getChildElement().createCopy());
result.setError(PacketError.Condition.not_authorized);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public IQ handleIQ(IQ packet) throws UnauthorizedException {
}

// Only a local user can publish its profile
if (!userManager.isRegisteredUser(sender.getNode())) {
if (!userManager.isRegisteredUser(sender, false)) {
IQ result = IQ.createResultIQ(packet);
result.setChildElement(packet.getChildElement().createCopy());
result.setError(PacketError.Condition.not_authorized);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public IQ handleIQ(IQ packet) throws UnauthorizedException {

// A valid request is an IQ of type get, for a valid and local recipient
if (!(packet.getType().equals(IQ.Type.get) && target != null && target.getNode() != null
&& userManager.isRegisteredUser(target.getNode()))) {
&& userManager.isRegisteredUser(target, false))) {
IQ result = IQ.createResultIQ(packet);
result.setChildElement(packet.getChildElement().createCopy());
result.setError(PacketError.Condition.bad_request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public IQ handleIQ(IQ packet) throws UnauthorizedException {

// A valid request is an IQ of type get, for a valid and local recipient
if (!(packet.getType().equals(IQ.Type.get) && target != null && target.getNode() != null
&& userManager.isRegisteredUser(target.getNode()))) {
&& userManager.isRegisteredUser(target, false))) {
IQ result = IQ.createResultIQ(packet);
result.setChildElement(packet.getChildElement().createCopy());
result.setError(PacketError.Condition.bad_request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public IQ handleIQ(IQ packet) throws UnauthorizedException {
}

// Only a local user can publish an activity to his stream
if (!userManager.isRegisteredUser(sender.getNode())) {
if (!userManager.isRegisteredUser(sender, false)) {
IQ result = IQ.createResultIQ(packet);
result.setChildElement(packet.getChildElement().createCopy());
result.setError(PacketError.Condition.not_authorized);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public IQ handleIQ(IQ packet) throws UnauthorizedException {
try {

// Only a local user can request to update a relation
if (!userManager.isRegisteredUser(sender.getNode())) {
if (!userManager.isRegisteredUser(sender, false)) {
IQ result = IQ.createResultIQ(packet);
result.setChildElement(packet.getChildElement().createCopy());
result.setError(PacketError.Condition.not_authorized);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private boolean validateLocalSession(String jid, String signature) {
}

// Is the session authenticated ?
if (session.getStatus() != Session.STATUS_AUTHENTICATED) {
if (session.getStatus() != Session.Status.AUTHENTICATED) {
return false;
}

Expand Down

0 comments on commit 5660e56

Please sign in to comment.