diff options
Diffstat (limited to 'id/server/idserverlib/src/main/java')
2 files changed, 51 insertions, 26 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/VerifyXMLSignatureResponseValidator.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/VerifyXMLSignatureResponseValidator.java index 4fd7fa965..00089735f 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/VerifyXMLSignatureResponseValidator.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/VerifyXMLSignatureResponseValidator.java @@ -130,8 +130,8 @@ public class VerifyXMLSignatureResponseValidator { // TEST CARDS if (whatToCheck.equals(CHECK_IDENTITY_LINK)) throw new ValidateException("validator.07", new Object[] { checkFailedReason } ); - else - throw new ValidateException("validator.19", new Object[] { checkFailedReason } ); +// else +// throw new ValidateException("validator.19", new Object[] { checkFailedReason } ); } //check QC diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/attributeproviders/SignedDocAttributeRequestProvider.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/attributeproviders/SignedDocAttributeRequestProvider.java index 3256e1812..42ef11758 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/attributeproviders/SignedDocAttributeRequestProvider.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/attributeproviders/SignedDocAttributeRequestProvider.java @@ -29,6 +29,7 @@ import org.apache.commons.lang.NotImplementedException; import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.VelocityEngine; +import org.bouncycastle.util.encoders.UrlBase64; import at.gv.egovernment.moa.id.auth.exception.MOAIDException; import at.gv.egovernment.moa.id.config.auth.OAAuthParameter; @@ -41,8 +42,10 @@ import eu.stork.oasisdss.api.ApiUtils; import eu.stork.oasisdss.api.LightweightSourceResolver; import eu.stork.oasisdss.api.exceptions.ApiUtilsException; import eu.stork.oasisdss.api.exceptions.UtilsException; +import eu.stork.oasisdss.profile.AnyType; import eu.stork.oasisdss.profile.Base64Data; import eu.stork.oasisdss.profile.DocumentType; +import eu.stork.oasisdss.profile.DocumentWithSignature; import eu.stork.oasisdss.profile.IncludeObject; import eu.stork.oasisdss.profile.SignRequest; import eu.stork.oasisdss.profile.SignResponse; @@ -112,9 +115,6 @@ public class SignedDocAttributeRequestProvider extends AttributeProvider { try { String signResponseString = new String(Base64.decodeBase64(httpReq.getParameter("signresponse")), "UTF8"); - //TODO - //FIXME - //test123 //create SignResponse object Source response = new StreamSource(new java.io.StringReader(signResponseString)); SignResponse signResponse = ApiUtils.unmarshal(response, SignResponse.class); @@ -133,21 +133,38 @@ public class SignedDocAttributeRequestProvider extends AttributeProvider { if (dssId != null && data!=null) { if(updateDocumentInDtl(data, docId, signResponseString)) - { -// SignResponse outRes = new SignResponse(); -// outRes.setDocUI(signResponse.getDocUI()); -// outRes.setProfile(signResponse.getProfile()); -// outRes.setRequestID(signResponse.getRequestID()); -// outRes.setSignatureObject(signResponse.getSignatureObject()); - //outRes; - - signResponse.getResult().setResultMinor(dtlUrl); - System.out.println("overwriting:"+signResponse.getResult().getResultMessage()+" with DTL url:"+dtlUrl); + { + // set the url in the SignResponse + DocumentWithSignature documentWithSignature = new DocumentWithSignature(); + DocumentType value = new DocumentType(); + value.setDocumentURL(dtlUrl); + documentWithSignature.setDocument(value); + if(signResponse.getOptionalOutputs()!=null) + { + //signResponse.getOptionalOutputs().getAny().add(documentWithSignature); + for(Object o :signResponse.getOptionalOutputs().getAny()) + { + if(o instanceof DocumentWithSignature) + { + signResponse.getOptionalOutputs().getAny().remove(o); + signResponse.getOptionalOutputs().getAny().add(documentWithSignature); + break; + } + } + } + else + { + AnyType anytype = new AnyType(); + anytype.getAny().add(documentWithSignature); + signResponse.setOptionalOutputs(anytype ); + } + +// System.out.println("overwriting:"+signResponse.getResult().getResultMessage()+" with DTL url:"+dtlUrl); InputStream istr = ApiUtils.marshalToInputStream(signResponse); StringWriter writer = new StringWriter(); IOUtils.copy(istr, writer, "UTF-8"); signResponseString = writer.toString(); - System.out.println("SignResponse overwritten:"+signResponseString); + Logger.info("SignResponse overwritten:"+signResponseString); } } else @@ -207,19 +224,30 @@ public class SignedDocAttributeRequestProvider extends AttributeProvider { Source signDoc = new StreamSource(new java.io.StringReader(signRequestString)); SignRequest signRequest = ApiUtils.unmarshal(signDoc, SignRequest.class); try{ - //TODO - //FIXME //search for DTL link String dtlURL = getDtlUrlFromRequest(signRequest); String docId = signRequest.getDocUI(); String docRequest = getDocTransferRequest(docId, dtlURL);//dtlUrl + //Start - code to be removed +// System.out.println("SAML Engine vidp init"); +// final STORKSAMLEngine engine = STORKSAMLEngine.getInstance("VIDP"); +// final byte[] samlToken = UrlBase64.decode(docRequest); +// final STORKAttrQueryRequest request= engine.validateSTORKAttrQueryRequest(samlToken); +// final IPersonalAttributeList pal = request.getPersonalAttributeList(); +// final PersonalAttribute sdoc = pal.get("docRequest"); +// if (sdoc != null) +// { +// String docId1 = sdoc.getValue().get(0); +// System.out.println("docId1:"+docId1); +// } + //End - code to be removed byte[] data = getDocumentFromDtl(docRequest, dtlURL);//dtlUrl //load doc from DTL - System.out.println("data:"+data); + Logger.debug("data:"+data); String mime = getDocumentMimeFromDtl(docId, dtlURL);//dtlUrl - System.out.println("mime:"+mime); + Logger.debug("mime:"+mime); //add doc as base64* to signrequest => post doc to oasis try{ List<IncludeObject> includeObjects = ApiUtils.findNamedElement( @@ -239,13 +267,11 @@ public class SignedDocAttributeRequestProvider extends AttributeProvider { StringWriter writer = new StringWriter(); IOUtils.copy(istr, writer, "UTF-8"); signRequestString = writer.toString(); - System.out.println("Signrequest overwritten"); + Logger.info("Signrequest overwritten"); } catch (Exception e) { e.printStackTrace(); throw new Exception("Could not marshall sign request", e); - } - - + } }catch(Exception e) { Logger.info("No documentservice used?"); @@ -266,7 +292,6 @@ public class SignedDocAttributeRequestProvider extends AttributeProvider { } } - /* (non-Javadoc) * @see at.gv.egovernment.moa.id.protocols.stork2.AttributeProvider#getSupportedAttributeNames() @@ -359,7 +384,7 @@ public class SignedDocAttributeRequestProvider extends AttributeProvider { */ private String getDocTransferRequest(String docId, String destinationUrl) throws Exception { - final STORKSAMLEngine engine = STORKSAMLEngine.getInstance("VIDP");//getInstance(samlDTLInstance); + final STORKSAMLEngine engine = STORKSAMLEngine.getInstance("VIDP"); STORKAttrQueryRequest req = new STORKAttrQueryRequest(); req.setAssertionConsumerServiceURL(dtlUrl); req.setDestination(destinationUrl); |