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:
commit
dfe6168b70
|
@ -9,23 +9,23 @@ import org.gcube.common.authorization.client.Constants;
|
||||||
import org.gcube.common.authorization.library.AuthorizationEntry;
|
import org.gcube.common.authorization.library.AuthorizationEntry;
|
||||||
import org.gcube.common.authorization.library.ClientType;
|
import org.gcube.common.authorization.library.ClientType;
|
||||||
import org.gcube.common.security.Owner;
|
import org.gcube.common.security.Owner;
|
||||||
import org.gcube.common.security.credentials.Credentials;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
public class GCubeSecret extends Secret {
|
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 String gcubeToken;
|
||||||
private Owner owner;
|
private Owner owner;
|
||||||
private String context;
|
private String context;
|
||||||
|
|
||||||
public GCubeSecret(String gcubeToken) {
|
public GCubeSecret(String gcubeToken) {
|
||||||
Objects.requireNonNull(gcubeToken);
|
if( gcubeToken == null || gcubeToken.isEmpty())
|
||||||
if(!Pattern.matches(GCubeSecret.GCUBE_TOKEN_REGEX, gcubeToken))
|
throw new RuntimeException("Invalid token: is null or empty");
|
||||||
throw new RuntimeException("The GUCBE token must comply with the regex " + GCUBE_TOKEN_REGEX);
|
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;
|
this.gcubeToken = gcubeToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue