You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2017/09/27 02:17:54 UTC

[02/29] incubator-guacamole-client git commit: GUACAMOLE-210: Move classes to reasonable packages.

GUACAMOLE-210: Move classes to reasonable packages.


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/1c6a603a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/1c6a603a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/1c6a603a

Branch: refs/heads/master
Commit: 1c6a603a08c9e291205c10e2a38a2e4e53533e24
Parents: 77e714b
Author: Michael Jumper <mj...@apache.org>
Authored: Sat Jan 2 00:43:18 2016 -0800
Committer: Michael Jumper <mj...@apache.org>
Committed: Mon Sep 25 13:06:42 2017 -0700

----------------------------------------------------------------------
 .../oauth/AuthenticationProviderService.java    |   2 +
 .../auth/oauth/ConfigurationService.java        | 107 -------------------
 .../OAuthAuthenticationProviderModule.java      |   1 +
 .../guacamole/auth/oauth/OAuthCodeField.java    |  97 -----------------
 .../auth/oauth/OAuthGuacamoleProperties.java    |  86 ---------------
 .../auth/oauth/conf/ConfigurationService.java   | 107 +++++++++++++++++++
 .../oauth/conf/OAuthGuacamoleProperties.java    |  86 +++++++++++++++
 .../auth/oauth/form/OAuthCodeField.java         |  97 +++++++++++++++++
 8 files changed, 293 insertions(+), 290 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/1c6a603a/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/AuthenticationProviderService.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/AuthenticationProviderService.java b/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/AuthenticationProviderService.java
index a183889..a1b9c46 100644
--- a/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/AuthenticationProviderService.java
+++ b/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/AuthenticationProviderService.java
@@ -24,6 +24,8 @@ import com.google.inject.Provider;
 import java.util.Arrays;
 import javax.servlet.http.HttpServletRequest;
 import org.apache.guacamole.auth.oauth.user.AuthenticatedUser;
+import org.apache.guacamole.auth.oauth.conf.ConfigurationService;
+import org.apache.guacamole.auth.oauth.form.OAuthCodeField;
 import org.glyptodon.guacamole.GuacamoleException;
 import org.glyptodon.guacamole.form.Field;
 import org.glyptodon.guacamole.net.auth.Credentials;

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/1c6a603a/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/ConfigurationService.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/ConfigurationService.java b/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/ConfigurationService.java
deleted file mode 100644
index d27b075..0000000
--- a/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/ConfigurationService.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * 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 org.glyptodon.guacamole.GuacamoleException;
-import org.glyptodon.guacamole.environment.Environment;
-
-/**
- * Service for retrieving configuration information regarding the OAuth service.
- */
-public class ConfigurationService {
-
-    /**
-     * The Guacamole server environment.
-     */
-    @Inject
-    private Environment environment;
-
-    /**
-     * Returns the authorization endpoint (URI) of the OAuth service as
-     * configured with guacamole.properties.
-     *
-     * @return
-     *     The authorization endpoint of the OAuth service, as configured with
-     *     guacamole.properties.
-     *
-     * @throws GuacamoleException
-     *     If guacamole.properties cannot be parsed, or if the authorization
-     *     endpoint property is missing.
-     */
-    public String getAuthorizationEndpoint() throws GuacamoleException {
-        return environment.getRequiredProperty(OAuthGuacamoleProperties.OAUTH_AUTHORIZATION_ENDPOINT);
-    }
-
-    /**
-     * Returns the OAuth client ID which should be submitted to the OAuth
-     * service when necessary, as configured with guacamole.properties. This
-     * value is typically provided by the OAuth service when OAuth credentials
-     * are generated for your application.
-     *
-     * @return
-     *     The client ID to use when communicating with the OAuth service,
-     *     as configured with guacamole.properties.
-     *
-     * @throws GuacamoleException
-     *     If guacamole.properties cannot be parsed, or if the client ID
-     *     property is missing.
-     */
-    public String getClientID() throws GuacamoleException {
-        return environment.getRequiredProperty(OAuthGuacamoleProperties.OAUTH_CLIENT_ID);
-    }
-
-    /**
-     * Returns the OAuth client secret which should be submitted to the OAuth
-     * service when necessary, as configured with guacamole.properties. This
-     * value is typically provided by the OAuth service when OAuth credentials
-     * are generated for your application.
-     *
-     * @return
-     *     The client secret to use when communicating with the OAuth service,
-     *     as configured with guacamole.properties.
-     *
-     * @throws GuacamoleException
-     *     If guacamole.properties cannot be parsed, or if the client secret
-     *     property is missing.
-     */
-    public String getClientSecret() throws GuacamoleException {
-        return environment.getRequiredProperty(OAuthGuacamoleProperties.OAUTH_CLIENT_SECRET);
-    }
-
-    /**
-     * Returns the URI that the OAuth service should redirect to after
-     * the authentication process is complete, as configured with
-     * guacamole.properties. This must be the full URL that a user would enter
-     * into their browser to access Guacamole.
-     *
-     * @return
-     *     The client secret to use when communicating with the OAuth service,
-     *     as configured with guacamole.properties.
-     *
-     * @throws GuacamoleException
-     *     If guacamole.properties cannot be parsed, or if the client secret
-     *     property is missing.
-     */
-    public String getRedirectURI() throws GuacamoleException {
-        return environment.getRequiredProperty(OAuthGuacamoleProperties.OAUTH_REDIRECT_URI);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/1c6a603a/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/OAuthAuthenticationProviderModule.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/OAuthAuthenticationProviderModule.java b/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/OAuthAuthenticationProviderModule.java
index 66860d1..e31c945 100644
--- a/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/OAuthAuthenticationProviderModule.java
+++ b/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/OAuthAuthenticationProviderModule.java
@@ -20,6 +20,7 @@
 package org.apache.guacamole.auth.oauth;
 
 import com.google.inject.AbstractModule;
+import org.apache.guacamole.auth.oauth.conf.ConfigurationService;
 import org.glyptodon.guacamole.GuacamoleException;
 import org.glyptodon.guacamole.environment.Environment;
 import org.glyptodon.guacamole.environment.LocalEnvironment;

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/1c6a603a/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/OAuthCodeField.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/OAuthCodeField.java b/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/OAuthCodeField.java
deleted file mode 100644
index 35ae5eb..0000000
--- a/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/OAuthCodeField.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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 java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import org.glyptodon.guacamole.form.Field;
-
-/**
- * Field definition which represents the code returned by an OAuth service.
- * Within the user interface, this will be rendered as an appropriate "Log in
- * with ..." button which links to the OAuth service.
- */
-public class OAuthCodeField extends Field {
-
-    /**
-     * The standard HTTP parameter which will be included within the URL by all
-     * OAuth services upon successful authentication and redirect.
-     */
-    public static final String PARAMETER_NAME = "code";
-
-    /**
-     * The full URI which the field should link to.
-     */
-    private final String authorizationURI;
-
-    /**
-     * Creates a new OAuth "code" field which links to the given OAuth service
-     * using the provided client ID. Successful authentication at the OAuth
-     * service will result in the client being redirected to the specified
-     * redirect URI. The OAuth code will be embedded in the query parameters of
-     * that URI.
-     *
-     * @param authorizationEndpoint
-     *     The full URL of the endpoint accepting OAuth authentication
-     *     requests.
-     *
-     * @param clientID
-     *     The ID of the OAuth client. This is normally determined ahead of
-     *     time by the OAuth service through some manual credential request
-     *     procedure.
-     *
-     * @param redirectURI
-     *     The URI that the OAuth service should redirect to upon successful
-     *     authentication.
-     */
-    public OAuthCodeField(String authorizationEndpoint, String clientID,
-            String redirectURI) {
-
-        // Init base field properties
-        super(PARAMETER_NAME, "GUAC_OAUTH_CODE");
-
-        // Build authorization URI from given values
-        try {
-            this.authorizationURI = authorizationEndpoint
-                    + "?scope=openid%20email%20profile"
-                    + "&response_type=code"
-                    + "&client_id=" + URLEncoder.encode(clientID, "UTF-8")
-                    + "&redirect_uri=" + URLEncoder.encode(redirectURI, "UTF-8");
-        }
-
-        // Java is required to provide UTF-8 support
-        catch (UnsupportedEncodingException e) {
-            throw new UnsupportedOperationException("Unexpected lack of UTF-8 support.", e);
-        }
-
-    }
-
-    /**
-     * Returns the full URI that this field should link to when a new code
-     * needs to be obtained from the OAuth service.
-     *
-     * @return
-     *     The full URI that this field should link to.
-     */
-    public String getAuthorizationURI() {
-        return authorizationURI;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/1c6a603a/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/OAuthGuacamoleProperties.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/OAuthGuacamoleProperties.java b/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/OAuthGuacamoleProperties.java
deleted file mode 100644
index bb1e4fd..0000000
--- a/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/OAuthGuacamoleProperties.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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 org.glyptodon.guacamole.properties.StringGuacamoleProperty;
-
-/**
- * Provides properties required for use of the OAuth authentication provider.
- * These properties will be read from guacamole.properties when the OAuth
- * authentication provider is used.
- */
-public class OAuthGuacamoleProperties {
-
-    /**
-     * This class should not be instantiated.
-     */
-    private OAuthGuacamoleProperties() {}
-
-    /**
-     * The authorization endpoint (URI) of the OAuth service.
-     */
-    public static final StringGuacamoleProperty OAUTH_AUTHORIZATION_ENDPOINT =
-            new StringGuacamoleProperty() {
-
-        @Override
-        public String getName() { return "oauth-authorization-endpoint"; }
-
-    };
-
-    /**
-     * OAuth client ID which should be submitted to the OAuth service when
-     * necessary. This value is typically provided by the OAuth service when
-     * OAuth credentials are generated for your application.
-     */
-    public static final StringGuacamoleProperty OAUTH_CLIENT_ID =
-            new StringGuacamoleProperty() {
-
-        @Override
-        public String getName() { return "oauth-client-id"; }
-
-    };
-
-    /**
-     * OAuth client secret which should be submitted to the OAuth service when
-     * necessary. This value is typically provided by the OAuth service when
-     * OAuth credentials are generated for your application.
-     */
-    public static final StringGuacamoleProperty OAUTH_CLIENT_SECRET =
-            new StringGuacamoleProperty() {
-
-        @Override
-        public String getName() { return "oauth-client-secret"; }
-
-    };
-
-    /**
-     * The URI that the OAuth service should redirect to after the
-     * authentication process is complete. This must be the full URL that a
-     * user would enter into their browser to access Guacamole.
-     */
-    public static final StringGuacamoleProperty OAUTH_REDIRECT_URI =
-            new StringGuacamoleProperty() {
-
-        @Override
-        public String getName() { return "oauth-redirect-uri"; }
-
-    };
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/1c6a603a/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/conf/ConfigurationService.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/conf/ConfigurationService.java b/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/conf/ConfigurationService.java
new file mode 100644
index 0000000..f987218
--- /dev/null
+++ b/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/conf/ConfigurationService.java
@@ -0,0 +1,107 @@
+/*
+ * 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.conf;
+
+import com.google.inject.Inject;
+import org.glyptodon.guacamole.GuacamoleException;
+import org.glyptodon.guacamole.environment.Environment;
+
+/**
+ * Service for retrieving configuration information regarding the OAuth service.
+ */
+public class ConfigurationService {
+
+    /**
+     * The Guacamole server environment.
+     */
+    @Inject
+    private Environment environment;
+
+    /**
+     * Returns the authorization endpoint (URI) of the OAuth service as
+     * configured with guacamole.properties.
+     *
+     * @return
+     *     The authorization endpoint of the OAuth service, as configured with
+     *     guacamole.properties.
+     *
+     * @throws GuacamoleException
+     *     If guacamole.properties cannot be parsed, or if the authorization
+     *     endpoint property is missing.
+     */
+    public String getAuthorizationEndpoint() throws GuacamoleException {
+        return environment.getRequiredProperty(OAuthGuacamoleProperties.OAUTH_AUTHORIZATION_ENDPOINT);
+    }
+
+    /**
+     * Returns the OAuth client ID which should be submitted to the OAuth
+     * service when necessary, as configured with guacamole.properties. This
+     * value is typically provided by the OAuth service when OAuth credentials
+     * are generated for your application.
+     *
+     * @return
+     *     The client ID to use when communicating with the OAuth service,
+     *     as configured with guacamole.properties.
+     *
+     * @throws GuacamoleException
+     *     If guacamole.properties cannot be parsed, or if the client ID
+     *     property is missing.
+     */
+    public String getClientID() throws GuacamoleException {
+        return environment.getRequiredProperty(OAuthGuacamoleProperties.OAUTH_CLIENT_ID);
+    }
+
+    /**
+     * Returns the OAuth client secret which should be submitted to the OAuth
+     * service when necessary, as configured with guacamole.properties. This
+     * value is typically provided by the OAuth service when OAuth credentials
+     * are generated for your application.
+     *
+     * @return
+     *     The client secret to use when communicating with the OAuth service,
+     *     as configured with guacamole.properties.
+     *
+     * @throws GuacamoleException
+     *     If guacamole.properties cannot be parsed, or if the client secret
+     *     property is missing.
+     */
+    public String getClientSecret() throws GuacamoleException {
+        return environment.getRequiredProperty(OAuthGuacamoleProperties.OAUTH_CLIENT_SECRET);
+    }
+
+    /**
+     * Returns the URI that the OAuth service should redirect to after
+     * the authentication process is complete, as configured with
+     * guacamole.properties. This must be the full URL that a user would enter
+     * into their browser to access Guacamole.
+     *
+     * @return
+     *     The client secret to use when communicating with the OAuth service,
+     *     as configured with guacamole.properties.
+     *
+     * @throws GuacamoleException
+     *     If guacamole.properties cannot be parsed, or if the client secret
+     *     property is missing.
+     */
+    public String getRedirectURI() throws GuacamoleException {
+        return environment.getRequiredProperty(OAuthGuacamoleProperties.OAUTH_REDIRECT_URI);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/1c6a603a/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/conf/OAuthGuacamoleProperties.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/conf/OAuthGuacamoleProperties.java b/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/conf/OAuthGuacamoleProperties.java
new file mode 100644
index 0000000..2098d45
--- /dev/null
+++ b/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/conf/OAuthGuacamoleProperties.java
@@ -0,0 +1,86 @@
+/*
+ * 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.conf;
+
+import org.glyptodon.guacamole.properties.StringGuacamoleProperty;
+
+/**
+ * Provides properties required for use of the OAuth authentication provider.
+ * These properties will be read from guacamole.properties when the OAuth
+ * authentication provider is used.
+ */
+public class OAuthGuacamoleProperties {
+
+    /**
+     * This class should not be instantiated.
+     */
+    private OAuthGuacamoleProperties() {}
+
+    /**
+     * The authorization endpoint (URI) of the OAuth service.
+     */
+    public static final StringGuacamoleProperty OAUTH_AUTHORIZATION_ENDPOINT =
+            new StringGuacamoleProperty() {
+
+        @Override
+        public String getName() { return "oauth-authorization-endpoint"; }
+
+    };
+
+    /**
+     * OAuth client ID which should be submitted to the OAuth service when
+     * necessary. This value is typically provided by the OAuth service when
+     * OAuth credentials are generated for your application.
+     */
+    public static final StringGuacamoleProperty OAUTH_CLIENT_ID =
+            new StringGuacamoleProperty() {
+
+        @Override
+        public String getName() { return "oauth-client-id"; }
+
+    };
+
+    /**
+     * OAuth client secret which should be submitted to the OAuth service when
+     * necessary. This value is typically provided by the OAuth service when
+     * OAuth credentials are generated for your application.
+     */
+    public static final StringGuacamoleProperty OAUTH_CLIENT_SECRET =
+            new StringGuacamoleProperty() {
+
+        @Override
+        public String getName() { return "oauth-client-secret"; }
+
+    };
+
+    /**
+     * The URI that the OAuth service should redirect to after the
+     * authentication process is complete. This must be the full URL that a
+     * user would enter into their browser to access Guacamole.
+     */
+    public static final StringGuacamoleProperty OAUTH_REDIRECT_URI =
+            new StringGuacamoleProperty() {
+
+        @Override
+        public String getName() { return "oauth-redirect-uri"; }
+
+    };
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/1c6a603a/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/form/OAuthCodeField.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/form/OAuthCodeField.java b/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/form/OAuthCodeField.java
new file mode 100644
index 0000000..9b0764a
--- /dev/null
+++ b/extensions/guacamole-auth-openid/src/main/java/org/apache/guacamole/auth/oauth/form/OAuthCodeField.java
@@ -0,0 +1,97 @@
+/*
+ * 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.form;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import org.glyptodon.guacamole.form.Field;
+
+/**
+ * Field definition which represents the code returned by an OAuth service.
+ * Within the user interface, this will be rendered as an appropriate "Log in
+ * with ..." button which links to the OAuth service.
+ */
+public class OAuthCodeField extends Field {
+
+    /**
+     * The standard HTTP parameter which will be included within the URL by all
+     * OAuth services upon successful authentication and redirect.
+     */
+    public static final String PARAMETER_NAME = "code";
+
+    /**
+     * The full URI which the field should link to.
+     */
+    private final String authorizationURI;
+
+    /**
+     * Creates a new OAuth "code" field which links to the given OAuth service
+     * using the provided client ID. Successful authentication at the OAuth
+     * service will result in the client being redirected to the specified
+     * redirect URI. The OAuth code will be embedded in the query parameters of
+     * that URI.
+     *
+     * @param authorizationEndpoint
+     *     The full URL of the endpoint accepting OAuth authentication
+     *     requests.
+     *
+     * @param clientID
+     *     The ID of the OAuth client. This is normally determined ahead of
+     *     time by the OAuth service through some manual credential request
+     *     procedure.
+     *
+     * @param redirectURI
+     *     The URI that the OAuth service should redirect to upon successful
+     *     authentication.
+     */
+    public OAuthCodeField(String authorizationEndpoint, String clientID,
+            String redirectURI) {
+
+        // Init base field properties
+        super(PARAMETER_NAME, "GUAC_OAUTH_CODE");
+
+        // Build authorization URI from given values
+        try {
+            this.authorizationURI = authorizationEndpoint
+                    + "?scope=openid%20email%20profile"
+                    + "&response_type=code"
+                    + "&client_id=" + URLEncoder.encode(clientID, "UTF-8")
+                    + "&redirect_uri=" + URLEncoder.encode(redirectURI, "UTF-8");
+        }
+
+        // Java is required to provide UTF-8 support
+        catch (UnsupportedEncodingException e) {
+            throw new UnsupportedOperationException("Unexpected lack of UTF-8 support.", e);
+        }
+
+    }
+
+    /**
+     * Returns the full URI that this field should link to when a new code
+     * needs to be obtained from the OAuth service.
+     *
+     * @return
+     *     The full URI that this field should link to.
+     */
+    public String getAuthorizationURI() {
+        return authorizationURI;
+    }
+
+}