-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed error on pool account resolution in case name contains numbers
Fix for #28
- Loading branch information
1 parent
1e81cc8
commit 3dde960
Showing
4 changed files
with
57 additions
and
36 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
src/main/java/org/glite/authz/pep/obligation/dfpmap/DefaultFilenameFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (c) Members of the EGEE Collaboration. 2006-2010. | ||
* See http://www.eu-egee.org/partners/ for details on the copyright holders. | ||
* | ||
* 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. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.glite.authz.pep.obligation.dfpmap; | ||
|
||
import java.io.File; | ||
import java.io.FilenameFilter; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
public class DefaultFilenameFilter implements FilenameFilter { | ||
|
||
private final String prefix; | ||
|
||
/** | ||
* RegExp pattern used to identify pool account names. | ||
* | ||
* Contains a single group match whose value is the pool account name prefix. | ||
* | ||
*/ | ||
private final Pattern poolAccountNamePattern = | ||
Pattern.compile("^([a-zA-Z][a-zA-Z0-9._-]*?)[0-9]{3,3}$"); | ||
|
||
public DefaultFilenameFilter(String prefix) { | ||
this.prefix = prefix; | ||
} | ||
|
||
@Override | ||
public boolean accept(File dir, String name) { | ||
|
||
Matcher nameMatcher = poolAccountNamePattern.matcher(name); | ||
|
||
return nameMatcher.matches() && (prefix == null || prefix.equals(nameMatcher.group(1))); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters