develop #1
|
@ -32,14 +32,16 @@ public class FrontEndLinkURIAuthenticationSuccessHandler implements Authenticati
|
||||||
@Value("${services.provide.aai.oidc.domain}")
|
@Value("${services.provide.aai.oidc.domain}")
|
||||||
private String domain;
|
private String domain;
|
||||||
|
|
||||||
|
|
||||||
|
private static final Pattern AUTH_REGEX = Pattern.compile("^([A-Za-z0-9-_=]+)\\.([A-Za-z0-9-_=]+)\\.?([A-Za-z0-9-_.+=]*)$");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
||||||
OIDCAuthenticationToken authOIDC = (OIDCAuthenticationToken) authentication;
|
OIDCAuthenticationToken authOIDC = (OIDCAuthenticationToken) authentication;
|
||||||
request.getSession().setAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, authOIDC.getUserInfo().getEmail());
|
request.getSession().setAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, authOIDC.getUserInfo().getEmail());
|
||||||
|
|
||||||
Cookie accessToken = new Cookie("AccessToken", authOIDC.getAccessTokenValue());
|
Cookie accessToken = new Cookie("AccessToken", authOIDC.getAccessTokenValue());
|
||||||
String regex = "^([A-Za-z0-9-_=]+)\\.([A-Za-z0-9-_=]+)\\.?([A-Za-z0-9-_.+=]*)$";
|
Matcher matcher = AUTH_REGEX.matcher(authOIDC.getAccessTokenValue());
|
||||||
Matcher matcher = Pattern.compile(regex).matcher(authOIDC.getAccessTokenValue());
|
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
long exp = new JsonParser().parse(new String(Base64.getDecoder().decode(matcher.group(2)))).getAsJsonObject().get("exp").getAsLong();
|
long exp = new JsonParser().parse(new String(Base64.getDecoder().decode(matcher.group(2)))).getAsJsonObject().get("exp").getAsLong();
|
||||||
accessToken.setMaxAge((int) (exp - (new Date().getTime() / 1000)));
|
accessToken.setMaxAge((int) (exp - (new Date().getTime() / 1000)));
|
||||||
|
|
|
@ -800,7 +800,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_ALL))
|
if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_ALL))
|
||||||
return compatibilityClasses;
|
return compatibilityClasses;
|
||||||
else if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_RE3DATA)) {
|
else if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_RE3DATA)) {
|
||||||
if (entry.getKey().matches("^openaire[1-9].0_data$")) {
|
if ( ValidatorServiceImpl.OPENAIRE_DATA_REGEX.matcher(entry.getKey()).matches() ) {
|
||||||
retMap.put(entry.getKey(), entry.getValue());
|
retMap.put(entry.getKey(), entry.getValue());
|
||||||
foundData = true;
|
foundData = true;
|
||||||
}
|
}
|
||||||
|
@ -811,7 +811,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
foundData = true;
|
foundData = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (entry.getKey().matches("^openaire[1-9].0$") || entry.getKey().equals("driver"))
|
if ( ValidatorServiceImpl.OPENAIRE_OR_DRIVER_REGEX.matcher(entry.getKey()).matches() )
|
||||||
retMap.put(entry.getKey(), entry.getValue());
|
retMap.put(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import javax.annotation.PostConstruct;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,6 +69,12 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private MapJobDao crisJobs;
|
private MapJobDao crisJobs;
|
||||||
|
|
||||||
|
|
||||||
|
public static final Pattern OPENAIRE_DATA_REGEX = Pattern.compile("^openaire[1-9].0_data$");
|
||||||
|
public static final Pattern OPENAIRE_OR_DRIVER_REGEX = Pattern.compile("^(?:openaire[1-9].0|driver)$");
|
||||||
|
public static final Pattern OPENAIRE_CRIS_REGEX = Pattern.compile("^openaire[1-9].0_cris$");
|
||||||
|
public static final Pattern FAIR_REGEX = Pattern.compile(".*fair$");
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
private void loadRules(){
|
private void loadRules(){
|
||||||
logger.debug("PostConstruct method! Load rules!");
|
logger.debug("PostConstruct method! Load rules!");
|
||||||
|
@ -75,13 +82,14 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
for (RuleSet ruleSet : getValidationService().getRuleSets()) {
|
for (RuleSet ruleSet : getValidationService().getRuleSets()) {
|
||||||
if (ruleSet.getVisibility() != null && ruleSet.getVisibility().contains("development")) {
|
if (ruleSet.getVisibility() != null && ruleSet.getVisibility().contains("development")) {
|
||||||
String key = "";
|
String key = "";
|
||||||
if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0_data$"))
|
String guidelinesAcronym = ruleSet.getGuidelinesAcronym();
|
||||||
|
if ( OPENAIRE_DATA_REGEX.matcher(guidelinesAcronym).matches() )
|
||||||
key = Constants.VALIDATION_MODE_DATA;
|
key = Constants.VALIDATION_MODE_DATA;
|
||||||
else if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0$") || ruleSet.getGuidelinesAcronym().equals("driver"))
|
else if ( OPENAIRE_OR_DRIVER_REGEX.matcher(guidelinesAcronym).matches() )
|
||||||
key = Constants.VALIDATION_MODE_LITERATURE;
|
key = Constants.VALIDATION_MODE_LITERATURE;
|
||||||
else if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0_cris$"))
|
else if ( OPENAIRE_CRIS_REGEX.matcher(guidelinesAcronym).matches() )
|
||||||
key = Constants.VALIDATION_MODE_CRIS;
|
key = Constants.VALIDATION_MODE_CRIS;
|
||||||
else if (ruleSet.getGuidelinesAcronym().matches(".*fair$"))
|
else if ( FAIR_REGEX.matcher(guidelinesAcronym).matches() )
|
||||||
key = Constants.VALIDATION_MODE_FAIR;
|
key = Constants.VALIDATION_MODE_FAIR;
|
||||||
|
|
||||||
if (rulesetMap.containsKey(key))
|
if (rulesetMap.containsKey(key))
|
||||||
|
@ -143,7 +151,7 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
if (jobForValidation.getSelectedContentRules()!=null && jobForValidation.getSelectedContentRules().size() == 1 &&
|
if (jobForValidation.getSelectedContentRules()!=null && jobForValidation.getSelectedContentRules().size() == 1 &&
|
||||||
jobForValidation.getSelectedContentRules().contains(-1000)
|
jobForValidation.getSelectedContentRules().contains(-1000)
|
||||||
|| jobForValidation.getDesiredCompatibilityLevel().matches("openaire-cris_1.1")) {
|
|| jobForValidation.getDesiredCompatibilityLevel().equals("openaire-cris_1.1")) {
|
||||||
crisValidatorExecutor.submit(jobForValidation.getBaseUrl(), jobForValidation.getUserEmail());
|
crisValidatorExecutor.submit(jobForValidation.getBaseUrl(), jobForValidation.getUserEmail());
|
||||||
} else {
|
} else {
|
||||||
this.getValidationService().submitValidationJob(jobForValidation);
|
this.getValidationService().submitValidationJob(jobForValidation);
|
||||||
|
@ -197,7 +205,7 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RuleSet> getRuleSets(String mode) {
|
public List<RuleSet> getRuleSets(String mode) {
|
||||||
logger.info("Getting rulesets for mode: " + mode);
|
logger.info("Getting ruleSets for mode: " + mode);
|
||||||
return rulesetMap.get(mode);
|
return rulesetMap.get(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import java.util.regex.Pattern;
|
||||||
public class AuthoritiesMapper {
|
public class AuthoritiesMapper {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(AuthoritiesMapper.class);
|
private static final Logger logger = Logger.getLogger(AuthoritiesMapper.class);
|
||||||
private static final String ENTITLEMENT_REGEX = "urn:geant:openaire[.]eu:group:([^:]*):?(.*)?:role=member#aai[.]openaire[.]eu";
|
private static final Pattern ENTITLEMENT_REGEX = Pattern.compile("urn:geant:openaire[.]eu:group:([^:]*):?(.*)?:role=member#aai[.]openaire[.]eu");
|
||||||
|
|
||||||
private AuthoritiesMapper() {
|
private AuthoritiesMapper() {
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ public class AuthoritiesMapper {
|
||||||
List<String> roles = new ArrayList<>();
|
List<String> roles = new ArrayList<>();
|
||||||
if (entitlements != null) {
|
if (entitlements != null) {
|
||||||
for (JsonElement obj : entitlements) {
|
for (JsonElement obj : entitlements) {
|
||||||
Matcher matcher = Pattern.compile(ENTITLEMENT_REGEX).matcher(obj.getAsString());
|
Matcher matcher = ENTITLEMENT_REGEX.matcher(obj.getAsString());
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
if (matcher.group(1) != null && matcher.group(1).length() > 0) {
|
if (matcher.group(1) != null && matcher.group(1).length() > 0) {
|
||||||
|
@ -50,7 +50,7 @@ public class AuthoritiesMapper {
|
||||||
private static void entityRoles(JsonArray entitlements, Set<GrantedAuthority> authorities) {
|
private static void entityRoles(JsonArray entitlements, Set<GrantedAuthority> authorities) {
|
||||||
if (entitlements != null) {
|
if (entitlements != null) {
|
||||||
for (JsonElement obj : entitlements) {
|
for (JsonElement obj : entitlements) {
|
||||||
Matcher matcher = Pattern.compile(ENTITLEMENT_REGEX).matcher(obj.getAsString());
|
Matcher matcher = ENTITLEMENT_REGEX.matcher(obj.getAsString());
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
if (matcher.group(1) != null && matcher.group(1).length() > 0) {
|
if (matcher.group(1) != null && matcher.group(1).length() > 0) {
|
||||||
|
|
Loading…
Reference in New Issue