Repository: incubator-guacamole-client
Updated Branches:
  refs/heads/master 48607bbe0 -> 9b5483edc


GUACAMOLE-210: Use same version of Jersey as the main Guacamole webapp.


Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/63b69ad0
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/63b69ad0
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/63b69ad0

Branch: refs/heads/master
Commit: 63b69ad0762676f6f3608cbd889f28b6c94c6c09
Parents: 1c6a603
Author: Michael Jumper <mjum...@apache.org>
Authored: Sat Jan 2 21:10:30 2016 -0800
Committer: Michael Jumper <mjum...@apache.org>
Committed: Mon Sep 25 13:06:42 2017 -0700

----------------------------------------------------------------------
 extensions/guacamole-auth-openid/pom.xml        |  39 ++++++-
 .../guacamole/auth/oauth/TokenResponse.java     | 113 +++++++++++++++++++
 2 files changed, 148 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/63b69ad0/extensions/guacamole-auth-openid/pom.xml
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-openid/pom.xml 
b/extensions/guacamole-auth-openid/pom.xml
index 9ec561c..d443cdd 100644
--- a/extensions/guacamole-auth-openid/pom.xml
+++ b/extensions/guacamole-auth-openid/pom.xml
@@ -41,12 +41,38 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.3</version>
                 <configuration>
                     <source>1.6</source>
                     <target>1.6</target>
+                    <compilerArgs>
+                        <arg>-Xlint:all</arg>
+                        <arg>-Werror</arg>
+                    </compilerArgs>
+                    <fork>true</fork>
                 </configuration>
             </plugin>
 
+            <!-- Copy dependencies prior to packaging -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <version>2.10</version>
+                <executions>
+                    <execution>
+                        <id>unpack-dependencies</id>
+                        <phase>prepare-package</phase>
+                        <goals>
+                            <goal>unpack-dependencies</goal>
+                        </goals>
+                        <configuration>
+                            <includeScope>runtime</includeScope>
+                            
<outputDirectory>${project.build.directory}/classes</outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
         </plugins>
     </build>
 
@@ -60,11 +86,16 @@
             <scope>provided</scope>
         </dependency>
 
-        <!-- Google OAuth Client API -->
+        <!-- Jersey Client -->
+        <dependency>
+            <groupId>com.sun.jersey</groupId>
+            <artifactId>jersey-client</artifactId>
+            <version>1.17.1</version>
+        </dependency>
         <dependency>
-            <groupId>com.google.oauth-client</groupId>
-            <artifactId>google-oauth-client</artifactId>
-            <version>1.21.0</version>
+            <groupId>com.sun.jersey</groupId>
+            <artifactId>jersey-json</artifactId>
+            <version>1.17.1</version>
         </dependency>
 
         <!-- Guice -->

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/63b69ad0/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/TokenResponse.java
----------------------------------------------------------------------
diff --git 
a/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/TokenResponse.java
 
b/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/TokenResponse.java
new file mode 100644
index 0000000..329fb16
--- /dev/null
+++ 
b/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/TokenResponse.java
@@ -0,0 +1,113 @@
+/*
+ * 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.auth.oauth;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import java.util.Arrays;
+import javax.servlet.http.HttpServletRequest;
+import org.glyptodon.guacamole.GuacamoleException;
+import org.apache.guacamole.auth.oauth.conf.ConfigurationService;
+import org.apache.guacamole.auth.oauth.form.OAuthCodeField;
+import org.apache.guacamole.auth.oauth.user.AuthenticatedUser;
+import org.glyptodon.guacamole.form.Field;
+import org.glyptodon.guacamole.net.auth.Credentials;
+import org.glyptodon.guacamole.net.auth.credentials.CredentialsInfo;
+import 
org.glyptodon.guacamole.net.auth.credentials.GuacamoleInvalidCredentialsException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Service providing convenience functions for the OAuth AuthenticationProvider
+ * implementation.
+ */
+public class AuthenticationProviderService {
+
+    /**
+     * Logger for this class.
+     */
+    private final Logger logger = 
LoggerFactory.getLogger(AuthenticationProviderService.class);
+
+    /**
+     * Service for retrieving OAuth configuration information.
+     */
+    @Inject
+    private ConfigurationService confService;
+
+    /**
+     * Provider for AuthenticatedUser objects.
+     */
+    @Inject
+    private Provider<AuthenticatedUser> authenticatedUserProvider;
+
+    /**
+     * Returns an AuthenticatedUser representing the user authenticated by the
+     * given credentials.
+     *
+     * @param credentials
+     *     The credentials to use for authentication.
+     *
+     * @return
+     *     An AuthenticatedUser representing the user authenticated by the
+     *     given credentials.
+     *
+     * @throws GuacamoleException
+     *     If an error occurs while authenticating the user, or if access is
+     *     denied.
+     */
+    public AuthenticatedUser authenticateUser(Credentials credentials)
+            throws GuacamoleException {
+
+        String code = null;
+
+        // Pull OAuth code from request if present
+        HttpServletRequest request = credentials.getRequest();
+        if (request != null)
+            code = request.getParameter(OAuthCodeField.PARAMETER_NAME);
+
+        // TODO: Actually complete authentication using received code
+        if (code != null) {
+            AuthenticatedUser authenticatedUser = 
authenticatedUserProvider.get();
+            authenticatedUser.init("STUB", credentials);
+            return authenticatedUser;
+        }
+
+        // Request auth code
+        throw new GuacamoleInvalidCredentialsException("Invalid login.",
+            new CredentialsInfo(Arrays.asList(new Field[] {
+
+                // Normal username/password fields
+                CredentialsInfo.USERNAME,
+                CredentialsInfo.PASSWORD,
+
+                // OAuth-specific code (will be rendered as an appropriate
+                // "Log in with..." button
+                new OAuthCodeField(
+                    confService.getAuthorizationEndpoint(),
+                    confService.getClientID(),
+                    confService.getRedirectURI()
+                )
+
+            }))
+        );
+
+    }
+
+}

Reply via email to