Commit 1997de77 authored by Tony Schaller's avatar Tony Schaller

Refactorings in order to get DemoXua running on .Net

git-svn-id: https://svn.code.sf.net/p/ehealthconnector/code/trunk@1686 e99adb7c-5e35-42fd-8d1b-cdb378af05e8
parent 83b51384
This diff is collapsed.
using System;
/*
* The authorship of this project and accompanying materials is held by medshare GmbH, Switzerland.
* All rights reserved. https://medshare.net
*
* Source code, documentation and other resources have been contributed by various people.
* Project Team: https://sourceforge.net/p/ehealthconnector/wiki/Team/
* For exact developer information, please refer to the commit history of the forge.
*
* This code is made available under the terms of the Eclipse Public License v1.0.
*
* Accompanying materials are made available under the terms of the Creative Commons
* Attribution-ShareAlike 4.0 License.
*
* This line is intended for UTF-8 encoding checks, do not modify/delete: äöüéè
*
*/
using System;
using ikvm.extensions;
using java.io;
......@@ -32,6 +49,12 @@ namespace eHealthConnectorDemo
txtLog = textBox;
}
/**
* The fn extension (_Java here and _Dotnet in the .Net demo allows
* efficient comparison in the test scripts).
*/
private static String FN_EXT = "_Dotnet.xml";
/** The logger. */
//protected Logger log = LoggerFactory.getLogger(DemoXuaOutputLogger.class);
......@@ -66,7 +89,7 @@ namespace eHealthConnectorDemo
AuthnRequestSerializerImpl serializer = new AuthnRequestSerializerImpl();
String xmlString = serializer.toXmlString(authnRequest);
txtLog.AppendText(xmlString + "\r\n");
txtLog.AppendText(xmlString + "\n");
}
catch (java.lang.Throwable t)
{
......@@ -86,7 +109,7 @@ namespace eHealthConnectorDemo
{
PrivacyPolicyFeedResponseSerializerImpl serializer = new PrivacyPolicyFeedResponseSerializerImpl();
String xmlString = serializer.toXmlString(response);
txtLog.AppendText(xmlString + "\r\n");
txtLog.AppendText(xmlString + "\n");
}
catch (java.lang.Throwable t)
{
......@@ -106,7 +129,7 @@ namespace eHealthConnectorDemo
{
PrivacyPolicyQueryResponseSerializerImpl serializer = new PrivacyPolicyQueryResponseSerializerImpl();
String xmlString = serializer.toXmlString(response);
txtLog.AppendText(xmlString + "\r\n");
txtLog.AppendText(xmlString + "\n");
}
catch (java.lang.Throwable t)
{
......@@ -127,7 +150,7 @@ namespace eHealthConnectorDemo
ResponseSerializerImpl serializer = new ResponseSerializerImpl();
String xmlString = serializer.toXmlString(response);
txtLog.AppendText(xmlString + "\r\n");
txtLog.AppendText(xmlString + "\n");
}
catch (java.lang.Throwable t)
{
......@@ -147,7 +170,7 @@ namespace eHealthConnectorDemo
{
XUserAssertionRequestSerializerImpl serializer = new XUserAssertionRequestSerializerImpl();
String xmlString = serializer.toXmlString(aXUserAssertionRequest);
txtLog.AppendText(xmlString + "\r\n");
txtLog.AppendText(xmlString + "\n");
}
catch (java.lang.Throwable t)
{
......@@ -167,7 +190,7 @@ namespace eHealthConnectorDemo
{
XUserAssertionResponseSerializerImpl serializer = new XUserAssertionResponseSerializerImpl();
String xmlString = serializer.toXmlString(aXUserAssertionResponse);
txtLog.AppendText(xmlString + "\r\n");
txtLog.AppendText(xmlString + "\n");
}
catch (java.lang.Throwable t)
{
......@@ -191,8 +214,8 @@ namespace eHealthConnectorDemo
byte[] xmlArray = serializer.toXmlByteArray(baseElement);
File outputFile = new File(getPathDir(aOutputFile),
baseElement.getClass().getSimpleName() + ".xml");
txtLog.AppendText("Write to file " + outputFile.getAbsolutePath() + "\r\n");
baseElement.getClass().getSimpleName() + FN_EXT);
txtLog.AppendText("Write to file " + outputFile.getAbsolutePath() + "\n");
FileOutputStream os = new FileOutputStream(outputFile);
os.write(xmlArray);
......@@ -219,7 +242,7 @@ namespace eHealthConnectorDemo
{
PrivacyPolicyFeedResponseSerializerImpl serializer = new PrivacyPolicyFeedResponseSerializerImpl();
String xmlString = serializer.toXmlString(response);
txtLog.AppendText(xmlString + "\r\n");
txtLog.AppendText(xmlString + "\n");
}
catch (java.lang.Throwable t)
{
......@@ -241,14 +264,14 @@ namespace eHealthConnectorDemo
{
int counter = 1;
File outputFile = new File(getPathDir(aOutputPath),
response.getClass().getSimpleName() + "_" + counter + ".xml");
response.getClass().getSimpleName() + "_" + counter + FN_EXT);
while (outputFile.exists())
{
++counter;
outputFile = new File(getPathDir(aOutputPath),
response.getClass().getSimpleName() + "_" + counter + ".xml");
response.getClass().getSimpleName() + "_" + counter + FN_EXT);
}
txtLog.AppendText("Write to file " + outputFile.getAbsolutePath() + "\r\n");
txtLog.AppendText("Write to file " + outputFile.getAbsolutePath() + "\n");
PrivacyPolicyQueryResponseSerializerImpl serializer = new PrivacyPolicyQueryResponseSerializerImpl();
String xmlString = serializer.toXmlString(response);
......@@ -277,15 +300,15 @@ namespace eHealthConnectorDemo
{
int counter = 1;
File outputFile = new File(getPathDir(aOutputPath),
aXUserAssertionRequest.getClass().getSimpleName() + "_" + counter + ".xml");
aXUserAssertionRequest.getClass().getSimpleName() + "_" + counter + FN_EXT);
while (outputFile.exists())
{
++counter;
outputFile = new File(getPathDir(aOutputPath),
aXUserAssertionRequest.getClass().getSimpleName() + "_" + counter + ".xml");
aXUserAssertionRequest.getClass().getSimpleName() + "_" + counter + FN_EXT);
}
txtLog.AppendText("Write to file " + outputFile.getAbsolutePath() + "\r\n");
txtLog.AppendText("Write to file " + outputFile.getAbsolutePath() + "\n");
XUserAssertionRequestSerializerImpl serializer = new XUserAssertionRequestSerializerImpl();
String xmlString = serializer.toXmlString(aXUserAssertionRequest);
......@@ -316,16 +339,16 @@ namespace eHealthConnectorDemo
int counter = 1;
File outputFile = new File(getPathDir(aOutputPath),
aXUserAssertionResponse.getClass().getSimpleName() + "_" + counter + ".xml");
aXUserAssertionResponse.getClass().getSimpleName() + "_" + counter + FN_EXT);
while (outputFile.exists())
{
++counter;
outputFile = new File(getPathDir(aOutputPath),
aXUserAssertionResponse.getClass().getSimpleName() + "_" + counter
+ ".xml");
+ FN_EXT);
}
txtLog.AppendText("Write to file " + outputFile.getAbsolutePath() + "\r\n");
txtLog.AppendText("Write to file " + outputFile.getAbsolutePath() + "\n");
XUserAssertionResponseSerializerImpl serializer = new XUserAssertionResponseSerializerImpl();
String xmlString = serializer.toXmlString(aXUserAssertionResponse);
......@@ -339,5 +362,7 @@ namespace eHealthConnectorDemo
log.error("Error", t);
}
}
}
}
\ No newline at end of file
......@@ -15,9 +15,6 @@
*
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace eHealthConnectorDemo
{
......@@ -71,5 +68,18 @@ namespace eHealthConnectorDemo
java.lang.Runtime.getRuntime().gc();
System.GC.Collect();
}
/**
* Writes the current content of the user outoutl Log to the console
*/
public static void updateConsole(System.Windows.Forms.TextBox txtLog)
{
byte[] utf8bytes = System.Text.Encoding.UTF8.GetBytes(txtLog.Text);
byte[] win1252bytes = System.Text.Encoding.Convert(System.Text.Encoding.UTF8, System.Text.Encoding.GetEncoding("windows-1252"), utf8bytes);
System.Console.Write(System.Text.Encoding.Default.GetString(win1252bytes));
txtLog.Text = "";
}
}
}
......@@ -172,9 +172,9 @@ namespace eHealthConnectorDemo
this.optDemoDocConsumer_A_all = new System.Windows.Forms.RadioButton();
this.txtDemoDocConsumerLog = new System.Windows.Forms.TextBox();
this.btnDemoDocConsumer = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.tab_DemoXua = new System.Windows.Forms.TabPage();
this.btnDemoXua = new System.Windows.Forms.Button();
this.txtDemoXuaLog = new System.Windows.Forms.TextBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.opt_Privacy_Policy_Feed_to_eHealth_Suisse_PPQ_Repository_Simulator = new System.Windows.Forms.RadioButton();
this.opt_Privacy_Policy_Query_to_eHealth_Suisse_PPQ_Repository_Simulator = new System.Windows.Forms.RadioButton();
......@@ -182,8 +182,8 @@ namespace eHealthConnectorDemo
this.opt_IdP_Authentication_Request_By_HTTPPOST_using_the_HIN_Client_to_authenticate_on_IdP_of_the_commercial_product_of_HIN = new System.Windows.Forms.RadioButton();
this.opt_IdP_Authentication_Request_By_HTTPPOST_and_custom_protocol_handler = new System.Windows.Forms.RadioButton();
this.opt_IdP_Authentication_Request_By_SOAP_to_eHealthSuisse_IdP_simulator = new System.Windows.Forms.RadioButton();
this.btnDemoXua = new System.Windows.Forms.Button();
this.txtDemoXuaLog = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.tabEHCDemo.SuspendLayout();
this.tab_CDACHDemos.SuspendLayout();
this.grpCDACHDemos.SuspendLayout();
......@@ -1703,20 +1703,6 @@ namespace eHealthConnectorDemo
this.btnDemoDocConsumer.UseVisualStyleBackColor = true;
this.btnDemoDocConsumer.Click += new System.EventHandler(this.btnDemoDocConsumer_Click);
//
// label2
//
this.label2.Location = new System.Drawing.Point(0, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(100, 23);
this.label2.TabIndex = 0;
//
// label9
//
this.label9.Location = new System.Drawing.Point(0, 0);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(100, 23);
this.label9.TabIndex = 0;
//
// tab_DemoXua
//
this.tab_DemoXua.Controls.Add(this.btnDemoXua);
......@@ -1729,6 +1715,32 @@ namespace eHealthConnectorDemo
this.tab_DemoXua.Text = "DemoXua";
this.tab_DemoXua.UseVisualStyleBackColor = true;
//
// btnDemoXua
//
this.btnDemoXua.Location = new System.Drawing.Point(15, 169);
this.btnDemoXua.Margin = new System.Windows.Forms.Padding(4);
this.btnDemoXua.Name = "btnDemoXua";
this.btnDemoXua.Size = new System.Drawing.Size(115, 28);
this.btnDemoXua.TabIndex = 6;
this.btnDemoXua.Text = "Demo XUA";
this.btnDemoXua.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.btnDemoXua.UseVisualStyleBackColor = true;
this.btnDemoXua.Click += new System.EventHandler(this.btnDemoXua_Click);
//
// txtDemoXuaLog
//
this.txtDemoXuaLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtDemoXuaLog.Font = new System.Drawing.Font("Courier New", 10.2F);
this.txtDemoXuaLog.Location = new System.Drawing.Point(10, 210);
this.txtDemoXuaLog.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.txtDemoXuaLog.Multiline = true;
this.txtDemoXuaLog.Name = "txtDemoXuaLog";
this.txtDemoXuaLog.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.txtDemoXuaLog.Size = new System.Drawing.Size(1069, 503);
this.txtDemoXuaLog.TabIndex = 7;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.opt_Privacy_Policy_Feed_to_eHealth_Suisse_PPQ_Repository_Simulator);
......@@ -1789,11 +1801,13 @@ namespace eHealthConnectorDemo
// opt_IdP_Authentication_Request_By_HTTPPOST_and_custom_protocol_handler
//
this.opt_IdP_Authentication_Request_By_HTTPPOST_and_custom_protocol_handler.AutoSize = true;
this.opt_IdP_Authentication_Request_By_HTTPPOST_and_custom_protocol_handler.Enabled = false;
this.opt_IdP_Authentication_Request_By_HTTPPOST_and_custom_protocol_handler.Location = new System.Drawing.Point(6, 48);
this.opt_IdP_Authentication_Request_By_HTTPPOST_and_custom_protocol_handler.Name = "opt_IdP_Authentication_Request_By_HTTPPOST_and_custom_protocol_handler";
this.opt_IdP_Authentication_Request_By_HTTPPOST_and_custom_protocol_handler.Size = new System.Drawing.Size(488, 21);
this.opt_IdP_Authentication_Request_By_HTTPPOST_and_custom_protocol_handler.Size = new System.Drawing.Size(734, 21);
this.opt_IdP_Authentication_Request_By_HTTPPOST_and_custom_protocol_handler.TabIndex = 1;
this.opt_IdP_Authentication_Request_By_HTTPPOST_and_custom_protocol_handler.Text = "IdP Authentication Request By HTTP-POST and custom protocol handler";
this.opt_IdP_Authentication_Request_By_HTTPPOST_and_custom_protocol_handler.Text = "IdP Authentication Request By HTTP-POST and custom protocol handler (does not wor" +
"k on Windows machines)";
this.opt_IdP_Authentication_Request_By_HTTPPOST_and_custom_protocol_handler.UseVisualStyleBackColor = true;
//
// opt_IdP_Authentication_Request_By_SOAP_to_eHealthSuisse_IdP_simulator
......@@ -1808,31 +1822,19 @@ namespace eHealthConnectorDemo
this.opt_IdP_Authentication_Request_By_SOAP_to_eHealthSuisse_IdP_simulator.Text = "IdP Authentication Request By SOAP to eHealthSuisse IdP simulator";
this.opt_IdP_Authentication_Request_By_SOAP_to_eHealthSuisse_IdP_simulator.UseVisualStyleBackColor = true;
//
// btnDemoXua
// label2
//
this.btnDemoXua.Location = new System.Drawing.Point(15, 169);
this.btnDemoXua.Margin = new System.Windows.Forms.Padding(4);
this.btnDemoXua.Name = "btnDemoXua";
this.btnDemoXua.Size = new System.Drawing.Size(115, 28);
this.btnDemoXua.TabIndex = 6;
this.btnDemoXua.Text = "Demo XUA";
this.btnDemoXua.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.btnDemoXua.UseVisualStyleBackColor = true;
this.btnDemoXua.Click += new System.EventHandler(this.btnDemoXua_Click);
this.label2.Location = new System.Drawing.Point(0, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(100, 23);
this.label2.TabIndex = 0;
//
// txtDemoXuaLog
// label9
//
this.txtDemoXuaLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtDemoXuaLog.Font = new System.Drawing.Font("Courier New", 10.2F);
this.txtDemoXuaLog.Location = new System.Drawing.Point(10, 210);
this.txtDemoXuaLog.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.txtDemoXuaLog.Multiline = true;
this.txtDemoXuaLog.Name = "txtDemoXuaLog";
this.txtDemoXuaLog.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.txtDemoXuaLog.Size = new System.Drawing.Size(1069, 503);
this.txtDemoXuaLog.TabIndex = 7;
this.label9.Location = new System.Drawing.Point(0, 0);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(100, 23);
this.label9.TabIndex = 0;
//
// MainForm
//
......
......@@ -1407,27 +1407,27 @@ namespace eHealthConnectorDemo
Application.DoEvents();
if (opt_IdP_Authentication_Request_By_SOAP_to_eHealthSuisse_IdP_simulator.Checked)
{
demo.doDemo("--IdpSoapEhs -u=aamrein -p=azerty -o=demoxua-out-dotnet/idp".Split(" ".ToCharArray()[0]));
demo.doDemo("--IdpSoapEhs -u=aamrein -p=azerty -o=demoxua-out/idp".Split(" ".ToCharArray()[0]));
}
if (opt_IdP_Authentication_Request_By_HTTPPOST_and_custom_protocol_handler.Checked)
{
demo.doDemo("--IdpProtoSoe -y=ehcdemo -o=demoxua-out-dotnet/idp".Split(" ".ToCharArray()[0]));
demo.doDemo("--IdpProtoSoe -y=ehcdemo -o=demoxua-out/idp".Split(" ".ToCharArray()[0]));
}
if (opt_IdP_Authentication_Request_By_HTTPPOST_using_the_HIN_Client_to_authenticate_on_IdP_of_the_commercial_product_of_HIN.Checked)
{
demo.doDemo("--IdpHttpHinClient -x=localhost:5016 -k=hin-user-keystore.p12:password:pkcs12:\"alias\" -o=demoxua-out-dotnet/idp".Split(" ".ToCharArray()[0]));
demo.doDemo("--IdpHttpHinClient -x=localhost:5016 -k=hin-user-keystore.p12:password:pkcs12:\"alias\" -o=demoxua-out/idp".Split(" ".ToCharArray()[0]));
}
if (opt_XUser_Assertion_Request_to__eHealth_Suisse_XAP_Simulator.Checked)
{
demo.doDemo("--XapEhs -i=rsc/demoXua/xap/ehs_xaprequest_input.xml -o=demoxua-out-dotnet/xap".Split(" ".ToCharArray()[0]));
demo.doDemo("--XapEhs -i=rsc/demoXua/xap/ehs_xaprequest_input.xml -o=demoxua-out/xap".Split(" ".ToCharArray()[0]));
}
if (opt_Privacy_Policy_Query_to_eHealth_Suisse_PPQ_Repository_Simulator.Checked)
{
demo.doDemo("--ChPpqEhs -m=query -i=rsc/demoXua/ppq/ehs_ppqrequest_input.xml -o=demoxua-out-dotnet/ppq".Split(" ".ToCharArray()[0]));
demo.doDemo("--ChPpqEhs -m=query -i=rsc/demoXua/ppq/ehs_ppqrequest_input.xml -o=demoxua-out/ppq".Split(" ".ToCharArray()[0]));
}
if (opt_Privacy_Policy_Feed_to_eHealth_Suisse_PPQ_Repository_Simulator.Checked)
{
demo.doDemo("-ChPpqEhs -m=add -n=rsc/demoXua/ppf/ehs_addpolicy.xml -i=rsc/demoXua/ppq/ehs_ppqrequest_input.xml -o=demoxua-out-dotnet/ppf".Split(" ".ToCharArray()[0]));
demo.doDemo("-ChPpqEhs -m=add -n=rsc/demoXua/ppf/ehs_addpolicy.xml -i=rsc/demoXua/ppq/ehs_ppqrequest_input.xml -o=demoxua-out/ppf".Split(" ".ToCharArray()[0]));
}
Application.DoEvents();
......
......@@ -659,10 +659,7 @@ namespace eHealthConnectorDemo
demo = Demos.Unknown;
break;
}
byte[] utf8bytes = System.Text.Encoding.UTF8.GetBytes(txtLog.Text);
byte[] win1252bytes = System.Text.Encoding.Convert(System.Text.Encoding.UTF8, System.Text.Encoding.GetEncoding("windows-1252"), utf8bytes);
System.Console.Write(System.Text.Encoding.Default.GetString(win1252bytes));
DotNetUtil.updateConsole(txtLog);
System.Console.WriteLine("----------------------------------------");
System.Console.WriteLine("Demo finished");
}
......@@ -1099,11 +1096,11 @@ namespace eHealthConnectorDemo
*/
private static void demoXua(String[] args)
{
//DemoXua demo = new DemoXua(rscDir, txtLog);
DemoXua demo = new DemoXua(rscDir, txtLog);
//String[] demoArgs = new String[args.length - 1];
//System.arraycopy(args, 1, demoArgs, 0, demoArgs.length);
//demo.doDemo(demoArgs);
String[] demoArgs = new String[args.Length - 1];
java.lang.System.arraycopy(args, 1, demoArgs, 0, demoArgs.Length);
demo.doDemo(demoArgs);
}
......
......@@ -21,7 +21,7 @@
<appender name="LogFileAppender" class="org.apache.log4j.FileAppender">
<param name="File" value="logs/ehealthconnectordemo.log" />
<!-- remove this entry if you want to debug:-->
<param name="Threshold" value="DEBUG" />
<param name="Threshold" value="FATAL" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %r [%t] %-5p %c %x - %m%n"/>
</layout>
......@@ -34,14 +34,6 @@
<param name="ConversionPattern" value="%d %r [%t] %-5p %c %x - %m%n"/>
</layout>
</appender>
<category name="org.ehealth_connector.security">
<level value="DEBUG" />
<appender-ref ref="LogFileAppender" />
</category>
<category name="org.openhealthtools.ihe.xua">
<level value="DEBUG" />
<appender-ref ref="LogFileAppender" />
</category>
<category name="httpclient">
<level value="DEBUG" />
......@@ -49,7 +41,7 @@
</category>
<root>
<priority value="WARN" />
<priority value="DEBUG" />
<!-- ignore STDOUT appender in order to switch off console logging -->
<appender-ref ref="LogFileAppender" />
</root>
......
......@@ -42,6 +42,12 @@ import org.slf4j.LoggerFactory;
*/
public class DemoXuaOutputLogger {
/**
* The fn extension (_Java here and _Dotnet in the .Net demo allows
* efficient comparison in the test scripts).
*/
private static String FN_EXT = "_Java.xml";
/** The logger. */
protected Logger log = LoggerFactory.getLogger(DemoXuaOutputLogger.class);
......@@ -173,7 +179,7 @@ public class DemoXuaOutputLogger {
final byte[] xmlArray = serializer.toXmlByteArray(baseElement);
final File outputFile = new File(getPathDir(aOutputFile),
baseElement.getClass().getSimpleName() + ".xml");
baseElement.getClass().getSimpleName() + FN_EXT);
System.out.print("Write to file " + outputFile.getAbsolutePath() + "\n");
final FileOutputStream os = new FileOutputStream(outputFile);
......@@ -215,11 +221,11 @@ public class DemoXuaOutputLogger {
try {
int counter = 1;
File outputFile = new File(getPathDir(aOutputPath),
response.getClass().getSimpleName() + "_" + counter + ".xml");
response.getClass().getSimpleName() + "_" + counter + FN_EXT);
while (outputFile.exists()) {
++counter;
outputFile = new File(getPathDir(aOutputPath),
response.getClass().getSimpleName() + "_" + counter + ".xml");
response.getClass().getSimpleName() + "_" + counter + FN_EXT);
}
System.out.print("Write to file " + outputFile.getAbsolutePath() + "\n");
final PrivacyPolicyQueryResponseSerializerImpl serializer = new PrivacyPolicyQueryResponseSerializerImpl();
......@@ -246,11 +252,11 @@ public class DemoXuaOutputLogger {
try {
int counter = 1;
File outputFile = new File(getPathDir(aOutputPath),
aXUserAssertionRequest.getClass().getSimpleName() + "_" + counter + ".xml");
aXUserAssertionRequest.getClass().getSimpleName() + "_" + counter + FN_EXT);
while (outputFile.exists()) {
++counter;
outputFile = new File(getPathDir(aOutputPath),
aXUserAssertionRequest.getClass().getSimpleName() + "_" + counter + ".xml");
aXUserAssertionRequest.getClass().getSimpleName() + "_" + counter + FN_EXT);
}
System.out.print("Write to file " + outputFile.getAbsolutePath() + "\n");
......@@ -280,12 +286,12 @@ public class DemoXuaOutputLogger {
int counter = 1;
File outputFile = new File(getPathDir(aOutputPath),
aXUserAssertionResponse.getClass().getSimpleName() + "_" + counter + ".xml");
aXUserAssertionResponse.getClass().getSimpleName() + "_" + counter + FN_EXT);
while (outputFile.exists()) {
++counter;
outputFile = new File(getPathDir(aOutputPath),
aXUserAssertionResponse.getClass().getSimpleName() + "_" + counter
+ ".xml");
+ FN_EXT);
}
System.out.print("Write to file " + outputFile.getAbsolutePath() + "\n");
......
......@@ -17,6 +17,9 @@
*/
package org.ehealth_connector.security.communication.ch.impl;
import java.util.ArrayList;
import java.util.List;
import org.ehealth_connector.security.ch.ppq.PrivacyPolicyFeed;
import org.ehealth_connector.security.ch.ppq.PrivacyPolicyFeedResponse;
import org.ehealth_connector.security.ch.ppq.PrivacyPolicyQuery;
......@@ -29,6 +32,8 @@ import org.ehealth_connector.security.communication.impl.ConvenienceUserAccessAu
import org.ehealth_connector.security.core.SecurityHeaderElement;
import org.ehealth_connector.security.exceptions.ClientSendException;
import org.ehealth_connector.security.saml2.Response;
import org.opensaml.core.config.InitializationException;
import org.opensaml.core.config.Initializer;
/**
* <!-- @formatter:off -->
......@@ -41,14 +46,39 @@ import org.ehealth_connector.security.saml2.Response;
public class ConvenienceUserAccessAuthenticationChImpl
extends ConvenienceUserAccessAuthenticationImpl implements PrivacyPolicyQueryModule {
/**
* Instantiates a new instance and initializes the OpenSaml Libraries.
*
* @throws InitializationException
*/
public ConvenienceUserAccessAuthenticationChImpl() throws InitializationException {
super();
// This makes sure the Marshallers are loaded for serialisation!
// Note: the initial implementation did not work under .net. It has been
// therefore changed as follows:
List<Initializer> initializers = new ArrayList<Initializer>();
initializers.add(
new org.ehealth_connector.security.ch.epr.config.EprObjectProviderInitializer());
initializers.add(new org.opensaml.xacml.config.XMLObjectProviderInitializer());
initializers.add(new org.opensaml.xacml.profile.saml.config.XMLObjectProviderInitializer());
for (Initializer initializer : initializers) {
initializer.init();
}
}
/**
*
* {@inheritDoc}
*
* @see org.ehealth_connector.security.ch.ppq.PrivacyPolicyQueryModule#invokePrivacyPolicyFeed(org.ehealth_connector.security.core.SecurityHeaderElement,
* org.ehealth_connector.security.ch.ppq.PrivacyPolicyFeed,
* org.ehealth_connector.security.communication.ch.ppq.config.PpClientConfig)
*/
@Override
public PrivacyPolicyFeedResponse invokePrivacyPolicyFeed(SecurityHeaderElement aAssertion,
PrivacyPolicyFeed feed, PpClientConfig clientConfiguration) throws ClientSendException {
if (!initialized)
throw new ClientSendException("Opensaml Libs are not initialized");
if (!initialized) {
throw new ClientSendException("Opensaml Libs are not initialized");
}
final PpfClient client = ClientFactoryCh.getPpfClient(clientConfiguration);
return client.send(aAssertion, feed);
}
......@@ -65,9 +95,6 @@ public class ConvenienceUserAccessAuthenticationChImpl
public Response invokePrivacyPolicyQuery(SecurityHeaderElement aAssertion,
PrivacyPolicyQuery query, PpClientConfig clientConfiguration)
throws ClientSendException {
if (!initialized) {
throw new ClientSendException("Opensaml Libs are not initialized");
}
final PpqClient client = ClientFactoryCh.getPpqClient(clientConfiguration);
return client.send(aAssertion, query);
......
......@@ -17,6 +17,7 @@
*/
package org.ehealth_connector.security.communication.impl;
import java.util.ArrayList;
import java.util.List;
import org.ehealth_connector.security.authentication.AuthenticationModule;
......@@ -31,10 +32,9 @@ import org.ehealth_connector.security.communication.xua.XUserAssertionRequest;
import org.ehealth_connector.security.communication.xua.XUserAssertionResponse;
import org.ehealth_connector.security.core.SecurityHeaderElement;
import org.ehealth_connector.security.exceptions.ClientSendException;
import org.ehealth_connector.security.exceptions.LibrariesInitializationException;
import org.ehealth_connector.security.saml2.Response;
import org.opensaml.core.config.InitializationException;
import org.opensaml.core.config.InitializationService;
import org.opensaml.core.config.Initializer;
/**
* <!-- @formatter:off -->
......@@ -47,17 +47,36 @@ import org.opensaml.core.config.InitializationService;
public class ConvenienceUserAccessAuthenticationImpl
implements AuthenticationModule, XUserAssertionModule {
protected boolean initialized = false;
/**
* Instantiates a new instance and initializes the OpenSaml Libraries.
*
* @throws InitializationException
*/
public ConvenienceUserAccessAuthenticationImpl() throws InitializationException {
public void initializeLibraries() throws LibrariesInitializationException {
try {
InitializationService.initialize();
initialized = true;
} catch (final InitializationException e) {
initialized = false;
throw new LibrariesInitializationException(e);
}
// This makes sure the Marshallers are loaded for serialisation!
// Note: the initial implementation did not work under .net. It has been
// therefore changed as follows:
List<Initializer> initializers = new ArrayList<Initializer>();
initializers.add(
new org.ehealth_connector.security.hl7v3.config.XmlObjectProviderInitializer());
initializers.add(new org.opensaml.core.metrics.impl.MetricRegistryInitializer());
initializers.add(new org.opensaml.core.xml.config.GlobalParserPoolInitializer());
initializers.add(new org.opensaml.core.xml.config.XMLObjectProviderInitializer());
initializers.add(new org.opensaml.saml.config.SAMLConfigurationInitializer());
initializers.add(new org.opensaml.saml.config.XMLObjectProviderInitializer());
initializers
.add(new org.opensaml.security.config.ClientTLSValidationConfiguratonInitializer());
initializers.add(new org.opensaml.soap.config.XMLObjectProviderInitializer());
initializers.add(new org.opensaml.xmlsec.config.ApacheXMLSecurityInitializer());
initializers.add(new org.opensaml.xmlsec.config.GlobalAlgorithmRegistryInitializer());
initializers.add(new org.opensaml.xmlsec.config.GlobalSecurityConfigurationInitializer());
initializers.add(new org.opensaml.xmlsec.config.JavaCryptoValidationInitializer());
initializers.add(new org.opensaml.xmlsec.config.XMLObjectProviderInitializer());
for (Initializer initializer : initializers) {
initializer.init();
}
}
/**
......@@ -72,8 +91,6 @@ public class ConvenienceUserAccessAuthenticationImpl
public List<XUserAssertionResponse> invokeGetXUserAssertion(
SecurityHeaderElement aSecurityHeaderElement, XUserAssertionRequest aRequest,
XuaClientConfig clientConfiguration) throws ClientSendException {
if (!initialized)
throw new ClientSendException("Opensaml Libs are not initialized");
final XuaClient client = ClientFactory.getXuaClient(clientConfiguration);
return client.send(aSecurityHeaderElement, aRequest);
}
......@@ -88,8 +105,6 @@ public class ConvenienceUserAccessAuthenticationImpl
@Override
public Response invokeUserAuthentication(AuthnRequest aAuthnRequest,
IdpClientConfig clientConfiguration) throws ClientSendException {
if (!initialized)
throw new ClientSendException("Opensaml Libs are not initialized");
final IdpClient client = ClientFactory.getIdpClient(clientConfiguration);
return client.send(aAuthnRequest);