Github user ceharris commented on a diff in the pull request:
https://github.com/apache/incubator-guacamole-client/pull/184#discussion_r133659431
--- Diff:
guacamole/src/main/java/org/apache/guacamole/rest/event/ListenerService.java ---
@@ -0,0 +1,142 @@
+/*
+ * 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.rest.event;
+
+import com.google.inject.Inject;
+import org.apache.guacamole.GuacamoleException;
+import org.apache.guacamole.extension.ListenerProvider;
+import org.apache.guacamole.net.event.AuthenticationFailureEvent;
+import org.apache.guacamole.net.event.AuthenticationSuccessEvent;
+import org.apache.guacamole.net.event.TunnelCloseEvent;
+import org.apache.guacamole.net.event.TunnelConnectEvent;
+import
org.apache.guacamole.net.event.listener.AuthenticationFailureListener;
+import
org.apache.guacamole.net.event.listener.AuthenticationSuccessListener;
+import org.apache.guacamole.net.event.listener.TunnelCloseListener;
+import org.apache.guacamole.net.event.listener.TunnelConnectListener;
+
+import java.util.List;
+
+/**
+ * A service used to notify listeners registered by extensions when events
of
+ * interest occur.
+ *
+ * @author Carl Harris
+ */
+public class ListenerService implements ListenerProvider {
+
+ @Inject
+ private List<ListenerProvider> listeners;
+
+ /**
+ * Notifies all bound listeners of an authentication success event.
Listeners
+ * are allowed to veto a successful authentication by returning false
from the
+ * listener method. Regardless of whether a particular listener
rejects the
+ * successful authentication, all listeners are notified.
+ * @param e
+ * The AuthenticationSuccessEvent describing the successful
authentication
+ * that just occurred.
+ *
+ * @return
+ * false if any bound listener returns false, else true
+ *
+ * @throws GuacamoleException
+ * If any bound listener throws this exception. If a listener
throws an exception
+ * some listeners may not receive the authentication success
event notification.
+ */
+ @Override
+ public boolean authenticationSucceeded(AuthenticationSuccessEvent e)
+ throws GuacamoleException {
+ boolean result = true;
+ for (AuthenticationSuccessListener listener : listeners) {
+ result = result && listener.authenticationSucceeded(e);
+ }
+ return result;
--- End diff --
Doing so would result in some listeners not being notified when some
listener determines that an authentication should be rejected. That seems
inconsistent with the the concept of `listener`. For example, you might have
listeners that are passing messages to external systems when an authentication
success occurs and want/need to get that notification even if a some filter
decides to reject the successful authentication. I documented the behavior in
the preceding doc comment, and noted in the PR that the listener API doesn't
really discuss the expected behavior.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---