All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.guacamole.net.auth.simple.SimpleConnectionGroup Maven / Gradle / Ivy

Go to download

The Java API for extending the main Guacamole web application. This is not needed for authoring a new Guacamole-based web application.

There is a newer version: 1.5.5
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.apache.guacamole.net.auth.simple;

import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.GuacamoleSecurityException;
import org.apache.guacamole.net.GuacamoleTunnel;
import org.apache.guacamole.net.auth.AbstractConnectionGroup;
import org.apache.guacamole.net.auth.ConnectionGroup;
import org.apache.guacamole.protocol.GuacamoleClientInformation;

/**
 * An extremely simple read-only implementation of a ConnectionGroup which
 * returns the connection and connection group identifiers it was constructed
 * with. Load balancing across this connection group is not allowed.
 */
public class SimpleConnectionGroup extends AbstractConnectionGroup {

    /**
     * The identifiers of all connections in this group.
     */
    private final Set connectionIdentifiers;

    /**
     * The identifiers of all connection groups in this group.
     */
    private final Set connectionGroupIdentifiers;

    /**
     * Creates a new SimpleConnectionGroup having the given name and identifier
     * which will expose the given contents.
     * 
     * @param name
     *     The name to associate with this connection group.
     *
     * @param identifier
     *     The identifier to associate with this connection group.
     *
     * @param connectionIdentifiers
     *     The connection identifiers to expose when requested.
     *
     * @param connectionGroupIdentifiers
     *     The connection group identifiers to expose when requested.
     */
    public SimpleConnectionGroup(String name, String identifier,
            Collection connectionIdentifiers, 
            Collection connectionGroupIdentifiers) {

        // Set name
        setName(name);

        // Set identifier
        setIdentifier(identifier);
        
        // Set group type
        setType(ConnectionGroup.Type.ORGANIZATIONAL);

        // Populate contents
        this.connectionIdentifiers = new HashSet(connectionIdentifiers);
        this.connectionGroupIdentifiers = new HashSet(connectionGroupIdentifiers);

    }

    @Override
    public int getActiveConnections() {
        return 0;
    }

    @Override
    public Set getConnectionIdentifiers() {
        return connectionIdentifiers;
    }

    @Override
    public Set getConnectionGroupIdentifiers() {
        return connectionGroupIdentifiers;
    }

    @Override
    public Map getAttributes() {
        return Collections.emptyMap();
    }

    @Override
    public void setAttributes(Map attributes) {
        // Do nothing - there are no attributes
    }

    @Override
    @Deprecated
    public GuacamoleTunnel connect(GuacamoleClientInformation info)
            throws GuacamoleException {
        throw new GuacamoleSecurityException("Permission denied.");
    }

    @Override
    public GuacamoleTunnel connect(GuacamoleClientInformation info,
            Map tokens) throws GuacamoleException {
        return connect(info);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy