mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
GUACAMOLE-524: Accept only supported attributes via setAttributes(). Do not replace existing attributes.
This commit is contained in:
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package org.apache.guacamole.auth.jdbc.user;
|
package org.apache.guacamole.auth.jdbc.user;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -47,11 +46,6 @@ public abstract class RemoteAuthenticatedUser implements AuthenticatedUser {
|
|||||||
*/
|
*/
|
||||||
private final String remoteHost;
|
private final String remoteHost;
|
||||||
|
|
||||||
/**
|
|
||||||
* Arbitrary attributes associated with this RemoteAuthenticatedUser object.
|
|
||||||
*/
|
|
||||||
private Map<String, String> attributes = new HashMap<String, String>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The identifiers of any groups of which this user is a member, including
|
* The identifiers of any groups of which this user is a member, including
|
||||||
* groups inherited through membership in other groups.
|
* groups inherited through membership in other groups.
|
||||||
@@ -60,12 +54,12 @@ public abstract class RemoteAuthenticatedUser implements AuthenticatedUser {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> getAttributes() {
|
public Map<String, String> getAttributes() {
|
||||||
return attributes;
|
return Collections.<String, String>emptyMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAttributes(Map<String, String> attributes) {
|
public void setAttributes(Map<String, String> attributes) {
|
||||||
this.attributes = attributes;
|
// No attributes supported
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -232,10 +232,7 @@ public class AuthenticationProviderService {
|
|||||||
try {
|
try {
|
||||||
// Return AuthenticatedUser if bind succeeds
|
// Return AuthenticatedUser if bind succeeds
|
||||||
AuthenticatedUser authenticatedUser = authenticatedUserProvider.get();
|
AuthenticatedUser authenticatedUser = authenticatedUserProvider.get();
|
||||||
authenticatedUser.init(credentials);
|
authenticatedUser.init(credentials, getLDAPAttributes(ldapConnection, credentials.getUsername()));
|
||||||
|
|
||||||
// Set attributes
|
|
||||||
authenticatedUser.setAttributes(getLDAPAttributes(ldapConnection, credentials.getUsername()));
|
|
||||||
|
|
||||||
return authenticatedUser;
|
return authenticatedUser;
|
||||||
|
|
||||||
|
@@ -20,7 +20,6 @@
|
|||||||
package org.apache.guacamole.auth.ldap.user;
|
package org.apache.guacamole.auth.ldap.user;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.apache.guacamole.net.auth.AbstractAuthenticatedUser;
|
import org.apache.guacamole.net.auth.AbstractAuthenticatedUser;
|
||||||
import org.apache.guacamole.net.auth.AuthenticationProvider;
|
import org.apache.guacamole.net.auth.AuthenticationProvider;
|
||||||
@@ -47,16 +46,22 @@ public class AuthenticatedUser extends AbstractAuthenticatedUser {
|
|||||||
/**
|
/**
|
||||||
* Arbitrary attributes associated with this AuthenticatedUser object.
|
* Arbitrary attributes associated with this AuthenticatedUser object.
|
||||||
*/
|
*/
|
||||||
private Map<String, String> attributes = new HashMap<String, String>();
|
private Map<String, String> attributes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes this AuthenticatedUser using the given credentials.
|
* Initializes this AuthenticatedUser using the given credentials and
|
||||||
|
* arbitrary attributes.
|
||||||
*
|
*
|
||||||
* @param credentials
|
* @param credentials
|
||||||
* The credentials provided when this user was authenticated.
|
* The credentials provided when this user was authenticated.
|
||||||
|
*
|
||||||
|
* @param attributes
|
||||||
|
* The map of arbitrary attribute name/value pairs to associate with
|
||||||
|
* this AuthenticatedUser.
|
||||||
*/
|
*/
|
||||||
public void init(Credentials credentials) {
|
public void init(Credentials credentials, Map<String, String> attributes) {
|
||||||
this.credentials = credentials;
|
this.credentials = credentials;
|
||||||
|
this.attributes = attributes;
|
||||||
setIdentifier(credentials.getUsername());
|
setIdentifier(credentials.getUsername());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +72,7 @@ public class AuthenticatedUser extends AbstractAuthenticatedUser {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAttributes(Map<String, String> attributes) {
|
public void setAttributes(Map<String, String> attributes) {
|
||||||
this.attributes = attributes;
|
// All attributes are read-only
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user