Mir
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
mir::cookie::Authority Class Referenceabstract

A source of moderately-difficult-to-spoof cookies. More...

#include <authority.h>

Inheritance diagram for mir::cookie::Authority:
[legend]

Public Member Functions

 Authority (Authority const &authority)=delete
 
Authorityoperator= (Authority const &authority)=delete
 
virtual ~Authority () noexcept=default
 
virtual std::unique_ptr< Cookiemake_cookie (uint64_t const &timestamp)=0
 Creates a cookie from a timestamp. More...
 
virtual std::unique_ptr< Cookiemake_cookie (std::vector< uint8_t > const &raw_cookie)=0
 Creates a cookie from a serialized representation. More...
 

Static Public Member Functions

static size_t optimal_secret_size ()
 Optimal size for the provided Secret. More...
 
static std::unique_ptr< Authoritycreate_from (Secret const &secret)
 Construction function used to create an Authority. More...
 
static std::unique_ptr< Authoritycreate_saving (Secret &save_secret)
 Construction function used to create an Authority as well as a secret. More...
 
static std::unique_ptr< Authoritycreate ()
 Construction function used to create an Authority and a secret which it keeps internally. More...
 

Static Public Attributes

static unsigned const minimum_secret_size = 8
 Absolute minimum size of secret key the Authority will accept. More...
 

Protected Member Functions

 Authority ()=default
 

Detailed Description

A source of moderately-difficult-to-spoof cookies.

The primary motivation for this is to provide event timestamps that clients find it difficult to spoof. This is useful for focus grant and similar operations where shell behaviour should be dependent on the timestamp of the client event that caused the request.

Some spoofing protection is desirable; experience with X clients shows that they will go to some effort to attempt to bypass focus stealing prevention.

Constructor & Destructor Documentation

mir::cookie::Authority::Authority ( Authority const &  authority)
delete
virtual mir::cookie::Authority::~Authority ( )
virtualdefaultnoexcept
mir::cookie::Authority::Authority ( )
protecteddefault

Member Function Documentation

std::unique_ptr< mir::cookie::Authority > mir::cookie::Authority::create ( )
static

Construction function used to create an Authority and a secret which it keeps internally.

Returns
An Authority
std::unique_ptr< mir::cookie::Authority > mir::cookie::Authority::create_from ( Secret const &  secret)
static

Construction function used to create an Authority.

The secret size must be no less then minimum_secret_size otherwise an exception will be thrown

Parameters
[in]secretA secret used to set the key for the hash function
Returns
An Authority
std::unique_ptr< mir::cookie::Authority > mir::cookie::Authority::create_saving ( Secret save_secret)
static

Construction function used to create an Authority as well as a secret.

Parameters
[out]save_secretThe secret that was created.
Returns
An Authority
virtual std::unique_ptr<Cookie> mir::cookie::Authority::make_cookie ( uint64_t const &  timestamp)
pure virtual

Creates a cookie from a timestamp.

Parameters
[in]timestampA timestamp
Returns
A cookie instance
virtual std::unique_ptr<Cookie> mir::cookie::Authority::make_cookie ( std::vector< uint8_t > const &  raw_cookie)
pure virtual

Creates a cookie from a serialized representation.

Parameters
[in]blobA blob of bytes representing a serialized cookie
Returns
A cookie instance
Authority& mir::cookie::Authority::operator= ( Authority const &  authority)
delete
size_t mir::cookie::Authority::optimal_secret_size ( )
static

Optimal size for the provided Secret.

This is the maximum useful size of the secret key. Keys of greater size will be reduced to this size internally, and keys of smaller size may be internally extended to this size.

Member Data Documentation

unsigned const mir::cookie::Authority::minimum_secret_size = 8
static

Absolute minimum size of secret key the Authority will accept.

Code should be using optimum_secret_size(); this minimum size is provided as a user convenience to guard against catastrophically bad initialisation.


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

Copyright © 2012-2015 Canonical Ltd.
Generated on Wed Mar 30 00:29:56 UTC 2016