GUACAMOLE-524: Fixed up code style and comments

Also added Override tag in AbstractAuthenticatedUser on getAttributes
and setAttributes.
This commit is contained in:
Jared Frees
2018-06-12 16:21:52 -04:00
parent 36bbdce7b1
commit 4791adaa46
5 changed files with 8 additions and 20 deletions

View File

@@ -197,7 +197,8 @@ public class AuthenticationProviderService {
/** /**
* Returns an AuthenticatedUser representing the user authenticated by the * Returns an AuthenticatedUser representing the user authenticated by the
* given credentials. Also adds custom LDAP attributes to credentials object. * given credentials. Also adds custom LDAP attributes to the
* AuthenticatedUser.
* *
* @param credentials * @param credentials
* The credentials to use for authentication. * The credentials to use for authentication.
@@ -233,7 +234,7 @@ public class AuthenticationProviderService {
AuthenticatedUser authenticatedUser = authenticatedUserProvider.get(); AuthenticatedUser authenticatedUser = authenticatedUserProvider.get();
authenticatedUser.init(credentials); authenticatedUser.init(credentials);
//set attributes // Set attributes
String username = credentials.getUsername(); String username = credentials.getUsername();
Map<String, String> attrs = getLDAPAttributes(ldapConnection, username); Map<String, String> attrs = getLDAPAttributes(ldapConnection, username);
authenticatedUser.setAttributes(attrs); authenticatedUser.setAttributes(attrs);
@@ -293,9 +294,7 @@ public class AuthenticationProviderService {
// Add each attribute into Map // Add each attribute into Map
for (Object attrObj : attrSet) { for (Object attrObj : attrSet) {
LDAPAttribute attr = (LDAPAttribute)attrObj; LDAPAttribute attr = (LDAPAttribute)attrObj;
String attrName = attr.getName(); attrMap.put(attr.getName(), attr.getStringValue());
String attrValue = attr.getStringValue();
attrMap.put(attrName, attrValue);
} }
} }
catch (LDAPException e) { catch (LDAPException e) {

View File

@@ -348,8 +348,7 @@ public class ConfigurationService {
* Returns names for custom LDAP user attributes. * Returns names for custom LDAP user attributes.
* *
* @return * @return
* LDAP user attributes as defined in the guacamole.properties file * Custom LDAP user attributes as configured in guacamole.properties.
* as ldap-user-attributes: ''
* *
* @throws GuacamoleException * @throws GuacamoleException
* If guacamole.properties cannot be parsed. * If guacamole.properties cannot be parsed.

View File

@@ -61,24 +61,11 @@ public class AuthenticatedUser extends AbstractAuthenticatedUser {
setIdentifier(credentials.getUsername()); setIdentifier(credentials.getUsername());
} }
/**
* Get a map of attributes associated with this AuthenticatedUser.
*
* @return
* The Map of arbitrary attributes associated with this
* AuthenticatedUser object.
*/
@Override @Override
public Map<String, String> getAttributes() { public Map<String, String> getAttributes() {
return attributes; return attributes;
} }
/**
* Sets a map of attributes associated with this AuthenticatedUser.
*
* @param attributes
* A map of attribute key/value pairs to add to this AuthenticatedUser.
*/
@Override @Override
public void setAttributes(Map<String, String> attributes) { public void setAttributes(Map<String, String> attributes) {
this.attributes = attributes; this.attributes = attributes;

View File

@@ -42,10 +42,12 @@ public abstract class AbstractAuthenticatedUser extends AbstractIdentifiable
// Nothing to invalidate // Nothing to invalidate
} }
@Override
public Map<String, String> getAttributes() { public Map<String, String> getAttributes() {
return Collections.<String, String>emptyMap(); return Collections.<String, String>emptyMap();
} }
@Override
public void setAttributes(Map<String, String> attributes) { public void setAttributes(Map<String, String> attributes) {
//do nothing //do nothing
} }

View File

@@ -25,6 +25,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import org.apache.guacamole.net.auth.AuthenticatedUser; import org.apache.guacamole.net.auth.AuthenticatedUser;
import org.apache.guacamole.net.auth.Credentials; import org.apache.guacamole.net.auth.Credentials;
/** /**
* Utility class which provides access to standardized token names, as well as * Utility class which provides access to standardized token names, as well as
* facilities for generating those tokens from common objects. * facilities for generating those tokens from common objects.