diff options
author | clemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2008-09-05 13:39:32 +0000 |
---|---|---|
committer | clemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2008-09-05 13:39:32 +0000 |
commit | 146f204a81af9ea52de889c7f4c07d4a0ec22333 (patch) | |
tree | a51651a139c38c0a4b028bfd62610d17703c8a08 /BKUOnline | |
parent | 3808a5b4ec9d13c8cbb1b7fd95afa62c133342fd (diff) | |
download | mocca-146f204a81af9ea52de889c7f4c07d4a0ec22333.tar.gz mocca-146f204a81af9ea52de889c7f4c07d4a0ec22333.tar.bz2 mocca-146f204a81af9ea52de889c7f4c07d4a0ec22333.zip |
HashDataInput
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@22 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'BKUOnline')
5 files changed, 305 insertions, 194 deletions
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java index d158b46e..a0a268e4 100644 --- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java +++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java @@ -30,6 +30,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import at.gv.egiz.bku.slcommands.impl.xsect.STALProvider; +import iaik.security.provider.IAIK; /** * @@ -51,19 +52,20 @@ public class Configurator { protected void configureProviders() { log.debug("Registering security providers"); - Security.addProvider(new STALProvider()); + Security.insertProviderAt(new IAIK(), 1); + Security.insertProviderAt(new ECCProvider(false), 2); + Security.addProvider(new STALProvider()); XSecProvider.addAsProvider(false); - Security.insertProviderAt(new ECCProvider(false), 1); - StringBuffer sb = new StringBuffer(); - sb.append("Following providers are now registered: "); + StringBuilder sb = new StringBuilder(); + sb.append("Registered providers: "); int i = 1; for (Provider prov : Security.getProviders()) { sb.append((i++) + ". : " + prov); } - log.debug("Configured provider" + sb.toString()); + log.debug(sb.toString()); } - public void configure() { + public void configure() { configureProviders(); configUrlConnections(); } diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java index 3e8ad6f3..f0df22ea 100644 --- a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java +++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java @@ -1,19 +1,19 @@ /* -* Copyright 2008 Federal Chancellery Austria and -* Graz University of Technology -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright 2008 Federal Chancellery Austria and + * Graz University of Technology + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* * To change this template, choose Tools | Templates * and open the template in the editor. @@ -22,13 +22,13 @@ package at.gv.egiz.stal.service.impl; import at.gv.egiz.bku.binding.BindingProcessor; import at.gv.egiz.bku.binding.BindingProcessorManager; +import at.gv.egiz.stal.HashDataInput; import at.gv.egiz.stal.service.*; import at.gv.egiz.bku.binding.Id; import at.gv.egiz.bku.binding.IdFactory; import at.gv.egiz.stal.ErrorResponse; import at.gv.egiz.stal.STALRequest; import at.gv.egiz.stal.STALResponse; -import at.gv.egiz.stal.HashDataInputCallback; import at.gv.egiz.stal.InfoboxReadRequest; import at.gv.egiz.stal.QuitRequest; import at.gv.egiz.stal.SignRequest; @@ -37,7 +37,10 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; +import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.annotation.Resource; import javax.jws.WebService; import javax.servlet.ServletContext; @@ -53,168 +56,206 @@ import org.apache.commons.logging.LogFactory; @WebService(endpointInterface = "at.gv.egiz.stal.service.STALPortType") public class STALServiceImpl implements STALPortType { - public static final String BINDING_PROCESSOR_MANAGER = "bindingProcessorManager"; - public static final String TEST_SESSION_ID = "TestSession"; - protected static final Log log = LogFactory.getLog(STALServiceImpl.class); - @Resource - WebServiceContext wsContext; - protected IdFactory idF = IdFactory.getInstance(); - - @Override - public GetNextRequestResponseType getNextRequest(GetNextRequestType request) { - - // HttpSession session = ((HttpServletRequest) - // mCtx.get(MessageContext.SERVLET_REQUEST)).getSession(); - String sessId = request.getSessionId(); - List<STALResponse> responses = request.getResponse(); - if (log.isDebugEnabled()) { - log.debug("Received GetNextRequest for session " + sessId - + " containing " + responses.size() + " responses"); - } + public static final String BINDING_PROCESSOR_MANAGER = "bindingProcessorManager"; + public static final String TEST_SESSION_ID = "TestSession"; + protected static final Log log = LogFactory.getLog(STALServiceImpl.class); + @Resource + WebServiceContext wsContext; + protected IdFactory idF = IdFactory.getInstance(); - GetNextRequestResponseType response = new GetNextRequestResponseType(); - response.setSessionId(sessId); - - if (TEST_SESSION_ID.equals(sessId)) { - if (responses.size() > 0 && responses.get(0) instanceof ErrorResponse) { - log - .info("Received TestSession GetNextRequest(ErrorResponse), returning QuitRequest"); - response.getRequest().add(new QuitRequest()); - } else { - log - .info("Received TestSession GetNextRequest, returning InfoboxReadRequest "); - SignRequest sig = new SignRequest(); - sig.setKeyIdentifier("SecureSignatureKeypair"); - sig.setSignedInfo("<dsig:SignedInfo xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:xpf=\"http://www.w3.org/2002/06/xmldsig-filter2\"><dsig:CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\" /> <dsig:SignatureMethod Algorithm=\"http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1\" /> <dsig:Reference Id=\"signed-data-reference-0-1214921968-27971781-24309\" URI=\"#signed-data-object-0-1214921968-27971781-13578\"><dsig:Transforms> <dsig:Transform Algorithm=\"http://www.w3.org/2002/06/xmldsig-filter2\"> <xpf:XPath xmlns:xpf=\"http://www.w3.org/2002/06/xmldsig-filter2\" Filter=\"intersect\">id('signed-data-object-0-1214921968-27971781-13578')/node()</xpf:XPath></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /> <dsig:DigestValue>H1IePEEfGQ2SG03H6LTzw1TpCuM=</dsig:DigestValue></dsig:Reference><dsig:Reference Id=\"etsi-data-reference-0-1214921968-27971781-25439\" Type=\"http://uri.etsi.org/01903/v1.1.1#SignedProperties\" URI=\"#xmlns(etsi=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('etsi-data-object-0-1214921968-27971781-3095')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)\"><dsig:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /><dsig:DigestValue>yV6Q+I60buqR4mMaxA7fi+CV35A=</dsig:DigestValue></dsig:Reference></dsig:SignedInfo>".getBytes()); - response.getRequest().add(sig); - InfoboxReadRequest req = new InfoboxReadRequest(); - req.setInfoboxIdentifier("IdentityLink"); - req.setDomainIdentifier("hansiwurzel"); - response.getRequest().add(req); - req = new InfoboxReadRequest(); - req.setInfoboxIdentifier("CertifiedKeypair"); - response.getRequest().add(req); - req = new InfoboxReadRequest(); - req.setInfoboxIdentifier("SecureSignatureKeypair"); - response.getRequest().add(req); - } - return response; - } + @Override + public GetNextRequestResponseType getNextRequest(GetNextRequestType request) { + + // HttpSession session = ((HttpServletRequest) + // mCtx.get(MessageContext.SERVLET_REQUEST)).getSession(); + String sessId = request.getSessionId(); + List<STALResponse> responses = request.getResponse(); + if (log.isDebugEnabled()) { + log.debug("Received GetNextRequest for session " + sessId + " containing " + responses.size() + " responses"); + } + + GetNextRequestResponseType response = new GetNextRequestResponseType(); + response.setSessionId(sessId); - // get Session Id - Id sessionId = idF.createId(sessId); - STALRequestBroker stal = getStal(sessionId); - - if (stal == null) { - log.error("Failed to get STAL for session " + sessId - + ", returning QuitRequest"); - response.getRequest().add(new QuitRequest()); - } else { - List<STALResponse> responsesIn = request.getResponse(); - for (STALResponse resp : responsesIn) { - log.debug(resp); - } - List<STALRequest> requestsOut = ((STALRequestBroker) stal) - .nextRequest(responsesIn); - response.getRequest().addAll(requestsOut); - if (log.isDebugEnabled()) { - log.debug("Returning GetNextRequestResponse for session " + sessId - + " containing " + requestsOut.size() + " requests"); - } + if (TEST_SESSION_ID.equals(sessId)) { + if (responses.size() > 0 && responses.get(0) instanceof ErrorResponse) { + log.info("Received TestSession GetNextRequest(ErrorResponse), returning QuitRequest"); + response.getRequest().add(new QuitRequest()); + } else { + log.info("Received TestSession GetNextRequest, returning InfoboxReadRequest "); + SignRequest sig = new SignRequest(); + sig.setKeyIdentifier("SecureSignatureKeypair"); + sig.setSignedInfo("<dsig:SignedInfo xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:xpf=\"http://www.w3.org/2002/06/xmldsig-filter2\"><dsig:CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\" /> <dsig:SignatureMethod Algorithm=\"http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1\" /> <dsig:Reference Id=\"signed-data-reference-0-1214921968-27971781-24309\" URI=\"#signed-data-object-0-1214921968-27971781-13578\"><dsig:Transforms> <dsig:Transform Algorithm=\"http://www.w3.org/2002/06/xmldsig-filter2\"> <xpf:XPath xmlns:xpf=\"http://www.w3.org/2002/06/xmldsig-filter2\" Filter=\"intersect\">id('signed-data-object-0-1214921968-27971781-13578')/node()</xpf:XPath></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /> <dsig:DigestValue>H1IePEEfGQ2SG03H6LTzw1TpCuM=</dsig:DigestValue></dsig:Reference><dsig:Reference Id=\"etsi-data-reference-0-1214921968-27971781-25439\" Type=\"http://uri.etsi.org/01903/v1.1.1#SignedProperties\" URI=\"#xmlns(etsi=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('etsi-data-object-0-1214921968-27971781-3095')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)\"><dsig:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /><dsig:DigestValue>yV6Q+I60buqR4mMaxA7fi+CV35A=</dsig:DigestValue></dsig:Reference></dsig:SignedInfo>".getBytes()); + response.getRequest().add(sig); + InfoboxReadRequest req = new InfoboxReadRequest(); + req.setInfoboxIdentifier("IdentityLink"); + req.setDomainIdentifier("hansiwurzel"); + response.getRequest().add(req); + req = new InfoboxReadRequest(); + req.setInfoboxIdentifier("CertifiedKeypair"); + response.getRequest().add(req); + req = new InfoboxReadRequest(); + req.setInfoboxIdentifier("SecureSignatureKeypair"); + response.getRequest().add(req); + } + return response; + } + + // get Session Id + Id sessionId = idF.createId(sessId); + STALRequestBroker stal = getStal(sessionId); + + if (stal == null) { + log.error("Failed to get STAL for session " + sessId + ", returning QuitRequest"); + response.getRequest().add(new QuitRequest()); + } else { + List<STALResponse> responsesIn = request.getResponse(); + for (STALResponse resp : responsesIn) { + log.debug(resp); + } + List<STALRequest> requestsOut = ((STALRequestBroker) stal).nextRequest(responsesIn); + response.getRequest().addAll(requestsOut); + if (log.isDebugEnabled()) { + log.debug("Returning GetNextRequestResponse for session " + sessId + " containing " + requestsOut.size() + " requests"); + } + } + return response; } - return response; - } - @Override - public GetHashDataInputResponseType getHashDataInput( + @Override + public GetHashDataInputResponseType getHashDataInput( GetHashDataInputType request) throws GetHashDataInputFault { - String sessId = request.getSessionId(); - if (log.isDebugEnabled()) { - log.debug("Received GetHashDataInputRequest for session " + sessId - + " containing " + request.getReference().size() + " referencese"); - } + String sessId = request.getSessionId(); + if (log.isDebugEnabled()) { + log.debug("Received GetHashDataInputRequest for session " + sessId + " containing " + request.getReference().size() + " referencese"); + } - // get Session Id - Id sessionId = idF.createId(sessId); - STALRequestBroker stal = getStal(sessionId); - - if (stal == null) { - String msg = "Failed to get STAL for session " + sessId; - log.error(msg); - GetHashDataInputFaultType faultInfo = new GetHashDataInputFaultType(); - faultInfo.setErrorCode(1); - faultInfo.setErrorMessage(msg); - throw new GetHashDataInputFault(msg, faultInfo); - } else { - GetHashDataInputResponseType response = new GetHashDataInputResponseType(); - response.setSessionId(sessId); - - HashDataInputCallback hashDataInput = stal.getHashDataInput(); - if (TEST_SESSION_ID.equals(sessId)) { - log - .debug("Received TestSession GetHashDataInput, setting dummy HashDataInputCallback"); - hashDataInput = new HashDataInputCallback() { - - @Override - public InputStream getHashDataInput(String referenceId) { - byte[] hd = ("dummyhashdatainput_" + referenceId).getBytes(); - return new ByteArrayInputStream(hd); - } - }; - } - if (hashDataInput != null) { - List<GetHashDataInputType.Reference> references = request - .getReference(); - for (GetHashDataInputType.Reference reference : references) { - String refId = reference.getID(); - if (log.isDebugEnabled()) { - log.debug("Resolving HashDataInput for reference " + refId); - } - ByteArrayOutputStream baos = null; - try { - InputStream hdi = hashDataInput.getHashDataInput(refId); - baos = new ByteArrayOutputStream(hdi.available()); - int c; - while ((c = hdi.read()) != -1) { - baos.write(c); - } - GetHashDataInputResponseType.Reference ref = new GetHashDataInputResponseType.Reference(); - ref.setID(refId); - ref.setValue(baos.toByteArray()); - response.getReference().add(ref); - } catch (IOException ex) { - String msg = "Failed to get HashDataInput for reference " + refId; - log.error(msg, ex); + // get Session Id + Id sessionId = idF.createId(sessId); + STALRequestBroker stal = getStal(sessionId); + + if (stal == null) { + String msg = "Failed to get STAL for session " + sessId; + log.error(msg); GetHashDataInputFaultType faultInfo = new GetHashDataInputFaultType(); faultInfo.setErrorCode(1); faultInfo.setErrorMessage(msg); - throw new GetHashDataInputFault(msg, faultInfo, ex); - } finally { - try { - baos.close(); - } catch (IOException ex) { + throw new GetHashDataInputFault(msg, faultInfo); + } else { + + List<HashDataInput> hashDataInputs = stal.getHashDataInput(); + + if (TEST_SESSION_ID.equals(sessId)) { + log.debug("Received TestSession GetHashDataInput, setting dummy HashDataInputCallback"); + + HashDataInput testHdi = new HashDataInput() { + + @Override + public String getReferenceId() { + return "hashDataInputId_" + TEST_SESSION_ID; + } + + @Override + public String getMimeType() { + return "text/plain"; + } + + @Override + public InputStream getHashDataInput() { + byte[] hd = ("hashDataInput_" + TEST_SESSION_ID).getBytes(); + return new ByteArrayInputStream(hd); + } + }; + hashDataInputs = Collections.singletonList(testHdi); + } + + + if (hashDataInputs != null) { + + Map<String, HashDataInput> hashDataIdMap = new HashMap<String, HashDataInput>(); + for (HashDataInput hdi : hashDataInputs) { + if (log.isTraceEnabled()) { + log.trace("Provided HashDataInput for reference " + hdi.getReferenceId()); + } + hashDataIdMap.put(hdi.getReferenceId(), hdi); + } + + GetHashDataInputResponseType response = new GetHashDataInputResponseType(); + response.setSessionId(sessId); + + List<GetHashDataInputType.Reference> reqRefs = request.getReference(); + for (GetHashDataInputType.Reference reqRef : reqRefs) { + String reqRefId = reqRef.getID(); + HashDataInput reqHdi = hashDataIdMap.get(reqRefId); + if (reqHdi == null) { + String msg = "Failed to resolve HashDataInput for reference " + reqRefId; + log.error(msg); + GetHashDataInputFaultType faultInfo = new GetHashDataInputFaultType(); + faultInfo.setErrorCode(1); + faultInfo.setErrorMessage(msg); + throw new GetHashDataInputFault(msg, faultInfo); + } + + InputStream hashDataIS = reqHdi.getHashDataInput(); + if (hashDataIS == null) { + //HashDataInput not cached? + String msg = "Failed to obtain HashDataInput for reference " + reqRefId + ", reference not cached"; + log.error(msg); + GetHashDataInputFaultType faultInfo = new GetHashDataInputFaultType(); + faultInfo.setErrorCode(1); + faultInfo.setErrorMessage(msg); + throw new GetHashDataInputFault(msg, faultInfo); + } + ByteArrayOutputStream baos = null; + try { + if(log.isDebugEnabled()) { + log.debug("Resolved HashDataInput " + reqRefId + " (" + reqHdi.getMimeType() + ")"); + } + baos = new ByteArrayOutputStream(hashDataIS.available()); + int c; + while ((c = hashDataIS.read()) != -1) { + baos.write(c); + } + GetHashDataInputResponseType.Reference ref = new GetHashDataInputResponseType.Reference(); + ref.setID(reqRefId); + ref.setMimeType(reqHdi.getMimeType()); + ref.setValue(baos.toByteArray()); + response.getReference().add(ref); + } catch (IOException ex) { + String msg = "Failed to get HashDataInput for reference " + reqRefId; + log.error(msg, ex); + GetHashDataInputFaultType faultInfo = new GetHashDataInputFaultType(); + faultInfo.setErrorCode(1); + faultInfo.setErrorMessage(msg); + throw new GetHashDataInputFault(msg, faultInfo, ex); + } finally { + try { + baos.close(); + } catch (IOException ex) { + } + } + } + return response; + } else { + String msg = "Failed to resolve any HashDataInputs for session " + sessId; + log.error(msg); + GetHashDataInputFaultType faultInfo = new GetHashDataInputFaultType(); + faultInfo.setErrorCode(1); + faultInfo.setErrorMessage(msg); + throw new GetHashDataInputFault(msg, faultInfo); } - } } - } else { - log.warn("Could not resolve any HashDataInputs for session " + sessId - + ", no callback provided."); - } - return response; } - } - - private STALRequestBroker getStal(Id sessionId) { - // log.warn("RETURNING DUMMY STAL REQUEST BROKER"); - // return new STALRequestBrokerImpl(); - - MessageContext mCtx = wsContext.getMessageContext(); - ServletContext sCtx = (ServletContext) mCtx - .get(MessageContext.SERVLET_CONTEXT); - BindingProcessorManager bpMgr = (BindingProcessorManager) sCtx - .getAttribute(BINDING_PROCESSOR_MANAGER); - BindingProcessor bp = bpMgr.getBindingProcessor(sessionId); - return (bp == null) ? null : (STALRequestBroker) bp.getSTAL(); - } + + private STALRequestBroker getStal(Id sessionId) { +// log.warn("RETURNING DUMMY STAL REQUEST BROKER"); +// return new STALRequestBrokerImpl(); + + MessageContext mCtx = wsContext.getMessageContext(); + ServletContext sCtx = (ServletContext) mCtx.get(MessageContext.SERVLET_CONTEXT); + BindingProcessorManager bpMgr = (BindingProcessorManager) sCtx.getAttribute(BINDING_PROCESSOR_MANAGER); + BindingProcessor bp = bpMgr.getBindingProcessor(sessionId); + return (bp == null) ? null : (STALRequestBroker) bp.getSTAL(); + } } diff --git a/BKUOnline/src/main/webapp/HTTP-ohne.html b/BKUOnline/src/main/webapp/HTTP-ohne.html index 9cdd67ab..f61081cc 100644 --- a/BKUOnline/src/main/webapp/HTTP-ohne.html +++ b/BKUOnline/src/main/webapp/HTTP-ohne.html @@ -62,12 +62,31 @@ legend { <fieldset><legend>Enter XML Request</legend> <p><label for="XMLRequest">XML Request</label> <textarea name="XMLRequest" rows=15 cols="60" id="XMLRequest"> +<?xml version="1.0" encoding="UTF-8"?> +<sl:CreateXMLSignatureRequest + xmlns:sl="http://www.buergerkarte.at/namespaces/securitylayer/1.2#"> +<sl:KeyboxIdentifier>SecureSignatureKeypair</sl:KeyboxIdentifier> + <sl:DataObjectInfo Structure="enveloping"> + <sl:DataObject> + <sl:XMLContent>Ich bin ein einfacher Text.</sl:XMLContent> + </sl:DataObject> + <sl:TransformsInfo> + <sl:FinalDataMetaInfo> + <sl:MimeType>text/plain</sl:MimeType> + </sl:FinalDataMetaInfo> + </sl:TransformsInfo> + </sl:DataObjectInfo> +</sl:CreateXMLSignatureRequest> +</textarea></p> +<!-- <?xml version="1.0" encoding="UTF-8" ?> <sl:InfoboxReadRequest xmlns:sl="http://www.buergerkarte.at/namespaces/securitylayer/1.2#"> <sl:InfoboxIdentifier>IdentityLink</sl:InfoboxIdentifier> <sl:BinaryFileParameters ContentIsXMLEntity="true" /> </sl:InfoboxReadRequest> +--> + </textarea></p> <!-- <p><label for="RedirectURL">RedirectURL</label> <input diff --git a/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.xsd b/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.xsd index 6627db00..74d5fe6e 100644 --- a/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.xsd +++ b/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.xsd @@ -118,7 +118,8 @@ <complexType> <simpleContent> <extension base="base64Binary"> - <attribute name="ID" type="ID"/> + <attribute name="ID" type="string"/> + <attribute name="MimeType" type="string"/> </extension> </simpleContent> </complexType> diff --git a/BKUOnline/src/test/java/at/gv/egiz/stal/service/STALRequestBrokerTest.java b/BKUOnline/src/test/java/at/gv/egiz/stal/service/STALRequestBrokerTest.java index cd321c71..62d6f8a6 100644 --- a/BKUOnline/src/test/java/at/gv/egiz/stal/service/STALRequestBrokerTest.java +++ b/BKUOnline/src/test/java/at/gv/egiz/stal/service/STALRequestBrokerTest.java @@ -24,7 +24,7 @@ import at.gv.egiz.stal.service.impl.STALRequestBrokerImpl; import at.gv.egiz.stal.service.impl.RequestBrokerSTALFactory; import at.gv.egiz.stal.service.impl.STALRequestBroker; import at.gv.egiz.stal.ErrorResponse; -import at.gv.egiz.stal.HashDataInputCallback; +import at.gv.egiz.stal.HashDataInput; import at.gv.egiz.stal.InfoboxReadRequest; import at.gv.egiz.stal.InfoboxReadResponse; import at.gv.egiz.stal.QuitRequest; @@ -95,13 +95,24 @@ public class STALRequestBrokerTest { SignRequest r1 = new SignRequest(); r1.setKeyIdentifier("keybox1"); r1.setSignedInfo("1234".getBytes()); - r1.setHashDataInput(new HashDataInputCallback() { + HashDataInput hdi = new HashDataInput() { @Override - public InputStream getHashDataInput(String referenceId) { + public String getReferenceId() { + return "refId1234"; + } + + @Override + public String getMimeType() { + return "text/plain"; + } + + @Override + public InputStream getHashDataInput() { return new ByteArrayInputStream("hashdatainput1234".getBytes()); } - }); + }; + r1.setHashDataInput(Collections.singletonList(hdi)); requests.add(r1); BindingProcessorSimulator bp = new BindingProcessorSimulator(); @@ -125,13 +136,24 @@ public class STALRequestBrokerTest { SignRequest r1 = new SignRequest(); r1.setKeyIdentifier("keybox1"); r1.setSignedInfo("1234".getBytes()); - r1.setHashDataInput(new HashDataInputCallback() { + HashDataInput hdi = new HashDataInput() { + + @Override + public String getReferenceId() { + return "refId1234"; + } + + @Override + public String getMimeType() { + return "text/plain"; + } @Override - public InputStream getHashDataInput(String referenceId) { + public InputStream getHashDataInput() { return new ByteArrayInputStream("hashdatainput1234".getBytes()); } - }); + }; + r1.setHashDataInput(Collections.singletonList(hdi)); requests.add(r1); BindingProcessorSimulator bp = new BindingProcessorSimulator(); @@ -169,26 +191,48 @@ public class STALRequestBrokerTest { SignRequest r1 = new SignRequest(); r1.setKeyIdentifier("keybox1"); r1.setSignedInfo("1234".getBytes()); - r1.setHashDataInput(new HashDataInputCallback() { + HashDataInput hdi = new HashDataInput() { @Override - public InputStream getHashDataInput(String referenceId) { + public String getReferenceId() { + return "refId1234"; + } + + @Override + public String getMimeType() { + return "text/plain"; + } + + @Override + public InputStream getHashDataInput() { return new ByteArrayInputStream("hashdatainput1234".getBytes()); } - }); + }; + r1.setHashDataInput(Collections.singletonList(hdi)); requests.add(r1); List<STALRequest> requests2 = new ArrayList<STALRequest>(); SignRequest r2 = new SignRequest(); r2.setKeyIdentifier("keybox2"); r2.setSignedInfo("6789".getBytes()); - r2.setHashDataInput(new HashDataInputCallback() { + HashDataInput hdi2 = new HashDataInput() { + + @Override + public String getReferenceId() { + return "refId6789"; + } + + @Override + public String getMimeType() { + return "text/xml"; + } @Override - public InputStream getHashDataInput(String referenceId) { - return new ByteArrayInputStream("hashdatainput6789".getBytes()); + public InputStream getHashDataInput() { + return new ByteArrayInputStream("<xml>hashdatainput6789</xml>".getBytes()); } - }); + }; + r2.setHashDataInput(Collections.singletonList(hdi2)); requests2.add(r2); BindingProcessorSimulator bp = new BindingProcessorSimulator(); @@ -228,9 +272,11 @@ public class STALRequestBrokerTest { } else if (request instanceof SignRequest) { log.debug("calling stal.getCurrentHashDataInputCallback"); - HashDataInputCallback cb = stal.getHashDataInput(); - assertNotNull(cb); - InputStream hd = cb.getHashDataInput("1234"); + List<HashDataInput> hdis = stal.getHashDataInput(); + assertNotNull(hdis); + assertEquals(hdis.size(), 1); + HashDataInput hdi = hdis.get(0);// cb.getHashDataInput("1234"); + InputStream hd = hdi.getHashDataInput(); byte[] data = new byte[hd.available()]; hd.read(data); log.debug("got HashDataInput " + new String(data)); @@ -280,9 +326,11 @@ public class STALRequestBrokerTest { // if (request instanceof InfoboxReadRequest) { if (request instanceof SignRequest) { log.debug("calling stal.getCurrentHashDataInputCallback"); - HashDataInputCallback cb = stal.getHashDataInput(); - assertNotNull(cb); - InputStream hd = cb.getHashDataInput("1234"); + List<HashDataInput> hdis = stal.getHashDataInput(); + assertNotNull(hdis); + assertEquals(hdis.size(), 1); + HashDataInput hdi = hdis.get(0);// cb.getHashDataInput("1234"); + InputStream hd = hdi.getHashDataInput(); byte[] data = new byte[hd.available()]; hd.read(data); log.debug("got HashDataInput " + new String(data)); |