DWN-39926 : use patterns to avoid multiple compilation
parent
9325917ce2
commit
42b6aa57bd
|
@ -21,6 +21,7 @@
|
|||
package org.mitre.oauth2.web;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.mitre.oauth2.model.SystemScope;
|
||||
import org.mitre.oauth2.service.SystemScopeService;
|
||||
|
@ -57,7 +58,7 @@ public class ScopeAPI {
|
|||
public static final String URL = RootController.API_URL + "/scopes";
|
||||
|
||||
private static final String characterMatcher = "[a-zA-Z]+";
|
||||
|
||||
private static final Pattern pattern = Pattern.compile(characterMatcher);
|
||||
@Autowired
|
||||
private SystemScopeService scopeService;
|
||||
|
||||
|
@ -183,7 +184,7 @@ public class ScopeAPI {
|
|||
}
|
||||
|
||||
private void validateScope(SystemScope scope) throws ScopeException {
|
||||
if (!scope.getValue().matches(characterMatcher)) {
|
||||
if (!pattern.matcher(scope.getValue()).matches()) {
|
||||
throw new ScopeException(scope.getValue());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ package org.mitre.openid.connect.web;
|
|||
import java.security.Principal;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.mitre.openid.connect.exception.ScopeException;
|
||||
import org.mitre.openid.connect.model.WhitelistedSite;
|
||||
|
@ -59,6 +60,7 @@ public class WhitelistAPI {
|
|||
|
||||
public static final String URL = RootController.API_URL + "/whitelist";
|
||||
private static final String characterMatcher = "[a-zA-Z]+";
|
||||
private static final Pattern pattern = Pattern.compile(characterMatcher);
|
||||
|
||||
@Autowired
|
||||
private WhitelistedSiteService whitelistService;
|
||||
|
@ -182,7 +184,7 @@ public class WhitelistAPI {
|
|||
|
||||
private void validateWhitelistScopes(Set<String> scopes) throws ScopeException {
|
||||
for (String s : scopes) {
|
||||
if (!s.matches(characterMatcher)) {
|
||||
if (!pattern.matcher(s).matches()) {
|
||||
throw new ScopeException(s);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue