common-security/src/main/java/org/gcube/common/security/secrets/SecretUtility.java

23 lines
539 B
Java

package org.gcube.common.security.secrets;
import java.util.regex.Pattern;
import org.gcube.common.security.secrets.Secret;
/**
* @author Luca Frosini (ISTI - CNR)
*/
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);
}
}
}