mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 17:13:21 +00:00 
			
		
		
		
	GUACAMOLE-96: Merge allow extensions to decorate each other's objects.
This commit is contained in:
		| @@ -168,6 +168,79 @@ public interface AuthenticationProvider { | ||||
|             AuthenticatedUser authenticatedUser, | ||||
|             Credentials credentials) throws GuacamoleException; | ||||
|  | ||||
|     /** | ||||
|      * Given a UserContext returned from getUserContext() of a different | ||||
|      * AuthenticationProvider, returns a UserContext instance which decorates | ||||
|      * (wraps) that UserContext, delegating and overriding implemented | ||||
|      * functions as necessary. Each UserContext created via getUserContext() | ||||
|      * will be passed to the decorate() functions of all other | ||||
|      * AuthenticationProviders, allowing those AuthenticationProviders to | ||||
|      * augment (or perhaps even limit) the functionality or data provided. | ||||
|      * | ||||
|      * @param context | ||||
|      *     An existing UserContext generated by getUserContext() of a different | ||||
|      *     AuthenticationProvider. | ||||
|      * | ||||
|      * @param authenticatedUser | ||||
|      *     The AuthenticatedUser object representing the user associated with | ||||
|      *     the given UserContext. | ||||
|      * | ||||
|      * @param credentials | ||||
|      *     The credentials which were most recently submitted for the given | ||||
|      *     AuthenticatedUser. These are not guaranteed to be the same as the | ||||
|      *     credentials associated with the AuthenticatedUser object, which are | ||||
|      *     the credentials provided when the user originally authenticated. | ||||
|      * | ||||
|      * @return | ||||
|      *     A decorated (wrapped) UserContext object, or the original, | ||||
|      *     undecorated UserContext. | ||||
|      * | ||||
|      * @throws GuacamoleException | ||||
|      *     If the UserContext cannot be decorated due to an error. | ||||
|      */ | ||||
|     UserContext decorate(UserContext context, | ||||
|             AuthenticatedUser authenticatedUser, | ||||
|             Credentials credentials) throws GuacamoleException; | ||||
|  | ||||
|     /** | ||||
|      * Given a UserContext returned by updateUserContext() of a different | ||||
|      * AuthenticationProvider, returns a UserContext instance which decorates | ||||
|      * (wraps) that UserContext, delegating and overriding implemented | ||||
|      * functions as necessary. Each UserContext created via updateUserContext() | ||||
|      * will be passed to the decorate() functions of all other | ||||
|      * AuthenticationProviders, allowing those AuthenticationProviders to | ||||
|      * augment (or perhaps even limit) the functionality or data provided. | ||||
|      * | ||||
|      * @param decorated | ||||
|      *     The UserContext returned when decorate() was invoked on this | ||||
|      *     AuthenticationProvider for the UserContext which was just updated | ||||
|      *     via a call to updateUserContext(). | ||||
|      * | ||||
|      * @param context | ||||
|      *     An existing UserContext generated by updateUserContext() of a | ||||
|      *     different AuthenticationProvider. | ||||
|      * | ||||
|      * @param authenticatedUser | ||||
|      *     The AuthenticatedUser object representing the user associated with | ||||
|      *     the given UserContext. | ||||
|      * | ||||
|      * @param credentials | ||||
|      *     The credentials which were most recently submitted for the given | ||||
|      *     AuthenticatedUser. These are not guaranteed to be the same as the | ||||
|      *     credentials associated with the AuthenticatedUser object, which are | ||||
|      *     the credentials provided when the user originally authenticated. | ||||
|      * | ||||
|      * @return | ||||
|      *     A decorated (wrapped) UserContext object, or the original, | ||||
|      *     undecorated UserContext. | ||||
|      * | ||||
|      * @throws GuacamoleException | ||||
|      *     If the UserContext cannot be decorated due to an error. | ||||
|      */ | ||||
|     UserContext redecorate(UserContext decorated, UserContext context, | ||||
|             AuthenticatedUser authenticatedUser, | ||||
|             Credentials credentials) throws GuacamoleException; | ||||
|  | ||||
|     /** | ||||
|      * Frees all resources associated with this AuthenticationProvider. This | ||||
|      * function will be automatically invoked when the Guacamole server is | ||||
|   | ||||
| @@ -0,0 +1,134 @@ | ||||
| /* | ||||
|  * Licensed to the Apache Software Foundation (ASF) under one | ||||
|  * or more contributor license agreements.  See the NOTICE file | ||||
|  * distributed with this work for additional information | ||||
|  * regarding copyright ownership.  The ASF licenses this file | ||||
|  * to you under the Apache License, Version 2.0 (the | ||||
|  * "License"); you may not use this file except in compliance | ||||
|  * with the License.  You may obtain a copy of the License at | ||||
|  * | ||||
|  *   http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, | ||||
|  * software distributed under the License is distributed on an | ||||
|  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||||
|  * KIND, either express or implied.  See the License for the | ||||
|  * specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| package org.apache.guacamole.net.auth; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collection; | ||||
| import org.apache.guacamole.GuacamoleException; | ||||
|  | ||||
| /** | ||||
|  * Directory implementation which simplifies decorating the objects within an | ||||
|  * underlying Directory. The decorate() and undecorate() functions must be | ||||
|  * implemented to define how each object is decorated, and how that decoration | ||||
|  * may be removed. | ||||
|  * | ||||
|  * @param <ObjectType> | ||||
|  *     The type of objects stored within this Directory. | ||||
|  */ | ||||
| public abstract class DecoratingDirectory<ObjectType extends Identifiable> | ||||
|         extends DelegatingDirectory<ObjectType> { | ||||
|  | ||||
|     /** | ||||
|      * Creates a new DecoratingDirectory which decorates the objects within | ||||
|      * the given directory. | ||||
|      * | ||||
|      * @param directory | ||||
|      *     The Directory whose objects are being decorated. | ||||
|      */ | ||||
|     public DecoratingDirectory(Directory<ObjectType> directory) { | ||||
|         super(directory); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Given an object retrieved from a Directory which originates from a | ||||
|      * different AuthenticationProvider, returns an identical type of object | ||||
|      * optionally wrapped with additional information, functionality, etc. If | ||||
|      * this directory chooses to decorate the object provided, it is up to the | ||||
|      * implementation of that decorated object to properly pass through | ||||
|      * operations as appropriate, as well as provide for an eventual | ||||
|      * undecorate() operation. All objects retrieved from this | ||||
|      * DecoratingDirectory will first be passed through this function. | ||||
|      * | ||||
|      * @param object | ||||
|      *     An object from a Directory which originates from a different | ||||
|      *     AuthenticationProvider. | ||||
|      * | ||||
|      * @return | ||||
|      *     An object which may have been decorated by this | ||||
|      *     DecoratingDirectory. If the object was not decorated, the original, | ||||
|      *     unmodified object may be returned instead. | ||||
|      * | ||||
|      * @throws GuacamoleException | ||||
|      *     If the provided object cannot be decorated due to an error. | ||||
|      */ | ||||
|     protected abstract ObjectType decorate(ObjectType object) | ||||
|             throws GuacamoleException; | ||||
|  | ||||
|     /** | ||||
|      * Given an object originally returned from a call to this | ||||
|      * DecoratingDirectory's decorate() function, reverses the decoration | ||||
|      * operation, returning the original object. This function is effectively | ||||
|      * the exact inverse of the decorate() function. The return value of | ||||
|      * undecorate(decorate(X)) must be identically X. All objects given to this | ||||
|      * DecoratingDirectory via add() or update() will first be passed through | ||||
|      * this function. | ||||
|      * | ||||
|      * @param object | ||||
|      *     An object which was originally returned by a call to this | ||||
|      *     DecoratingDirectory's decorate() function. | ||||
|      * | ||||
|      * @return | ||||
|      *     The original object which was provided to this DecoratingDirectory's | ||||
|      *     decorate() function. | ||||
|      * | ||||
|      * @throws GuacamoleException | ||||
|      *     If the provided object cannot be undecorated due to an error. | ||||
|      */ | ||||
|     protected abstract ObjectType undecorate(ObjectType object) | ||||
|             throws GuacamoleException; | ||||
|  | ||||
|     @Override | ||||
|     public ObjectType get(String identifier) throws GuacamoleException { | ||||
|  | ||||
|         // Decorate only if object exists | ||||
|         ObjectType object = super.get(identifier); | ||||
|         if (object != null) | ||||
|             return decorate(object); | ||||
|  | ||||
|         return null; | ||||
|  | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Collection<ObjectType> getAll(Collection<String> identifiers) | ||||
|             throws GuacamoleException { | ||||
|  | ||||
|         Collection<ObjectType> objects = super.getAll(identifiers); | ||||
|  | ||||
|         // Decorate all retrieved objects, if any | ||||
|         Collection<ObjectType> decorated = new ArrayList<ObjectType>(objects.size()); | ||||
|         for (ObjectType object : objects) | ||||
|             decorated.add(decorate(object)); | ||||
|  | ||||
|         return decorated; | ||||
|  | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void add(ObjectType object) throws GuacamoleException { | ||||
|         super.add(decorate(object)); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void update(ObjectType object) throws GuacamoleException { | ||||
|         super.update(undecorate(object)); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,131 @@ | ||||
| /* | ||||
|  * Licensed to the Apache Software Foundation (ASF) under one | ||||
|  * or more contributor license agreements.  See the NOTICE file | ||||
|  * distributed with this work for additional information | ||||
|  * regarding copyright ownership.  The ASF licenses this file | ||||
|  * to you under the Apache License, Version 2.0 (the | ||||
|  * "License"); you may not use this file except in compliance | ||||
|  * with the License.  You may obtain a copy of the License at | ||||
|  * | ||||
|  *   http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, | ||||
|  * software distributed under the License is distributed on an | ||||
|  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||||
|  * KIND, either express or implied.  See the License for the | ||||
|  * specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| package org.apache.guacamole.net.auth; | ||||
|  | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.Set; | ||||
| import org.apache.guacamole.GuacamoleException; | ||||
| import org.apache.guacamole.net.GuacamoleTunnel; | ||||
| import org.apache.guacamole.protocol.GuacamoleClientInformation; | ||||
| import org.apache.guacamole.protocol.GuacamoleConfiguration; | ||||
|  | ||||
| /** | ||||
|  * Connection implementation which simply delegates all function calls to an | ||||
|  * underlying Connection. | ||||
|  */ | ||||
| public class DelegatingConnection implements Connection { | ||||
|  | ||||
|     /** | ||||
|      * The wrapped Connection. | ||||
|      */ | ||||
|     private final Connection connection; | ||||
|  | ||||
|     /** | ||||
|      * Wraps the given Connection such that all function calls against this | ||||
|      * DelegatingConnection will be delegated to it. | ||||
|      * | ||||
|      * @param connection | ||||
|      *     The Connection to wrap. | ||||
|      */ | ||||
|     public DelegatingConnection(Connection connection) { | ||||
|         this.connection = connection; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String getIdentifier() { | ||||
|         return connection.getIdentifier(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void setIdentifier(String identifier) { | ||||
|         connection.setIdentifier(identifier); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String getName() { | ||||
|         return connection.getName(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void setName(String name) { | ||||
|         connection.setName(name); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String getParentIdentifier() { | ||||
|         return connection.getParentIdentifier(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void setParentIdentifier(String parentIdentifier) { | ||||
|         connection.setParentIdentifier(parentIdentifier); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public GuacamoleConfiguration getConfiguration() { | ||||
|         return connection.getConfiguration(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void setConfiguration(GuacamoleConfiguration config) { | ||||
|         connection.setConfiguration(config); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Map<String, String> getAttributes() { | ||||
|         return connection.getAttributes(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void setAttributes(Map<String, String> attributes) { | ||||
|         connection.setAttributes(attributes); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Date getLastActive() { | ||||
|         return connection.getLastActive(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<? extends ConnectionRecord> getHistory() | ||||
|             throws GuacamoleException { | ||||
|         return connection.getHistory(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Set<String> getSharingProfileIdentifiers() | ||||
|             throws GuacamoleException { | ||||
|         return connection.getSharingProfileIdentifiers(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public GuacamoleTunnel connect(GuacamoleClientInformation info) | ||||
|             throws GuacamoleException { | ||||
|         return connection.connect(info); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public int getActiveConnections() { | ||||
|         return connection.getActiveConnections(); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,120 @@ | ||||
| /* | ||||
|  * Licensed to the Apache Software Foundation (ASF) under one | ||||
|  * or more contributor license agreements.  See the NOTICE file | ||||
|  * distributed with this work for additional information | ||||
|  * regarding copyright ownership.  The ASF licenses this file | ||||
|  * to you under the Apache License, Version 2.0 (the | ||||
|  * "License"); you may not use this file except in compliance | ||||
|  * with the License.  You may obtain a copy of the License at | ||||
|  * | ||||
|  *   http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, | ||||
|  * software distributed under the License is distributed on an | ||||
|  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||||
|  * KIND, either express or implied.  See the License for the | ||||
|  * specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| package org.apache.guacamole.net.auth; | ||||
|  | ||||
| import java.util.Map; | ||||
| import java.util.Set; | ||||
| import org.apache.guacamole.GuacamoleException; | ||||
| import org.apache.guacamole.net.GuacamoleTunnel; | ||||
| import org.apache.guacamole.protocol.GuacamoleClientInformation; | ||||
|  | ||||
| /** | ||||
|  * ConnectionGroup implementation which simply delegates all function calls to | ||||
|  * an underlying ConnectionGroup. | ||||
|  */ | ||||
| public class DelegatingConnectionGroup implements ConnectionGroup { | ||||
|  | ||||
|     /** | ||||
|      * The wrapped ConnectionGroup. | ||||
|      */ | ||||
|     private final ConnectionGroup connectionGroup; | ||||
|  | ||||
|     /** | ||||
|      * Wraps the given ConnectionGroup such that all function calls against this | ||||
|      * DelegatingConnectionGroup will be delegated to it. | ||||
|      * | ||||
|      * @param connectionGroup | ||||
|      *     The ConnectionGroup to wrap. | ||||
|      */ | ||||
|     public DelegatingConnectionGroup(ConnectionGroup connectionGroup) { | ||||
|         this.connectionGroup = connectionGroup; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String getIdentifier() { | ||||
|         return connectionGroup.getIdentifier(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void setIdentifier(String identifier) { | ||||
|         connectionGroup.setIdentifier(identifier); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String getName() { | ||||
|         return connectionGroup.getName(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void setName(String name) { | ||||
|         connectionGroup.setName(name); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String getParentIdentifier() { | ||||
|         return connectionGroup.getParentIdentifier(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void setParentIdentifier(String parentIdentifier) { | ||||
|         connectionGroup.setParentIdentifier(parentIdentifier); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void setType(Type type) { | ||||
|         connectionGroup.setType(type); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Type getType() { | ||||
|         return connectionGroup.getType(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Set<String> getConnectionIdentifiers() throws GuacamoleException { | ||||
|         return connectionGroup.getConnectionIdentifiers(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Set<String> getConnectionGroupIdentifiers() throws GuacamoleException { | ||||
|         return connectionGroup.getConnectionGroupIdentifiers(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Map<String, String> getAttributes() { | ||||
|         return connectionGroup.getAttributes(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void setAttributes(Map<String, String> attributes) { | ||||
|         connectionGroup.setAttributes(attributes); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public GuacamoleTunnel connect(GuacamoleClientInformation info) throws GuacamoleException { | ||||
|         return connectionGroup.connect(info); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public int getActiveConnections() { | ||||
|         return connectionGroup.getActiveConnections(); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,83 @@ | ||||
| /* | ||||
|  * Licensed to the Apache Software Foundation (ASF) under one | ||||
|  * or more contributor license agreements.  See the NOTICE file | ||||
|  * distributed with this work for additional information | ||||
|  * regarding copyright ownership.  The ASF licenses this file | ||||
|  * to you under the Apache License, Version 2.0 (the | ||||
|  * "License"); you may not use this file except in compliance | ||||
|  * with the License.  You may obtain a copy of the License at | ||||
|  * | ||||
|  *   http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, | ||||
|  * software distributed under the License is distributed on an | ||||
|  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||||
|  * KIND, either express or implied.  See the License for the | ||||
|  * specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| package org.apache.guacamole.net.auth; | ||||
|  | ||||
| import java.util.Collection; | ||||
| import java.util.Set; | ||||
| import org.apache.guacamole.GuacamoleException; | ||||
|  | ||||
| /** | ||||
|  * Directory implementation which simply delegates all function calls to an | ||||
|  * underlying Directory. | ||||
|  * | ||||
|  * @param <ObjectType> | ||||
|  *     The type of objects stored within this Directory. | ||||
|  */ | ||||
| public class DelegatingDirectory<ObjectType extends Identifiable> | ||||
|         implements Directory<ObjectType> { | ||||
|  | ||||
|     /** | ||||
|      * The wrapped Directory. | ||||
|      */ | ||||
|     private final Directory<ObjectType> directory; | ||||
|  | ||||
|     /** | ||||
|      * Wraps the given Directory such that all function calls against this | ||||
|      * DelegatingDirectory will be delegated to it. | ||||
|      * | ||||
|      * @param directory | ||||
|      *     The directory to wrap. | ||||
|      */ | ||||
|     public DelegatingDirectory(Directory<ObjectType> directory) { | ||||
|         this.directory = directory; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public ObjectType get(String identifier) throws GuacamoleException { | ||||
|         return directory.get(identifier); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Collection<ObjectType> getAll(Collection<String> identifiers) | ||||
|             throws GuacamoleException { | ||||
|         return directory.getAll(identifiers); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Set<String> getIdentifiers() throws GuacamoleException { | ||||
|         return directory.getIdentifiers(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void add(ObjectType object) throws GuacamoleException { | ||||
|         directory.add(object); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void update(ObjectType object) throws GuacamoleException { | ||||
|         directory.update(object); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void remove(String identifier) throws GuacamoleException { | ||||
|         directory.remove(identifier); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,96 @@ | ||||
| /* | ||||
|  * Licensed to the Apache Software Foundation (ASF) under one | ||||
|  * or more contributor license agreements.  See the NOTICE file | ||||
|  * distributed with this work for additional information | ||||
|  * regarding copyright ownership.  The ASF licenses this file | ||||
|  * to you under the Apache License, Version 2.0 (the | ||||
|  * "License"); you may not use this file except in compliance | ||||
|  * with the License.  You may obtain a copy of the License at | ||||
|  * | ||||
|  *   http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, | ||||
|  * software distributed under the License is distributed on an | ||||
|  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||||
|  * KIND, either express or implied.  See the License for the | ||||
|  * specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| package org.apache.guacamole.net.auth; | ||||
|  | ||||
| import java.util.Map; | ||||
|  | ||||
| /** | ||||
|  * SharingProfile implementation which simply delegates all function calls to an | ||||
|  * underlying SharingProfile. | ||||
|  */ | ||||
| public class DelegatingSharingProfile implements SharingProfile { | ||||
|  | ||||
|     /** | ||||
|      * The wrapped SharingProfile. | ||||
|      */ | ||||
|     private final SharingProfile sharingProfile; | ||||
|  | ||||
|     /** | ||||
|      * Wraps the given SharingProfile such that all function calls against this | ||||
|      * DelegatingSharingProfile will be delegated to it. | ||||
|      * | ||||
|      * @param sharingProfile | ||||
|      *     The SharingProfile to wrap. | ||||
|      */ | ||||
|     public DelegatingSharingProfile(SharingProfile sharingProfile) { | ||||
|         this.sharingProfile = sharingProfile; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String getIdentifier() { | ||||
|         return sharingProfile.getIdentifier(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void setIdentifier(String identifier) { | ||||
|         sharingProfile.setIdentifier(identifier); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String getName() { | ||||
|         return sharingProfile.getName(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void setName(String name) { | ||||
|         sharingProfile.setName(name); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String getPrimaryConnectionIdentifier() { | ||||
|         return sharingProfile.getPrimaryConnectionIdentifier(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void setPrimaryConnectionIdentifier(String identifier) { | ||||
|         sharingProfile.setPrimaryConnectionIdentifier(identifier); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Map<String, String> getParameters() { | ||||
|         return sharingProfile.getParameters(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void setParameters(Map<String, String> parameters) { | ||||
|         sharingProfile.setParameters(parameters); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Map<String, String> getAttributes() { | ||||
|         return sharingProfile.getAttributes(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void setAttributes(Map<String, String> attributes) { | ||||
|         sharingProfile.setAttributes(attributes); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,127 @@ | ||||
| /* | ||||
|  * Licensed to the Apache Software Foundation (ASF) under one | ||||
|  * or more contributor license agreements.  See the NOTICE file | ||||
|  * distributed with this work for additional information | ||||
|  * regarding copyright ownership.  The ASF licenses this file | ||||
|  * to you under the Apache License, Version 2.0 (the | ||||
|  * "License"); you may not use this file except in compliance | ||||
|  * with the License.  You may obtain a copy of the License at | ||||
|  * | ||||
|  *   http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, | ||||
|  * software distributed under the License is distributed on an | ||||
|  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||||
|  * KIND, either express or implied.  See the License for the | ||||
|  * specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| package org.apache.guacamole.net.auth; | ||||
|  | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import org.apache.guacamole.GuacamoleException; | ||||
| import org.apache.guacamole.net.auth.permission.ObjectPermissionSet; | ||||
| import org.apache.guacamole.net.auth.permission.SystemPermissionSet; | ||||
|  | ||||
| /** | ||||
|  * User implementation which simply delegates all function calls to an | ||||
|  * underlying User. | ||||
|  */ | ||||
| public class DelegatingUser implements User { | ||||
|  | ||||
|     /** | ||||
|      * The wrapped User. | ||||
|      */ | ||||
|     private final User user; | ||||
|  | ||||
|     /** | ||||
|      * Wraps the given User such that all function calls against this | ||||
|      * DelegatingUser will be delegated to it. | ||||
|      * | ||||
|      * @param user | ||||
|      *     The User to wrap. | ||||
|      */ | ||||
|     public DelegatingUser(User user) { | ||||
|         this.user = user; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String getIdentifier() { | ||||
|         return user.getIdentifier(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void setIdentifier(String identifier) { | ||||
|         user.setIdentifier(identifier); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String getPassword() { | ||||
|         return user.getPassword(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void setPassword(String password) { | ||||
|         user.setPassword(password); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Map<String, String> getAttributes() { | ||||
|         return user.getAttributes(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void setAttributes(Map<String, String> attributes) { | ||||
|         user.setAttributes(attributes); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Date getLastActive() { | ||||
|         return user.getLastActive(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<? extends ActivityRecord> getHistory() | ||||
|             throws GuacamoleException { | ||||
|         return user.getHistory(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public SystemPermissionSet getSystemPermissions() | ||||
|             throws GuacamoleException { | ||||
|         return user.getSystemPermissions(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public ObjectPermissionSet getConnectionPermissions() | ||||
|             throws GuacamoleException { | ||||
|         return user.getConnectionPermissions(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public ObjectPermissionSet getConnectionGroupPermissions() | ||||
|             throws GuacamoleException { | ||||
|         return user.getConnectionGroupPermissions(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public ObjectPermissionSet getSharingProfilePermissions() | ||||
|             throws GuacamoleException { | ||||
|         return user.getSharingProfilePermissions(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public ObjectPermissionSet getActiveConnectionPermissions() | ||||
|             throws GuacamoleException { | ||||
|         return user.getActiveConnectionPermissions(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public ObjectPermissionSet getUserPermissions() throws GuacamoleException { | ||||
|         return user.getUserPermissions(); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,134 @@ | ||||
| /* | ||||
|  * Licensed to the Apache Software Foundation (ASF) under one | ||||
|  * or more contributor license agreements.  See the NOTICE file | ||||
|  * distributed with this work for additional information | ||||
|  * regarding copyright ownership.  The ASF licenses this file | ||||
|  * to you under the Apache License, Version 2.0 (the | ||||
|  * "License"); you may not use this file except in compliance | ||||
|  * with the License.  You may obtain a copy of the License at | ||||
|  * | ||||
|  *   http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, | ||||
|  * software distributed under the License is distributed on an | ||||
|  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||||
|  * KIND, either express or implied.  See the License for the | ||||
|  * specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| package org.apache.guacamole.net.auth; | ||||
|  | ||||
| import java.util.Collection; | ||||
| import org.apache.guacamole.GuacamoleException; | ||||
| import org.apache.guacamole.form.Form; | ||||
|  | ||||
| /** | ||||
|  * UserContext implementation which simply delegates all function calls to | ||||
|  * an underlying UserContext. | ||||
|  */ | ||||
| public class DelegatingUserContext implements UserContext { | ||||
|  | ||||
|     /** | ||||
|      * The wrapped UserContext. | ||||
|      */ | ||||
|     private final UserContext userContext; | ||||
|  | ||||
|     /** | ||||
|      * Wraps the given UserContext such that all function calls against this | ||||
|      * DelegatingUserContext will be delegated to it. | ||||
|      * | ||||
|      * @param userContext | ||||
|      *     The UserContext to wrap. | ||||
|      */ | ||||
|     public DelegatingUserContext(UserContext userContext) { | ||||
|         this.userContext = userContext; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public User self() { | ||||
|         return userContext.self(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Object getResource() throws GuacamoleException { | ||||
|         return userContext.getResource(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public AuthenticationProvider getAuthenticationProvider() { | ||||
|         return userContext.getAuthenticationProvider(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Directory<User> getUserDirectory() throws GuacamoleException { | ||||
|         return userContext.getUserDirectory(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Directory<Connection> getConnectionDirectory() | ||||
|             throws GuacamoleException { | ||||
|         return userContext.getConnectionDirectory(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Directory<ConnectionGroup> getConnectionGroupDirectory() | ||||
|             throws GuacamoleException { | ||||
|         return userContext.getConnectionGroupDirectory(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Directory<ActiveConnection> getActiveConnectionDirectory() | ||||
|             throws GuacamoleException { | ||||
|         return userContext.getActiveConnectionDirectory(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Directory<SharingProfile> getSharingProfileDirectory() | ||||
|             throws GuacamoleException { | ||||
|         return userContext.getSharingProfileDirectory(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public ActivityRecordSet<ConnectionRecord> getConnectionHistory() | ||||
|             throws GuacamoleException { | ||||
|         return userContext.getConnectionHistory(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public ActivityRecordSet<ActivityRecord> getUserHistory() | ||||
|             throws GuacamoleException { | ||||
|         return userContext.getUserHistory(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public ConnectionGroup getRootConnectionGroup() throws GuacamoleException { | ||||
|         return userContext.getRootConnectionGroup(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Collection<Form> getUserAttributes() { | ||||
|         return userContext.getUserAttributes(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Collection<Form> getConnectionAttributes() { | ||||
|         return userContext.getConnectionAttributes(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Collection<Form> getConnectionGroupAttributes() { | ||||
|         return userContext.getConnectionGroupAttributes(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Collection<Form> getSharingProfileAttributes() { | ||||
|         return userContext.getSharingProfileAttributes(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void invalidate() { | ||||
|         userContext.invalidate(); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -260,6 +260,23 @@ public abstract class SimpleAuthenticationProvider | ||||
|          | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public UserContext decorate(UserContext context, | ||||
|             AuthenticatedUser authenticatedUser, Credentials credentials) | ||||
|             throws GuacamoleException { | ||||
|  | ||||
|         // Simply return the given context, decorating nothing | ||||
|         return context; | ||||
|  | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public UserContext redecorate(UserContext decorated, UserContext context, | ||||
|             AuthenticatedUser authenticatedUser, Credentials credentials) | ||||
|             throws GuacamoleException { | ||||
|         return decorate(context, authenticatedUser, credentials); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void shutdown() { | ||||
|         // Do nothing | ||||
|   | ||||
		Reference in New Issue
	
	Block a user