pub struct Actor<A> { /* private fields */ }
Expand description
An actor with an identifier of type T
and an ECDSA keypair used to sign tokens.
IMPORTANT NOTE: for security reasons, although Actor
implements Clone
, its secret key will
NOT be cloned. For example:
let actor = Actor::<String>::new("id".to_string()); // this has a new secret key
let cloned = actor.clone(); // this does NOT have a secret key, only a public key
Implementations§
source§impl<A> Actor<A>
impl<A> Actor<A>
sourcepub fn with_keypair(
id: A,
public_key: &[u8],
secret: &[u8]
) -> Result<Self, Error>
pub fn with_keypair( id: A, public_key: &[u8], secret: &[u8] ) -> Result<Self, Error>
Return an Actor
with the given keypair, or an error if the keypair is invalid.
sourcepub fn with_public_key(id: A, public_key: &[u8]) -> Result<Self, Error>
pub fn with_public_key(id: A, public_key: &[u8]) -> Result<Self, Error>
Return an Actor
with the given public key, or an error if the key is invalid.
sourcepub fn public_key(&self) -> &VerifyingKey
pub fn public_key(&self) -> &VerifyingKey
Borrow the public key of this actor, which a client can use to verify a signature.
pub fn sign_token_inner<H, C>( &self, token: &Token<H, A, C> ) -> Result<String, Error>
sourcepub fn sign_token<H, C>(
&self,
token: Token<H, A, C>
) -> Result<SignedToken<H, A, C>, Error>
pub fn sign_token<H, C>( &self, token: Token<H, A, C> ) -> Result<SignedToken<H, A, C>, Error>
Encode and sign the given token
data.
sourcepub fn consume_and_sign<H, C>(
&self,
token: SignedToken<H, A, C>,
host_id: H,
claims: C,
now: SystemTime
) -> Result<SignedToken<H, A, C>, Error>
pub fn consume_and_sign<H, C>( &self, token: SignedToken<H, A, C>, host_id: H, claims: C, now: SystemTime ) -> Result<SignedToken<H, A, C>, Error>
Encode and sign a new token which inherits the claims of the given token
and includes the new claims
.
Trait Implementations§
Auto Trait Implementations§
impl<A> RefUnwindSafe for Actor<A>where
A: RefUnwindSafe,
impl<A> Send for Actor<A>where
A: Send,
impl<A> Sync for Actor<A>where
A: Sync,
impl<A> Unpin for Actor<A>where
A: Unpin,
impl<A> UnwindSafe for Actor<A>where
A: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more