Merge patch branch changes to main.
This commit is contained in:
commit
ed54b5b12a
10 files changed
+28
-17
No files matched your search
+2
-1
@@ -59,7 +59,8 @@ public class ActiveConnectionObjectTranslator
|
||||
|
||||
@Override
|
||||
public void filterExternalObject(UserContext context,
|
||||
APIActiveConnection object) throws GuacamoleException {
|
||||
ActiveConnection existingObject, APIActiveConnection object)
|
||||
throws GuacamoleException {
|
||||
// Nothing to filter on ActiveConnections (no attributes)
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -62,7 +62,8 @@ public class ConnectionObjectTranslator
|
||||
|
||||
@Override
|
||||
public void filterExternalObject(UserContext userContext,
|
||||
APIConnection object) throws GuacamoleException {
|
||||
Connection existingObject, APIConnection object)
|
||||
throws GuacamoleException {
|
||||
|
||||
// Filter object attributes by defined schema
|
||||
object.setAttributes(filterAttributes(
|
||||
|
||||
+2
-1
@@ -56,7 +56,8 @@ public class ConnectionGroupObjectTranslator
|
||||
|
||||
@Override
|
||||
public void filterExternalObject(UserContext userContext,
|
||||
APIConnectionGroup object) throws GuacamoleException {
|
||||
ConnectionGroup existingObject, APIConnectionGroup object)
|
||||
throws GuacamoleException {
|
||||
|
||||
// Filter object attributes by defined schema
|
||||
object.setAttributes(filterAttributes(
|
||||
|
||||
+1
-1
@@ -311,7 +311,7 @@ public abstract class DirectoryObjectResource<InternalType extends Identifiable,
|
||||
throw new GuacamoleClientException("Data must be submitted when updating objects.");
|
||||
|
||||
// Filter/sanitize object contents
|
||||
translator.filterExternalObject(userContext, modifiedObject);
|
||||
translator.filterExternalObject(userContext, object, modifiedObject);
|
||||
|
||||
// Perform update
|
||||
translator.applyExternalChanges(object, modifiedObject);
|
||||
|
||||
+6
-1
@@ -106,6 +106,10 @@ public abstract class DirectoryObjectTranslator<InternalType extends Identifiabl
|
||||
* @param userContext
|
||||
* The UserContext associated with the object being filtered.
|
||||
*
|
||||
* @param existingObject
|
||||
* The existing object from the Guacamole extension API which is being
|
||||
* modified, or null if the object is being created.
|
||||
*
|
||||
* @param object
|
||||
* The object to modify such that it strictly conforms to the declared
|
||||
* schema.
|
||||
@@ -114,7 +118,8 @@ public abstract class DirectoryObjectTranslator<InternalType extends Identifiabl
|
||||
* If the object cannot be filtered due to an error.
|
||||
*/
|
||||
public abstract void filterExternalObject(UserContext userContext,
|
||||
ExternalType object) throws GuacamoleException;
|
||||
InternalType existingObject, ExternalType object)
|
||||
throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Filters the given map of attribute name/value pairs, producing a new
|
||||
|
||||
@@ -355,8 +355,9 @@ public abstract class DirectoryResource<InternalType extends Identifiable, Exter
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter and sanitize the provided external object, translate to the
|
||||
* internal type, and return the translated internal object.
|
||||
* Filter and sanitize the provided external object that is being created
|
||||
* (does not already exist), translate to the internal type, and return the
|
||||
* translated internal object.
|
||||
*
|
||||
* @param object
|
||||
* The external object to filter and translate.
|
||||
@@ -368,11 +369,11 @@ public abstract class DirectoryResource<InternalType extends Identifiable, Exter
|
||||
* If an error occurs while filtering or translating the external
|
||||
* object.
|
||||
*/
|
||||
private InternalType filterAndTranslate(ExternalType object)
|
||||
private InternalType filterAndTranslateNewObject(ExternalType object)
|
||||
throws GuacamoleException {
|
||||
|
||||
// Filter and sanitize the external object
|
||||
translator.filterExternalObject(userContext, object);
|
||||
translator.filterExternalObject(userContext, null, object);
|
||||
|
||||
// Translate to the internal type
|
||||
return translator.toInternalObject(object);
|
||||
@@ -599,7 +600,7 @@ public abstract class DirectoryResource<InternalType extends Identifiable, Exter
|
||||
if (op == APIPatch.Operation.add) {
|
||||
|
||||
// Filter/sanitize object contents
|
||||
InternalType internal = filterAndTranslate(patch.getValue());
|
||||
InternalType internal = filterAndTranslateNewObject(patch.getValue());
|
||||
|
||||
try {
|
||||
|
||||
@@ -823,7 +824,7 @@ public abstract class DirectoryResource<InternalType extends Identifiable, Exter
|
||||
throw new GuacamoleClientException("Data must be submitted when creating objects.");
|
||||
|
||||
// Filter/sanitize object contents
|
||||
InternalType internal = filterAndTranslate(object);
|
||||
InternalType internal = filterAndTranslateNewObject(object);
|
||||
|
||||
// Create the new object within the directory
|
||||
try {
|
||||
|
||||
+2
-1
@@ -56,7 +56,8 @@ public class SharingProfileObjectTranslator
|
||||
|
||||
@Override
|
||||
public void filterExternalObject(UserContext userContext,
|
||||
APISharingProfile object) throws GuacamoleException {
|
||||
SharingProfile existingObject, APISharingProfile object)
|
||||
throws GuacamoleException {
|
||||
|
||||
// Filter object attributes by defined schema
|
||||
object.setAttributes(filterAttributes(
|
||||
|
||||
@@ -59,11 +59,11 @@ public class UserObjectTranslator
|
||||
}
|
||||
|
||||
@Override
|
||||
public void filterExternalObject(UserContext userContext, APIUser object)
|
||||
throws GuacamoleException {
|
||||
public void filterExternalObject(UserContext userContext,
|
||||
User existingObject, APIUser object) throws GuacamoleException {
|
||||
|
||||
// If a user is editing themselves ...
|
||||
if (object.getUsername().equals(userContext.self().getIdentifier())) {
|
||||
if (existingObject != null && existingObject.getIdentifier().equals(userContext.self().getIdentifier())) {
|
||||
|
||||
// ... they may only edit preference attributes
|
||||
object.setAttributes(filterAttributes(userContext.getUserPreferenceAttributes(),
|
||||
|
||||
@@ -138,7 +138,7 @@ public class UserResource
|
||||
try {
|
||||
User currentUser = getUserContext().self();
|
||||
if (
|
||||
currentUser.getIdentifier().equals(modifiedObject.getUsername())
|
||||
currentUser.getIdentifier().equals(getInternalObject().getIdentifier())
|
||||
&& modifiedObject.getPassword() != null) {
|
||||
throw new GuacamoleSecurityException(
|
||||
"Permission denied. The password update endpoint must"
|
||||
|
||||
+2
-1
@@ -56,7 +56,8 @@ public class UserGroupObjectTranslator
|
||||
}
|
||||
|
||||
@Override
|
||||
public void filterExternalObject(UserContext userContext, APIUserGroup object)
|
||||
public void filterExternalObject(UserContext userContext,
|
||||
UserGroup existingObject, APIUserGroup object)
|
||||
throws GuacamoleException {
|
||||
|
||||
// Filter object attributes by defined schema
|
||||
|
||||
Reference in new issue
Block a user