Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
nsClientAuthRememberService Class Reference

#include <nsClientAuthRemember.h>

Inheritance diagram for nsClientAuthRememberService:
Inheritance graph
[legend]
Collaboration diagram for nsClientAuthRememberService:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER 
nsClientAuthRememberService ()
 ~nsClientAuthRememberService ()
nsresult Init ()
nsresult RememberDecision (const nsACString &aHostName, CERTCertificate *aServerCert, CERTCertificate *aClientCert)
nsresult HasRememberedDecision (const nsACString &aHostName, CERTCertificate *aCert, nsACString &aClientNickname, PRBool *_retval)
void ClearRememberedDecisions ()
void observe (in nsISupports aSubject, in string aTopic, in wstring aData)
 Observe will be called when there is a notification for the topic |aTopic|.

Static Public Member Functions

static void GetHostWithCert (const nsACString &aHostName, const nsACString &nickname, nsACString &_retval)

Protected Member Functions

void RemoveAllFromMemory ()
nsresult AddEntryToList (const nsACString &host, const nsACString &server_fingerprint, const nsACString &client_nickname)

Protected Attributes

PRMonitormonitor
nsTHashtable
< nsClientAuthRememberEntry
mSettingsTable

Detailed Description

Definition at line 142 of file nsClientAuthRemember.h.


Constructor & Destructor Documentation

Definition at line 65 of file nsClientAuthRemember.cpp.

Here is the call graph for this function:

Definition at line 70 of file nsClientAuthRemember.cpp.

Here is the call graph for this function:


Member Function Documentation

nsresult nsClientAuthRememberService::AddEntryToList ( const nsACString &  host,
const nsACString &  server_fingerprint,
const nsACString &  client_nickname 
) [protected]

Definition at line 219 of file nsClientAuthRemember.cpp.

{
  nsCAutoString hostCert;
  GetHostWithCert(aHostName, fingerprint, hostCert);

  {
    nsAutoMonitor lock(monitor);
    nsClientAuthRememberEntry *entry = mSettingsTable.PutEntry(hostCert.get());

    if (!entry) {
      NS_ERROR("can't insert a null entry!");
      return NS_ERROR_OUT_OF_MEMORY;
    }

    entry->mHostWithCert = hostCert;

    nsClientAuthRemember &settings = entry->mSettings;
    settings.mAsciiHost = aHostName;
    settings.mFingerprint = fingerprint;
    settings.mClientNickname = client_nickname;
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 120 of file nsClientAuthRemember.cpp.

{
  nsAutoMonitor lock(monitor);
  RemoveAllFromMemory();
}

Here is the call graph for this function:

void nsClientAuthRememberService::GetHostWithCert ( const nsACString &  aHostName,
const nsACString &  nickname,
nsACString &  _retval 
) [static]

Definition at line 248 of file nsClientAuthRemember.cpp.

{
  nsCAutoString hostCert(aHostName);
  hostCert.AppendLiteral(":");
  hostCert.Append(fingerprint);
  
  _retval.Assign(hostCert);
}

Here is the caller graph for this function:

nsresult nsClientAuthRememberService::HasRememberedDecision ( const nsACString &  aHostName,
CERTCertificate *  aCert,
nsACString &  aClientNickname,
PRBool _retval 
)

Definition at line 183 of file nsClientAuthRemember.cpp.

{
  if (aHostName.IsEmpty())
    return NS_ERROR_INVALID_ARG;

  NS_ENSURE_ARG_POINTER(aCert);
  NS_ENSURE_ARG_POINTER(_retval);
  *_retval = PR_FALSE;

  nsresult rv;
  nsCAutoString fpStr;
  rv = GetCertFingerprintByOidTag(aCert, SEC_OID_SHA256, fpStr);
  if (NS_FAILED(rv))
    return rv;

  nsCAutoString hostCert;
  GetHostWithCert(aHostName, fpStr, hostCert);
  nsClientAuthRemember settings;

  {
    nsAutoMonitor lock(monitor);
    nsClientAuthRememberEntry *entry = mSettingsTable.GetEntry(hostCert.get());
    if (!entry)
      return NS_OK;
    settings = entry->mSettings; // copy
  }

  aClientNickname = settings.mClientNickname;
  *_retval = PR_TRUE;
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 78 of file nsClientAuthRemember.cpp.

{
  if (!mSettingsTable.Init())
    return NS_ERROR_OUT_OF_MEMORY;

  nsCOMPtr<nsIProxyObjectManager> proxyman(do_GetService(NS_XPCOMPROXY_CONTRACTID));
  if (!proxyman)
    return NS_ERROR_FAILURE;

  nsCOMPtr<nsIObserverService> observerService(do_GetService("@mozilla.org/observer-service;1"));
  nsCOMPtr<nsIObserverService> proxiedObserver;

  proxyman->GetProxyForObject(NS_UI_THREAD_EVENTQ,
                              NS_GET_IID(nsIObserverService),
                              NS_STATIC_CAST(nsIObserverService*, observerService),
                              PROXY_SYNC,
                              getter_AddRefs(proxiedObserver));

  if (proxiedObserver) {
    proxiedObserver->AddObserver(this, "profile-before-change", PR_TRUE);
  }

  return NS_OK;
}

Here is the call graph for this function:

void nsIObserver::observe ( in nsISupports  aSubject,
in string  aTopic,
in wstring  aData 
) [inherited]

Observe will be called when there is a notification for the topic |aTopic|.

This assumes that the object implementing this interface has been registered with an observer service such as the nsIObserverService.

If you expect multiple topics/subjects, the impl is responsible for filtering.

You should not modify, add, remove, or enumerate notifications in the implemention of observe.

Parameters:
aSubject: Notification specific interface pointer.
aTopic: The notification topic or subject.
aData: Notification specific wide string. subject event.
nsresult nsClientAuthRememberService::RememberDecision ( const nsACString &  aHostName,
CERTCertificate *  aServerCert,
CERTCertificate *  aClientCert 
)

Definition at line 154 of file nsClientAuthRemember.cpp.

{
  // aClientCert == NULL means: remember that user does not want to use a cert
  NS_ENSURE_ARG_POINTER(aServerCert);
  if (aHostName.IsEmpty())
    return NS_ERROR_INVALID_ARG;

  nsCAutoString fpStr;
  nsresult rv = GetCertFingerprintByOidTag(aServerCert, SEC_OID_SHA256, fpStr);
  if (NS_FAILED(rv))
    return rv;

  {
    nsAutoMonitor lock(monitor);
    if (aClientCert) {
      AddEntryToList(aHostName, fpStr, 
                     nsDependentCString(aClientCert->nickname));
    }
    else {
      nsCString empty;
      AddEntryToList(aHostName, fpStr, empty);
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

Definition at line 127 of file nsClientAuthRemember.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 165 of file nsClientAuthRemember.h.

Definition at line 166 of file nsClientAuthRemember.h.


The documentation for this class was generated from the following files: