diff options
7 files changed, 105 insertions, 31 deletions
diff --git a/DocumentService/pom.xml b/DocumentService/pom.xml index c93a901ca..be2252137 100644 --- a/DocumentService/pom.xml +++ b/DocumentService/pom.xml @@ -69,6 +69,15 @@ <version>2.2.8</version> <scope>provided</scope> </dependency> + <dependency> + <groupId>xml-apis</groupId> + <artifactId>xml-apis</artifactId> + <version>1.4.01</version> +</dependency> +<!-- <dependency> --> +<!-- <groupId>org.opensaml</groupId> --> +<!-- <artifactId>opensaml</artifactId> --> +<!-- </dependency> --> <dependency> <groupId>javax.xml</groupId> <artifactId>jaxrpc-api</artifactId> diff --git a/DocumentService/src/eu/stork/documentservice/DocumentServiceImpl.java b/DocumentService/src/eu/stork/documentservice/DocumentServiceImpl.java index 74519dfee..913c2f704 100644 --- a/DocumentService/src/eu/stork/documentservice/DocumentServiceImpl.java +++ b/DocumentService/src/eu/stork/documentservice/DocumentServiceImpl.java @@ -29,7 +29,7 @@ public class DocumentServiceImpl implements DocumentService private DatabaseConnector conn; private Properties props = new Properties(); private static final Logger LOG = Logger.getLogger(DocumentServiceImpl.class.getName()); - + @Override public String addDocument(byte[] document, String xmlRequest, String destinationCountry, String SpId, String mimeType, String receiverCert) { String returnMessage = ""; diff --git a/DocumentService/src/eu/stork/documentservice/utils/Bootstrap.java b/DocumentService/src/eu/stork/documentservice/utils/Bootstrap.java new file mode 100644 index 000000000..72da74e52 --- /dev/null +++ b/DocumentService/src/eu/stork/documentservice/utils/Bootstrap.java @@ -0,0 +1,31 @@ +package eu.stork.documentservice.utils; + +import org.opensaml.DefaultBootstrap; +import org.opensaml.xml.ConfigurationException; + +public class Bootstrap extends DefaultBootstrap { + + static boolean initializied = false; + public static synchronized void bootstrap() throws ConfigurationException { + + if(!initializied) + { + initializeXMLSecurity(); + + initializeXMLTooling(); + +// initializeArtifactBuilderFactories(); +// +// initializeGlobalSecurityConfiguration(); +// +// initializeParserPool(); +// +// initializeESAPI(); + } + else + { + System.out.println("Skipping initialization..."); + } + } + +} diff --git a/DocumentService/src/eu/stork/documentservice/utils/GetDSSFileAction.java b/DocumentService/src/eu/stork/documentservice/utils/GetDSSFileAction.java index b80c63dc2..2fce0165d 100644 --- a/DocumentService/src/eu/stork/documentservice/utils/GetDSSFileAction.java +++ b/DocumentService/src/eu/stork/documentservice/utils/GetDSSFileAction.java @@ -16,6 +16,7 @@ package eu.stork.documentservice.utils; import org.apache.log4j.Logger; import org.bouncycastle.util.encoders.UrlBase64; +import org.opensaml.xml.ConfigurationException; import eu.stork.peps.auth.commons.IPersonalAttributeList; import eu.stork.peps.auth.commons.PEPSUtil; @@ -59,8 +60,10 @@ public final class GetDSSFileAction { final PersonalAttribute sdoc = pal.get("docRequest"); if (sdoc != null) { - String docId = sdoc.getValue().get(0); - return docId; + String docId = sdoc.getValue().get(0);//remove countries from beginning + docId = docId.substring(docId.indexOf("/")+1); + docId = docId.substring(docId.indexOf('/')+1); + return docId.replace("/", ""); } } catch (final STORKSAMLEngineException e) { e.printStackTrace(); @@ -73,7 +76,13 @@ public final class GetDSSFileAction { // fetch the samlToken from the request final byte[] samlToken = UrlBase64.decode(samlRequest); - + //System.out.println("SAML Engine DokumentService init"); + try { + Bootstrap.bootstrap(); + } catch (ConfigurationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } final STORKSAMLEngine engine = STORKSAMLEngine.getInstance(SAML_INSTANCE); final STORKAttrQueryRequest attrData= engine.validateSTORKAttrQueryRequest(samlToken); diff --git a/id/ConfigWebTool/pom.xml b/id/ConfigWebTool/pom.xml index 01359e38a..9b3ef3862 100644 --- a/id/ConfigWebTool/pom.xml +++ b/id/ConfigWebTool/pom.xml @@ -10,7 +10,6 @@ <groupId>MOA.id</groupId> <artifactId>moa-id-configuration</artifactId> <version>${configtool-version}</version> - <packaging>war</packaging> <name>MOA-ID 2.0 Configuration Tool</name> <description>Web based Configuration Tool for MOA-ID 2.x</description> @@ -187,4 +186,5 @@ </build> + <packaging>war</packaging> </project> 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); |