diff options
author | tkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7> | 2013-04-10 19:32:14 +0000 |
---|---|---|
committer | tkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7> | 2013-04-10 19:32:14 +0000 |
commit | 33c49abc111f184ac87076fa735e75877dfbeab3 (patch) | |
tree | 75269ef14ce27ab49613d47c0fc6b8c5d6978926 /pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/ATrustHandler.java | |
parent | e497e79c707d335ebb0610e9bc993a180098db55 (diff) | |
download | pdf-over-33c49abc111f184ac87076fa735e75877dfbeab3.tar.gz pdf-over-33c49abc111f184ac87076fa735e75877dfbeab3.tar.bz2 pdf-over-33c49abc111f184ac87076fa735e75877dfbeab3.zip |
Rework mobile BKU handling
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@371 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/ATrustHandler.java')
-rw-r--r-- | pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/ATrustHandler.java | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/ATrustHandler.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/ATrustHandler.java new file mode 100644 index 00000000..4093102b --- /dev/null +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/ATrustHandler.java @@ -0,0 +1,134 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.gui.workflow.states.mobilebku; + +// Imports +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.asit.pdfover.gui.workflow.states.MobileBKUState; +import at.asit.pdfover.signator.SLResponse; + +/** + * A-Trust mobile BKU handler + */ +public class ATrustHandler extends MobileBKUHandler { + /** + * @param state + */ + public ATrustHandler(MobileBKUState state) { + super(state); + } + + /** + * SLF4J Logger instance + **/ + private static final Logger log = LoggerFactory + .getLogger(ATrustHandler.class); + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUHandler#handleSLRequestResponse(java.lang.String) + */ + @Override + public void handleSLRequestResponse(String responseData) throws Exception { + // Extract infos: + + String sessionID = MobileBKUHelper.extractTag(responseData, + "identification.aspx?sid=", "\""); //$NON-NLS-1$ //$NON-NLS-2$ + + String viewState = MobileBKUHelper.extractTag(responseData, + "id=\"__VIEWSTATE\" value=\"", "\""); //$NON-NLS-1$ //$NON-NLS-2$ + + String eventValidation = MobileBKUHelper.extractTag(responseData, + "id=\"__EVENTVALIDATION\" value=\"", "\""); //$NON-NLS-1$ //$NON-NLS-2$ + + log.info("sessionID: " + sessionID); //$NON-NLS-1$ + log.info("viewState: " + viewState); //$NON-NLS-1$ + log.info("eventValidation: " + eventValidation); //$NON-NLS-1$ + + getStatus().setSessionID(sessionID); + + getStatus().setViewstate(viewState); + + getStatus().setEventvalidation(eventValidation); + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUHandler#handleCredentialsResponse(java.lang.String) + */ + @Override + public void handleCredentialsResponse(String responseData) throws Exception { + MobileBKUStatus status = getStatus(); + String viewState = status.getViewstate(); + String eventValidation = status.getEventvalidation(); + String sessionID = status.getSessionID(); + String refVal = null; + + status.setRefVal(null); + status.setErrorMessage(null); + + if(responseData.contains("signature.aspx?sid=")) { //$NON-NLS-1$ + // credentials ok! TAN entry + sessionID = MobileBKUHelper.extractTag(responseData, "signature.aspx?sid=", "\""); //$NON-NLS-1$ //$NON-NLS-2$ + viewState = MobileBKUHelper.extractTag(responseData, "id=\"__VIEWSTATE\" value=\"", "\""); //$NON-NLS-1$ //$NON-NLS-2$ + eventValidation = MobileBKUHelper.extractTag(responseData, "id=\"__EVENTVALIDATION\" value=\"", "\""); //$NON-NLS-1$ //$NON-NLS-2$ + refVal = MobileBKUHelper.extractTag(responseData, "id='vergleichswert'><b>Vergleichswert:</b>", "</div>"); //$NON-NLS-1$//$NON-NLS-2$ + + status.setRefVal(refVal); + getState().setCommunicationState(MobileBKUCommunicationState.POST_TAN); + } else { + // error page + // extract error text! + String errorMessage = MobileBKUHelper.extractTag(responseData, "<span id=\"Label1\" class=\"ErrorClass\">", "</span>"); //$NON-NLS-1$ //$NON-NLS-2$ + + status.setErrorMessage(errorMessage); + + // force UI again! + status.setMobilePassword(null); + } + + log.info("sessionID: " + sessionID); //$NON-NLS-1$ + log.info("Vergleichswert: " + refVal); //$NON-NLS-1$ + log.info("viewState: " + viewState); //$NON-NLS-1$ + log.info("eventValidation: " + eventValidation); //$NON-NLS-1$ + + status.setSessionID(sessionID); + status.setViewstate(viewState); + status.setEventvalidation(eventValidation); + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUHandler#handleTANResponse(java.lang.String) + */ + @Override + public void handleTANResponse(String responseData) { + if (responseData.contains("sl:CreateXMLSignatureResponse xmlns:sl")) { //$NON-NLS-1$ + // success !! + + getSigningState().setSignatureResponse( + new SLResponse(responseData, getStatus().getServer(), null, null)); + getState().setCommunicationState(MobileBKUCommunicationState.FINAL); + } else { + getStatus().decreaseTanTries(); + + if (getStatus().getTanTries() <= 0) { + // move to POST_REQUEST + getState().setCommunicationState(MobileBKUCommunicationState.POST_REQUEST); + } + } + } + +} |