X-Git-Url: https://gerrit.onap.org/r/gitweb?p=dmaap%2Fdatarouter.git;a=blobdiff_plain;f=datarouter-prov%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdatarouter%2Fauthz%2Fimpl%2FAuthzResource.java;h=c248468fd6225044cfc22997ec0756bc4a289e9e;hp=2e957939af6c39c824fbbfaffd0238b59219f37c;hb=00cc27b0fa1346435c7685300286f1adc98b69fb;hpb=e4b20cc6f7c31f48ddd0de5bcd054b09a35cd510
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/AuthzResource.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/AuthzResource.java
index 2e957939..c248468f 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/AuthzResource.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/AuthzResource.java
@@ -7,9 +7,9 @@
* * Licensed 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.
@@ -30,7 +30,6 @@ import java.util.regex.Pattern;
/** Internal representation of an authorization resource (the entity to which access is being requested). Consists
* of a type and an identifier. The constructor takes the request URI from an HTTP request and checks it against
* patterns for the the different resource types. In DR R1, there are four resource types:
- *
* - the feeds collection resource, the target of POST requests to create a new feed and GET requests to list
* the existing feeds. This is the root resource for the DR provisioning system, and it has no explicit id.
*
@@ -44,57 +43,57 @@ import java.util.regex.Pattern;
* - a subscription resource, the target of GET, PUT, and DELETE requests used to manage an existing subscription.
* Each subscription has a unique subscription ID.
*
- *
+ *
* @author J. F. Lucas
*
*/
public class AuthzResource {
- private ResourceType type = null;
- private String id = "";
+ private ResourceType type = null;
+ private String id = "";
+
+ /* Construct an AuthzResource by matching a request URI against the various patterns */
+ AuthzResource(String requestUri) {
+ if (requestUri != null) {
+ for (ResourceType t : ResourceType.values()) {
+ Matcher m = t.getPattern().matcher(requestUri);
+ if (m.find(0)) {
+ this.type = t;
+ if (m.group("id") != null) {
+ this.id = m.group("id");
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ public ResourceType getType() {
+ return this.type;
+ }
+
+ public String getId() {
+ return this.id;
+ }
+
+ /* Enumeration that helps turn a request URI into something more useful for
+ * authorization purposes by given a type name and a pattern for determining if the URI
+ * represents that resource type.
+ * Highly dependent on the URL scheme, could be parameterized.
+ */
+ public enum ResourceType {
+ FEEDS_COLLECTION("((://[^/]+/)|(^/))(?)$"),
+ SUBS_COLLECTION("((://[^/]+/)|(^/{0,1}))subscribe/(?[^/]+)$"),
+ FEED("((://[^/]+/)|(^/{0,1}))feed/(?[^/]+)$"),
+ SUB("((://[^/]+/)|(^/{0,1}))subs/(?[^/]+)$");
+
+ private Pattern uriPattern;
+
+ ResourceType(String patternString) {
+ this.uriPattern = Pattern.compile(patternString);
+ }
- /* Construct an AuthzResource by matching a request URI against the various patterns */
- public AuthzResource(String rURI) {
- if (rURI != null) {
- for (ResourceType t : ResourceType.values()) {
- Matcher m = t.getPattern().matcher(rURI);
- if (m.find(0)) {
- this.type = t;
- if (m.group("id") != null) {
- this.id = m.group("id");
- }
- break;
- }
- }
- }
- }
-
- public ResourceType getType() {
- return this.type;
- }
-
- public String getId() {
- return this.id;
- }
-
- /* Enumeration that helps turn a request URI into something more useful for
- * authorization purposes by given a type name and a pattern for determining if the URI
- * represents that resource type.
- * Highly dependent on the URL scheme, could be parameterized.
- */
- public enum ResourceType {
- FEEDS_COLLECTION("((://[^/]+/)|(^/))(?)$"),
- SUBS_COLLECTION ("((://[^/]+/)|(^/{0,1}))subscribe/(?[^/]+)$"),
- FEED("((://[^/]+/)|(^/{0,1}))feed/(?[^/]+)$"),
- SUB("((://[^/]+/)|(^/{0,1}))subs/(?[^/]+)$");
-
- private Pattern uriPattern;
-
- private ResourceType(String patternString) {
- this.uriPattern = Pattern.compile(patternString);
- }
-
- Pattern getPattern() {
- return this.uriPattern;
- }
- }
+ Pattern getPattern() {
+ return this.uriPattern;
+ }
+ }
}