[][src]Struct http_signatures::HttpSignature

pub struct HttpSignature { /* fields omitted */ }

The HttpSignature struct, this is the entry point for creating Authorization or Signature headers. It contains all the values required for generation.

Methods

impl HttpSignature
[src]

pub fn new(
    key_id: String,
    key: CreateKey,
    headers: BTreeMap<String, Vec<String>>
) -> Result<Self, CreationError>
[src]

Create a new HttpSignature from its components.

This method will Error if headers is empty.

Example

use http_signatures::{
    CreateKey,
    HttpSignature,
    Input,
    ShaSize,
    REQUEST_TARGET,
};
use ring::signature::RSAKeyPair;

let mut priv_key_file = File::open("tests/assets/private.der")?;
let mut priv_key_vec = Vec::new();
priv_key_file.read_to_end(&mut priv_key_vec)?;
let priv_key_input = Input::from(&priv_key_vec);
let priv_key = RSAKeyPair::from_der(priv_key_input).unwrap();

let priv_creation_key = CreateKey::rsa(priv_key, ShaSize::SHA512);
let key_id = "tests/assets/public.der".into();

let mut headers = BTreeMap::new();
headers.insert(REQUEST_TARGET.into(), vec!["get /".into()]);

let http_sig = HttpSignature::new(key_id, priv_creation_key, headers)?;

pub fn key_id(&self) -> &str
[src]

pub fn headers(&self) -> &BTreeMap<String, Vec<String>>
[src]

pub fn authorization_header(self) -> Result<String, CreationError>
[src]

Generate the Authorization Header from the HttpSignature

This method errors if signing the signing-string fails.

Example

use http_signatures::HttpSignature;

let auth_header = http_signature.authorization_header()?;
println!("Authorization: {}", auth_header);

pub fn signature_header(self) -> Result<String, CreationError>
[src]

Generate the Signature Header from the HttpSignature

This method errors if signing the signing-string fails.

Example

use http_signatures::HttpSignature;

let sig_header = http_signature.signature_header()?;
println!("Signature: {}", sig_header);

pub fn signature(self) -> Result<Signature, CreationError>
[src]

Auto Trait Implementations

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]