mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUAC-586: Associate unique identifier with each AuthenticationProvider.
This commit is contained in:
@@ -105,6 +105,11 @@ public class BasicFileAuthenticationProvider extends SimpleAuthenticationProvide
|
||||
environment = new LocalEnvironment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "default";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a UserMapping containing all authorization data given within
|
||||
* the XML file specified by the "basic-user-mapping" property in
|
||||
|
@@ -23,6 +23,7 @@
|
||||
package org.glyptodon.guacamole.net.basic.extension;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.UUID;
|
||||
import org.glyptodon.guacamole.GuacamoleException;
|
||||
import org.glyptodon.guacamole.net.auth.AuthenticatedUser;
|
||||
import org.glyptodon.guacamole.net.auth.AuthenticationProvider;
|
||||
@@ -53,6 +54,12 @@ public class AuthenticationProviderFacade implements AuthenticationProvider {
|
||||
*/
|
||||
private final AuthenticationProvider authProvider;
|
||||
|
||||
/**
|
||||
* The identifier to provide for the underlying authentication provider if
|
||||
* the authentication provider could not be loaded.
|
||||
*/
|
||||
private final String facadeIdentifier = UUID.randomUUID().toString();
|
||||
|
||||
/**
|
||||
* Creates a new AuthenticationProviderFacade which delegates all function
|
||||
* calls to an instance of the given AuthenticationProvider subclass. If
|
||||
@@ -118,6 +125,20 @@ public class AuthenticationProviderFacade implements AuthenticationProvider {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
|
||||
// Ignore auth attempts if no auth provider could be loaded
|
||||
if (authProvider == null) {
|
||||
logger.warn("The authentication system could not be loaded. Please check for errors earlier in the logs.");
|
||||
return facadeIdentifier;
|
||||
}
|
||||
|
||||
// Delegate to underlying auth provider
|
||||
return authProvider.getIdentifier();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthenticatedUser authenticateUser(Credentials credentials)
|
||||
throws GuacamoleException {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Glyptodon LLC
|
||||
* Copyright (C) 2015 Glyptodon LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -48,29 +48,33 @@ public class ObjectRetrievalService {
|
||||
* @param session
|
||||
* The GuacamoleSession to retrieve the UserContext from.
|
||||
*
|
||||
* @param id
|
||||
* The numeric ID of the UserContext to retrieve. This ID is the index
|
||||
* of the UserContext within the overall list of UserContexts
|
||||
* associated with the user's session.
|
||||
* @param identifier
|
||||
* The unique identifier of the AuthenticationProvider that created the
|
||||
* UserContext being retrieved. Only one UserContext per
|
||||
* AuthenticationProvider can exist.
|
||||
*
|
||||
* @return
|
||||
* The user having the given identifier.
|
||||
* The UserContext that was created by the AuthenticationProvider
|
||||
* having the given identifier.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while retrieving the user, or if the
|
||||
* user does not exist.
|
||||
* If an error occurs while retrieving the UserContext, or if the
|
||||
* UserContext does not exist.
|
||||
*/
|
||||
public UserContext retrieveUserContext(GuacamoleSession session,
|
||||
int id) throws GuacamoleException {
|
||||
String identifier) throws GuacamoleException {
|
||||
|
||||
// Get list of UserContexts
|
||||
List<UserContext> userContexts = session.getUserContexts();
|
||||
|
||||
// Verify context exists
|
||||
if (id < 0 || id >= userContexts.size())
|
||||
throw new GuacamoleResourceNotFoundException("No such user context: \"" + id + "\"");
|
||||
// Locate and return the UserContext associated with the
|
||||
// AuthenticationProvider having the given identifier, if any
|
||||
for (UserContext userContext : userContexts) {
|
||||
if (userContext.getAuthenticationProvider().getIdentifier().equals(identifier))
|
||||
return userContext;
|
||||
}
|
||||
|
||||
return userContexts.get(id);
|
||||
throw new GuacamoleResourceNotFoundException("Session not associated with authentication provider \"" + identifier + "\".");
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user