ServiceLookupProxy.java 2.32 KB
Newer Older
Matt Tucker's avatar
Matt Tucker committed
1
/**
Matt Tucker's avatar
Matt Tucker committed
2 3 4 5
 * $RCSfile$
 * $Revision$
 * $Date$
 *
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
package org.jivesoftware.messenger.container.spi;

import org.jivesoftware.messenger.container.EventListener;
import org.jivesoftware.messenger.container.EventRegistration;
import org.jivesoftware.messenger.container.ServiceID;
import org.jivesoftware.messenger.container.ServiceItem;
import org.jivesoftware.messenger.container.ServiceLookup;
import org.jivesoftware.messenger.container.ServiceMatches;
import org.jivesoftware.messenger.container.ServiceRegistration;
import org.jivesoftware.messenger.container.ServiceTemplate;
import org.jivesoftware.messenger.auth.AuthToken;
import org.jivesoftware.messenger.auth.Permissions;

/**
 * Authorization proxy for service lookups.
 *
 * @author Iain Shigeoka
 */
public class ServiceLookupProxy implements ServiceLookup {

    private AuthToken authToken;
    private Permissions permissions;
    private ServiceLookup lookup;

    /**
     * Create a lookup security proxy
     *
     * @param authToken   the authentication token for the user.
     * @param permissions the permissions of the user.
     * @param lookup      the lookup being proxied.
     */
    public ServiceLookupProxy(AuthToken authToken, Permissions permissions, ServiceLookup lookup) {
        this.authToken = authToken;
        this.permissions = permissions;
        this.lookup = lookup;
    }

    public ServiceID getServiceID() {
        return lookup.getServiceID();
    }

    public Class[] getServiceTypes(ServiceTemplate tmpl, String prefix) {
        return lookup.getServiceTypes(tmpl, prefix);
    }

    public Object lookup(Class type) {
        return lookup.lookup(type);
    }

    public Object lookup(ServiceTemplate tmpl) {
        return lookup.lookup(tmpl);
    }

    public ServiceMatches lookup(ServiceTemplate tmpl, int maxMatches) {
        return lookup.lookup(tmpl, maxMatches);
    }

    public EventRegistration notifyRegister(ServiceTemplate tmpl, int transitions, EventListener listener) {
        return lookup.notifyRegister(tmpl, transitions, listener);
    }

    public ServiceRegistration register(ServiceItem item) {
        return lookup.register(item);
    }
}