diff options
Diffstat (limited to 'id/server')
3 files changed, 62 insertions, 26 deletions
diff --git a/id/server/idserverlib/pom.xml b/id/server/idserverlib/pom.xml index 51e6395fa..5b2890658 100644 --- a/id/server/idserverlib/pom.xml +++ b/id/server/idserverlib/pom.xml @@ -295,7 +295,18 @@ <version>6.1.1</version>
<scope>test</scope>
</dependency>
-
+ <dependency>
+ <groupId>eu.stork</groupId>
+ <artifactId>DocumentService</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <classifier>classes</classifier>
+ <exclusions>
+ <exclusion>
+ <artifactId>axis</artifactId>
+ <groupId>org.apache.axis</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
<build>
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); diff --git a/id/server/legacy-backup/mw-messages-api/.settings/org.eclipse.jdt.core.prefs b/id/server/legacy-backup/mw-messages-api/.settings/org.eclipse.jdt.core.prefs index 45a6e0e0d..76393eede 100644 --- a/id/server/legacy-backup/mw-messages-api/.settings/org.eclipse.jdt.core.prefs +++ b/id/server/legacy-backup/mw-messages-api/.settings/org.eclipse.jdt.core.prefs @@ -5,4 +5,4 @@ org.eclipse.jdt.core.compiler.compliance=1.5 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.5
\ No newline at end of file |