Merge branch 'master' of

https://code-repo.d4science.org/gCubeSystem/gcube-secrets.git

Conflicts:
	src/main/java/org/gcube/common/security/secrets/GCubeSecret.java
This commit is contained in:
Lucio Lelii 2022-11-11 09:30:36 +01:00
commit dfe6168b70
1 changed files with 5 additions and 5 deletions

View File

@ -9,23 +9,23 @@ import org.gcube.common.authorization.client.Constants;
import org.gcube.common.authorization.library.AuthorizationEntry;
import org.gcube.common.authorization.library.ClientType;
import org.gcube.common.security.Owner;
import org.gcube.common.security.credentials.Credentials;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class GCubeSecret extends Secret {
public static final String GCUBE_TOKEN_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 final String GCUBE_TOKEN_REGEX = "([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(-[0-9]+)?";
private String gcubeToken;
private Owner owner;
private String context;
public GCubeSecret(String gcubeToken) {
Objects.requireNonNull(gcubeToken);
if(!Pattern.matches(GCubeSecret.GCUBE_TOKEN_REGEX, gcubeToken))
throw new RuntimeException("The GUCBE token must comply with the regex " + GCUBE_TOKEN_REGEX);
if( gcubeToken == null || gcubeToken.isEmpty())
throw new RuntimeException("Invalid token: is null or empty");
if(!Pattern.matches(GCUBE_TOKEN_REGEX, gcubeToken))
throw new RuntimeException("Invalid token: the gCube token must comply with the regex " + GCUBE_TOKEN_REGEX);
this.gcubeToken = gcubeToken;
}