Package org.glyptodon.guacamole

Examples of org.glyptodon.guacamole.GuacamoleClientException


    @Override
    public void add(Connection object) throws GuacamoleException {

        String name = object.getName().trim();
        if(name.isEmpty())
            throw new GuacamoleClientException("The connection name cannot be blank.");
       
        // Verify permission to create
        permissionCheckService.verifySystemAccess(this.user_id,
                MySQLConstants.SYSTEM_CONNECTION_CREATE);
       
        // Verify permission to edit the connection group
        permissionCheckService.verifyConnectionGroupAccess(this.user_id,
                this.parentID, MySQLConstants.CONNECTION_GROUP_UPDATE);
       
        // Verify permission to use the connection group for organizational purposes
        permissionCheckService.verifyConnectionGroupUsageAccess
                (parentID, user_id, MySQLConstants.CONNECTION_GROUP_ORGANIZATIONAL);

        // Verify that no connection already exists with this name.
        MySQLConnection previousConnection =
                connectionService.retrieveConnection(name, parentID, user_id);
        if(previousConnection != null)
            throw new GuacamoleClientException("That connection name is already in use.");

        // Create connection
        MySQLConnection connection = connectionService.createConnection(
                name, object.getConfiguration().getProtocol(), user_id, parentID);
       
View Full Code Here


        // Verify that no connection already exists with this name.
        MySQLConnection previousConnection =
                connectionService.retrieveConnection(mySQLConnection.getName(),
                toConnectionGroupID, user_id);
        if(previousConnection != null)
            throw new GuacamoleClientException("That connection name is already in use.");
       
        // Update the connection
        mySQLConnection.setParentID(toConnectionGroupID);
        connectionService.updateConnection(mySQLConnection);
    }
