ServerSession.java 3.89 KB
Newer Older
Matt Tucker's avatar
Matt Tucker committed
1 2 3 4
/**
 * $RCSfile$
 * $Revision$
 * $Date$
Matt Tucker's avatar
Matt Tucker committed
5
 *
Matt Tucker's avatar
Matt Tucker committed
6
 * Copyright (C) 2004 Jive Software. All rights reserved.
Matt Tucker's avatar
Matt Tucker committed
7
 *
Matt Tucker's avatar
Matt Tucker committed
8 9
 * This software is published under the terms of the GNU Public License (GPL),
 * a copy of which is included in this distribution.
Matt Tucker's avatar
Matt Tucker committed
10
 */
Matt Tucker's avatar
Matt Tucker committed
11

Matt Tucker's avatar
Matt Tucker committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
package org.jivesoftware.messenger;

import org.jivesoftware.messenger.auth.AuthToken;
import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.jivesoftware.messenger.user.UserManager;
import org.jivesoftware.messenger.user.UserNotFoundException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Date;
import javax.xml.stream.XMLStreamWriter;

public class ServerSession implements Session {

    private StreamID streamID;
    private XMPPAddress address;
    private Date creationDate;
    private Connection connection = new ServerConnection();

    public ServerSession(XMPPAddress address, StreamID streamID) {
        this.address = address;
        this.streamID = streamID;
        creationDate = new Date();
    }

    public Connection getConnection() {
        return connection;
    }

    public int getStatus() {
        return Session.STATUS_AUTHENTICATED;
    }

    public void setStatus(int status) {
    }

    public boolean isInitialized() {
        return true;
    }

    public void setInitialized(boolean isInit) throws UnauthorizedException {
    }

    public Presence getPresence() {
        return null;
    }

    public Presence setPresence(Presence presence) {
        return null;
    }

    public void setAuthToken(AuthToken auth,
                             UserManager userManager,
                             String resource) {
    }

    public void setAnonymousAuth() throws UnauthorizedException {
    }

    // TODO: we need a server auth token for priviledged services to use
    public AuthToken getAuthToken() {
        return null;
    }

    public StreamID getStreamID() {
        return streamID;
    }

    public long getUserID() throws UserNotFoundException, UnauthorizedException {
        return 0;
    }

    public String getServerName() {
        return address.toString();
    }

    public Date getCreationDate() {
        return creationDate;
    }

    public Date getLastActiveDate() {
        return new Date();
    }

    public void incrementClientPacketCount() {
    }

    public void incrementServerPacketCount() {
    }

    public long getNumClientPackets() {
        return 0;
    }

    public long getNumServerPackets() {
        return 0;
    }

    public int getConflictCount() {
        return 0;
    }

    public void incrementConflictCount() {
    }

    public XMPPAddress getAddress() {
        return address;
    }

    public void process(XMPPPacket packet) {
    }

    private class ServerConnection implements Connection {
        public boolean validate() {
            return true;
        }

        public void init(Session session) {
        }

        public InetAddress getInetAddress()
                throws UnauthorizedException, UnknownHostException {
            return InetAddress.getLocalHost();
        }

        public XMLStreamWriter getSerializer() throws UnauthorizedException {
            // todo: implement so this loops back
            return null;
        }

        public void close() throws UnauthorizedException {
        }

        public boolean isClosed() {
            return false;
        }

        public boolean isSecure() {
            return true;
        }

        public Object registerCloseListener(ConnectionCloseListener listener,
                                            Object handbackMessage)
                throws UnauthorizedException {
            return null;
        }

        public Object removeCloseListener(ConnectionCloseListener listener)
                throws UnauthorizedException {
            return null;
        }

        public void deliver(XMPPPacket packet)
                throws UnauthorizedException {

        }
    }
}