mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-10-27 15:13:07 +00:00
GUAC-1161: Add CredentialsInfo and credential-specific exceptions,
This commit is contained in:
@@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.glyptodon.guacamole.net.auth.credentials;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import org.glyptodon.guacamole.form.Parameter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Information which describes a set of valid credentials.
|
||||||
|
*
|
||||||
|
* @author Michael Jumper
|
||||||
|
*/
|
||||||
|
public class CredentialsInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All parameters required for valid credentials.
|
||||||
|
*/
|
||||||
|
private final Collection<Parameter> parameters;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new CredentialsInfo object which requires the given parameters
|
||||||
|
* for any conforming credentials.
|
||||||
|
*
|
||||||
|
* @param parameters
|
||||||
|
* The parameters to require.
|
||||||
|
*/
|
||||||
|
public CredentialsInfo(Collection<Parameter> parameters) {
|
||||||
|
this.parameters = parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all parameters required for valid credentials as described by
|
||||||
|
* this object.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* All parameters required for valid credentials.
|
||||||
|
*/
|
||||||
|
public Collection<Parameter> getParameters() {
|
||||||
|
return Collections.unmodifiableCollection(parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CredentialsInfo object which describes empty credentials. No parameters
|
||||||
|
* are required.
|
||||||
|
*/
|
||||||
|
public static final CredentialsInfo EMPTY = new CredentialsInfo(Collections.EMPTY_LIST);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CredentialsInfo object which describes standard username/password
|
||||||
|
* credentials.
|
||||||
|
*/
|
||||||
|
public static final CredentialsInfo USERNAME_PASSWORD = new CredentialsInfo(Arrays.asList(
|
||||||
|
new Parameter("username", "username", Parameter.Type.USERNAME),
|
||||||
|
new Parameter("password", "password", Parameter.Type.PASSWORD)
|
||||||
|
));
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.glyptodon.guacamole.net.auth.credentials;
|
||||||
|
|
||||||
|
import org.glyptodon.guacamole.GuacamoleSecurityException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A security-related exception thrown when access is denied to a user because
|
||||||
|
* of a problem related to the provided credentials. Additional information
|
||||||
|
* describing the form of valid credentials is provided.
|
||||||
|
*
|
||||||
|
* @author Michael Jumper
|
||||||
|
*/
|
||||||
|
public class GuacamoleCredentialsException extends GuacamoleSecurityException {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Information describing the form of valid credentials.
|
||||||
|
*/
|
||||||
|
private final CredentialsInfo credentialsInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new GuacamoleInvalidCredentialsException with the given
|
||||||
|
* message, cause, and associated credential information.
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
* A human readable description of the exception that occurred.
|
||||||
|
*
|
||||||
|
* @param cause
|
||||||
|
* The cause of this exception.
|
||||||
|
*
|
||||||
|
* @param credentialsInfo
|
||||||
|
* Information describing the form of valid credentials.
|
||||||
|
*/
|
||||||
|
public GuacamoleCredentialsException(String message, Throwable cause,
|
||||||
|
CredentialsInfo credentialsInfo) {
|
||||||
|
super(message, cause);
|
||||||
|
this.credentialsInfo = credentialsInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new GuacamoleInvalidCredentialsException with the given
|
||||||
|
* message and associated credential information.
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
* A human readable description of the exception that occurred.
|
||||||
|
*
|
||||||
|
* @param credentialsInfo
|
||||||
|
* Information describing the form of valid credentials.
|
||||||
|
*/
|
||||||
|
public GuacamoleCredentialsException(String message, CredentialsInfo credentialsInfo) {
|
||||||
|
super(message);
|
||||||
|
this.credentialsInfo = credentialsInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new GuacamoleInvalidCredentialsException with the given cause
|
||||||
|
* and associated credential information.
|
||||||
|
*
|
||||||
|
* @param cause
|
||||||
|
* The cause of this exception.
|
||||||
|
*
|
||||||
|
* @param credentialsInfo
|
||||||
|
* Information describing the form of valid credentials.
|
||||||
|
*/
|
||||||
|
public GuacamoleCredentialsException(Throwable cause, CredentialsInfo credentialsInfo) {
|
||||||
|
super(cause);
|
||||||
|
this.credentialsInfo = credentialsInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns information describing the form of valid credentials.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* Information describing the form of valid credentials.
|
||||||
|
*/
|
||||||
|
public CredentialsInfo getCredentialsInfo() {
|
||||||
|
return credentialsInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.glyptodon.guacamole.net.auth.credentials;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A security-related exception thrown when access is denied to a user because
|
||||||
|
* the provided credentials are not sufficient for authentication to succeed.
|
||||||
|
* The validity or invalidity of the given credentials is not specified, and
|
||||||
|
* more information is needed before a decision can be made. Additional
|
||||||
|
* information describing the form of valid credentials is provided.
|
||||||
|
*
|
||||||
|
* @author Michael Jumper
|
||||||
|
*/
|
||||||
|
public class GuacamoleInsufficientCredentialsException extends GuacamoleCredentialsException {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new GuacamoleInsufficientCredentialsException with the given
|
||||||
|
* message, cause, and associated credential information.
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
* A human readable description of the exception that occurred.
|
||||||
|
*
|
||||||
|
* @param cause
|
||||||
|
* The cause of this exception.
|
||||||
|
*
|
||||||
|
* @param credentialsInfo
|
||||||
|
* Information describing the form of valid credentials.
|
||||||
|
*/
|
||||||
|
public GuacamoleInsufficientCredentialsException(String message, Throwable cause,
|
||||||
|
CredentialsInfo credentialsInfo) {
|
||||||
|
super(message, cause, credentialsInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new GuacamoleInsufficientCredentialsException with the given
|
||||||
|
* message and associated credential information.
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
* A human readable description of the exception that occurred.
|
||||||
|
*
|
||||||
|
* @param credentialsInfo
|
||||||
|
* Information describing the form of valid credentials.
|
||||||
|
*/
|
||||||
|
public GuacamoleInsufficientCredentialsException(String message, CredentialsInfo credentialsInfo) {
|
||||||
|
super(message, credentialsInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new GuacamoleInsufficientCredentialsException with the given
|
||||||
|
* cause and associated credential information.
|
||||||
|
*
|
||||||
|
* @param cause
|
||||||
|
* The cause of this exception.
|
||||||
|
*
|
||||||
|
* @param credentialsInfo
|
||||||
|
* Information describing the form of valid credentials.
|
||||||
|
*/
|
||||||
|
public GuacamoleInsufficientCredentialsException(Throwable cause, CredentialsInfo credentialsInfo) {
|
||||||
|
super(cause, credentialsInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.glyptodon.guacamole.net.auth.credentials;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A security-related exception thrown when access is denied to a user because
|
||||||
|
* the provided credentials are invalid. Additional information describing
|
||||||
|
* the form of valid credentials is provided.
|
||||||
|
*
|
||||||
|
* @author Michael Jumper
|
||||||
|
*/
|
||||||
|
public class GuacamoleInvalidCredentialsException extends GuacamoleCredentialsException {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new GuacamoleInvalidCredentialsException with the given
|
||||||
|
* message, cause, and associated credential information.
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
* A human readable description of the exception that occurred.
|
||||||
|
*
|
||||||
|
* @param cause
|
||||||
|
* The cause of this exception.
|
||||||
|
*
|
||||||
|
* @param credentialsInfo
|
||||||
|
* Information describing the form of valid credentials.
|
||||||
|
*/
|
||||||
|
public GuacamoleInvalidCredentialsException(String message, Throwable cause,
|
||||||
|
CredentialsInfo credentialsInfo) {
|
||||||
|
super(message, cause, credentialsInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new GuacamoleInvalidCredentialsException with the given
|
||||||
|
* message and associated credential information.
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
* A human readable description of the exception that occurred.
|
||||||
|
*
|
||||||
|
* @param credentialsInfo
|
||||||
|
* Information describing the form of valid credentials.
|
||||||
|
*/
|
||||||
|
public GuacamoleInvalidCredentialsException(String message, CredentialsInfo credentialsInfo) {
|
||||||
|
super(message, credentialsInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new GuacamoleInvalidCredentialsException with the given cause
|
||||||
|
* and associated credential information.
|
||||||
|
*
|
||||||
|
* @param cause
|
||||||
|
* The cause of this exception.
|
||||||
|
*
|
||||||
|
* @param credentialsInfo
|
||||||
|
* Information describing the form of valid credentials.
|
||||||
|
*/
|
||||||
|
public GuacamoleInvalidCredentialsException(Throwable cause, CredentialsInfo credentialsInfo) {
|
||||||
|
super(cause, credentialsInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user