mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
Fix style issues.
This commit is contained in:
@@ -38,7 +38,6 @@ package net.sourceforge.guacamole.net.auth.mysql;
|
|||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import net.sourceforge.guacamole.GuacamoleClientException;
|
import net.sourceforge.guacamole.GuacamoleClientException;
|
||||||
import net.sourceforge.guacamole.GuacamoleException;
|
import net.sourceforge.guacamole.GuacamoleException;
|
||||||
@@ -133,17 +132,17 @@ public class ConnectionDirectory implements Directory<String, Connection>{
|
|||||||
String identifier = object.getIdentifier().trim();
|
String identifier = object.getIdentifier().trim();
|
||||||
if(identifier.isEmpty())
|
if(identifier.isEmpty())
|
||||||
throw new GuacamoleClientException("The connection identifier cannot be blank.");
|
throw new GuacamoleClientException("The connection identifier cannot be blank.");
|
||||||
|
|
||||||
// Verify permission to create
|
// Verify permission to create
|
||||||
permissionCheckService.verifySystemAccess(this.user_id,
|
permissionCheckService.verifySystemAccess(this.user_id,
|
||||||
MySQLConstants.SYSTEM_CONNECTION_CREATE);
|
MySQLConstants.SYSTEM_CONNECTION_CREATE);
|
||||||
|
|
||||||
// Verify that no connection already exists with this identifier.
|
// Verify that no connection already exists with this identifier.
|
||||||
MySQLConnection previousConnection =
|
MySQLConnection previousConnection =
|
||||||
connectionService.retrieveConnection(identifier, user_id);
|
connectionService.retrieveConnection(identifier, user_id);
|
||||||
if(previousConnection != null)
|
if(previousConnection != null)
|
||||||
throw new GuacamoleClientException("That connection identifier is already in use.");
|
throw new GuacamoleClientException("That connection identifier is already in use.");
|
||||||
|
|
||||||
// Create connection
|
// Create connection
|
||||||
MySQLConnection connection = connectionService.createConnection(
|
MySQLConnection connection = connectionService.createConnection(
|
||||||
identifier, object.getConfiguration().getProtocol(),
|
identifier, object.getConfiguration().getProtocol(),
|
||||||
|
@@ -485,6 +485,8 @@ public class UserDirectory implements Directory<String, net.sourceforge.guacamol
|
|||||||
* @param user_id The ID of the user whose permissions should be updated.
|
* @param user_id The ID of the user whose permissions should be updated.
|
||||||
* @param permissions The new system permissions that the given user should
|
* @param permissions The new system permissions that the given user should
|
||||||
* have when this operation completes.
|
* have when this operation completes.
|
||||||
|
* @throws GuacamoleException If permission to administer system permissions
|
||||||
|
* is denied.
|
||||||
*/
|
*/
|
||||||
private void createSystemPermissions(int user_id,
|
private void createSystemPermissions(int user_id,
|
||||||
Collection<SystemPermission> permissions) throws GuacamoleException {
|
Collection<SystemPermission> permissions) throws GuacamoleException {
|
||||||
@@ -499,7 +501,7 @@ public class UserDirectory implements Directory<String, net.sourceforge.guacamol
|
|||||||
|
|
||||||
// Insert all requested permissions
|
// Insert all requested permissions
|
||||||
for (SystemPermission permission : permissions) {
|
for (SystemPermission permission : permissions) {
|
||||||
|
|
||||||
// Insert permission
|
// Insert permission
|
||||||
SystemPermissionKey newSystemPermission = new SystemPermissionKey();
|
SystemPermissionKey newSystemPermission = new SystemPermissionKey();
|
||||||
newSystemPermission.setUser_id(user_id);
|
newSystemPermission.setUser_id(user_id);
|
||||||
@@ -531,7 +533,7 @@ public class UserDirectory implements Directory<String, net.sourceforge.guacamol
|
|||||||
// Prevent self-de-adminifying
|
// Prevent self-de-adminifying
|
||||||
if (user_id == this.user_id)
|
if (user_id == this.user_id)
|
||||||
throw new GuacamoleClientException("Removing your own administrative permissions is not allowed.");
|
throw new GuacamoleClientException("Removing your own administrative permissions is not allowed.");
|
||||||
|
|
||||||
// Build list of requested system permissions
|
// Build list of requested system permissions
|
||||||
List<String> systemPermissionTypes = new ArrayList<String>();
|
List<String> systemPermissionTypes = new ArrayList<String>();
|
||||||
for (SystemPermission permission : permissions)
|
for (SystemPermission permission : permissions)
|
||||||
@@ -585,7 +587,7 @@ public class UserDirectory implements Directory<String, net.sourceforge.guacamol
|
|||||||
// Prevent self-deletion
|
// Prevent self-deletion
|
||||||
if (user.getUserID() == this.user_id)
|
if (user.getUserID() == this.user_id)
|
||||||
throw new GuacamoleClientException("Deleting your own user is not allowed.");
|
throw new GuacamoleClientException("Deleting your own user is not allowed.");
|
||||||
|
|
||||||
// Validate current user has permission to remove the specified user
|
// Validate current user has permission to remove the specified user
|
||||||
permissionCheckService.verifyUserAccess(this.user_id,
|
permissionCheckService.verifyUserAccess(this.user_id,
|
||||||
user.getUserID(),
|
user.getUserID(),
|
||||||
|
@@ -291,12 +291,12 @@ public class ConnectionService {
|
|||||||
|
|
||||||
// We want to return the newest records first
|
// We want to return the newest records first
|
||||||
example.setOrderByClause("start_date DESC");
|
example.setOrderByClause("start_date DESC");
|
||||||
|
|
||||||
// Set the maximum number of history records returned to 100
|
// Set the maximum number of history records returned to 100
|
||||||
RowBounds rowBounds = new RowBounds(0, 100);
|
RowBounds rowBounds = new RowBounds(0, 100);
|
||||||
|
|
||||||
// Retrieve all connection history entries
|
// Retrieve all connection history entries
|
||||||
List<ConnectionHistory> connectionHistories =
|
List<ConnectionHistory> connectionHistories =
|
||||||
connectionHistoryDAO.selectByExampleWithRowbounds(example, rowBounds);
|
connectionHistoryDAO.selectByExampleWithRowbounds(example, rowBounds);
|
||||||
|
|
||||||
// Convert history entries to connection records
|
// Convert history entries to connection records
|
||||||
@@ -412,10 +412,10 @@ public class ConnectionService {
|
|||||||
connectionDAO.updateByPrimaryKeySelective(connection);
|
connectionDAO.updateByPrimaryKeySelective(connection);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the names of all the connections defined in the system.
|
* Get the names of all the connections defined in the system.
|
||||||
*
|
*
|
||||||
* @return A Set of names of all the connections defined in the system.
|
* @return A Set of names of all the connections defined in the system.
|
||||||
*/
|
*/
|
||||||
public Set<String> getAllConnectionNames() {
|
public Set<String> getAllConnectionNames() {
|
||||||
@@ -428,19 +428,19 @@ public class ConnectionService {
|
|||||||
connectionDAO.selectByExample(new ConnectionExample());
|
connectionDAO.selectByExample(new ConnectionExample());
|
||||||
for (Connection connection : connections)
|
for (Connection connection : connections)
|
||||||
names.add(connection.getConnection_name());
|
names.add(connection.getConnection_name());
|
||||||
|
|
||||||
return names;
|
return names;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the connection IDs of all the connections defined in the system.
|
* Get the connection IDs of all the connections defined in the system.
|
||||||
*
|
*
|
||||||
* @return A list of connection IDs of all the connections defined in the system.
|
* @return A list of connection IDs of all the connections defined in the system.
|
||||||
*/
|
*/
|
||||||
public List<Integer> getAllConnectionIDs() {
|
public List<Integer> getAllConnectionIDs() {
|
||||||
|
|
||||||
// Set of all present connection IDs
|
// Set of all present connection IDs
|
||||||
List<Integer> connectionIDs = new ArrayList<Integer>();
|
List<Integer> connectionIDs = new ArrayList<Integer>();
|
||||||
|
|
||||||
// Query all connection IDs
|
// Query all connection IDs
|
||||||
@@ -448,7 +448,7 @@ public class ConnectionService {
|
|||||||
connectionDAO.selectByExample(new ConnectionExample());
|
connectionDAO.selectByExample(new ConnectionExample());
|
||||||
for (Connection connection : connections)
|
for (Connection connection : connections)
|
||||||
connectionIDs.add(connection.getConnection_id());
|
connectionIDs.add(connection.getConnection_id());
|
||||||
|
|
||||||
return connectionIDs;
|
return connectionIDs;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -164,7 +164,7 @@ public class PermissionCheckService {
|
|||||||
// A system administrator has full access to everything.
|
// A system administrator has full access to everything.
|
||||||
if(checkSystemAdministratorAccess(userID))
|
if(checkSystemAdministratorAccess(userID))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Check existence of requested permission
|
// Check existence of requested permission
|
||||||
UserPermissionExample example = new UserPermissionExample();
|
UserPermissionExample example = new UserPermissionExample();
|
||||||
example.createCriteria().andUser_idEqualTo(userID).andAffected_user_idEqualTo(affectedUserID).andPermissionEqualTo(permissionType);
|
example.createCriteria().andUser_idEqualTo(userID).andAffected_user_idEqualTo(affectedUserID).andPermissionEqualTo(permissionType);
|
||||||
@@ -187,7 +187,7 @@ public class PermissionCheckService {
|
|||||||
// A system administrator has full access to everything.
|
// A system administrator has full access to everything.
|
||||||
if(checkSystemAdministratorAccess(userID))
|
if(checkSystemAdministratorAccess(userID))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Check existence of requested permission
|
// Check existence of requested permission
|
||||||
ConnectionPermissionExample example = new ConnectionPermissionExample();
|
ConnectionPermissionExample example = new ConnectionPermissionExample();
|
||||||
example.createCriteria().andUser_idEqualTo(userID).andConnection_idEqualTo(affectedConnectionID).andPermissionEqualTo(permissionType);
|
example.createCriteria().andUser_idEqualTo(userID).andConnection_idEqualTo(affectedConnectionID).andPermissionEqualTo(permissionType);
|
||||||
@@ -207,14 +207,14 @@ public class PermissionCheckService {
|
|||||||
// A system administrator has full access to everything.
|
// A system administrator has full access to everything.
|
||||||
if(checkSystemAdministratorAccess(userID))
|
if(checkSystemAdministratorAccess(userID))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Check existence of requested permission
|
// Check existence of requested permission
|
||||||
SystemPermissionExample example = new SystemPermissionExample();
|
SystemPermissionExample example = new SystemPermissionExample();
|
||||||
example.createCriteria().andUser_idEqualTo(userID).andPermissionEqualTo(systemPermissionType);
|
example.createCriteria().andUser_idEqualTo(userID).andPermissionEqualTo(systemPermissionType);
|
||||||
return systemPermissionDAO.countByExample(example) > 0;
|
return systemPermissionDAO.countByExample(example) > 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether a user has system administrator access to the system.
|
* Checks whether a user has system administrator access to the system.
|
||||||
@@ -244,7 +244,7 @@ public class PermissionCheckService {
|
|||||||
// A system administrator has access to all users.
|
// A system administrator has access to all users.
|
||||||
if(checkSystemAdministratorAccess(userID))
|
if(checkSystemAdministratorAccess(userID))
|
||||||
return userService.getAllUserIDs();
|
return userService.getAllUserIDs();
|
||||||
|
|
||||||
// Query all user permissions for the given user and permission type
|
// Query all user permissions for the given user and permission type
|
||||||
UserPermissionExample example = new UserPermissionExample();
|
UserPermissionExample example = new UserPermissionExample();
|
||||||
example.createCriteria().andUser_idEqualTo(userID).andPermissionEqualTo(permissionType);
|
example.createCriteria().andUser_idEqualTo(userID).andPermissionEqualTo(permissionType);
|
||||||
@@ -296,7 +296,7 @@ public class PermissionCheckService {
|
|||||||
/**
|
/**
|
||||||
* Retrieve all existing usernames that the given user has permission to
|
* Retrieve all existing usernames that the given user has permission to
|
||||||
* perform the given operation upon.
|
* perform the given operation upon.
|
||||||
*
|
*
|
||||||
* @param userID The user whose permissions should be checked.
|
* @param userID The user whose permissions should be checked.
|
||||||
* @param permissionType The permission to check.
|
* @param permissionType The permission to check.
|
||||||
* @return A set of all usernames for which the given user has the given
|
* @return A set of all usernames for which the given user has the given
|
||||||
@@ -320,7 +320,7 @@ public class PermissionCheckService {
|
|||||||
/**
|
/**
|
||||||
* Retrieve all existing usernames that the given user has permission to
|
* Retrieve all existing usernames that the given user has permission to
|
||||||
* perform the given operation upon.
|
* perform the given operation upon.
|
||||||
*
|
*
|
||||||
* @param userID The user whose permissions should be checked.
|
* @param userID The user whose permissions should be checked.
|
||||||
* @param permissionType The permission to check.
|
* @param permissionType The permission to check.
|
||||||
* @return A set of all usernames for which the given user has the given
|
* @return A set of all usernames for which the given user has the given
|
||||||
|
@@ -337,10 +337,10 @@ public class UserService {
|
|||||||
userDAO.updateByPrimaryKeySelective(user);
|
userDAO.updateByPrimaryKeySelective(user);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the usernames of all the users defined in the system.
|
* Get the usernames of all the users defined in the system.
|
||||||
*
|
*
|
||||||
* @return A Set of usernames of all the users defined in the system.
|
* @return A Set of usernames of all the users defined in the system.
|
||||||
*/
|
*/
|
||||||
public Set<String> getAllUsernames() {
|
public Set<String> getAllUsernames() {
|
||||||
@@ -353,19 +353,19 @@ public class UserService {
|
|||||||
userDAO.selectByExample(new UserExample());
|
userDAO.selectByExample(new UserExample());
|
||||||
for (User user : users)
|
for (User user : users)
|
||||||
usernames.add(user.getUsername());
|
usernames.add(user.getUsername());
|
||||||
|
|
||||||
return usernames;
|
return usernames;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the user IDs of all the users defined in the system.
|
* Get the user IDs of all the users defined in the system.
|
||||||
*
|
*
|
||||||
* @return A list of user IDs of all the users defined in the system.
|
* @return A list of user IDs of all the users defined in the system.
|
||||||
*/
|
*/
|
||||||
public List<Integer> getAllUserIDs() {
|
public List<Integer> getAllUserIDs() {
|
||||||
|
|
||||||
// Set of all present user IDs
|
// Set of all present user IDs
|
||||||
List<Integer> userIDs = new ArrayList<Integer>();
|
List<Integer> userIDs = new ArrayList<Integer>();
|
||||||
|
|
||||||
// Query all user IDs
|
// Query all user IDs
|
||||||
@@ -373,7 +373,7 @@ public class UserService {
|
|||||||
userDAO.selectByExample(new UserExample());
|
userDAO.selectByExample(new UserExample());
|
||||||
for (User user : users)
|
for (User user : users)
|
||||||
userIDs.add(user.getUser_id());
|
userIDs.add(user.getUser_id());
|
||||||
|
|
||||||
return userIDs;
|
return userIDs;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user