Commit 48cccc58 authored by Christian Schudt's avatar Christian Schudt

Remove support for Legacy date/time (XEP-0090 and XEP-0091).

These specifications are deprecated long enough (since 2007) in favor of XEP-202/203.
parent 82e13c81
...@@ -158,10 +158,6 @@ XEPs that only require client-side support are omitted.</p> ...@@ -158,10 +158,6 @@ XEPs that only require client-side support are omitted.</p>
<td><a href="http://www.xmpp.org/extensions/xep-0082.html">XEP-0082</a>: XMPP Date and Time Profiles</td> <td><a href="http://www.xmpp.org/extensions/xep-0082.html">XEP-0082</a>: XMPP Date and Time Profiles</td>
</tr><tr> </tr><tr>
<td><a href="http://www.xmpp.org/extensions/xep-0086.html">XEP-0086</a>: Error Condition Mappings</td> <td><a href="http://www.xmpp.org/extensions/xep-0086.html">XEP-0086</a>: Error Condition Mappings</td>
</tr><tr>
<td><a href="http://www.xmpp.org/extensions/xep-0090.html">XEP-0090</a>: Legacy Entity Time</td>
</tr><tr>
<td><a href="http://www.xmpp.org/extensions/xep-0091.html">XEP-0091</a>: Legacy Delayed Delivery</td>
</tr><tr> </tr><tr>
<td><a href="http://www.xmpp.org/extensions/xep-0092.html">XEP-0092</a>: Software Version</td> <td><a href="http://www.xmpp.org/extensions/xep-0092.html">XEP-0092</a>: Software Version</td>
</tr><tr> </tr><tr>
......
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
<module interface="org.jivesoftware.openfire.handler.IQPrivateHandler" implementation="org.jivesoftware.openfire.handler.IQPrivateHandler" /> <module interface="org.jivesoftware.openfire.handler.IQPrivateHandler" implementation="org.jivesoftware.openfire.handler.IQPrivateHandler" />
<module interface="org.jivesoftware.openfire.handler.IQRegisterHandler" implementation="org.jivesoftware.openfire.handler.IQRegisterHandler" /> <module interface="org.jivesoftware.openfire.handler.IQRegisterHandler" implementation="org.jivesoftware.openfire.handler.IQRegisterHandler" />
<module interface="org.jivesoftware.openfire.handler.IQRosterHandler" implementation="org.jivesoftware.openfire.handler.IQRosterHandler" /> <module interface="org.jivesoftware.openfire.handler.IQRosterHandler" implementation="org.jivesoftware.openfire.handler.IQRosterHandler" />
<module interface="org.jivesoftware.openfire.handler.IQTimeHandler" implementation="org.jivesoftware.openfire.handler.IQTimeHandler" />
<module interface="org.jivesoftware.openfire.handler.IQEntityTimeHandler" implementation="org.jivesoftware.openfire.handler.IQEntityTimeHandler" /> <module interface="org.jivesoftware.openfire.handler.IQEntityTimeHandler" implementation="org.jivesoftware.openfire.handler.IQEntityTimeHandler" />
<module interface="org.jivesoftware.openfire.handler.IQvCardHandler" implementation="org.jivesoftware.openfire.handler.IQvCardHandler" /> <module interface="org.jivesoftware.openfire.handler.IQvCardHandler" implementation="org.jivesoftware.openfire.handler.IQvCardHandler" />
<module interface="org.jivesoftware.openfire.handler.IQVersionHandler" implementation="org.jivesoftware.openfire.handler.IQVersionHandler" /> <module interface="org.jivesoftware.openfire.handler.IQVersionHandler" implementation="org.jivesoftware.openfire.handler.IQVersionHandler" />
......
...@@ -222,10 +222,6 @@ public class OfflineMessageStore extends BasicModule implements UserEventListene ...@@ -222,10 +222,6 @@ public class OfflineMessageStore extends BasicModule implements UserEventListene
Element delay = message.addChildElement("delay", "urn:xmpp:delay"); Element delay = message.addChildElement("delay", "urn:xmpp:delay");
delay.addAttribute("from", XMPPServer.getInstance().getServerInfo().getXMPPDomain()); delay.addAttribute("from", XMPPServer.getInstance().getServerInfo().getXMPPDomain());
delay.addAttribute("stamp", XMPPDateTimeFormat.format(creationDate)); delay.addAttribute("stamp", XMPPDateTimeFormat.format(creationDate));
// Add a legacy delayed delivery (XEP-0091) element to the message. XEP is obsolete and support should be dropped in future.
delay = message.addChildElement("x", "jabber:x:delay");
delay.addAttribute("from", XMPPServer.getInstance().getServerInfo().getXMPPDomain());
delay.addAttribute("stamp", XMPPDateTimeFormat.formatOld(creationDate));
} }
messages.add(message); messages.add(message);
} }
...@@ -290,10 +286,6 @@ public class OfflineMessageStore extends BasicModule implements UserEventListene ...@@ -290,10 +286,6 @@ public class OfflineMessageStore extends BasicModule implements UserEventListene
Element delay = message.addChildElement("delay", "urn:xmpp:delay"); Element delay = message.addChildElement("delay", "urn:xmpp:delay");
delay.addAttribute("from", XMPPServer.getInstance().getServerInfo().getXMPPDomain()); delay.addAttribute("from", XMPPServer.getInstance().getServerInfo().getXMPPDomain());
delay.addAttribute("stamp", XMPPDateTimeFormat.format(creationDate)); delay.addAttribute("stamp", XMPPDateTimeFormat.format(creationDate));
// Add a legacy delayed delivery (XEP-0091) element to the message. XEP is obsolete and support should be dropped in future.
delay = message.addChildElement("x", "jabber:x:delay");
delay.addAttribute("from", XMPPServer.getInstance().getServerInfo().getXMPPDomain());
delay.addAttribute("stamp", XMPPDateTimeFormat.formatOld(creationDate));
} }
} }
catch (Exception e) { catch (Exception e) {
......
...@@ -1257,11 +1257,8 @@ public class SessionManager extends BasicModule implements ClusterEventListener/ ...@@ -1257,11 +1257,8 @@ public class SessionManager extends BasicModule implements ClusterEventListener/
if (unacked.packet instanceof Message) { if (unacked.packet instanceof Message) {
Message m = (Message)unacked.packet; Message m = (Message)unacked.packet;
Element delayInformation = m.addChildElement("delay", "urn:xmpp:delay"); Element delayInformation = m.addChildElement("delay", "urn:xmpp:delay");
Element delayInformationOld = m.addChildElement("x", "jabber:x:delay");
delayInformation.addAttribute("stamp", XMPPDateTimeFormat.format(unacked.timestamp)); delayInformation.addAttribute("stamp", XMPPDateTimeFormat.format(unacked.timestamp));
delayInformationOld.addAttribute("stamp", XMPPDateTimeFormat.formatOld(unacked.timestamp));
delayInformation.addAttribute("from", serverAddress.toBareJID()); delayInformation.addAttribute("from", serverAddress.toBareJID());
delayInformationOld.addAttribute("from", serverAddress.toBareJID());
} }
router.route(unacked.packet); router.route(unacked.packet);
} }
......
/**
* $RCSfile$
* $Revision: 1747 $
* $Date: 2005-08-04 18:36:36 -0300 (Thu, 04 Aug 2005) $
*
* Copyright (C) 2004-2008 Jive Software. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.openfire.handler;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.QName;
import org.jivesoftware.openfire.IQHandlerInfo;
import org.jivesoftware.openfire.disco.ServerFeaturesProvider;
import org.jivesoftware.util.XMPPDateTimeFormat;
import org.xmpp.packet.IQ;
import java.text.DateFormat;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
/**
* Implements the TYPE_IQ jabber:iq:time protocol (time info) as
* as defined by JEP-0090. Allows Jabber entities to query each
* other's local time. The server will respond with its local time.
* <h2>Assumptions</h2>
* This handler assumes that the time request is addressed to itself.
* An appropriate TYPE_IQ tag matcher should be placed in front of this
* one to route TYPE_IQ time requests not addressed to the server to
* another channel (probably for direct delivery to the recipient).
* <h2>Warning</h2>
* There should be a way of determining whether a session has
* authorization to access this feature. I'm not sure it is a good
* idea to do authorization in each handler. It would be nice if
* the framework could assert authorization policies across channels.
*
* @author Iain Shigeoka
*/
public class IQTimeHandler extends IQHandler implements ServerFeaturesProvider {
// todo: Make display text match the locale of user (xml:lang support)
private static final DateFormat DATE_FORMAT = DateFormat.getDateInstance(DateFormat.MEDIUM);
private static final DateFormat TIME_FORMAT = DateFormat.getTimeInstance(DateFormat.LONG);
private Element responseElement;
private IQHandlerInfo info;
public IQTimeHandler() {
super("XMPP Server Time Handler");
info = new IQHandlerInfo("query", "jabber:iq:time");
responseElement = DocumentHelper.createElement(QName.get("query", "jabber:iq:time"));
responseElement.addElement("utc");
responseElement.addElement("tz").setText(TIME_FORMAT.getTimeZone().getDisplayName());
responseElement.addElement("display");
}
@Override
public IQ handleIQ(IQ packet) {
IQ response = null;
response = IQ.createResultIQ(packet);
response.setChildElement(buildResponse());
return response;
}
/**
* Build the responseElement packet
*/
private Element buildResponse() {
Element response = responseElement.createCopy();
Date current = new Date();
response.element("utc").setText(XMPPDateTimeFormat.formatOld(current));
StringBuilder display = new StringBuilder(DATE_FORMAT.format(current));
display.append(' ');
display.append(TIME_FORMAT.format(current));
response.element("display").setText(display.toString());
return response;
}
@Override
public IQHandlerInfo getInfo() {
return info;
}
@Override
public Iterator<String> getFeatures() {
return Collections.singleton("jabber:iq:time").iterator();
}
}
\ No newline at end of file
...@@ -200,7 +200,7 @@ public class PacketCopier implements PacketInterceptor, ComponentEventListener { ...@@ -200,7 +200,7 @@ public class PacketCopier implements PacketInterceptor, ComponentEventListener {
"http://jabber.org/protocol/packet#event"); "http://jabber.org/protocol/packet#event");
childElement.addAttribute("incoming", subscription.isIncoming() ? "true" : "false"); childElement.addAttribute("incoming", subscription.isIncoming() ? "true" : "false");
childElement.addAttribute("processed", subscription.isProcessed() ? "true" : "false"); childElement.addAttribute("processed", subscription.isProcessed() ? "true" : "false");
childElement.addAttribute("date", XMPPDateTimeFormat.formatOld(interceptedPacket.getCreationDate())); childElement.addAttribute("date", XMPPDateTimeFormat.format(interceptedPacket.getCreationDate()));
childElement.add(interceptedPacket.getElement().createCopy()); childElement.add(interceptedPacket.getElement().createCopy());
// Send message notification to subscribed component // Send message notification to subscribed component
routingTable.routePacket(message.getTo(), message, true); routingTable.routePacket(message.getTo(), message, true);
......
...@@ -178,7 +178,7 @@ public class HistoryRequest { ...@@ -178,7 +178,7 @@ public class HistoryRequest {
} }
if (getSeconds() > -1 || getSince() != null) { if (getSeconds() > -1 || getSince() != null) {
delayInformation = message.getChildElement("x", "jabber:x:delay"); delayInformation = message.getChildElement("delay", "urn:xmpp:delay");
try { try {
// Get the date when the historic message was sent // Get the date when the historic message was sent
Date delayedDate = xmppDateTime.parseString(delayInformation.attributeValue("stamp")); Date delayedDate = xmppDateTime.parseString(delayInformation.attributeValue("stamp"));
......
...@@ -325,8 +325,8 @@ public class HistoryStrategy { ...@@ -325,8 +325,8 @@ public class HistoryStrategy {
private static class MessageComparator implements Comparator<Message> { private static class MessageComparator implements Comparator<Message> {
@Override @Override
public int compare(Message o1, Message o2) { public int compare(Message o1, Message o2) {
String stamp1 = o1.getChildElement("x", "jabber:x:delay").attributeValue("stamp"); String stamp1 = o1.getChildElement("delay", "urn:xmpp:delay").attributeValue("stamp");
String stamp2 = o2.getChildElement("x", "jabber:x:delay").attributeValue("stamp"); String stamp2 = o2.getChildElement("delay", "urn:xmpp:delay").attributeValue("stamp");
return stamp1.compareTo(stamp2); return stamp1.compareTo(stamp2);
} }
} }
......
...@@ -80,7 +80,7 @@ public final class MUCRoomHistory { ...@@ -80,7 +80,7 @@ public final class MUCRoomHistory {
// TODO Make this update in a separate thread // TODO Make this update in a separate thread
for (Iterator<Message> it = getMessageHistory(); it.hasNext();) { for (Iterator<Message> it = getMessageHistory(); it.hasNext();) {
Message message = it.next(); Message message = it.next();
Element delayElement = message.getChildElement("x", "jabber:x:delay"); Element delayElement = message.getChildElement("delay", "urn:xmpp:delay");
if (room.canAnyoneDiscoverJID()) { if (room.canAnyoneDiscoverJID()) {
// Set the Full JID as the "from" attribute // Set the Full JID as the "from" attribute
try { try {
...@@ -101,16 +101,13 @@ public final class MUCRoomHistory { ...@@ -101,16 +101,13 @@ public final class MUCRoomHistory {
// Add the delay information to the message // Add the delay information to the message
Element delayInformation = packetToAdd.addChildElement("delay", "urn:xmpp:delay"); Element delayInformation = packetToAdd.addChildElement("delay", "urn:xmpp:delay");
Element delayInformationOld = packetToAdd.addChildElement("x", "jabber:x:delay");
Date current = new Date(); Date current = new Date();
delayInformation.addAttribute("stamp", XMPPDateTimeFormat.format(current)); delayInformation.addAttribute("stamp", XMPPDateTimeFormat.format(current));
delayInformationOld.addAttribute("stamp", XMPPDateTimeFormat.formatOld(current));
if (room.canAnyoneDiscoverJID()) { if (room.canAnyoneDiscoverJID()) {
// Set the Full JID as the "from" attribute // Set the Full JID as the "from" attribute
try { try {
MUCRole role = room.getOccupant(packet.getFrom().getResource()); MUCRole role = room.getOccupant(packet.getFrom().getResource());
delayInformation.addAttribute("from", role.getUserAddress().toString()); delayInformation.addAttribute("from", role.getUserAddress().toString());
delayInformationOld.addAttribute("from", role.getUserAddress().toString());
} }
catch (UserNotFoundException e) { catch (UserNotFoundException e) {
// Ignore. // Ignore.
...@@ -119,7 +116,6 @@ public final class MUCRoomHistory { ...@@ -119,7 +116,6 @@ public final class MUCRoomHistory {
else { else {
// Set the Room JID as the "from" attribute // Set the Room JID as the "from" attribute
delayInformation.addAttribute("from", packet.getFrom().toString()); delayInformation.addAttribute("from", packet.getFrom().toString());
delayInformationOld.addAttribute("from", packet.getFrom().toString());
} }
historyStrategy.addMessage(packetToAdd); historyStrategy.addMessage(packetToAdd);
} }
...@@ -170,18 +166,14 @@ public final class MUCRoomHistory { ...@@ -170,18 +166,14 @@ public final class MUCRoomHistory {
// Add the delay information to the message // Add the delay information to the message
Element delayInformation = message.addChildElement("delay", "urn:xmpp:delay"); Element delayInformation = message.addChildElement("delay", "urn:xmpp:delay");
Element delayInformationOld = message.addChildElement("x", "jabber:x:delay");
delayInformation.addAttribute("stamp", XMPPDateTimeFormat.format(sentDate)); delayInformation.addAttribute("stamp", XMPPDateTimeFormat.format(sentDate));
delayInformationOld.addAttribute("stamp", XMPPDateTimeFormat.formatOld(sentDate));
if (room.canAnyoneDiscoverJID()) { if (room.canAnyoneDiscoverJID()) {
// Set the Full JID as the "from" attribute // Set the Full JID as the "from" attribute
delayInformation.addAttribute("from", senderJID); delayInformation.addAttribute("from", senderJID);
delayInformationOld.addAttribute("from", senderJID);
} }
else { else {
// Set the Room JID as the "from" attribute // Set the Room JID as the "from" attribute
delayInformation.addAttribute("from", room.getRole().getRoleAddress().toString()); delayInformation.addAttribute("from", room.getRole().getRoleAddress().toString());
delayInformationOld.addAttribute("from", room.getRole().getRoleAddress().toString());
} }
historyStrategy.addMessage(message); historyStrategy.addMessage(message);
} }
......
...@@ -1458,7 +1458,7 @@ public class MultiUserChatServiceImpl implements Component, MultiUserChatService ...@@ -1458,7 +1458,7 @@ public class MultiUserChatServiceImpl implements Component, MultiUserChatService
final FormField fieldDate = dataForm.addField(); final FormField fieldDate = dataForm.addField();
fieldDate.setVariable("x-muc#roominfo_creationdate"); fieldDate.setVariable("x-muc#roominfo_creationdate");
fieldDate.setLabel(LocaleUtils.getLocalizedString("muc.extended.info.creationdate")); fieldDate.setLabel(LocaleUtils.getLocalizedString("muc.extended.info.creationdate"));
fieldDate.addValue(XMPPDateTimeFormat.formatOld(room.getCreationDate())); fieldDate.addValue(XMPPDateTimeFormat.format(room.getCreationDate()));
return dataForm; return dataForm;
} }
......
...@@ -68,12 +68,9 @@ public class XMPPDateTimeFormat { ...@@ -68,12 +68,9 @@ public class XMPPDateTimeFormat {
private static final FastDateFormat FAST_FORMAT = FastDateFormat.getInstance( private static final FastDateFormat FAST_FORMAT = FastDateFormat.getInstance(
XMPP_DATETIME_FORMAT, TimeZone.getTimeZone("UTC")); XMPP_DATETIME_FORMAT, TimeZone.getTimeZone("UTC"));
private static final FastDateFormat FAST_FORMAT_OLD = FastDateFormat.getInstance(
XMPP_DELAY_DATETIME_FORMAT, TimeZone.getTimeZone("UTC"));
private final DateFormat dateTimeFormat = new SimpleDateFormat(XMPP_DATETIME_FORMAT_WO_TIMEZONE + 'Z'); private final DateFormat dateTimeFormat = new SimpleDateFormat(XMPP_DATETIME_FORMAT_WO_TIMEZONE + 'Z');
private final DateFormat dateTimeFormatWoMillies = new SimpleDateFormat(XMPP_DATETIME_FORMAT_WO_MILLIS_WO_TIMEZONE + 'Z'); private final DateFormat dateTimeFormatWoMillies = new SimpleDateFormat(XMPP_DATETIME_FORMAT_WO_MILLIS_WO_TIMEZONE + 'Z');
private final DateFormat dateTimeFormatOld = new SimpleDateFormat(XMPP_DELAY_DATETIME_FORMAT);
/** /**
* Create a new thread-safe instance of this utility class * Create a new thread-safe instance of this utility class
...@@ -82,7 +79,6 @@ public class XMPPDateTimeFormat { ...@@ -82,7 +79,6 @@ public class XMPPDateTimeFormat {
TimeZone utc = TimeZone.getTimeZone("UTC"); TimeZone utc = TimeZone.getTimeZone("UTC");
dateTimeFormat.setTimeZone(utc); dateTimeFormat.setTimeZone(utc);
dateTimeFormatWoMillies.setTimeZone(utc); dateTimeFormatWoMillies.setTimeZone(utc);
dateTimeFormatOld.setTimeZone(utc);
} }
/** /**
...@@ -129,29 +125,8 @@ public class XMPPDateTimeFormat { ...@@ -129,29 +125,8 @@ public class XMPPDateTimeFormat {
return dateTimeFormat.parse(rfc822Date); return dateTimeFormat.parse(rfc822Date);
} }
} }
} else {
// at last try with the legacy format
synchronized (dateTimeFormatOld) {
return dateTimeFormatOld.parse(dateString);
}
}
}
/**
* Tries to convert a given string to a Date object.
* This method only supports the legacy XMPP time format: CCYYMMDDThh:mm:ss
*
* This method either returns a Date instance as result or it will return null or throw a ParseException
* in case the String couldn't be parsed.
*
* @param dateStr
* @return the parsed date or null if the String could not be parsed
* @throws ParseException
*/
public Date parseOldDate(String dateStr) throws ParseException {
synchronized (dateTimeFormatOld) {
return dateTimeFormatOld.parse(dateStr);
} }
throw new ParseException("Date String could not be parsed", 0);
} }
/** /**
...@@ -166,16 +141,4 @@ public class XMPPDateTimeFormat { ...@@ -166,16 +141,4 @@ public class XMPPDateTimeFormat {
public static String format(Date date) { public static String format(Date date) {
return FAST_FORMAT.format(date); return FAST_FORMAT.format(date);
} }
/**
* Formats a Date object to String as defined in legacy XMPP protocols (e.g. XEP-0090)
*
* CCYYMMDDThh:mm:ss
*
* @param date
* @return String
*/
public static String formatOld(Date date) {
return FAST_FORMAT_OLD.format(date);
}
} }
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