mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-1289: Move AuthenticationSession components to guacamole-exit.
This commit is contained in:
committed by
Alex Leitner
parent
5a135f3361
commit
13494baa4a
@@ -19,11 +19,11 @@
|
||||
|
||||
package org.apache.guacamole.auth.sso;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.apache.guacamole.net.auth.IdentifierGenerator;
|
||||
|
||||
/**
|
||||
* Service for generating and validating single-use random tokens (nonces).
|
||||
@@ -31,12 +31,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
*/
|
||||
public class NonceService {
|
||||
|
||||
/**
|
||||
* Generator of arbitrary, unique, unpredictable identifiers.
|
||||
*/
|
||||
@Inject
|
||||
private IdentifierGenerator idGenerator;
|
||||
|
||||
/**
|
||||
* Map of all generated nonces to their corresponding expiration timestamps.
|
||||
* This Map must be periodically swept of expired nonces to avoid growing
|
||||
@@ -107,7 +101,7 @@ public class NonceService {
|
||||
sweepExpiredNonces();
|
||||
|
||||
// Generate and store nonce, along with expiration timestamp
|
||||
String nonce = idGenerator.generateIdentifier(NONCE_BITS, false);
|
||||
String nonce = IdentifierGenerator.generateIdentifier(NONCE_BITS, false);
|
||||
nonces.put(nonce, System.currentTimeMillis() + maxAge);
|
||||
return nonce;
|
||||
|
||||
|
@@ -19,7 +19,7 @@
|
||||
|
||||
package org.apache.guacamole.auth.saml.acs;
|
||||
|
||||
import org.apache.guacamole.auth.sso.AuthenticationSession;
|
||||
import org.apache.guacamole.net.auth.AuthenticationSession;
|
||||
|
||||
/**
|
||||
* Representation of an in-progress SAML authentication attempt.
|
||||
|
@@ -20,7 +20,7 @@
|
||||
package org.apache.guacamole.auth.saml.acs;
|
||||
|
||||
import com.google.inject.Singleton;
|
||||
import org.apache.guacamole.auth.sso.AuthenticationSessionManager;
|
||||
import org.apache.guacamole.net.auth.AuthenticationSessionManager;
|
||||
|
||||
/**
|
||||
* Manager service that temporarily stores SAML authentication attempts while
|
||||
|
@@ -36,7 +36,7 @@ import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleSecurityException;
|
||||
import org.apache.guacamole.GuacamoleServerException;
|
||||
import org.apache.guacamole.auth.saml.conf.ConfigurationService;
|
||||
import org.apache.guacamole.auth.sso.IdentifierGenerator;
|
||||
import org.apache.guacamole.net.auth.IdentifierGenerator;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
@@ -58,12 +58,6 @@ public class SAMLService {
|
||||
@Inject
|
||||
private SAMLAuthenticationSessionManager sessionManager;
|
||||
|
||||
/**
|
||||
* Generator of arbitrary, unique, unpredictable identifiers.
|
||||
*/
|
||||
@Inject
|
||||
private IdentifierGenerator idGenerator;
|
||||
|
||||
/**
|
||||
* Creates a new SAML request, beginning the overall authentication flow
|
||||
* that will ultimately result in an asserted user identity if the user is
|
||||
@@ -89,7 +83,7 @@ public class SAMLService {
|
||||
Auth auth = new Auth(samlSettings, null, null);
|
||||
|
||||
// Generate a unique ID to use for the relay state
|
||||
String identifier = idGenerator.generateIdentifier();
|
||||
String identifier = IdentifierGenerator.generateIdentifier();
|
||||
|
||||
// Create the request URL for the SAML IdP
|
||||
String requestUrl = auth.login(
|
||||
|
@@ -24,7 +24,6 @@ import com.onelogin.saml2.settings.IdPMetadataParser;
|
||||
import com.onelogin.saml2.settings.Saml2Settings;
|
||||
import com.onelogin.saml2.settings.SettingsBuilder;
|
||||
import com.onelogin.saml2.util.Constants;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
@@ -20,14 +20,8 @@
|
||||
package org.apache.guacamole.auth.ssl;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.auth.ssl.SSLAuthenticationSessionManager;
|
||||
import org.apache.guacamole.auth.sso.SSOAuthenticationEventListener;
|
||||
import org.apache.guacamole.net.auth.Credentials;
|
||||
import org.apache.guacamole.net.event.AuthenticationFailureEvent;
|
||||
import org.apache.guacamole.net.event.AuthenticationSuccessEvent;
|
||||
import org.apache.guacamole.net.event.listener.Listener;
|
||||
|
||||
/**
|
||||
* A Listener that will reactivate or invalidate SSL auth sessions depending on
|
||||
|
@@ -19,7 +19,7 @@
|
||||
|
||||
package org.apache.guacamole.auth.ssl;
|
||||
|
||||
import org.apache.guacamole.auth.sso.AuthenticationSession;
|
||||
import org.apache.guacamole.net.auth.AuthenticationSession;
|
||||
|
||||
/**
|
||||
* Representation of an in-progress SSL/TLS authentication attempt.
|
||||
|
@@ -20,7 +20,7 @@
|
||||
package org.apache.guacamole.auth.ssl;
|
||||
|
||||
import com.google.inject.Singleton;
|
||||
import org.apache.guacamole.auth.sso.AuthenticationSessionManager;
|
||||
import org.apache.guacamole.net.auth.AuthenticationSessionManager;
|
||||
|
||||
/**
|
||||
* Manager service that temporarily stores SSL/TLS authentication attempts
|
||||
|
@@ -17,7 +17,7 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.auth.sso;
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
/**
|
||||
* Representation of an in-progress authentication attempt.
|
@@ -17,10 +17,7 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.auth.sso;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -39,14 +36,7 @@ import java.util.concurrent.TimeUnit;
|
||||
* @param <T>
|
||||
* The type of sessions managed by this session manager.
|
||||
*/
|
||||
@Singleton
|
||||
public class AuthenticationSessionManager<T extends AuthenticationSession> {
|
||||
|
||||
/**
|
||||
* Generator of arbitrary, unique, unpredictable identifiers.
|
||||
*/
|
||||
@Inject
|
||||
private IdentifierGenerator idGenerator;
|
||||
public abstract class AuthenticationSessionManager<T extends AuthenticationSession> {
|
||||
|
||||
/**
|
||||
* Map of authentication session identifiers to their associated
|
||||
@@ -98,7 +88,7 @@ public class AuthenticationSessionManager<T extends AuthenticationSession> {
|
||||
* token.
|
||||
*/
|
||||
public String generateInvalid() {
|
||||
return idGenerator.generateIdentifier();
|
||||
return IdentifierGenerator.generateIdentifier();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -193,7 +183,7 @@ public class AuthenticationSessionManager<T extends AuthenticationSession> {
|
||||
* given session when calling resume().
|
||||
*/
|
||||
public String defer(T session) {
|
||||
String identifier = idGenerator.generateIdentifier();
|
||||
String identifier = IdentifierGenerator.generateIdentifier();
|
||||
sessions.put(identifier, session);
|
||||
return identifier;
|
||||
}
|
@@ -17,10 +17,9 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.auth.sso;
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import com.google.common.io.BaseEncoding;
|
||||
import com.google.inject.Singleton;
|
||||
import java.math.BigInteger;
|
||||
import java.security.SecureRandom;
|
||||
|
||||
@@ -29,14 +28,13 @@ import java.security.SecureRandom;
|
||||
* is an arbitrary, random string produced using a cryptographically-secure
|
||||
* random number generator.
|
||||
*/
|
||||
@Singleton
|
||||
public class IdentifierGenerator {
|
||||
|
||||
/**
|
||||
* Cryptographically-secure random number generator for generating unique
|
||||
* identifiers.
|
||||
*/
|
||||
private final SecureRandom secureRandom = new SecureRandom();
|
||||
private static final SecureRandom secureRandom = new SecureRandom();
|
||||
|
||||
/**
|
||||
* Generates a unique and unpredictable identifier. Each identifier is at
|
||||
@@ -48,7 +46,7 @@ public class IdentifierGenerator {
|
||||
* A unique and unpredictable identifier with at least 256 bits of
|
||||
* entropy.
|
||||
*/
|
||||
public String generateIdentifier() {
|
||||
public static String generateIdentifier() {
|
||||
return generateIdentifier(256);
|
||||
}
|
||||
|
||||
@@ -65,7 +63,7 @@ public class IdentifierGenerator {
|
||||
* A unique and unpredictable identifier with at least the given number
|
||||
* of bits of entropy.
|
||||
*/
|
||||
public String generateIdentifier(int minBits) {
|
||||
public static String generateIdentifier(int minBits) {
|
||||
return generateIdentifier(minBits, true);
|
||||
}
|
||||
|
||||
@@ -87,7 +85,7 @@ public class IdentifierGenerator {
|
||||
* A unique and unpredictable identifier with at least the given number
|
||||
* of bits of entropy.
|
||||
*/
|
||||
public String generateIdentifier(int minBits, boolean caseSensitive) {
|
||||
public static String generateIdentifier(int minBits, boolean caseSensitive) {
|
||||
|
||||
// Generate a base64 identifier if we're allowed to vary by case
|
||||
if (caseSensitive) {
|
Reference in New Issue
Block a user