View Full Code Here

    @Override
    public void add(ConnectionGroup object) throws GuacamoleException {

        String name = object.getName().trim();
        if(name.isEmpty())
            throw new GuacamoleClientException("The connection group name cannot be blank.");
       
        Type type = object.getType();
       
        String mySQLType = MySQLConstants.getConnectionGroupTypeConstant(type);
       
        // Verify permission to create
        permissionCheckService.verifySystemAccess(this.user_id,
                MySQLConstants.SYSTEM_CONNECTION_GROUP_CREATE);
       
        // Verify permission to edit the parent connection group
        permissionCheckService.verifyConnectionGroupAccess(this.user_id,
                this.parentID, MySQLConstants.CONNECTION_GROUP_UPDATE);
       
        // Verify permission to use the parent connection group for organizational purposes
        permissionCheckService.verifyConnectionGroupUsageAccess
                (parentID, user_id, MySQLConstants.CONNECTION_GROUP_ORGANIZATIONAL);

        // Verify that no connection already exists with this name.
        MySQLConnectionGroup previousConnectionGroup =
                connectionGroupService.retrieveConnectionGroup(name, parentID, user_id);
        if(previousConnectionGroup != null)
            throw new GuacamoleClientException("That connection group name is already in use.");

        // Create connection group
        MySQLConnectionGroup connectionGroup = connectionGroupService
                .createConnectionGroup(name, user_id, parentID, mySQLType);
       
View Full Code Here

        // Verify that no connection already exists with this name.
        MySQLConnectionGroup previousConnectionGroup =
                connectionGroupService.retrieveConnectionGroup(mySQLConnectionGroup.getName(),
                toConnectionGroupID, user_id);
        if(previousConnectionGroup != null)
            throw new GuacamoleClientException("That connection group name is already in use.");
       
        // Verify that moving this connectionGroup would not cause a cycle
        Integer relativeParentID = toConnectionGroupID;
        while(relativeParentID != null) {
            if(relativeParentID == mySQLConnectionGroup.getConnectionGroupID())
View Full Code Here

        try {

            String query = request.getQueryString();
            if (query == null)
                throw new GuacamoleClientException("No query string provided.");

            // If connect operation, call doConnect() and return tunnel UUID
            // in response.
            if (query.equals("connect")) {

                GuacamoleTunnel tunnel = doConnect(request);
                if (tunnel != null) {

                    // Get session
                    HttpSession httpSession = request.getSession(true);
                    GuacamoleSession session = new GuacamoleSession(httpSession);

                    // Attach tunnel to session
                    session.attachTunnel(tunnel);

                    try {
                        // Ensure buggy browsers do not cache response
                        response.setHeader("Cache-Control", "no-cache");

                        // Send UUID to client
                        response.getWriter().print(tunnel.getUUID().toString());
                    }
                    catch (IOException e) {
                        throw new GuacamoleServerException(e);
                    }

                }

                // Failed to connect
                else
                    throw new GuacamoleResourceNotFoundException("No tunnel created.");

            }

            // If read operation, call doRead() with tunnel UUID, ignoring any
            // characters following the tunnel UUID.
            else if(query.startsWith(READ_PREFIX))
                doRead(request, response, query.substring(
                        READ_PREFIX_LENGTH,
                        READ_PREFIX_LENGTH + UUID_LENGTH));

            // If write operation, call doWrite() with tunnel UUID, ignoring any
            // characters following the tunnel UUID.
            else if(query.startsWith(WRITE_PREFIX))
                doWrite(request, response, query.substring(
                        WRITE_PREFIX_LENGTH,
                        WRITE_PREFIX_LENGTH + UUID_LENGTH));

            // Otherwise, invalid operation
            else
                throw new GuacamoleClientException("Invalid tunnel operation: " + query);
        }

        // Catch any thrown guacamole exception and attempt to pass within the
        // HTTP response, logging each error appropriately.
        catch (GuacamoleClientException e) {
View Full Code Here

    public void add(org.glyptodon.guacamole.net.auth.User object)
            throws GuacamoleException {

        String username = object.getUsername().trim();
        if(username.isEmpty())
            throw new GuacamoleClientException("The username cannot be blank.");

        // Verify current user has permission to create users
        permissionCheckService.verifySystemAccess(this.user_id,
                MySQLConstants.SYSTEM_USER_CREATE);
        Preconditions.checkNotNull(object);

        // Verify that no user already exists with this username.
        MySQLUser previousUser = userService.retrieveUser(username);
        if(previousUser != null)
            throw new GuacamoleClientException("That username is already in use.");

        // Create new user
        MySQLUser user = userService.createUser(username, object.getPassword());

        // Create permissions of new user in database
View Full Code Here

        String id = request.getParameter("id");
        TunnelRequest.IdentifierType id_type = TunnelRequest.IdentifierType.getType(id);

        // Do not continue if unable to determine type
        if (id_type == null)
            throw new GuacamoleClientException("Illegal identifier - unknown type.");

        // Remove prefix
        id = id.substring(id_type.PREFIX.length());

        // Get credentials
        final Credentials credentials = AuthenticatingFilter.getCredentials(httpSession);

        // Get context
        final UserContext context = AuthenticatingFilter.getUserContext(httpSession);

        // If no context or no credentials, not logged in
        if (context == null || credentials == null)
            throw new GuacamoleSecurityException("Cannot connect - user not logged in.");

        // Get clipboard
        final ClipboardState clipboard = AuthenticatingFilter.getClipboardState(httpSession);

        // Get client information
        GuacamoleClientInformation info = new GuacamoleClientInformation();

        // Set width if provided
        String width  = request.getParameter("width");
        if (width != null)
            info.setOptimalScreenWidth(Integer.parseInt(width));

        // Set height if provided
        String height = request.getParameter("height");
        if (height != null)
            info.setOptimalScreenHeight(Integer.parseInt(height));

        // Set resolution if provided
        String dpi = request.getParameter("dpi");
        if (dpi != null)
            info.setOptimalResolution(Integer.parseInt(dpi));

        // Add audio mimetypes
        List<String> audio_mimetypes = request.getParameterValues("audio");
        if (audio_mimetypes != null)
            info.getAudioMimetypes().addAll(audio_mimetypes);

        // Add video mimetypes
        List<String> video_mimetypes = request.getParameterValues("video");
        if (video_mimetypes != null)
            info.getVideoMimetypes().addAll(video_mimetypes);

        // Create connected socket from identifier
        GuacamoleSocket socket;
        switch (id_type) {

            // Connection identifiers
            case CONNECTION: {

                // Get connection directory
                Directory<String, Connection> directory =
                    context.getRootConnectionGroup().getConnectionDirectory();

                // Get authorized connection
                Connection connection = directory.get(id);
                if (connection == null) {
                    logger.info("Connection \"{}\" does not exist for user \"{}\".", id, context.self().getUsername());
                    throw new GuacamoleSecurityException("Requested connection is not authorized.");
                }

                // Connect socket
                socket = connection.connect(info);
                logger.info("User \"{}\" successfully connected to \"{}\".", context.self().getUsername(), id);
                break;
            }

            // Connection group identifiers
            case CONNECTION_GROUP: {

                // Get connection group directory
                Directory<String, ConnectionGroup> directory =
                    context.getRootConnectionGroup().getConnectionGroupDirectory();

                // Get authorized connection group
                ConnectionGroup group = directory.get(id);
                if (group == null) {
                    logger.info("Connection group \"{}\" does not exist for user \"{}\".", id, context.self().getUsername());
                    throw new GuacamoleSecurityException("Requested connection group is not authorized.");
                }

                // Connect socket
                socket = group.connect(info);
                logger.info("User \"{}\" successfully connected to group \"{}\".", context.self().getUsername(), id);
                break;
            }

            // Fail if unsupported type
            default:
                throw new GuacamoleClientException("Connection not supported for provided identifier type.");

        }

        // Associate socket with tunnel
        GuacamoleTunnel tunnel = new GuacamoleTunnel(socket) {
View Full Code Here

        // Administration
        if (str.startsWith(ADMIN_PREFIX))
            return new ConnectionPermission(ObjectPermission.Type.ADMINISTER,
                    str.substring(ADMIN_PREFIX.length()));

        throw new GuacamoleClientException("Invalid permission string.");

    }
View Full Code Here

        // Administration
        if (str.startsWith(ADMIN_PREFIX))
            return new ConnectionGroupPermission(ObjectPermission.Type.ADMINISTER,
                    str.substring(ADMIN_PREFIX.length()));

        throw new GuacamoleClientException("Invalid permission string.");

    }
View Full Code Here

                    xml.writeAttribute("name", up.getObjectIdentifier());

                }

                else
                    throw new GuacamoleClientException(
                            "Unsupported permission type.");

            }

            // End document
View Full Code Here

TOP

Related Classes of org.glyptodon.guacamole.GuacamoleClientException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.