userWithSecret = authenticate(domain, authRequest.passwordCredentials.username,
authRequest.passwordCredentials.password);
} else if (authRequest.tokenCredentials != null) {
String tokenId = authRequest.tokenCredentials.id;
TokenInfo tokenInfo = findTokenInfo(tokenId);
if (tokenInfo == null) {
return null;
}
userWithSecret = checkSecret(tokenInfo);
domain = authRepository.getDomains().find(tokenInfo.getDomainId());
if (domain == null) {
throw new IllegalStateException();
}
if (projectSpec.projectId == 0 && projectSpec.projectName == null) {
log.info("Token login with scope: {}", tokenInfo.getTokenScope());
if (tokenInfo.getTokenScope() == TokenScope.Project) {
projectSpec.projectId = tokenInfo.getProjectId();
log.info("Set projectId to: {}", projectSpec.projectId);
}
}
// This is weird, but valid with V3's deprecation of unscoped
// tokens...