Tie together CORS filter initialization constats 12/96212/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 17 May 2021 15:48:33 +0000 (17:48 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 17 May 2021 15:48:33 +0000 (17:48 +0200)
CrossOriginFilter has well-known constants, use them to ensure
consistency of configuration properties.

Change-Id: Ie4f5021fc5b9f3b617286fe03a303ae67baf3c2c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/web/env/ShiroWebContextSecurer.java

index 2a922bf7324c79830da260856e62b2965e89a778..cb072936a871ba9cea43d23f78302a4ce9b20f57 100644 (file)
@@ -21,16 +21,15 @@ import org.opendaylight.aaa.web.WebContextSecurer;
  * @author Michael Vorburger.ch
  */
 public class ShiroWebContextSecurer implements WebContextSecurer {
-
     private final EnvironmentLoaderListener shiroEnvironmentLoaderListener;
 
-    public ShiroWebContextSecurer(EnvironmentLoaderListener shiroEnvironmentLoaderListener) {
+    public ShiroWebContextSecurer(final EnvironmentLoaderListener shiroEnvironmentLoaderListener) {
         this.shiroEnvironmentLoaderListener = shiroEnvironmentLoaderListener;
     }
 
     @Override
-    public void requireAuthentication(WebContextBuilder webContextBuilder, boolean asyncSupported,
-            String... urlPatterns) {
+    public void requireAuthentication(final WebContextBuilder webContextBuilder, final boolean asyncSupported,
+            final String... urlPatterns) {
         webContextBuilder.addListener(shiroEnvironmentLoaderListener)
 
                 // AAA filter in front of these REST web services as well as for moon endpoints
@@ -45,11 +44,10 @@ public class ShiroWebContextSecurer implements WebContextSecurer {
                         .filter(new CrossOriginFilter())
                         .addUrlPatterns(urlPatterns)
                         .asyncSupported(asyncSupported)
-                        .putInitParam("allowedOrigins", "*")
-                        .putInitParam("allowedMethods", "GET,POST,OPTIONS,DELETE,PUT,HEAD")
-                        .putInitParam("allowedHeaders", "origin, content-type, accept, authorization")
+                        .putInitParam(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, "*")
+                        .putInitParam(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET,POST,OPTIONS,DELETE,PUT,HEAD")
+                        .putInitParam(CrossOriginFilter.ALLOWED_HEADERS_PARAM,
+                            "origin, content-type, accept, authorization")
                         .build());
-
     }
-
 }