~ubuntu-branches/ubuntu/trusty/nordugrid-arc/trusty

« back to all changes in this revision

Viewing changes to src/hed/libs/credential/Credential.h

  • Committer: Package Import Robot
  • Author(s): Mattias Ellert
  • Date: 2013-11-29 13:39:10 UTC
  • mfrom: (3.1.16 sid)
  • Revision ID: package-import@ubuntu.com-20131129133910-sy6ayoavphc5hozs
Tags: 4.0.0-1
4.0.0 Release (Closes: #715131) (LP: #1049798)

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#include <arc/UserConfig.h>
18
18
 
19
19
#include <arc/credential/CertUtil.h>
 
20
#include <arc/credential/PasswordSource.h>
20
21
 
21
22
namespace Arc {
22
23
 
38
39
};
39
40
 
40
41
typedef enum {CRED_PEM, CRED_DER, CRED_PKCS, CRED_UNKNOWN} Credformat;
 
42
typedef enum { SIGN_DEFAULT = 0, SIGN_SHA1, SIGN_SHA224, SIGN_SHA256, SIGN_SHA384, SIGN_SHA512 } Signalgorithm;
41
43
 
42
44
/**Logger to be used by all modules of credentials library*/
43
45
extern Logger CredentialLogger;
81
83
               const std::string& extfile, const std::string& extsect,
82
84
               const std::string& passphrase4key);
83
85
 
 
86
    /** Same as previuos constructor but allows password to be
 
87
    * supplied from different sources.
 
88
    */
 
89
    Credential(const std::string& CAfile, const std::string& CAkey,
 
90
               const std::string& CAserial,
 
91
               const std::string& extfile, const std::string& extsect,
 
92
               PasswordSource& passphrase4key);
 
93
 
84
94
    /**Constructor, specific constructor for proxy certificate, only acts as a
85
95
    * container for constraining certificate signing and/or generating certificate
86
96
    * request (only keybits is useful for creating certificate request), is meaningless
143
153
               const std::string& cafile, const std::string& passphrase4key = "",
144
154
               const bool is_file = true);
145
155
 
 
156
    /** Same as previuos constructor but allows password to be
 
157
    * supplied from different sources.
 
158
    */
 
159
    Credential(const std::string& cert, const std::string& key, const std::string& cadir,
 
160
               const std::string& cafile, PasswordSource& passphrase4key,
 
161
               const bool is_file = true);
 
162
 
146
163
    /**Constructor, specific constructor for usual certificate, constructing from
147
164
    * information in UserConfig object. Only acts as a container for parsing the 
148
165
    * certificate and key files, is meaningless for any other use. this constructor 
152
169
    */
153
170
    Credential(const UserConfig& usercfg, const std::string& passphrase4key = "");
154
171
 
 
172
    /** Same as previuos constructor but allows password to be
 
173
    * supplied from different sources.
 
174
    */
 
175
    Credential(const UserConfig& usercfg, PasswordSource& passphrase4key);
 
176
 
155
177
    /**Initiate nid for proxy certificate extension*/
156
178
    static void InitProxyCertInfo(void);
157
179
 
164
186
    /**General method for adding a new nid into openssl's global const*/
165
187
    void AddCertExtObj(std::string& sn, std::string& oid);
166
188
 
 
189
    void SetSigningAlgorithm(Signalgorithm signing_algorithm = SIGN_DEFAULT);
 
190
 
 
191
    void SetKeybits(int keybits = 0);
 
192
 
167
193
    static std::string NoPassword(void) { return std::string("\0",1); };
168
194
 
169
195
  private:
172
198
    Credential(const Credential&);
173
199
 
174
200
    void InitCredential(const std::string& cert, const std::string& key, const std::string& cadir,
175
 
               const std::string& cafile, const std::string& passphrase4key, const bool is_file);
 
201
               const std::string& cafile, PasswordSource& passphrase4key, const bool is_file);
176
202
 
177
203
    /**load key from argument keybio, and put key information into argument pkey */
178
 
    void loadKeyString(const std::string& key, EVP_PKEY* &pkey, const std::string& passphrase = "");
179
 
    void loadKeyFile(const std::string& keyfile, EVP_PKEY* &pkey, const std::string& passphrase = "");
 
204
    //void loadKeyString(const std::string& key, EVP_PKEY* &pkey, const std::string& passphrase = "");
 
205
    void loadKeyString(const std::string& key, EVP_PKEY* &pkey, PasswordSource& passphrase);
 
206
    //void loadKeyFile(const std::string& keyfile, EVP_PKEY* &pkey, const std::string& passphrase = "");
 
207
    void loadKeyFile(const std::string& keyfile, EVP_PKEY* &pkey, PasswordSource& passphrase);
180
208
    //void loadKey(BIO* bio, EVP_PKEY* &pkey, const std::string& passphrase = "", const std::string& prompt_info = "", const bool is_file = true);
181
209
 
182
210
    /**load certificate from argument certbio, and put certificate information into
272
300
     */
273
301
    std::string GetCAName(void) const;
274
302
 
 
303
    /**Get signing algorithm used to sign the certificate attached to this object*/
 
304
    Signalgorithm GetSigningAlgorithm(void) const;
 
305
 
 
306
    /**Get key size of the certificate attached to this object*/
 
307
    int GetKeybits(void) const;
 
308
 
275
309
    /**Get the proxy policy attached to the "proxy certificate
276
310
     * information" extension of the proxy certificate
277
311
     */
290
324
     */
291
325
    bool OutputPrivatekey(std::string &content,  bool encryption = false, const std::string& passphrase ="");
292
326
 
 
327
    /**Output the private key into string
 
328
     * @param content Filled with private key content
 
329
     * @param encryption whether encrypt the output private key or not
 
330
     * @param passphrase the source for passphrase to encrypt the output private key
 
331
     */
 
332
    bool OutputPrivatekey(std::string &content,  bool encryption, PasswordSource& passphrase);
 
333
 
293
334
    /**Output the public key into string*/
294
335
    bool OutputPublickey(std::string &content);
295
336