summaryrefslogtreecommitdiffstats
path: root/tools/nfast-find
blob: 8e0fc16897d55971f55e743fa84221f031df9623 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/sh

verbose=
token=
password_file=

# read the options
TEMP=`getopt -o t:f:v --long help -n 'nfast-find' -- "$@"`
eval set -- "$TEMP"

# extract options and their arguments into variables.
while true ; do
    case "$1" in
        -t)
            token=$2
            shift 2
            ;;
        -f)
            password_file=$2
            shift 2
            ;;
        --help)
            echo "Usage: nfast-find <prefix> -f <password file> [OPTIONS]"
            echo
            echo "Options:"
            echo " -t <token name>      Token name."
            echo " -f <password file>   File containing token password."
            echo " -v                   Run in verbose mode."
            echo " --help               Show help message."
            exit 0
            ;;
        -v)
            verbose=1
            shift
            ;;
        --)
            shift
            break
            ;;
        *)
            echo "Error: invalid option $1" >&2
            echo "Run nfast-find --help for help." >&2
            exit 1
            ;;
    esac
done

if [[ "$verbose" != "" ]]
then
    echo "token name: $token"
    echo "password file: $password_file"
fi

if [[ "$token" == "" ]]
then
    echo "Error: missing token name" >&2
    echo "Run nfast-find --help for help." >&2
    exit 1
fi

if [[ "$password_file" == "" ]]
then
    echo "Error: missing password file" >&2
    echo "Run nfast-find --help for help." >&2
    exit 1
fi

password="`cat $password_file`"

/opt/nfast/bin/cklist -s "$token" -p "$password" | egrep "CKA_CLASS|CKA_LABEL|CKA_NFKM_ID"