From c3f9ccd914117b4619b97abcdc3e19e841221f4f Mon Sep 17 00:00:00 2001
From: Jack Magne <jmagne@localhost.localdomain>
Date: Thu, 9 Jul 2015 17:32:19 -0700
Subject: [PATCH] The man page for tpsclient does not exist.

Ticket #1629

Provide a man page for the tool "tpsclient".
---
 base/tps-client/CMakeLists.txt         |  11 +++
 base/tps-client/abrt_checker_21190.log |   9 ---
 base/tps-client/man/man1/tpsclient.1   | 140 +++++++++++++++++++++++++++++++++
 specs/pki-core.spec                    |   2 +-
 4 files changed, 152 insertions(+), 10 deletions(-)
 delete mode 100644 base/tps-client/abrt_checker_21190.log
 create mode 100644 base/tps-client/man/man1/tpsclient.1

diff --git a/base/tps-client/CMakeLists.txt b/base/tps-client/CMakeLists.txt
index 1778ff7..aaddb0b 100644
--- a/base/tps-client/CMakeLists.txt
+++ b/base/tps-client/CMakeLists.txt
@@ -212,3 +212,14 @@ install(
     DESTINATION
         ${SYSTEMD_ETC_INSTALL_DIR}/pki-tpsd.target.wants
 )
+
+install(
+    DIRECTORY
+        man/
+    DESTINATION
+        ${MAN_INSTALL_DIR}
+    FILE_PERMISSIONS
+        OWNER_READ OWNER_WRITE
+        GROUP_READ
+        WORLD_READ
+)
diff --git a/base/tps-client/abrt_checker_21190.log b/base/tps-client/abrt_checker_21190.log
deleted file mode 100644
index 97d259e..0000000
--- a/base/tps-client/abrt_checker_21190.log
+++ /dev/null
@@ -1,9 +0,0 @@
-Uncaught java.lang.ClassNotFoundException exception in thread "main" in a method java.lang.ClassLoader.loadClass() with signature (Ljava/lang/String;Z)Ljava/lang/Class;
-Exception in thread "main" java.lang.ClassNotFoundException: .usr.lib64.eclipse..plugins.org.eclipse.equinox.launcher_1.3.0.v20130930-1720.jar
-	at java.net.URLClassLoader$1.run(URLClassLoader.java:366) [jar:file:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.60-2.4.2.9.fc20.x86_64/jre/lib/rt.jar!/java/net/URLClassLoader$1.class]
-	at java.net.URLClassLoader$1.run(URLClassLoader.java:355) [jar:file:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.60-2.4.2.9.fc20.x86_64/jre/lib/rt.jar!/java/net/URLClassLoader$1.class]
-	at java.security.AccessController.doPrivileged(Native Method) [jar:file:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.60-2.4.2.9.fc20.x86_64/jre/lib/rt.jar!/java/security/AccessController.class]
-	at java.net.URLClassLoader.findClass(URLClassLoader.java:354) [jar:file:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.60-2.4.2.9.fc20.x86_64/jre/lib/rt.jar!/java/net/URLClassLoader.class]
-	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) [jar:file:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.60-2.4.2.9.fc20.x86_64/jre/lib/rt.jar!/java/lang/ClassLoader.class]
-	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) [jar:file:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.60-2.4.2.9.fc20.x86_64/jre/lib/rt.jar!/sun/misc/Launcher$AppClassLoader.class]
-	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) [jar:file:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.60-2.4.2.9.fc20.x86_64/jre/lib/rt.jar!/java/lang/ClassLoader.class]
diff --git a/base/tps-client/man/man1/tpsclient.1 b/base/tps-client/man/man1/tpsclient.1
new file mode 100644
index 0000000..f87afc7
--- /dev/null
+++ b/base/tps-client/man/man1/tpsclient.1
@@ -0,0 +1,140 @@
+.\" First parameter, NAME, should be all caps
+.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
+.\" other parameters are allowed: see man(7), man(1)
+.TH tpsclient 1 "Jul 8, 2015" "version 10.2" "PKI TPS tpsclient test program" Dogtag Team
+.\" Please adjust this date whenever revising the man page.
+.\"
+.\" Some roff macros, for reference:
+.\" .nh        disable hyphenation
+.\" .hy        enable hyphenation
+.\" .ad l      left justify
+.\" .ad b      justify to both left and right margins
+.\" .nf        disable filling
+.\" .fi        enable filling
+.\" .br        insert line break
+.\" .sp <n>    insert n+1 empty lines
+.\" for man page specific macros, see man(7)
+.SH NAME
+\fBtpsclient\fR \- TPS testing tool to exercise TPS server functionality, simulating a smart card. 
+
+.SH SYNOPSIS
+.nf
+\fBtpsclient\fR < <script-file-name>\fR
+\fBtpsclent\fR
+
+Note this tool currently works to simulate Secure Channel Protocol 01 , GP201 tokens. Support for SCP02/GP211 planned in future versions.
+
+.fi
+
+.SH DESCRIPTION
+.PP
+The \fBtpsclient\fR command provides a way to exercise the TPS server without a hardware token, through the use of a simple script file containing commands to the \fBtpsclient\fR engine.
+.PP
+
+.SH OPTIONS
+The only option is whether or not to provide a script file. Not providing the script argument will launch the program in interactive mode, though this is not recommended. The best way to interact with the TPS server is to provide a simple script file to \fBtpsclient\fR.
+
+.SH OPERATIONS
+The Operations are contained within the \fBtpsclient\fR script file. Some sample scirpts are provided below.
+
+.SH EXAMPLES
+\fBtpsclient\fR 
+
+This will simply run the program in interactive mode. Commands will have to be issued inside this mode one by one and is not recommended.
+
+
+List of commands inside interactive mode:
+
+.nf
+
+Output> Available Operations:
+Output> op=debug filename=<filename> - enable debugging
+Output> op=help
+Output> op=ra_enroll uid=<uid> pwd=<pwd> num_threads=<number of threads> secureid_pin=<secureid_pin> keygen=<true|false> - Enrollment Via RA
+Output> op=ra_reset_pin uid=<uid> pwd=<pwd> num_threads=<number of threads> secureid_pin=<secureid_pin> new_pin=<new_pin> - Reset Pin Via RA
+Output> op=ra_update uid=<uid> pwd=<pwd> num_threads=<number of threads> secureid_pin=<secureid_pin> new_pin=<new_pin> - Reset Pin Via RA
+Output> op=token_set <name>=<value> - Set Token Value
+Output> op=token_status - Print Token Status
+Output> op=var_get name=<name> - Get Value of Variable
+Output> op=var_list - List All Variables
+Output> op=var_set name=<name> value=<value> - Set Value to Variable
+
+.fi
+
+
+\fBtpsclient\fR < format.txt
+
+\fBtpsclient\fR < enroll.txt
+
+.SH format.txt contents:
+.nf
+
+# Set the host name of the TPS server
+op=var_set name=ra_host value=localhost.localdomain
+
+# Set the port where the TPS server is listening
+op=var_set name=ra_port value=8080
+
+# Set the URL on the TPS that responds to client token operation requests
+op=var_set name=ra_uri value=/tps/tps
+
+# Set the cuid number of our virtual token and some other values needed by TPS
+op=token_set cuid=40906145C76224192D2B msn=01020304 app_ver=6FBBC105 key_info=0101 major_ver=1 minor_ver=1
+
+# Set the global platform auth key for the virtual token
+op=token_set auth_key=404142434445464748494a4b4c4d4e4f
+
+# Set the global platform mac key for the virtual token
+op=token_set mac_key=404142434445464748494a4b4c4d4e4f
+
+# Set the global platform kek key for the virtual token
+op=token_set kek_key=404142434445464748494a4b4c4d4e4f
+
+#Issue the actual request to format our token to the TPS server.
+# Within this command we must provide the authentication userid, authentication password, and virtual token PIN value to proceed
+# Also, the "extensions" consist of extra info evaluated by TPS. In this case we declare the "type" of our virtual token.
+# The TPS uses the type to control the flow of the operation.
+
+op=ra_format uid=jmagne pwd=netscape new_pin=netscape num_threads=1  extensions=tokenType=userKey
+
+# Exit the operation and leave the program
+
+op=exit
+
+.fi
+
+.SH enroll.txt contents:
+
+.nf
+
+# Set the host name of the TPS server
+op=var_set name=ra_host value=localhost.localdomain
+
+# Set the port where the TPS server is listening
+op=var_set name=ra_port value=8080
+
+# Set the URL on the TPS that responds to client token operation requests
+op=var_set name=ra_uri value=/tps/tps
+
+# Set the cuid number of our virtual token and some other values needed by TPS
+op=token_set cuid=40906145C76224192D2B msn=01020304 app_ver=6FBBC105 key_info=0101 major_ver=1 minor_ver=1
+
+# Set the global platform auth key for the virtual token
+op=token_set auth_key=404142434445464748494a4b4c4d4e4f
+
+# Set the global platform mac key for the virtual token
+op=token_set mac_key=404142434445464748494a4b4c4d4e4f
+
+# Set the global platform kek key for the virtual token
+op=token_set kek_key=404142434445464748494a4b4c4d4e4f
+
+#Issue the actual request to format our token to the TPS server.
+# Within this command we must provide the authentication userid, authentication password, and virtual token PIN value to proceed
+# Also, the "extensions" consist of extra info evaluated by TPS. In this case we declare the "type" of our virtual token.
+# The TPS uses the type to control the flow of the operation.
+
+op=ra_enroll uid=jmagne pwd=netscape new_pin=netscape num_threads=1  extensions=tokenType=userKey
+.fi
+
+.SH COPYRIGHT
+Copyright (c) 2014 Red Hat, Inc. This is licensed under the GNU General Public License, version 2 (GPLv2). A copy of this license is available at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
diff --git a/specs/pki-core.spec b/specs/pki-core.spec
index 7e94f28..148c907 100644
--- a/specs/pki-core.spec
+++ b/specs/pki-core.spec
@@ -850,7 +850,6 @@ systemctl daemon-reload
 %{_mandir}/man1/pki-user-cert.1.gz
 %{_mandir}/man1/pki-ca-profile.1.gz
 
-
 %if %{with server}
 
 %files -n pki-server
@@ -943,6 +942,7 @@ systemctl daemon-reload
 %{_datadir}/pki/tps/webapps/
 %{_mandir}/man5/pki-tps-connector.5.gz
 %{_mandir}/man5/pki-tps-profile.5.gz
+%{_mandir}/man1/tpsclient.1.gz
 # files for native 'tpsclient'
 # REMINDER:  Remove this comment once 'tpsclient' is rewritten as a Java app
 %{_bindir}/tpsclient
-- 
2.1.0

