From 41059f5e09016669b7384f71fd636ee28a8bc7c6 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 27 Oct 2017 11:08:08 -0700 Subject: [PATCH] GUACAMOLE-96: Add convenience class for overriding the behavior of an existing UserContext. --- .../net/auth/DelegatingUserContext.java | 134 ++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 guacamole-ext/src/main/java/org/apache/guacamole/net/auth/DelegatingUserContext.java diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/DelegatingUserContext.java b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/DelegatingUserContext.java new file mode 100644 index 000000000..a37faf952 --- /dev/null +++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/DelegatingUserContext.java @@ -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 getUserDirectory() throws GuacamoleException { + return userContext.getUserDirectory(); + } + + @Override + public Directory getConnectionDirectory() + throws GuacamoleException { + return userContext.getConnectionDirectory(); + } + + @Override + public Directory getConnectionGroupDirectory() + throws GuacamoleException { + return userContext.getConnectionGroupDirectory(); + } + + @Override + public Directory getActiveConnectionDirectory() + throws GuacamoleException { + return userContext.getActiveConnectionDirectory(); + } + + @Override + public Directory getSharingProfileDirectory() + throws GuacamoleException { + return userContext.getSharingProfileDirectory(); + } + + @Override + public ActivityRecordSet getConnectionHistory() + throws GuacamoleException { + return userContext.getConnectionHistory(); + } + + @Override + public ActivityRecordSet getUserHistory() + throws GuacamoleException { + return userContext.getUserHistory(); + } + + @Override + public ConnectionGroup getRootConnectionGroup() throws GuacamoleException { + return userContext.getRootConnectionGroup(); + } + + @Override + public Collection
getUserAttributes() { + return userContext.getUserAttributes(); + } + + @Override + public Collection getConnectionAttributes() { + return userContext.getConnectionAttributes(); + } + + @Override + public Collection getConnectionGroupAttributes() { + return userContext.getConnectionGroupAttributes(); + } + + @Override + public Collection getSharingProfileAttributes() { + return userContext.getSharingProfileAttributes(); + } + + @Override + public void invalidate() { + userContext.invalidate(); + } + +}