You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by "lprimak (via GitHub)" <gi...@apache.org> on 2023/04/03 04:46:38 UTC

[GitHub] [shiro] lprimak commented on a diff in pull request #824: Refactor

lprimak commented on code in PR #824:
URL: https://github.com/apache/shiro/pull/824#discussion_r1155475587


##########
web/src/main/java/org/apache/shiro/web/filter/authc/HttpMethodsExtractor.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.shiro.web.filter.authc;
+
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+
+public class HttpMethodsExtractor {
+
+    public static final String PERMISSIVE = "permissive";

Review Comment:
   Remove this, can use `AuthenticatingFilter`.PERMISSIVE



##########
web/src/main/java/org/apache/shiro/web/filter/authc/HttpMethodsExtractor.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.shiro.web.filter.authc;
+
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+
+public class HttpMethodsExtractor {
+
+    public static final String PERMISSIVE = "permissive";
+
+    /**
+     * HTTP Authorization header, equal to <code>Authorization</code>
+     */
+    protected static final String AUTHORIZATION_HEADER = "Authorization";
+
+    /**
+     * HTTP Authentication header, equal to <code>WWW-Authenticate</code>
+     */
+    protected static final String AUTHENTICATE_HEADER = "WWW-Authenticate";
+
+    public Set<String> extractHttpMethodsFromOptions(String[] options) {
+        Set<String> methods = new HashSet<String>();
+
+        if (options != null) {
+            for (String option : options) {
+                if (isHttpMethod(option)) {
+                    methods.add(option.toUpperCase(Locale.ENGLISH));
+                }
+            }
+        }
+        return methods;
+    }
+
+    private boolean isHttpMethod(String option) {

Review Comment:
   Make static



##########
web/src/main/java/org/apache/shiro/web/filter/authc/HttpMethodsExtractor.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.shiro.web.filter.authc;
+
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+
+public class HttpMethodsExtractor {
+
+    public static final String PERMISSIVE = "permissive";
+
+    /**
+     * HTTP Authorization header, equal to <code>Authorization</code>
+     */
+    protected static final String AUTHORIZATION_HEADER = "Authorization";

Review Comment:
   Remove this. Make `HttpAuthenticationFilter`.AUTHORIZATION_HEADER package-private and use that



##########
web/src/main/java/org/apache/shiro/web/filter/authc/HttpMethodsExtractor.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.shiro.web.filter.authc;
+
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+
+public class HttpMethodsExtractor {
+
+    public static final String PERMISSIVE = "permissive";
+
+    /**
+     * HTTP Authorization header, equal to <code>Authorization</code>
+     */
+    protected static final String AUTHORIZATION_HEADER = "Authorization";
+
+    /**
+     * HTTP Authentication header, equal to <code>WWW-Authenticate</code>
+     */
+    protected static final String AUTHENTICATE_HEADER = "WWW-Authenticate";
+
+    public Set<String> extractHttpMethodsFromOptions(String[] options) {

Review Comment:
   Make static



##########
web/src/main/java/org/apache/shiro/web/filter/authc/HttpMethodsExtractor.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.shiro.web.filter.authc;
+
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+
+public class HttpMethodsExtractor {
+
+    public static final String PERMISSIVE = "permissive";
+
+    /**
+     * HTTP Authorization header, equal to <code>Authorization</code>
+     */
+    protected static final String AUTHORIZATION_HEADER = "Authorization";
+
+    /**
+     * HTTP Authentication header, equal to <code>WWW-Authenticate</code>
+     */
+    protected static final String AUTHENTICATE_HEADER = "WWW-Authenticate";

Review Comment:
   Remove. Same as above



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@shiro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org