|
|
@ -87,18 +87,19 @@ public class PermissionTree {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public Permission getPermission(String url, String httpMethod) {
|
|
|
|
public Permission getPermission(String url, String httpMethod) {
|
|
|
|
StringTokenizer st = new StringTokenizer(url, ROOT);
|
|
|
|
StringTokenizer st = new StringTokenizer(url, ROOT);
|
|
|
|
PermissionNode tempRoot = rootNode;
|
|
|
|
PermissionNode tempRoot;
|
|
|
|
|
|
|
|
PermissionNode currentRoot = rootNode;
|
|
|
|
while (st.hasMoreTokens()) {
|
|
|
|
while (st.hasMoreTokens()) {
|
|
|
|
String currentToken = st.nextToken();
|
|
|
|
String currentToken = st.nextToken();
|
|
|
|
|
|
|
|
|
|
|
|
// returns the child node which matches with the 'currentToken' path.
|
|
|
|
// returns the child node which matches with the 'currentToken' path.
|
|
|
|
tempRoot = tempRoot.getChild(currentToken);
|
|
|
|
tempRoot = currentRoot.getChild(currentToken);
|
|
|
|
|
|
|
|
|
|
|
|
// if tempRoot is null, that means 'currentToken' is not matched with the child's path.
|
|
|
|
// if tempRoot is null, that means 'currentToken' is not matched with the child's path.
|
|
|
|
// It means that it is at a point where the request must have dynamic path variables.
|
|
|
|
// It means that it is at a point where the request must have dynamic path variables.
|
|
|
|
// Therefor it looks for '*' in the request path. ('*' denotes dynamic path variable).
|
|
|
|
// Therefor it looks for '*' in the request path. ('*' denotes dynamic path variable).
|
|
|
|
if (tempRoot == null) {
|
|
|
|
if (tempRoot == null) {
|
|
|
|
tempRoot = tempRoot.getChild(DYNAMIC_PATH_NOTATION);
|
|
|
|
tempRoot = currentRoot.getChild(DYNAMIC_PATH_NOTATION);
|
|
|
|
// if tempRoot is null, that means there is no any permission which matches with the
|
|
|
|
// if tempRoot is null, that means there is no any permission which matches with the
|
|
|
|
// given path
|
|
|
|
// given path
|
|
|
|
if (tempRoot == null) {
|
|
|
|
if (tempRoot == null) {
|
|
|
@ -108,7 +109,8 @@ public class PermissionTree {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
currentRoot = tempRoot;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return tempRoot.getPermission(httpMethod);
|
|
|
|
return currentRoot.getPermission(httpMethod);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|