aboutsummaryrefslogtreecommitdiff
path: root/openssl/agent/pkcs11/url.test.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'openssl/agent/pkcs11/url.test.cxx')
-rw-r--r--openssl/agent/pkcs11/url.test.cxx46
1 files changed, 46 insertions, 0 deletions
diff --git a/openssl/agent/pkcs11/url.test.cxx b/openssl/agent/pkcs11/url.test.cxx
new file mode 100644
index 0000000..501137a
--- /dev/null
+++ b/openssl/agent/pkcs11/url.test.cxx
@@ -0,0 +1,46 @@
+// file : openssl/agent/pkcs11/url.test.cxx -*- C++ -*-
+// copyright : Copyright (c) 2014-2018 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+#include <iostream>
+
+#include <openssl/agent/pkcs11/url.hxx>
+
+// Usage: argv[0]
+//
+// Create pkcs11::url objects from stdin lines, and for each of them print its
+// string representation to stdout, one per line.
+//
+int
+main ()
+{
+ using namespace std;
+ using namespace openssl;
+ using namespace openssl::agent::pkcs11;
+
+ cin.exceptions (ios::badbit);
+ cout.exceptions (ios::failbit | ios::badbit);
+
+ try
+ {
+ string s;
+ while (!eof (getline (cin, s)))
+ {
+ url u (s);
+
+ // Validate the URL attributes.
+ //
+ identity idn (u);
+ access acc (u);
+
+ cout << u.string () << endl;
+ }
+
+ return 0;
+ }
+ catch (const exception& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+}