check on empty token added
This commit is contained in:
parent
569c61416b
commit
0c725c8fc1
|
@ -9,22 +9,25 @@ 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.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue