#include <CredentialSelectorDlg.h>
The following sample code demonstrates how to use this class:
IPKIFMediator* m = MakeDefaultMediator(); csd.SetMediator(m); csd.SetKeyUsages(std::bitset<9>(DigitalSignature | NonRepudiation | KeyEncipherment)); if(wxID_OK == csd.ShowModal()) { CPKIFCredentialPtr cred = csd.GetSelectedCredential(); } FreeDefaultMediator(m);
TSP-enforcing: No
Definition at line 57 of file CredentialSelectorDlg.h.
Public Member Functions | |
CPKIFCredentialSelectorDlg (wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE) | |
~CPKIFCredentialSelectorDlg () | |
wxButton * | GetMoInfo () |
wxListBox * | GetListOfCredentials () |
bool | SetMediator (IPKIFMediatorPtr &m) |
void | SetKeyUsages (std::bitset< 9 > &ku) |
CPKIFCredentialPtr | GetSelectedCredential () const |
void | OnInitDialog (wxInitDialogEvent &event) |
CPKIFCredentialSelectorDlg::CPKIFCredentialSelectorDlg | ( | wxWindow * | parent, | |
wxWindowID | id, | |||
const wxString & | title, | |||
const wxPoint & | position = wxDefaultPosition , |
|||
const wxSize & | size = wxDefaultSize , |
|||
long | style = wxDEFAULT_DIALOG_STYLE | |||
) |
Interface: External
Dialog constructor
Definition at line 53 of file CredentialSelector.cpp.
References PKIFCRYPTO::DigitalSignature, PKIFCRYPTO::KeyEncipherment, and PKIFCRYPTO::NonRepudiation.
CPKIFCredentialSelectorDlg::~CPKIFCredentialSelectorDlg | ( | ) |
Interface: External
Dialog destructor
Definition at line 74 of file CredentialSelector.cpp.
wxButton* CPKIFCredentialSelectorDlg::GetMoInfo | ( | ) | [inline] |
wxListBox* CPKIFCredentialSelectorDlg::GetListOfCredentials | ( | ) | [inline] |
bool CPKIFCredentialSelectorDlg::SetMediator | ( | IPKIFMediatorPtr & | m | ) |
Interface: External
SetMediator is used to specify the mediator object that is used to discover credentials when the dialog is displayed. The calling application must make sure the pointer passed to this function is valid when the dialog is displayed. The calling application is also responsible for freeing memory associated with this pointer.
The mediator/colleague set passed to the function must implement the IPKIFCryptoKeyIDOperations interface.
The pointer passed to this function replaces any previously specified value. If the pointer passed to this function is non-NULL and does not implement the IPKIFCryptoKeyIDOperations interface, the previously specified value will remain in effect. Passing NULL to this function clears previously specified values.
true is returned if the previously specified value was replaced. false is returned when a non-NULL pointer is passed and does not implement IPKIFCryptoKeyIDOperations.
m | This parameter is used to pass a pointer to a mediator/colleague set used to discover available credentials |
Definition at line 210 of file CredentialSelector.cpp.
void CPKIFCredentialSelectorDlg::SetKeyUsages | ( | std::bitset< 9 > & | ku | ) |
Interface: External
SetKeyUsages is used to limit the types of credentials that are displayed when the dialog is displayed based on the key usage value each certificate. The KeyUsage enumeration defined in PKIFCryptoConstants.h can be used. For example, the following code demostrates how to display only credentials that may be used for encryption purposes:
CPKIFCredentialSelectorDlg csd(NULL,-1,wxT("Select a credential")); csd.SetKeyUsages(std::bitset<9>(KeyEncipherment));
The following code demonstrates how to display only credentials that may be used for digital signatures or non-repudiation.
CPKIFCredentialSelectorDlg csd(NULL,-1,wxT("Select a credential")); csd.SetKeyUsages(std::bitset<9>(DigitalSignature | NonRepudiation));
By default, credentials with the following key usages are displayed:
DigitalSignature | NonRepudiation | KeyEncipherment
ku | Bitset indicating the types of credentials to display. The KeyUsage enum values can be used. |
Definition at line 250 of file CredentialSelector.cpp.
CPKIFCredentialPtr CPKIFCredentialSelectorDlg::GetSelectedCredential | ( | ) | const |
Interface: External
GetSelectedCredential returns a CPKIFCredentialPtr to the credential selected by the user. If no credential was selected, NULL is returned.
Definition at line 265 of file CredentialSelector.cpp.
void CPKIFCredentialSelectorDlg::OnInitDialog | ( | wxInitDialogEvent & | event | ) |
Interface: External
OnInitDialog obtains a pointer to the IPKIFCryptoKeyIDOperations interface from the mediator passed to SetMediator and gets a list of credentials. The name of each credential is read and populated in the list box. The index of the item in the list box corresponds to the index in the vector of credentials obtained via the call to GetKeyList.
A mediator object must have been specified via a call to SetMediator prior to displaying the dialog. Otherwise, an error message is displayed to the user and the dialog is displayed with an empty credentials list.
On non-windows platforms the View Certificate button is disabled.
Definition at line 287 of file CredentialSelector.cpp.
References IPKIFCryptoKeyIDOperations::GetKeyList(), GetListOfCredentials(), GetMoInfo(), and MakeDefaultMediator().