xrootd
XrdCryptoX509.hh
Go to the documentation of this file.
1 // $Id$
2 #ifndef __CRYPTO_X509_H__
3 #define __CRYPTO_X509_H__
4 /******************************************************************************/
5 /* */
6 /* X r d C r y p t o X 5 0 9 . h h */
7 /* */
8 /* */
9 /* (c) 2005 G. Ganis , CERN */
10 /* */
11 /******************************************************************************/
12 
13 /* ************************************************************************** */
14 /* */
15 /* Abstract interface for X509 certificates. */
16 /* Allows to plug-in modules based on different crypto implementation */
17 /* (OpenSSL, Botan, ...) */
18 /* */
19 /* ************************************************************************** */
20 
21 #include <XProtocol/XPtypes.hh>
22 #include <XrdSut/XrdSutBucket.hh>
24 
25 typedef void * XrdCryptoX509data;
26 
27 // ---------------------------------------------------------------------------//
28 //
29 // X509 interface
30 // Describes one certificate
31 //
32 // ---------------------------------------------------------------------------//
34 public:
35 
36  // Certificate type
37  enum EX509Type { kUnknown = -1, kCA = 0, kEEC = 1, kProxy = 2 };
39 
40 
42  virtual ~XrdCryptoX509() { }
43 
44  // Status
45  virtual bool IsValid(int when = 0); // object correctly loaded
46  virtual bool IsExpired(int when = 0); // Expired
47 
48  // Access underlying data (in opaque form: used in chains)
49  virtual XrdCryptoX509data Opaque();
50 
51  // Access certificate key
52  virtual XrdCryptoRSA *PKI();
53  virtual void SetPKI(XrdCryptoX509data pki);
54 
55  // Export in form of bucket (for transfers)
56  virtual XrdSutBucket *Export();
57 
58  // Dump information
59  virtual void Dump();
60  const char *Type(EX509Type t = kUnknown) const
61  { return ((t == kUnknown) ? ctype[type+1] : ctype[t+1]); }
62  virtual const char *ParentFile();
63 
64  // Key strength
65  virtual int BitStrength();
66 
67  // Serial number
68  virtual kXR_int64 SerialNumber();
70 
71  // Validity interval
72  virtual int NotBefore(); // begin-validity time in secs since Epoch
73  virtual int NotAfter(); // end-validity time in secs since Epoch
74 
75  // Issuer of top certificate
76  virtual const char *Issuer();
77  virtual const char *IssuerHash(); // hash
78 
79  // Subject of bottom certificate
80  virtual const char *Subject();
81  virtual const char *SubjectHash(); // hash
82 
83  // Retrieve a given extension if there (in opaque form)
84  virtual XrdCryptoX509data GetExtension(const char *oid);
85 
86  // Verify signature
87  virtual bool Verify(XrdCryptoX509 *ref);
88 
89 private:
90 
91  static const char *ctype[4]; // Names of types
92 };
93 
94 #endif