Skip to content

Commit

Permalink
support for importCert
Browse files Browse the repository at this point in the history
  • Loading branch information
dforsber committed Jul 29, 2017
1 parent e36eb98 commit 5d5f35f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
17 changes: 13 additions & 4 deletions wscli-php-sdk/src/WsCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,20 @@ private function handleCerts($api, $cmd)
$this->log->debug(print_r($resp, true));
return $resp;
case "importCert":
$error = $this->checkArgs(['apikey', 'idtoken', 'certpemdata']);
$error = $this->checkArgs(['apikey', 'idtoken', 'bank', 'certificate', 'privatekey']);
if ($this->opts['bank'] === "danskebank") {
$error = $this->checkArgs(['apikey', 'idtoken', 'bank', 'certificate', 'privatekey', 'enccertificate', 'encprivatekey']);
}
if ($error) {
return $error;
}
$this->log->error("Unimplemented API command");
return 3;
$resp = $this->${"api"}->${"cmd"}(
$this->opts['idtoken'],
$this->getBodyParams(),
$this->opts['bank']
);
$this->log->debug(print_r($resp, true));
return $resp;
case "exportCert":
$error = $this->checkArgs(['apikey', 'idtoken', 'pgpkeyid', 'outfilename']);
if ($error) {
Expand Down Expand Up @@ -555,7 +563,6 @@ private function getOptsFromConfig()
$config_args = yaml_parse(file_get_contents($this->config_filename));
if ($config_args === false) {
$this->log->error("Config file YAML parse error; " . $this->config_filename);

return -1;
}
if ($config_args['settings']) {
Expand All @@ -568,6 +575,8 @@ private function getOptsFromConfig()
$this->log->info("Removing old token from config");
$this->updateConfig("idtoken: \"\"");
$this->updateConfig("idtokenexpiry: \"\"");
$config_args['settings']['idtoken'] = "";
$config_args['settings']['idtokenexpiry'] = "";
}
if (strlen($config_args['settings']['idtoken']) <= 0) {
$this->log->debug("Removing idtoken from settings; " . $config_args['settings']['idtoken']);
Expand Down
9 changes: 4 additions & 5 deletions wscli-php/src/wscli.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
wscli files deleteFile [-c CONF] [-a APIKEY] [-i IDTOKEN] [-b BANK] [--filetype=<filetype>] [--filereference=<fileref>]
wscli files uploadFile [-c CONF] [-a APIKEY] [-i IDTOKEN] [-b BANK] [--filetype=<filetype>] [--filename=<filename>]
[--filecontents=<filecontents>]
wscli certs listCerts [-c CONF] [-a APIKEY] [-i IDTOKEN] [-b BANK]
wscli certs importCert [-c CONF] [-a APIKEY] [-i IDTOKEN] [--certificate=<pem>] [--privatekey=<pem>] [--enccertificate=<pem>] [--encprivatekey=<pem>]
wscli certs listCerts [-c CONF] [-a APIKEY] [-i IDTOKEN]
wscli certs exportCert [-c CONF] [-a APIKEY] [-i IDTOKEN] [-b BANK] [--pgpkeyid=<pgpkeyid>] [--outfilename=<outfilename>]
wscli certs shareCerts [-c CONF] [-a APIKEY] [-i IDTOKEN] [--extemail=<extemail>]
wscli certs unshareCerts [-c CONF] [-a APIKEY] [-i IDTOKEN] [--extemail=<extemail>]
wscli certs enrollCert [-c CONF] [-a APIKEY] [-i IDTOKEN] [-b BANK] [--pincode=<pincode>] [--company=<company>]
[--wsuserid=<wsuserid>] [--wstargetid=<wstargetid>]
wscli certs enrollCert [-c CONF] [-a APIKEY] [-i IDTOKEN] [-b BANK] [--pincode=<pincode>] [--company=<company>] [--wsuserid=<wsuserid>] [--wstargetid=<wstargetid>]
wscli certs importCert [-c CONF] [-a APIKEY] [-i IDTOKEN] [-b BANK] [--certificate=<pem>] [--privatekey=<pem>]
[--wsuserid=<wsuserid>] [--wstargetid=<wstargetid>] [--enccertificate=<pem>] [--encprivatekey=<pem>]
wscli pgp listKeys [-c CONF] [-a APIKEY] [-i IDTOKEN]
wscli pgp uploadKey [-c CONF] [-a APIKEY] [-i IDTOKEN] [--pgpkeycontents=<pgpkeycontents>]
wscli pgp deleteKey [-c CONF] [-a APIKEY] [-i IDTOKEN] [--pgpkeyid=<pgpkeyid>]
Expand Down Expand Up @@ -81,7 +81,6 @@
--wsuserid=<wsuserid> Use wsuserid in certificate enrollment
--pgpkeyid=<pgpkeyid> PGP/GPG Key Id
--outfilename=<outfilename> Output filename for exported cert in PEM format
--certpemdata=<certpemdata> Import cert data in PEM format
--pgpkeycontents=<pgpkeycontents> PGP key contents for PGP key upload
--certificate=<pem> Imported certificate in PEM format
--privatekey=<pem> Imported private key in PEM format, must match with certificate
Expand Down

0 comments on commit 5d5f35f

Please sign in to comment.