oltu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1813300 - in /oltu/trunk/oauth-2.0/resourceserver-filter/src/main/java/org/apache/oltu/oauth2/rsfilter: OAuthFilter.java OAuthUtils.java
Date Wed, 25 Oct 2017 14:28:10 GMT
Author: simonetripodi
Date: Wed Oct 25 14:28:10 2017
New Revision: 1813300

URL: http://svn.apache.org/viewvc?rev=1813300&view=rev
Log:
OLTU-197 - OAuthFilter looks for oauth.rs.provider-class init parameter in wrong place

Modified:
    oltu/trunk/oauth-2.0/resourceserver-filter/src/main/java/org/apache/oltu/oauth2/rsfilter/OAuthFilter.java
    oltu/trunk/oauth-2.0/resourceserver-filter/src/main/java/org/apache/oltu/oauth2/rsfilter/OAuthUtils.java

Modified: oltu/trunk/oauth-2.0/resourceserver-filter/src/main/java/org/apache/oltu/oauth2/rsfilter/OAuthFilter.java
URL: http://svn.apache.org/viewvc/oltu/trunk/oauth-2.0/resourceserver-filter/src/main/java/org/apache/oltu/oauth2/rsfilter/OAuthFilter.java?rev=1813300&r1=1813299&r2=1813300&view=diff
==============================================================================
--- oltu/trunk/oauth-2.0/resourceserver-filter/src/main/java/org/apache/oltu/oauth2/rsfilter/OAuthFilter.java
(original)
+++ oltu/trunk/oauth-2.0/resourceserver-filter/src/main/java/org/apache/oltu/oauth2/rsfilter/OAuthFilter.java
Wed Oct 25 14:28:10 2017
@@ -65,9 +65,9 @@ public class OAuthFilter implements Filt
     public void init(FilterConfig filterConfig) throws ServletException {
 
         provider = OAuthUtils
-            .initiateServletContext(filterConfig.getServletContext(), OAUTH_RS_PROVIDER_CLASS,
+            .initiateServletContext(filterConfig, OAUTH_RS_PROVIDER_CLASS,
                 OAuthRSProvider.class);
-        realm = filterConfig.getServletContext().getInitParameter(RS_REALM);
+        realm = filterConfig.getInitParameter(RS_REALM);
         if (OAuthUtils.isEmpty(realm)) {
             realm = RS_REALM_DEFAULT;
         }

Modified: oltu/trunk/oauth-2.0/resourceserver-filter/src/main/java/org/apache/oltu/oauth2/rsfilter/OAuthUtils.java
URL: http://svn.apache.org/viewvc/oltu/trunk/oauth-2.0/resourceserver-filter/src/main/java/org/apache/oltu/oauth2/rsfilter/OAuthUtils.java?rev=1813300&r1=1813299&r2=1813300&view=diff
==============================================================================
--- oltu/trunk/oauth-2.0/resourceserver-filter/src/main/java/org/apache/oltu/oauth2/rsfilter/OAuthUtils.java
(original)
+++ oltu/trunk/oauth-2.0/resourceserver-filter/src/main/java/org/apache/oltu/oauth2/rsfilter/OAuthUtils.java
Wed Oct 25 14:28:10 2017
@@ -21,6 +21,7 @@
 
 package org.apache.oltu.oauth2.rsfilter;
 
+import javax.servlet.FilterConfig;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 
@@ -31,34 +32,34 @@ import javax.servlet.ServletException;
  */
 public class OAuthUtils {
 
-    public static <T> T initiateServletContext(ServletContext context, String key,
Class<T> expectedClass)
+    public static <T> T initiateServletContext(FilterConfig config, String key, Class<T>
expectedClass)
         throws ServletException {
 
-        T provider = (T)context.getAttribute(key);
+        T provider = (T) config.getServletContext().getAttribute(key);
 
         if (provider != null) {
             return provider;
         }
 
-        provider = (T)loadObject(context, key, expectedClass);
+        provider = (T) loadObject(config, key, expectedClass);
 
         // set the provider and validator
-        context.setAttribute(key, provider);
+        config.getServletContext().setAttribute(key, provider);
 
         return provider;
     }
 
-    public static Object loadObject(ServletContext context, String classParamName, Class
expectedClass)
+    public static <T> T loadObject(FilterConfig config, String classParamName, Class<T>
expectedClass)
         throws ServletException {
 
-        Object ob = null;
+        T ob = null;
 
-        String providerClassName = context.getInitParameter(classParamName);
+        String providerClassName = config.getInitParameter(classParamName);
         if (isEmpty(providerClassName)) {
             throw new ServletException(classParamName + " context param required");
         }
         try {
-            Class<?> clazz = Class.forName(providerClassName);
+            Class<T> clazz = (Class<T>) Class.forName(providerClassName);
             if (!expectedClass.isAssignableFrom(clazz)) {
                 throw new ServletException(classParamName + " class: " + providerClassName
                     + " must be an instance of: " + expectedClass.getName());
@@ -72,12 +73,11 @@ public class OAuthUtils {
         return ob;
     }
 
-    public static Object createObjectFromClassName(Class clazz)
-        throws IllegalAccessException, InstantiationException {
+    public static <T> T createObjectFromClassName(Class<T> clazz) throws IllegalAccessException,
InstantiationException {
         return clazz.newInstance();
     }
 
     public static boolean isEmpty(String value) {
-        return value == null || "".equals(value);
+        return value == null || value.isEmpty();
     }
 }



Mime
View raw message