summaryrefslogtreecommitdiff
path: root/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/modules/AbstractAuthServletTask.java
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2019-05-03 06:59:13 +0200
committerThomas Lenz <thomas.lenz@egiz.gv.at>2019-05-03 06:59:13 +0200
commitdc8587693201e34fe0f7a87b3e401fac4325ce04 (patch)
tree80a574fe7b6429256e5dcb86969f6c8687862b73 /eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/modules/AbstractAuthServletTask.java
parent02851082661a924adc68230615f61a308705ce2b (diff)
downloadEAAF-Components-dc8587693201e34fe0f7a87b3e401fac4325ce04.tar.gz
EAAF-Components-dc8587693201e34fe0f7a87b3e401fac4325ce04.tar.bz2
EAAF-Components-dc8587693201e34fe0f7a87b3e401fac4325ce04.zip
update process finalization and update pendingReqIdGenerationStrategy
Diffstat (limited to 'eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/modules/AbstractAuthServletTask.java')
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/modules/AbstractAuthServletTask.java55
1 files changed, 38 insertions, 17 deletions
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/modules/AbstractAuthServletTask.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/modules/AbstractAuthServletTask.java
index eb87e893..5027a84b 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/modules/AbstractAuthServletTask.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/modules/AbstractAuthServletTask.java
@@ -52,8 +52,10 @@ import at.gv.egiz.eaaf.core.api.IRequest;
import at.gv.egiz.eaaf.core.api.IRequestStorage;
import at.gv.egiz.eaaf.core.api.data.EAAFConstants;
import at.gv.egiz.eaaf.core.api.idp.IConfiguration;
+import at.gv.egiz.eaaf.core.api.idp.auth.services.IProtocolAuthenticationService;
import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext;
import at.gv.egiz.eaaf.core.api.logging.IRevisionLogger;
+import at.gv.egiz.eaaf.core.exceptions.EAAFException;
import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException;
import at.gv.egiz.eaaf.core.impl.idp.controller.ProtocolFinalizationController;
import at.gv.egiz.eaaf.core.impl.idp.process.springweb.AbstractTask;
@@ -66,6 +68,7 @@ import at.gv.egiz.eaaf.core.impl.utils.DataURLBuilder;
public abstract class AbstractAuthServletTask extends AbstractTask {
private static final Logger log = LoggerFactory.getLogger(AbstractAuthServletTask.class);
+ @Autowired(required=true) IProtocolAuthenticationService protAuchService;
@Autowired(required=true) protected IRequestStorage requestStoreage;
@Autowired(required=true) protected IConfiguration authConfig;
@@ -75,10 +78,12 @@ public abstract class AbstractAuthServletTask extends AbstractTask {
protected IRequest pendingReq = null;
+ @Override
public abstract void execute(ExecutionContext executionContext, HttpServletRequest request,
HttpServletResponse response) throws TaskExecutionException;
+ @Override
protected final IRequest internalExecute(IRequest pendingReq, ExecutionContext executionContext, HttpServletRequest request,
HttpServletResponse response) throws TaskExecutionException {
//set pending-request object
@@ -96,12 +101,28 @@ public abstract class AbstractAuthServletTask extends AbstractTask {
/**
* Redirect the authentication process to protocol specific finalization endpoint.
+ * @param executionContext
*
* @param pendingReq Actually processed protocol specific authentication request
* @param httpResp
+ * @throws IOException
+ * @throws EAAFException
*/
- protected void performRedirectToProtocolFinialization(IRequest pendingReq, HttpServletResponse httpResp) {
- performRedirectToItself(pendingReq, httpResp, ProtocolFinalizationController.ENDPOINT_FINALIZEPROTOCOL);
+ protected void performRedirectToProtocolFinialization(ExecutionContext executionContext, IRequest pendingReq, HttpServletRequest httpReq, HttpServletResponse httpResp) throws EAAFException, IOException {
+ final Object frontChannelRedirectFlagObj = executionContext.get(EAAFConstants.PROCESS_ENGINE_REQUIRES_NO_POSTAUTH_REDIRECT);
+ if (frontChannelRedirectFlagObj != null && frontChannelRedirectFlagObj instanceof Boolean &&
+ (Boolean)frontChannelRedirectFlagObj) {
+ log.info("AuthProcess finished. Forward to Protocol finalization.");
+ protAuchService.finalizeAuthentication(httpReq, httpResp, pendingReq);
+
+ } else {
+ log.info("AuthProcess finished. Redirect to Protocol Dispatcher.");
+ requestStoreage.storePendingRequest(pendingReq);
+ performRedirectToItself(pendingReq, httpResp, ProtocolFinalizationController.ENDPOINT_FINALIZEPROTOCOL);
+
+ }
+
+
}
@@ -113,7 +134,7 @@ public abstract class AbstractAuthServletTask extends AbstractTask {
* @param idpEndPoint Servlet EndPoint that should receive the redirect
*/
protected void performRedirectToItself(IRequest pendingReq, HttpServletResponse httpResp, String idpEndPoint) {
- String redirectURL = new DataURLBuilder().buildDataURL(pendingReq.getAuthURL(),
+ final String redirectURL = new DataURLBuilder().buildDataURL(pendingReq.getAuthURL(),
idpEndPoint, pendingReq.getPendingRequestId());
httpResp.setContentType("text/html");
@@ -142,32 +163,32 @@ public abstract class AbstractAuthServletTask extends AbstractTask {
protected Map<String, String> getParameters(HttpServletRequest req) throws IOException,
FileUploadException {
- Map<String, String> parameters = new HashMap<String, String>();
+ final Map<String, String> parameters = new HashMap<String, String>();
if (ServletFileUpload.isMultipartContent(req)) {
// request is encoded as mulitpart/form-data
- FileItemFactory factory = new DiskFileItemFactory();
+ final FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = null;
upload = new ServletFileUpload(factory);
List items = null;
items = upload.parseRequest(req);
for (int i = 0; i < items.size(); i++) {
- FileItem item = (FileItem) items.get(i);
+ final FileItem item = (FileItem) items.get(i);
if (item.isFormField()) {
// Process only form fields - no file upload items
parameters.put(item.getFieldName(), item.getString("UTF-8"));
//log requests on trace
if (log.isTraceEnabled()) {
- String logString = item.getString("UTF-8");
+ final String logString = item.getString("UTF-8");
// TODO use RegExp
- String startS = "<pr:Identification><pr:Value>";
- String endS = "</pr:Value><pr:Type>urn:publicid:gv.at:baseid</pr:Type>";
+ final String startS = "<pr:Identification><pr:Value>";
+ final String endS = "</pr:Value><pr:Type>urn:publicid:gv.at:baseid</pr:Type>";
String logWithMaskedBaseid = logString;
- int start = logString.indexOf(startS);
+ final int start = logString.indexOf(startS);
if (start > -1) {
- int end = logString.indexOf(endS);
+ final int end = logString.indexOf(endS);
if (end > -1) {
logWithMaskedBaseid = logString.substring(0, start);
logWithMaskedBaseid += startS;
@@ -188,11 +209,11 @@ public abstract class AbstractAuthServletTask extends AbstractTask {
}
else {
- Iterator<Entry<String, String[]>> requestParamIt = req.getParameterMap().entrySet().iterator();
+ final Iterator<Entry<String, String[]>> requestParamIt = req.getParameterMap().entrySet().iterator();
while (requestParamIt.hasNext()) {
- Entry<String, String[]> entry = requestParamIt.next();
- String key = entry.getKey();
- String[] values = entry.getValue();
+ final Entry<String, String[]> entry = requestParamIt.next();
+ final String key = entry.getKey();
+ final String[] values = entry.getValue();
// take the last value from the value array since the legacy code above also does it this way
parameters.put(key, ArrayUtils.isEmpty(values) ? null : values[values.length-1]);
}
@@ -214,7 +235,7 @@ public abstract class AbstractAuthServletTask extends AbstractTask {
*/
protected String readBytesUpTo(InputStream in, char delimiter)
throws IOException {
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ final ByteArrayOutputStream bout = new ByteArrayOutputStream();
boolean done = false;
int b;
while (!done && (b = in.read()) >= 0) {
@@ -239,7 +260,7 @@ public abstract class AbstractAuthServletTask extends AbstractTask {
*/
protected static String addURLParameter(String url, String paramname,
String paramvalue) {
- String param = paramname + "=" + paramvalue;
+ final String param = paramname + "=" + paramvalue;
if (url.indexOf("?") < 0)
return url + "?" + param;
else