X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=datarouter-prov%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdatarouter%2Fauthz%2Fimpl%2FAuthzResource.java;fp=datarouter-prov%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdatarouter%2Fauthz%2Fimpl%2FAuthzResource.java;h=0357fa74b34af54521f66b2bf798177f4dbda853;hb=4261823d84c2b911b68cdf4cb4dc3be429ebe285;hp=2e957939af6c39c824fbbfaffd0238b59219f37c;hpb=13639e1b05d8c8b5b1e9efd543573834501aefaa;p=dmaap%2Fdatarouter.git
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..0357fa74 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.
@@ -44,57 +44,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 */
+ 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);
+ }
- /* 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;
+ }
+ }
}