summaryrefslogtreecommitdiff
path: root/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java
diff options
context:
space:
mode:
Diffstat (limited to 'BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java')
-rw-r--r--BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java90
1 files changed, 90 insertions, 0 deletions
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java
new file mode 100644
index 00000000..f9965240
--- /dev/null
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ */
+package at.gv.egiz.bku.online.applet;
+
+import at.gv.egiz.stal.HashDataInput;
+import at.gv.egiz.bku.smccstal.SMCCSTALRequestHandler;
+import at.gv.egiz.bku.smccstal.SignRequestHandler;
+import at.gv.egiz.stal.impl.ByteArrayHashDataInput;
+import at.gv.egiz.stal.service.GetHashDataInputResponseType;
+import at.gv.egiz.stal.service.GetHashDataInputType;
+import at.gv.egiz.stal.service.STALPortType;
+import at.gv.egiz.stal.signedinfo.ReferenceType;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author clemens
+ */
+public class WSSignRequestHandler extends SignRequestHandler {
+
+ private static final Log log = LogFactory.getLog(WSSignRequestHandler.class);
+ STALPortType stalPort;
+ String sessId;
+
+ public WSSignRequestHandler(String sessId, STALPortType stalPort) {
+ if (stalPort == null || sessId == null) {
+ throw new NullPointerException("STAL port must not be null");
+ }
+ this.sessId = sessId;
+ this.stalPort = stalPort;
+ }
+
+ @Override
+ protected List<HashDataInput> getHashDataInputs(List<ReferenceType> dsigReferences) throws Exception {
+ GetHashDataInputType request = new GetHashDataInputType();
+ request.setSessionId(sessId);
+ for (ReferenceType dsigRef : dsigReferences) {
+ //don't get Manifest, QualifyingProperties, ...
+ if (dsigRef.getType() == null) {
+ String dsigRefId = dsigRef.getId();
+ if (dsigRefId != null) {
+ GetHashDataInputType.Reference reference = new GetHashDataInputType.Reference();
+ reference.setID(dsigRefId);
+ request.getReference().add(reference);
+ } else {
+ throw new Exception("Cannot get HashDataInput for dsig:Reference without Id attribute");
+ }
+ }
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Calling GetHashDataInput for session " + sessId);
+ }
+ GetHashDataInputResponseType response = stalPort.getHashDataInput(request);
+ ArrayList<HashDataInput> hashDataInputs = new ArrayList<HashDataInput>();
+ for (GetHashDataInputResponseType.Reference reference : response.getReference()) {
+ byte[] hdi = reference.getValue();
+ String id = reference.getID();
+ String mimeType = reference.getMimeType();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Got HashDataInput " + id + " (" + mimeType + ")");
+ }
+ hashDataInputs.add(new ByteArrayHashDataInput(hdi, id, mimeType));
+ }
+ return hashDataInputs;
+ }
+
+ @Override
+ public SMCCSTALRequestHandler newInstance() {
+ return new WSSignRequestHandler(this.sessId, this.stalPort);
+ }
+}