Debian Codegraph @

script/ecaccess-certificate-create

raw
1 #!/usr/bin/perl -w
2 #
3 # ecaccess-certificate-create: Create Certificate for the ECtools
4 #
5 # [email protected] - 2010-10-15
6
7 use ECMWF::ECaccess;
8 use Getopt::Long;
9 use Pod::Usage;
10 use Term::ReadKey;
11
12 my %opt = ( version => 0, help => 0, manual => 0, retry => 0, debug => 0 );
13
14 pod2usage( -noperldoc => 1, -exit => 1, verbose => 1 ) if !GetOptions(
15 \%opt,
16 qw(
17 version
18 help|?
19 manual
20 retry=i
21 debug
22 )
23 );
24
25 # Display version if requested
26 die ECMWF::ECaccess->VERSION . "\n" if ( $opt{version} );
27
28 pod2usage( -noperldoc => 1, -exit => 1, verbose => 1 ) if ( $opt{help} );
29 pod2usage( -noperldoc => 1, -exit => 1, verbose => 2 ) if ( $opt{manual} );
30
31 my $userid = $ARGV[0];
32
33 # Get the userid if not specified
34 if ( not($userid) ) {
35 print "Please enter your user-id: ";
36 $userid = <STDIN>;
37 chomp($userid);
38 }
39
40 # Get the passcode
41 print "Your passcode: ";
42 ReadMode('noecho') if ( -t STDIN && -t STDOUT );
43 my $passcode = <STDIN>;
44 ReadMode('normal') if ( -t STDIN && -t STDOUT );
45 chomp($passcode);
46 print "\n";
47
48 # Create the ECaccess Controler
49 my $ecaccess = ECMWF::ECaccess->new( $opt{retry}, $opt{debug});
50
51 # Create the certificate
52 $ecaccess->getCertificate( $userid, $passcode );
53
54 __END__
55 =head1 NAME
56
57 ecaccess-certificate-create - Create Certificate for the ECtools
58
59 =head1 SYNOPSIS
60
61 B<ecaccess-certificate-create -version|-help|-manual>
62
63 B<ecaccess-certificate-create [-debug] [>I<user-id>B<]>
64
65 =head1 DESCRIPTION
66
67 This command allow creating a Certificate with your ECMWF User Identifier and
68 Security Token. The Certificate is required to use the ECtools. It is stored
69 in your home directory ($HOME/.eccert.crt). If you don't specify your ECMWF
70 User Identifier on the command-line then you will be prompted for it.
71
72 =head1 ARGUMENTS
73
74 =over 8
75
76 =item I<user-id> (optional)
77
78 The ECMWF User Identifier to use.
79
80 =back
81
82 =head1 OPTIONS
83
84 =over 8
85
86 =item B<-version>
87
88 Display version number and exits.
89
90 =item B<-help>
91
92 Print a brief help message and exits.
93
94 =item B<-manual>
95
96 Prints the manual page and exits.
97
98 =item B<-retry> I<count>
99
100 Number of SSL connection retries per 5s to ECMWF. This parameter only apply to the
101 initial SSL connection initiated by the command to the ECMWF server. It does not
102 apply to all the subsequent requests made afteward as it is mainly targeting errors
103 that can happen from time to time during the SSL handshake. Default is no retry.
104
105 =item B<-debug>
106
107 Display the SOAP and SSL messages exchanged.
108
109 =back
110
111 =head1 EXAMPLES
112
113 B<ecaccess-certificate-create> I<xyz>
114
115 Create a new ECaccess Certificate for the ECMWF User Identifier I<xyz> and store it
116 in the "$HOME/.eccert.crt" File.
117
118 =head1 SEE ALSO
119
120 B<ecaccess-certificate-list> and B<ecaccess>.
121
122 =cut