-
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 2a6a823
Showing
2 changed files
with
38 additions
and
32 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
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,33 @@ | ||
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