aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/main/java/at/gv/egovernment/moa
diff options
context:
space:
mode:
authorFlorian Reimair <florian.reimair@iaik.tugraz.at>2014-01-23 13:46:37 +0100
committerFlorian Reimair <florian.reimair@iaik.tugraz.at>2014-01-27 16:43:21 +0100
commitbb986a1225a594cf72572af8cbf0edb14039b5c1 (patch)
treeda92c41beb798ecc1b90ab05b5cad41a189e90d2 /id/server/idserverlib/src/main/java/at/gv/egovernment/moa
parent8cdac4252e1ea43aada04b71ee95d2509c4a75f3 (diff)
downloadmoa-id-spss-bb986a1225a594cf72572af8cbf0edb14039b5c1.tar.gz
moa-id-spss-bb986a1225a594cf72572af8cbf0edb14039b5c1.tar.bz2
moa-id-spss-bb986a1225a594cf72572af8cbf0edb14039b5c1.zip
added signrequest to authrequest
Diffstat (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment/moa')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/AuthenticationServer.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/AuthenticationServer.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/AuthenticationServer.java
index 0fbcc97b2..49e2cbdd5 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/AuthenticationServer.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/AuthenticationServer.java
@@ -33,8 +33,10 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.security.GeneralSecurityException;
+import java.security.NoSuchAlgorithmException;
import java.security.Principal;
import java.security.cert.CertificateException;
+import java.util.ArrayList;
//import java.security.cert.CertificateFactory;
import java.util.Calendar;
import java.util.Date;
@@ -54,6 +56,8 @@ import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
import org.apache.xpath.XPathAPI;
+import org.opensaml.common.IdentifierGenerator;
+import org.opensaml.common.impl.SecureRandomIdentifierGenerator;
import org.opensaml.xml.util.Base64;
import org.opensaml.xml.util.XMLHelper;
import org.springframework.util.xml.DomUtils;
@@ -1839,6 +1843,15 @@ public class AuthenticationServer implements MOAIDAuthConstants {
attributeList.add(newAttribute);
}
+ // add sign request
+ PersonalAttribute newAttribute = new PersonalAttribute();
+ newAttribute.setName("signedDoc");
+ List<String> value = new ArrayList<String>();
+ value.add(generateDssSignRequest(Base64.encodeBytes(CreateXMLSignatureRequestBuilder.buildForeignIDTextToBeSigned("wie im Signaturzertifikat (as in my signature certificate)", oaParam, moasession).getBytes()), "application/xhtml+xml"));
+ newAttribute.setValue(value);
+ attributeList.add(newAttribute);
+
+
if (Logger.isDebugEnabled()) {
Logger.debug("The following attributes are requested for this OA:");
for (OAStorkAttribute logReqAttr : attributesFromConfig)
@@ -1925,6 +1938,25 @@ public class AuthenticationServer implements MOAIDAuthConstants {
Logger.info("STORK AuthnRequest successfully successfully prepared for client with target location: " + authnRequest.getDestination());
}
+ private static String generateDssSignRequest(String text, String mimeType) {
+ IdentifierGenerator idGenerator;
+ try {
+ idGenerator = new SecureRandomIdentifierGenerator();
+
+ return "<dss:SignRequest xmlns:dss=\"urn:oasis:names:tc:dss:1.0:core:schema\" " +
+ "RequestID=\"" + idGenerator.generateIdentifier() + "\">" +
+ "<dss:InputDocuments>" +
+ "<dss:Document>" +
+ "<dss:Base64Data MimeType=\"" + mimeType + "\">" + text + "</dss:Base64Data>" +
+ "</dss:Document>" +
+ "</dss:InputDocuments>" +
+ "</dss:SignRequest>";
+ } catch (NoSuchAlgorithmException e) {
+ Logger.error("Cannot generate id", e);
+ throw new RuntimeException(e);
+ }
+ }
+
/**
* Extracts an X509 Certificate out of an XML signagture element
* @param signedXML XML signature element