85276: Store and retrieve the Authentication method in the JWT

This commit is contained in:
Yana De Pauw
2021-12-01 15:33:13 +01:00
parent dcfa74a2c3
commit 16e704a285
14 changed files with 200 additions and 4 deletions

View File

@@ -128,6 +128,8 @@ public class X509Authentication implements AuthenticationMethod {
protected ConfigurationService configurationService =
DSpaceServicesFactory.getInstance().getConfigurationService();
private static final String X509_AUTHENTICATED = "x509.authenticated";
/**
* Initialization: Set caPublicKey and/or keystore. This loads the
@@ -544,6 +546,7 @@ public class X509Authentication implements AuthenticationMethod {
context.dispatchEvents();
context.restoreAuthSystemState();
context.setCurrentUser(eperson);
request.getSession().setAttribute(X509_AUTHENTICATED, true);
setSpecialGroupsFlag(request, email);
return SUCCESS;
} else {
@@ -563,6 +566,7 @@ public class X509Authentication implements AuthenticationMethod {
log.info(LogHelper.getHeader(context, "login",
"type=x509certificate"));
context.setCurrentUser(eperson);
request.getSession().setAttribute(X509_AUTHENTICATED, true);
setSpecialGroupsFlag(request, email);
return SUCCESS;
}
@@ -594,4 +598,14 @@ public class X509Authentication implements AuthenticationMethod {
public String getName() {
return "x509";
}
@Override
public boolean isUsed(final Context context, final HttpServletRequest request) {
if (request != null &&
context.getCurrentUser() != null &&
request.getSession().getAttribute(X509_AUTHENTICATED) != null) {
return true;
}
return false;
}
}