aboutsummaryrefslogtreecommitdiff
path: root/openssl/agent/pkcs11/url.test.cxx
blob: 0e5c614c4a158634ffa468fac4d659c7eecca8ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// file      : openssl/agent/pkcs11/url.test.cxx -*- C++ -*-
// 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.
      //
      agent::pkcs11::identity idn (u);
      agent::pkcs11::access   acc (u);

      cout << u << endl;
    }

    return 0;
  }
  catch (const exception& e)
  {
    cerr << e << endl;
    return 1;
  }
}