Added utlity to get a secret from a token string

This commit is contained in:
Luca Frosini 2021-12-16 12:32:42 +01:00
parent 061159b6cd
commit 09b537567b
1 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1,17 @@
package org.gcube.common.authorization.utils.secret;
import java.util.regex.Pattern;
public class SecretUtility {
public static final String UUID_REGEX = "^([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}-[a-fA-F0-9]{8,9}){1}$";
public static Secret getSecretByTokenString(String token) {
if(Pattern.matches(UUID_REGEX, token)) {
return new GCubeSecret(token);
}else {
return new JWTSecret(token);
}
}
}