chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1553188 - in /chemistry/opencmis/trunk: chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/ chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/o...
Date Mon, 23 Dec 2013 19:17:32 GMT
Author: fmui
Date: Mon Dec 23 19:17:32 2013
New Revision: 1553188

URL: http://svn.apache.org/r1553188
Log:
added simple OAuth 2.0 breaker token support to standard authentication provider

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/AbstractAuthenticationProvider.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/StandardAuthenticationProvider.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/AbstractAuthenticationProvider.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/AbstractAuthenticationProvider.java?rev=1553188&r1=1553187&r2=1553188&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/AbstractAuthenticationProvider.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/AbstractAuthenticationProvider.java
Mon Dec 23 19:17:32 2013
@@ -77,7 +77,7 @@ public abstract class AbstractAuthentica
     /**
      * Gets the user name from the session.
      * 
-     * @return the user name or <code>null</code> if the user name is not set
+     * @return the user name or {@code null} if the user name is not set
      */
     protected String getUser() {
         Object userObject = getSession().get(SessionParameter.USER);
@@ -91,7 +91,7 @@ public abstract class AbstractAuthentica
     /**
      * Gets the password from the session.
      * 
-     * @return the password or <code>null</code> if the password is not set
+     * @return the password or {@code null} if the password is not set
      */
     protected String getPassword() {
         Object passwordObject = getSession().get(SessionParameter.PASSWORD);
@@ -103,10 +103,23 @@ public abstract class AbstractAuthentica
     }
 
     /**
+     * Gets the bearer token from the session.
+     * 
+     * @return the bearer token or {@code null} if the token is not set
+     */
+    protected String getBearerToken() {
+        Object tokenObject = getSession().get(SessionParameter.BREARER_TOKEN);
+        if (tokenObject instanceof String) {
+            return (String) tokenObject;
+        }
+
+        return null;
+    }
+
+    /**
      * Gets the proxy user name from the session.
      * 
-     * @return the proxy user name or <code>null</code> if the user name is not
-     *         set
+     * @return the proxy user name or {@code null} if the user name is not set
      */
     protected String getProxyUser() {
         Object userObject = getSession().get(SessionParameter.PROXY_USER);
@@ -120,8 +133,7 @@ public abstract class AbstractAuthentica
     /**
      * Gets the proxy password from the session.
      * 
-     * @return the proxy password or <code>null</code> if the password is not
-     *         set
+     * @return the proxy password or {@code null} if the password is not set
      */
     protected String getProxyPassword() {
         Object passwordObject = getSession().get(SessionParameter.PROXY_PASSWORD);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/StandardAuthenticationProvider.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/StandardAuthenticationProvider.java?rev=1553188&r1=1553187&r2=1553188&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/StandardAuthenticationProvider.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/StandardAuthenticationProvider.java
Mon Dec 23 19:17:32 2013
@@ -72,6 +72,18 @@ public class StandardAuthenticationProvi
             }
         }
 
+        boolean sendBearerToken = getSendBearerToken();
+
+        // send bearer token
+        if (sendBearerToken) {
+            String token = getBearerToken();
+
+            // if no token is set, don't set bearer header
+            if (token != null) {
+                fixedHeaders.put("Authorization", Collections.singletonList("Bearer " + token));
+            }
+        }
+
         // proxy authentication
         if (getProxyUser() != null) {
             // get proxy user and password
@@ -230,6 +242,13 @@ public class StandardAuthenticationProvi
     }
 
     /**
+     * Returns if an OAuth Bearer token header should be sent. (All bindings.)
+     */
+    protected boolean getSendBearerToken() {
+        return isTrue(SessionParameter.AUTH_OAUTH_BEARER);
+    }
+
+    /**
      * Returns if a UsernameToken should be sent. (Web Services binding only.)
      */
     protected boolean getSendUsernameToken() {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java?rev=1553188&r1=1553187&r2=1553188&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java
Mon Dec 23 19:17:32 2013
@@ -500,6 +500,7 @@ public final class SessionParameter {
     // ---- general parameter ----
     public static final String USER = "org.apache.chemistry.opencmis.user";
     public static final String PASSWORD = "org.apache.chemistry.opencmis.password";
+    public static final String BREARER_TOKEN = "org.apache.chemistry.opencmis.oauth.brearertoken";
 
     // --- binding parameter ----
     /** Predefined binding types (see {@code BindingType}). */
@@ -562,6 +563,12 @@ public final class SessionParameter {
     public static final String AUTH_HTTP_BASIC = "org.apache.chemistry.opencmis.binding.auth.http.basic";
 
     /**
+     * Toggle for OAuth Bearer token authentication. Evaluated by the standard
+     * authentication provider.
+     */
+    public static final String AUTH_OAUTH_BEARER = "org.apache.chemistry.opencmis.binding.auth.http.oauth.bearer";
+
+    /**
      * Toggle for WS-Security UsernameToken authentication. Evaluated by the
      * standard authentication provider.
      */



Mime
View raw message