Commit 3a31141c authored by Derek DeMoro's avatar Derek DeMoro Committed by derek

Refactoring work.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@605 b35dd754-fafc-0310-a699-88a17e54d16e
parent 5f5dad2f
......@@ -11,17 +11,13 @@
package org.jivesoftware.messenger.forms.spi;
import org.jivesoftware.messenger.forms.FormField;
import org.jivesoftware.util.Log;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.io.IOException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.XMLWriter;
import org.xmlpull.v1.XmlPullParserException;
import org.jivesoftware.messenger.forms.FormField;
/**
* A concrete FormField capable of sending itself to a writer and recover its state from an XMPP
......@@ -246,23 +242,6 @@ public class XFormFieldImpl implements FormField {
return value;
}
public void send(XMLWriter xmlSerializer, int version) throws XmlPullParserException {
Element jabber = DocumentHelper.createElement("option").addNamespace("", "jabber:x:data");
if (getLabel() != null) {
jabber.addAttribute("label", getLabel());
}
if (getValue() != null) {
Element subElement = jabber.addElement("value", "jabber:x:data");
subElement.addText(getValue());
}
try {
xmlSerializer.write(jabber);
}
catch (IOException e) {
Log.error(e);
}
}
public Element asXMLElement() {
Element option = DocumentHelper.createElement("option");
if (getLabel() != null) {
......
/**
* $RCSfile$
* $Revision$
* $Date$
*
* Copyright (C) 2004 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.
*/
package org.jivesoftware.messenger.spi;
import org.jivesoftware.messenger.*;
import org.jivesoftware.messenger.auth.AuthToken;
import org.jivesoftware.messenger.auth.Permissions;
import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.xmpp.packet.Packet;
import java.net.InetAddress;
import java.net.UnknownHostException;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
/**
* Decorates a connection object with permission checks.
*
* @author Iain Shigeoka
*/
public class ConnectionProxy implements Connection {
/**
* Permissions associated with this connection
*/
private Permissions permissions;
/**
* The connection this proxy is protecting
*/
private Connection conn;
/**
* Authentication token for this proxy
*/
private AuthToken auth;
public ConnectionProxy(Connection connection, AuthToken auth, Permissions perm) {
conn = connection;
permissions = perm;
this.auth = auth;
}
public boolean validate() {
return conn.validate();
}
public void init(Session session) {
conn.init(session);
}
public InetAddress getInetAddress()
throws UnauthorizedException, UnknownHostException {
if (permissions.hasPermission(Permissions.SYSTEM_ADMIN
| Permissions.USER_ADMIN)) {
return conn.getInetAddress();
}
else {
throw new org.jivesoftware.messenger.auth.UnauthorizedException();
}
}
public XMLStreamWriter getSerializer() throws UnauthorizedException {
if (permissions.hasPermission(Permissions.SYSTEM_ADMIN
| Permissions.USER_ADMIN)) {
return conn.getSerializer();
}
else {
throw new org.jivesoftware.messenger.auth.UnauthorizedException();
}
}
public void close() throws UnauthorizedException {
if (permissions.hasPermission(Permissions.SYSTEM_ADMIN
| Permissions.USER_ADMIN)) {
conn.close();
}
else {
throw new org.jivesoftware.messenger.auth.UnauthorizedException();
}
}
public boolean isClosed() {
return conn.isClosed();
}
public boolean isSecure() {
return conn.isSecure();
}
public Object registerCloseListener(ConnectionCloseListener listener,
Object handbackMessage)
throws UnauthorizedException {
if (permissions.hasPermission(Permissions.SYSTEM_ADMIN
| Permissions.USER_ADMIN)) {
return conn.registerCloseListener(listener, handbackMessage);
}
else {
throw new UnauthorizedException();
}
}
public Object removeCloseListener(ConnectionCloseListener listener)
throws UnauthorizedException {
if (permissions.hasPermission(Permissions.SYSTEM_ADMIN
| Permissions.USER_ADMIN)) {
return conn.removeCloseListener(listener);
}
else {
throw new UnauthorizedException();
}
}
public void deliver(Packet packet) throws UnauthorizedException,
PacketException, XMLStreamException {
//if (permissions.hasPermission(Permissions.SYSTEM_ADMIN
// | Permissions.USER_ADMIN)) {
// Look into doing something about limiting delivery
// of packets until properly authenticated
if (true) {
conn.deliver(packet);
}
else {
throw new UnauthorizedException();
}
}
}
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