本文整理汇总了Java中org.apache.guacamole.net.auth.User类的典型用法代码示例。如果您正苦于以下问题:Java User类的具体用法?Java User怎么用?Java User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
User类属于org.apache.guacamole.net.auth包,在下文中一共展示了User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getObjects
import org.apache.guacamole.net.auth.User; //导入依赖的package包/类
/**
* Returns a map of all objects available within this DirectoryResource,
* filtering the returned map by the given permission, if specified.
*
* @param permissions
* The set of permissions to filter with. A user must have one or more
* of these permissions for the affected objects to appear in the
* result. If null, no filtering will be performed.
*
* @return
* A map of all visible objects. If a permission was specified, this
* map will contain only those objects for which the current user has
* that permission.
*
* @throws GuacamoleException
* If an error is encountered while retrieving the objects.
*/
@GET
public Map<String, ExternalType> getObjects(
@QueryParam("permission") List<ObjectPermission.Type> permissions)
throws GuacamoleException {
// An admin user has access to all objects
User self = userContext.self();
SystemPermissionSet systemPermissions = self.getSystemPermissions();
boolean isAdmin = systemPermissions.hasPermission(SystemPermission.Type.ADMINISTER);
// Filter objects, if requested
Collection<String> identifiers = directory.getIdentifiers();
if (!isAdmin && permissions != null && !permissions.isEmpty()) {
ObjectPermissionSet objectPermissions = self.getUserPermissions();
identifiers = objectPermissions.getAccessibleObjects(permissions, identifiers);
}
// Translate each retrieved object into the corresponding external object
Map<String, ExternalType> apiObjects = new HashMap<String, ExternalType>();
for (InternalType object : directory.getAll(identifiers))
apiObjects.put(object.getIdentifier(), translator.toExternalObject(object));
return apiObjects;
}
示例2: getParameters
import org.apache.guacamole.net.auth.User; //导入依赖的package包/类
/**
* Retrieves the connection parameters associated with the SharingProfile
* exposed by this SharingProfile resource.
*
* @return
* A map of parameter name/value pairs.
*
* @throws GuacamoleException
* If an error occurs while retrieving the connection parameters of the
* SharingProfile.
*/
@GET
@Path("parameters")
public Map<String, String> getParameters()
throws GuacamoleException {
User self = userContext.self();
// Retrieve permission sets
SystemPermissionSet systemPermissions = self.getSystemPermissions();
ObjectPermissionSet sharingProfilePermissions = self.getSharingProfilePermissions();
// Deny access if adminstrative or update permission is missing
String identifier = sharingProfile.getIdentifier();
if (!systemPermissions.hasPermission(SystemPermission.Type.ADMINISTER)
&& !sharingProfilePermissions.hasPermission(ObjectPermission.Type.UPDATE, identifier))
throw new GuacamoleSecurityException("Permission to read sharing profile parameters denied.");
// Return parameter map
return sharingProfile.getParameters();
}
示例3: configure
import org.apache.guacamole.net.auth.User; //导入依赖的package包/类
@Override
protected void configure() {
// Create the required DirectoryResourceFactory implementation
install(new FactoryModuleBuilder()
.implement(
new TypeLiteral<DirectoryResource<User, APIUser>>() {},
UserDirectoryResource.class
)
.build(new TypeLiteral<DirectoryResourceFactory<User, APIUser>>() {}));
// Create the required DirectoryObjectResourceFactory implementation
install(new FactoryModuleBuilder()
.implement(
new TypeLiteral<DirectoryObjectResource<User, APIUser>>() {},
UserResource.class
)
.build(new TypeLiteral<DirectoryObjectResourceFactory<User, APIUser>>() {}));
// Bind translator for converting between User and APIUser
bind(new TypeLiteral<DirectoryObjectTranslator<User, APIUser>>() {})
.to(UserObjectTranslator.class);
}
示例4: getConnectionParameters
import org.apache.guacamole.net.auth.User; //导入依赖的package包/类
/**
* Retrieves the parameters associated with a single connection.
*
* @return
* A map of parameter name/value pairs.
*
* @throws GuacamoleException
* If an error occurs while retrieving the connection parameters.
*/
@GET
@Path("parameters")
public Map<String, String> getConnectionParameters()
throws GuacamoleException {
User self = userContext.self();
// Retrieve permission sets
SystemPermissionSet systemPermissions = self.getSystemPermissions();
ObjectPermissionSet connectionPermissions = self.getConnectionPermissions();
// Deny access if adminstrative or update permission is missing
String identifier = connection.getIdentifier();
if (!systemPermissions.hasPermission(SystemPermission.Type.ADMINISTER)
&& !connectionPermissions.hasPermission(ObjectPermission.Type.UPDATE, identifier))
throw new GuacamoleSecurityException("Permission to read connection parameters denied.");
// Retrieve connection configuration
GuacamoleConfiguration config = connection.getConfiguration();
// Return parameter map
return config.getParameters();
}
示例5: ConnectionGroupTree
import org.apache.guacamole.net.auth.User; //导入依赖的package包/类
/**
* Creates a new connection group tree using the given connection group as
* the tree root.
*
* @param userContext
* The context of the user obtaining the connection group tree.
*
* @param root
* The connection group to use as the root of this connection group
* tree.
*
* @param permissions
* If specified and non-empty, limit the contents of the tree to only
* those connections for which the current user has any of the given
* permissions. Otherwise, all visible connections are returned.
* Connection groups are unaffected by this parameter.
*
* @throws GuacamoleException
* If an error occurs while retrieving the tree of connection groups
* and their descendants.
*/
public ConnectionGroupTree(UserContext userContext, ConnectionGroup root,
List<ObjectPermission.Type> permissions) throws GuacamoleException {
// Store root of tree
this.rootAPIGroup = new APIConnectionGroup(root);
retrievedGroups.put(root.getIdentifier(), this.rootAPIGroup);
// Store user's current permissions
User self = userContext.self();
this.connectionPermissions = self.getConnectionPermissions();
this.sharingProfilePermissions = self.getSharingProfilePermissions();
// Store required directories
this.connectionDirectory = userContext.getConnectionDirectory();
this.connectionGroupDirectory = userContext.getConnectionGroupDirectory();
this.sharingProfileDirectory = userContext.getSharingProfileDirectory();
// Add all descendants
addConnectionGroupDescendants(Collections.singleton(root), permissions);
}
示例6: init
import org.apache.guacamole.net.auth.User; //导入依赖的package包/类
/**
* Creates a new SharedUserContext which provides access ONLY to the given
* user, the SharedConnections associated with the share keys used by that
* user, and an internal root connection group containing only those
* SharedConnections.
*
* @param authProvider
* The AuthenticationProvider that created this
* SharedUserContext;
*
* @param user
* The RemoteAuthenticatedUser for whom this SharedUserContext is being
* created.
*/
public void init(AuthenticationProvider authProvider, RemoteAuthenticatedUser user) {
// Associate the originating authentication provider
this.authProvider = authProvider;
// Provide access to all connections shared with the given user
this.connectionDirectory.init(user);
// The connection group directory contains only the root group
this.rootGroup = new SharedRootConnectionGroup(this);
this.connectionGroupDirectory = new SimpleConnectionGroupDirectory(
Collections.singletonList(this.rootGroup));
// Create internal pseudo-account representing the authenticated user
this.self = new SharedUser(user, this);
// Do not provide access to any user accounts via the directory
this.userDirectory = new SimpleDirectory<User>();
}
示例7: getModelInstance
import org.apache.guacamole.net.auth.User; //导入依赖的package包/类
@Override
protected UserModel getModelInstance(ModeledAuthenticatedUser currentUser,
final User object) throws GuacamoleException {
// Create new ModeledUser backed by blank model
UserModel model = new UserModel();
ModeledUser user = getObjectInstance(currentUser, model);
// Set model contents through ModeledUser, copying the provided user
user.setIdentifier(object.getIdentifier());
user.setPassword(object.getPassword());
user.setAttributes(object.getAttributes());
return model;
}
示例8: beforeCreate
import org.apache.guacamole.net.auth.User; //导入依赖的package包/类
@Override
protected void beforeCreate(ModeledAuthenticatedUser user, User object,
UserModel model) throws GuacamoleException {
super.beforeCreate(user, object, model);
// Username must not be blank
if (model.getIdentifier() == null || model.getIdentifier().trim().isEmpty())
throw new GuacamoleClientException("The username must not be blank.");
// Do not create duplicate users
Collection<UserModel> existing = userMapper.select(Collections.singleton(model.getIdentifier()));
if (!existing.isEmpty())
throw new GuacamoleClientException("User \"" + model.getIdentifier() + "\" already exists.");
// Verify new password does not violate defined policies (if specified)
if (object.getPassword() != null)
passwordPolicyService.verifyPassword(object.getIdentifier(), object.getPassword());
}
示例9: getUsers
import org.apache.guacamole.net.auth.User; //导入依赖的package包/类
/**
* Returns all Guacamole users accessible to the user currently bound under
* the given LDAP connection.
*
* @param ldapConnection
* The current connection to the LDAP server, associated with the
* current user.
*
* @return
* All users accessible to the user currently bound under the given
* LDAP connection, as a map of connection identifier to corresponding
* user object.
*
* @throws GuacamoleException
* If an error occurs preventing retrieval of users.
*/
public Map<String, User> getUsers(LDAPConnection ldapConnection)
throws GuacamoleException {
// Build map of users by querying each username attribute separately
Map<String, User> users = new HashMap<String, User>();
for (String usernameAttribute : confService.getUsernameAttributes()) {
// Attempt to pull all users with given attribute
try {
putAllUsers(users, ldapConnection, usernameAttribute);
}
// Log any errors non-fatally
catch (GuacamoleException e) {
logger.warn("Could not query list of all users for attribute \"{}\": {}",
usernameAttribute, e.getMessage());
logger.debug("Error querying list of all users.", e);
}
}
// Return map of all users
return users;
}
示例10: getUser
import org.apache.guacamole.net.auth.User; //导入依赖的package包/类
/**
* Returns the user object of the user to whom the given UserData object
* belongs.
*
* @param userData
* All data associated with the user whose own user object is being
* retrieved.
*
* @return
* The user object of the user to whom the given UserData object
* belongs.
*/
public User getUser(UserData userData) {
// Pull username from user data
String username = userData.getUsername();
// Build user object with READ access to all available data
return new SimpleUser(
username,
getUserIdentifiers(userData),
getConnectionIdentifiers(userData),
getConnectionGroupIdentifiers(userData)
);
}
示例11: APIPermissionSet
import org.apache.guacamole.net.auth.User; //导入依赖的package包/类
/**
* Creates a new permission set containing all permissions currently
* granted to the given user.
*
* @param user
* The user whose permissions should be stored within this permission
* set.
*
* @throws GuacamoleException
* If an error occurs while retrieving the user's permissions.
*/
public APIPermissionSet(User user) throws GuacamoleException {
// Add all permissions from the provided user
addSystemPermissions(systemPermissions, user.getSystemPermissions());
addObjectPermissions(connectionPermissions, user.getConnectionPermissions());
addObjectPermissions(connectionGroupPermissions, user.getConnectionGroupPermissions());
addObjectPermissions(sharingProfilePermissions, user.getSharingProfilePermissions());
addObjectPermissions(activeConnectionPermissions, user.getActiveConnectionPermissions());
addObjectPermissions(userPermissions, user.getUserPermissions());
}
示例12: applyExternalChanges
import org.apache.guacamole.net.auth.User; //导入依赖的package包/类
@Override
public void applyExternalChanges(User existingObject,
APIUser object) throws GuacamoleException {
// Do not update the user password if no password was provided
if (object.getPassword() != null)
existingObject.setPassword(object.getPassword());
// Update user attributes
existingObject.setAttributes(object.getAttributes());
}
示例13: APIUser
import org.apache.guacamole.net.auth.User; //导入依赖的package包/类
/**
* Construct a new APIUser from the provided User.
* @param user The User to construct the APIUser from.
*/
public APIUser(User user) {
// Set user information
this.username = user.getIdentifier();
this.password = user.getPassword();
this.lastActive = user.getLastActive();
// Associate any attributes
this.attributes = user.getAttributes();
}
示例14: init
import org.apache.guacamole.net.auth.User; //导入依赖的package包/类
/**
* Initializes this UserContext using the provided AuthenticatedUser and
* LDAPConnection.
*
* @param user
* The AuthenticatedUser representing the user that authenticated. This
* user may have been authenticated by a different authentication
* provider (not LDAP).
*
* @param ldapConnection
* The connection to the LDAP server to use when querying accessible
* Guacamole users and connections.
*
* @throws GuacamoleException
* If associated data stored within the LDAP directory cannot be
* queried due to an error.
*/
public void init(AuthenticatedUser user, LDAPConnection ldapConnection)
throws GuacamoleException {
// Query all accessible users
userDirectory = new SimpleDirectory<User>(
userService.getUsers(ldapConnection)
);
// Query all accessible connections
connectionDirectory = new SimpleDirectory<Connection>(
connectionService.getConnections(user, ldapConnection)
);
// Root group contains only connections
rootGroup = new SimpleConnectionGroup(
LDAPAuthenticationProvider.ROOT_CONNECTION_GROUP,
LDAPAuthenticationProvider.ROOT_CONNECTION_GROUP,
connectionDirectory.getIdentifiers(),
Collections.<String>emptyList()
);
// Expose only the root group in the connection group directory
connectionGroupDirectory = new SimpleConnectionGroupDirectory(Collections.singleton(rootGroup));
// Init self with basic permissions
self = new SimpleUser(
user.getIdentifier(),
userDirectory.getIdentifiers(),
connectionDirectory.getIdentifiers(),
connectionGroupDirectory.getIdentifiers()
);
}
示例15: self
import org.apache.guacamole.net.auth.User; //导入依赖的package包/类
@Override
public User self() {
return userDataService.getUser(userData);
}