From fcefa7a7c7a0454994f0e184b70a2b4d631f12ec Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 12 Aug 2016 12:51:53 -0700 Subject: [PATCH] GUACAMOLE-78: Define a standard identifier for anonymous users. --- .../guacamole/net/auth/AuthenticatedUser.java | 6 ++++++ .../app/auth/service/authenticationService.js | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AuthenticatedUser.java b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AuthenticatedUser.java index 514e65a52..b121abff4 100644 --- a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AuthenticatedUser.java +++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AuthenticatedUser.java @@ -28,6 +28,12 @@ package org.apache.guacamole.net.auth; */ public interface AuthenticatedUser extends Identifiable { + /** + * The identifier reserved for representing a user that has authenticated + * anonymously. + */ + public static final String ANONYMOUS_IDENTIFIER = ""; + /** * Returns the AuthenticationProvider that authenticated this user. * diff --git a/guacamole/src/main/webapp/app/auth/service/authenticationService.js b/guacamole/src/main/webapp/app/auth/service/authenticationService.js index 2bd6a9f9c..339a3e1cf 100644 --- a/guacamole/src/main/webapp/app/auth/service/authenticationService.js +++ b/guacamole/src/main/webapp/app/auth/service/authenticationService.js @@ -256,6 +256,19 @@ angular.module('auth').factory('authenticationService', ['$injector', }; + /** + * Returns whether the current user has authenticated anonymously. An + * anonymous user is denoted by the identifier reserved by the Guacamole + * extension API for anonymous users (the empty string). + * + * @returns {Boolean} + * true if the current user has authenticated anonymously, false + * otherwise. + */ + service.isAnonymous = function isAnonymous() { + return service.getCurrentUsername() === ''; + }; + /** * Returns the username of the current user. If the current user is not * logged in, this value may not be valid.