#include <SSLIOP_Credentials.h>
Inheritance diagram for TAO::SSLIOP_Credentials:
Public Types | |
typedef SSLIOP::Credentials_ptr | _ptr_type |
typedef SSLIOP::Credentials_var | _var_type |
typedef SSLIOP::Credentials_out | _out_type |
Public Member Functions | |
SSLIOP_Credentials (::X509 *cert,::EVP_PKEY *evp) | |
Constructor. | |
::EVP_PKEY * | evp (void) |
Return a pointer to the underlying private key. | |
bool | operator== (const SSLIOP_Credentials &rhs) |
CORBA::ULong | hash (void) const |
SecurityLevel3::Credentials Methods | |
Methods required by the SecurityLevel3::Credentials interface. | |
virtual char * | creds_id (void) |
virtual SecurityLevel3::CredentialsType | creds_type (void)=0 |
virtual SecurityLevel3::CredentialsUsage | creds_usage () |
virtual TimeBase::UtcT | expiry_time (void) |
virtual SecurityLevel3::CredentialsState | creds_state () |
virtual char * | add_relinquished_listener (SecurityLevel3::RelinquishedCredentialsListener_ptr listener) |
virtual void | remove_relinquished_listener (const char *id) |
::X509 * | x509 (void) |
Return a pointer to the underlying X.509 certificate. | |
Static Public Member Functions | |
SSLIOP::Credentials_ptr | _duplicate (SSLIOP::Credentials_ptr obj) |
SSLIOP::Credentials_ptr | _narrow (CORBA::Object_ptr obj) |
SSLIOP::Credentials_ptr | _nil (void) |
Protected Member Functions | |
~SSLIOP_Credentials (void) | |
Destructor. | |
Protected Attributes | |
SSLIOP::X509_var | x509_ |
SSLIOP::EVP_PKEY_var | evp_ |
CORBA::String_var | id_ |
Credentials Identifier. | |
SecurityLevel3::CredentialsUsage | creds_usage_ |
The intended usage of the Credentials. | |
TimeBase::UtcT | expiry_time_ |
The time these Credentials expire. | |
SecurityLevel3::CredentialsState | creds_state_ |
The validity of the Credentials. |
This class encapsulates the X.509 certificate associated with a given a principal.
Definition at line 58 of file SSLIOP_Credentials.h.
|
Reimplemented from CORBA::LocalObject. Reimplemented in TAO::SSLIOP::OwnCredentials. Definition at line 65 of file SSLIOP_Credentials.h. |
|
Reimplemented from CORBA::LocalObject. Reimplemented in TAO::SSLIOP::OwnCredentials. Definition at line 63 of file SSLIOP_Credentials.h. |
|
Reimplemented from CORBA::LocalObject. Reimplemented in TAO::SSLIOP::OwnCredentials. Definition at line 64 of file SSLIOP_Credentials.h. |
|
Constructor.
Definition at line 19 of file SSLIOP_Credentials.cpp. References ACE_CString, ACE_SIZEOF_LONG_LONG, ACE_UINT64_LITERAL, EVP_PKEY, expiry_time_, CORBA::string_dup(), TimeBase::UtcT::time, and X509.
00020 : x509_ (TAO::SSLIOP::OpenSSL_traits< ::X509 >::_duplicate (cert)), 00021 evp_ (TAO::SSLIOP::OpenSSL_traits< ::EVP_PKEY >::_duplicate (evp)), 00022 id_ (), 00023 creds_usage_ (SecurityLevel3::CU_Indefinite), 00024 expiry_time_ (), 00025 creds_state_ (SecurityLevel3::CS_Invalid) 00026 { 00027 ::X509 *x = cert; 00028 00029 if (x != 0) 00030 { 00031 // We use the X.509 certificate's serial number as the 00032 // credentials Id. 00033 BIGNUM * bn = ASN1_INTEGER_to_BN (::X509_get_serialNumber (x), 0); 00034 if (BN_is_zero (bn)) 00035 this->id_ = CORBA::string_dup ("X509: 00"); 00036 else 00037 { 00038 char * id = BN_bn2hex (bn); 00039 00040 ACE_CString s = 00041 ACE_CString ("X509: ") 00042 + ACE_CString (const_cast<const char *> (id)); 00043 00044 this->id_ = CORBA::string_dup (s.c_str ()); 00045 00046 #ifdef OPENSSL_free 00047 OPENSSL_free (id); 00048 #else 00049 // Older versions of OpenSSL didn't define the OpenSSL 00050 // macro. 00051 CRYPTO_free (id); 00052 #endif /* OPENSSL_free */ 00053 } 00054 00055 // ------------------------------------------- 00056 00057 TimeBase::UtcT & t = this->expiry_time_; 00058 00059 const ASN1_TIME * exp = X509_get_notAfter (x); 00060 00061 if (exp->length > ACE_SIZEOF_LONG_LONG) 00062 { 00063 // @@ Will this ever happen? 00064 00065 // Overflow! 00066 t.time = ACE_UINT64_LITERAL (0xffffffffffffffff); 00067 } 00068 else 00069 { 00070 t.time = 0; 00071 for (int i = 0; i < exp->length; ++i) 00072 { 00073 t.time <<= 8; 00074 t.time |= (unsigned char) exp->data[i]; 00075 } 00076 } 00077 } 00078 } |
|
Destructor. Protected destructor to enforce proper memory management through the reference counting mechanism. Definition at line 80 of file SSLIOP_Credentials.cpp.
00081 { 00082 } |
|
Definition at line 206 of file SSLIOP_Credentials.cpp. References TAO_Local_RefCounted_Object::_add_ref(), TAO::SSLIOP::Credentials_ptr, and CORBA::is_nil(). Referenced by _narrow(), and tao_TAO_SSLIOP_Credentials_duplicate().
00207 { 00208 if (!CORBA::is_nil (obj)) 00209 obj->_add_ref (); 00210 00211 return obj; 00212 } |
|
Reimplemented from CORBA::LocalObject. Reimplemented in TAO::SSLIOP::OwnCredentials. Definition at line 199 of file SSLIOP_Credentials.cpp. References _duplicate(). Referenced by tao_TAO_SSLIOP_Credentials_narrow().
00200 { 00201 return TAO::SSLIOP_Credentials::_duplicate ( 00202 dynamic_cast<TAO::SSLIOP_Credentials *> (obj)); 00203 } |
|
Reimplemented from CORBA::LocalObject. Reimplemented in TAO::SSLIOP::OwnCredentials. Definition at line 124 of file SSLIOP_Credentials.h. References TAO::SSLIOP::Credentials_ptr. Referenced by tao_TAO_SSLIOP_Credentials_nil().
00125 {
00126 return (SSLIOP::Credentials_ptr) 0;
00127 }
|
|
Definition at line 147 of file SSLIOP_Credentials.cpp.
00149 {
00150 throw CORBA::NO_IMPLEMENT ();
00151 }
|
|
Definition at line 85 of file SSLIOP_Credentials.cpp. References CORBA::string_dup().
00086 { 00087 return CORBA::string_dup (this->id_.in ()); 00088 } |
|
Definition at line 103 of file SSLIOP_Credentials.cpp. References creds_state_, TAO::SSLIOP::OpenSSL_st_var< T >::in(), and x509_.
00104 { 00105 const ::X509 *x = this->x509_.in (); 00106 00107 // The pointer to the underlying X509 structure should only be zero 00108 // if destroy() was called on this Credentials object. 00109 if (x == 0) 00110 throw CORBA::BAD_OPERATION (); 00111 00112 if (this->creds_state_ == SecurityLevel3::CS_Valid) 00113 { 00114 // Make sure the X.509 certificate is still valid. 00115 00116 const int after_status = 00117 ::X509_cmp_current_time (X509_get_notAfter (x)); 00118 00119 if (after_status == 0) 00120 { 00121 // Error in certificate's "not after" field. 00122 throw CORBA::BAD_PARAM (); 00123 } 00124 else if (after_status > 0) // Certificate has expired. 00125 this->creds_state_ = SecurityLevel3::CS_Expired; 00126 } 00127 else if (this->creds_state_ == SecurityLevel3::CS_Invalid) 00128 { 00129 // Check if the X.509 certificate has become valid. 00130 00131 const int before_status = 00132 ::X509_cmp_current_time (X509_get_notBefore (x)); 00133 00134 if (before_status == 0) 00135 { 00136 // Error in certificate's "not before" field. 00137 throw CORBA::BAD_PARAM (); 00138 } 00139 else if (before_status < 0) // Certificate is now valid. 00140 this->creds_state_ = SecurityLevel3::CS_Valid; 00141 } 00142 00143 return this->creds_state_; 00144 } |
|
Implemented in TAO::SSLIOP::ClientCredentials, TAO::SSLIOP::OwnCredentials, and TAO::SSLIOP::TargetCredentials. Referenced by operator==(). |
|
Definition at line 91 of file SSLIOP_Credentials.cpp.
00092 {
00093 return SecurityLevel3::CU_Indefinite;
00094 }
|
|
Return a pointer to the underlying private key.
Definition at line 15 of file SSLIOP_Credentials.inl. References TAO::SSLIOP::_duplicate().
00016 { 00017 return 00018 TAO::SSLIOP::OpenSSL_traits< ::EVP_PKEY >::_duplicate (this->evp_.in ()); 00019 } |
|
Definition at line 97 of file SSLIOP_Credentials.cpp. References expiry_time_.
00098 { 00099 return this->expiry_time_; 00100 } |
|
Definition at line 191 of file SSLIOP_Credentials.cpp. References TAO::SSLIOP::OpenSSL_st_var< T >::in(), x509(), and x509_.
|
|
Definition at line 160 of file SSLIOP_Credentials.cpp. References creds_type(), creds_usage_, TAO::SSLIOP::OpenSSL_st_var< T >::in(), and x509_.
00161 { 00162 ::X509 * xa = this->x509_.in (); 00163 ::X509 * xb = rhs.x509_.in (); 00164 // EVP_PKEY *ea = this->evp_.in (); 00165 // EVP_PKEY *eb = rhs.evp_.in (); 00166 00167 // No need for a full blown ACE_TRY/CATCH block. 00168 00169 const SecurityLevel3::CredentialsType lct = 00170 this->creds_type (); 00171 00172 const SecurityLevel3::CredentialsType rct = 00173 const_cast<TAO::SSLIOP_Credentials &> (rhs).creds_type (); 00174 00175 // Don't bother check the creds_id and expiry_time attributes. They 00176 // are checked implicitly by the below X509_cmp() call. 00177 // 00178 // Additionally, the creds_state attribute is not included in the 00179 // check since it is not considered important when distinguishing 00180 // between two Credentials. 00181 00182 return 00183 lct == rct 00184 && this->creds_usage_ == rhs.creds_usage_ 00185 && ((xa == xb) || (xa != 0 && xb != 0 && ::X509_cmp (xa, xb) == 0)) 00186 // && ((ea == eb) || (ea != 0 && eb != 0 && ::EVP_PKEY_cmp (ea, eb) == 0)) 00187 ; 00188 } |
|
Definition at line 154 of file SSLIOP_Credentials.cpp.
00155 {
00156 throw CORBA::NO_IMPLEMENT ();
00157 }
|
|
Return a pointer to the underlying X.509 certificate.
Definition at line 8 of file SSLIOP_Credentials.inl. References TAO::SSLIOP::_duplicate(). Referenced by hash().
00009 { 00010 return 00011 TAO::SSLIOP::OpenSSL_traits< ::X509 >::_duplicate (this->x509_.in ()); 00012 } |
|
The validity of the Credentials.
Definition at line 160 of file SSLIOP_Credentials.h. Referenced by creds_state(). |
|
The intended usage of the Credentials.
Definition at line 154 of file SSLIOP_Credentials.h. Referenced by operator==(). |
|
Reference to the private key associated with the X.509 certificate. Definition at line 148 of file SSLIOP_Credentials.h. |
|
The time these Credentials expire.
Definition at line 157 of file SSLIOP_Credentials.h. Referenced by expiry_time(), and SSLIOP_Credentials(). |
|
Credentials Identifier.
Definition at line 151 of file SSLIOP_Credentials.h. |
|
Reference to the X.509 certificate associated with this SSLIOP Credentials object. Definition at line 144 of file SSLIOP_Credentials.h. Referenced by creds_state(), hash(), and operator==(). |