GUACAMOLE-394: Add API support for user login/logout records.

This commit is contained in:
Michael Jumper
2017-09-09 13:43:49 -07:00
parent 26122ebc3e
commit 5340f55361
6 changed files with 82 additions and 0 deletions

View File

@@ -37,6 +37,7 @@ import org.apache.guacamole.net.auth.Directory;
import org.apache.guacamole.net.auth.SharingProfile; import org.apache.guacamole.net.auth.SharingProfile;
import org.apache.guacamole.net.auth.User; import org.apache.guacamole.net.auth.User;
import org.apache.guacamole.net.auth.UserContext; import org.apache.guacamole.net.auth.UserContext;
import org.apache.guacamole.net.auth.UserRecord;
import org.apache.guacamole.net.auth.simple.SimpleActivityRecordSet; import org.apache.guacamole.net.auth.simple.SimpleActivityRecordSet;
import org.apache.guacamole.net.auth.simple.SimpleConnectionGroupDirectory; import org.apache.guacamole.net.auth.simple.SimpleConnectionGroupDirectory;
import org.apache.guacamole.net.auth.simple.SimpleDirectory; import org.apache.guacamole.net.auth.simple.SimpleDirectory;
@@ -180,6 +181,12 @@ public class SharedUserContext implements UserContext {
return new SimpleActivityRecordSet<ConnectionRecord>(); return new SimpleActivityRecordSet<ConnectionRecord>();
} }
@Override
public ActivityRecordSet<UserRecord> getUserHistory()
throws GuacamoleException {
return new SimpleActivityRecordSet<UserRecord>();
}
@Override @Override
public ConnectionGroup getRootConnectionGroup() { public ConnectionGroup getRootConnectionGroup() {
return rootGroup; return rootGroup;

View File

@@ -36,12 +36,15 @@ import org.apache.guacamole.auth.jdbc.sharingprofile.ModeledSharingProfile;
import org.apache.guacamole.auth.jdbc.sharingprofile.SharingProfileDirectory; import org.apache.guacamole.auth.jdbc.sharingprofile.SharingProfileDirectory;
import org.apache.guacamole.form.Form; import org.apache.guacamole.form.Form;
import org.apache.guacamole.net.auth.ActiveConnection; import org.apache.guacamole.net.auth.ActiveConnection;
import org.apache.guacamole.net.auth.ActivityRecordSet;
import org.apache.guacamole.net.auth.AuthenticationProvider; import org.apache.guacamole.net.auth.AuthenticationProvider;
import org.apache.guacamole.net.auth.Connection; import org.apache.guacamole.net.auth.Connection;
import org.apache.guacamole.net.auth.ConnectionGroup; import org.apache.guacamole.net.auth.ConnectionGroup;
import org.apache.guacamole.net.auth.Directory; import org.apache.guacamole.net.auth.Directory;
import org.apache.guacamole.net.auth.SharingProfile; import org.apache.guacamole.net.auth.SharingProfile;
import org.apache.guacamole.net.auth.User; import org.apache.guacamole.net.auth.User;
import org.apache.guacamole.net.auth.UserRecord;
import org.apache.guacamole.net.auth.simple.SimpleActivityRecordSet;
/** /**
* UserContext implementation which is driven by an arbitrary, underlying * UserContext implementation which is driven by an arbitrary, underlying
@@ -161,6 +164,12 @@ public class ModeledUserContext extends RestrictedObject
return connectionRecordSet; return connectionRecordSet;
} }
@Override
public ActivityRecordSet<UserRecord> getUserHistory()
throws GuacamoleException {
return new SimpleActivityRecordSet<UserRecord>();
}
@Override @Override
public ConnectionGroup getRootConnectionGroup() throws GuacamoleException { public ConnectionGroup getRootConnectionGroup() throws GuacamoleException {

View File

@@ -37,6 +37,7 @@ import org.apache.guacamole.net.auth.ConnectionRecord;
import org.apache.guacamole.net.auth.Directory; import org.apache.guacamole.net.auth.Directory;
import org.apache.guacamole.net.auth.SharingProfile; import org.apache.guacamole.net.auth.SharingProfile;
import org.apache.guacamole.net.auth.User; import org.apache.guacamole.net.auth.User;
import org.apache.guacamole.net.auth.UserRecord;
import org.apache.guacamole.net.auth.simple.SimpleActivityRecordSet; import org.apache.guacamole.net.auth.simple.SimpleActivityRecordSet;
import org.apache.guacamole.net.auth.simple.SimpleConnectionGroup; import org.apache.guacamole.net.auth.simple.SimpleConnectionGroup;
import org.apache.guacamole.net.auth.simple.SimpleConnectionGroupDirectory; import org.apache.guacamole.net.auth.simple.SimpleConnectionGroupDirectory;
@@ -210,6 +211,12 @@ public class UserContext implements org.apache.guacamole.net.auth.UserContext {
return new SimpleActivityRecordSet<ConnectionRecord>(); return new SimpleActivityRecordSet<ConnectionRecord>();
} }
@Override
public ActivityRecordSet<UserRecord> getUserHistory()
throws GuacamoleException {
return new SimpleActivityRecordSet<UserRecord>();
}
@Override @Override
public Collection<Form> getUserAttributes() { public Collection<Form> getUserAttributes() {
return Collections.<Form>emptyList(); return Collections.<Form>emptyList();

View File

@@ -156,6 +156,19 @@ public interface UserContext {
ActivityRecordSet<ConnectionRecord> getConnectionHistory() ActivityRecordSet<ConnectionRecord> getConnectionHistory()
throws GuacamoleException; throws GuacamoleException;
/**
* Retrieves all user records visible to current user. The resulting
* set of user records can be further filtered and ordered using the
* methods defined on ActivityRecordSet.
*
* @return
* A set of all user records visible to the current user.
*
* @throws GuacamoleException
* If an error occurs while retrieving the user records.
*/
ActivityRecordSet<UserRecord> getUserHistory() throws GuacamoleException;
/** /**
* Retrieves a connection group which can be used to view and manipulate * Retrieves a connection group which can be used to view and manipulate
* connections, but only as allowed by the permissions given to the user of * connections, but only as allowed by the permissions given to the user of

View File

@@ -0,0 +1,39 @@
/*
* 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;
/**
* A logging record describing when a user started and ended their Guacamole
* session.
*/
public interface UserRecord extends ActivityRecord {
/**
* Returns the authentication token associated with the user's session, if
* known. If permission is not granted to view the authentication tokens of
* other users, this may be null.
*
* @return
* The authentication token associated with the user's session, or null
* if this information is unavailable.
*/
public String getToken();
}

View File

@@ -36,6 +36,7 @@ import org.apache.guacamole.net.auth.Directory;
import org.apache.guacamole.net.auth.SharingProfile; import org.apache.guacamole.net.auth.SharingProfile;
import org.apache.guacamole.net.auth.User; import org.apache.guacamole.net.auth.User;
import org.apache.guacamole.net.auth.UserContext; import org.apache.guacamole.net.auth.UserContext;
import org.apache.guacamole.net.auth.UserRecord;
import org.apache.guacamole.protocol.GuacamoleConfiguration; import org.apache.guacamole.protocol.GuacamoleConfiguration;
/** /**
@@ -215,6 +216,12 @@ public class SimpleUserContext implements UserContext {
return new SimpleActivityRecordSet<ConnectionRecord>(); return new SimpleActivityRecordSet<ConnectionRecord>();
} }
@Override
public ActivityRecordSet<UserRecord> getUserHistory()
throws GuacamoleException {
return new SimpleActivityRecordSet<UserRecord>();
}
@Override @Override
public Collection<Form> getUserAttributes() { public Collection<Form> getUserAttributes() {
return Collections.<Form>emptyList(); return Collections.<Form>emptyList();