[Pki-devel] [PATCH] Fix NumberFormatException for tps-cert-find when given non integer value to size and start option

Geetika Kapoor gkapoor at redhat.com
Wed Jul 27 12:37:39 UTC 2016


Hi,

I tried to fix NumberFormatException when i did tps-cert-find with
non-integer/invalid range value for size and start.I was doing testing
for tps-cert and then i came across this.I thought giving some
additional info to users inplace of numberformat.I have done similar
fix  on rhel7  compile it and make a jar and test on rhel7 .I can share
that patch if needed. Below are the test result.

Before fix testing:

1. pki -h pki1.example.com -p 25080 tps-cert-find --start "gy"
NumberFormatException: For input string: "gy"

2. pki -h pki1.example.com -p 25080 tps-cert-find --size "gy"
NumberFormatException: For input string: "gy"

3. pki -p 25080 tps-cert-find --start
1789999999999999999999999999999999999999999999
NumberFormatException: For input string:
"1789999999999999999999999999999999999999999999"


After fix testing:

1. [root at pki1 ~]# pki -d /opt/rhqa_pki/certdb -c Secret123 -h
pki1.example.com -p 25080 tps-cert-find --start "gy"
Error: Enter valid integer value for size/start option
usage: tps-cert-find [FILTER] [OPTIONS...]
    --help            Show help options
    --size <size>     Page size
    --start <start>   Page start
    --token <ID>      Token ID

2. [root at pki1 ~]# pki -d /opt/rhqa_pki/certdb -c Secret123 -h
pki1.example.com -p 25080 tps-cert-find --size "hy"
Error: Enter valid integer value for size/start option
usage: tps-cert-find [FILTER] [OPTIONS...]
    --help            Show help options
    --size <size>     Page size
    --start <start>   Page start
    --token <ID>      Token ID

3. [root at pki1 ~]# pki -d /opt/rhqa_pki/certdb -c Secret123 -h
pki1.example.com -p 25080 tps-cert-find --start 1
-----------------
2 entries matched
-----------------
  Cert ID: 3d.20160720042931
  Serial Number: 0x3d
  Subject: UID=ldapuser7,O=Token Key User
  Token ID: 40906145C76224192D78
  Key Type: encryption
  Status: active
  User ID: ldapuser7
  Create Time: Wed Jul 20 04:29:31 EDT 2016
----------------------------
Number of entries returned 1
----------------------------

4. [root at pki1 ~]# pki -d /opt/rhqa_pki/certdb -c Secret123 -h
pki1.example.com -p 25080 tps-cert-find --size 1
-----------------
2 entries matched
-----------------
  Cert ID: 3c.20160720042931
  Serial Number: 0x3c
  Subject: UID=ldapuser7,O=Token Key User
  Token ID: 40906145C76224192D78
  Key Type: signing
  Status: active
  User ID: ldapuser7
  Create Time: Wed Jul 20 04:29:31 EDT 2016
----------------------------
Number of entries returned 1
----------------------------

5. [root at pki1 cert]# pki -d /opt/rhqa_pki/certdb -c Secret123 -h
pki1.example.com -p 25080 tps-cert-find --start
1789999999999999999999999999999999999999999999
Error: Enter valid integer value for size/start option
usage: tps-cert-find [FILTER] [OPTIONS...]
    --help            Show help options
    --size <size>     Page size
    --start <start>   Page start
    --token <ID>      Token ID

Thanks
Geetika
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Added-logging-inplace-of-NumberFormatException-for-t.patch
Type: text/x-patch
Size: 3166 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/pki-devel/attachments/20160727/dce90217/attachment.bin>


More information about the Pki-devel mailing list