Class Auth

java.lang.Object
org.stellar.sdk.Auth

public class Auth extends Object
This class contains helper methods to sign SorobanAuthorizationEntry.
See Also:
  • Constructor Details

    • Auth

      public Auth()
  • Method Details

    • authorizeEntry

      public static SorobanAuthorizationEntry authorizeEntry(String entry, KeyPair signer, Long validUntilLedgerSeq, Network network)
      Actually authorizes an existing authorization entry using the given the credentials and expiration details, returning a signed copy.

      This "fills out" the authorization entry with a signature, indicating to the InvokeHostFunctionOperation it's attached to that:

      • a particular identity (i.e. signing KeyPair or Auth.Signer)
      • approving the execution of an invocation tree (i.e. a simulation-acquired SorobanAuthorizedInvocation or otherwise built)
      • on a particular network (uniquely identified by its passphrase, see Network)
      • until a particular ledger sequence is reached.
      Parameters:
      entry - a base64 encoded unsigned Soroban authorization entry
      signer - a KeyPair which should correspond to the address in the `entry`
      validUntilLedgerSeq - the (exclusive) future ledger sequence number until which this authorization entry should be valid (if `currentLedgerSeq==validUntil`, this is expired)
      network - the network is incorprated into the signature
      Returns:
      a signed Soroban authorization entry
    • authorizeEntry

      public static SorobanAuthorizationEntry authorizeEntry(SorobanAuthorizationEntry entry, KeyPair signer, Long validUntilLedgerSeq, Network network)
      Actually authorizes an existing authorization entry using the given the credentials and expiration details, returning a signed copy.

      This "fills out" the authorization entry with a signature, indicating to the InvokeHostFunctionOperation it's attached to that:

      • a particular identity (i.e. signing KeyPair or Auth.Signer)
      • approving the execution of an invocation tree (i.e. a simulation-acquired SorobanAuthorizedInvocation or otherwise built)
      • on a particular network (uniquely identified by its passphrase, see Network)
      • until a particular ledger sequence is reached.
      Parameters:
      entry - a base64 encoded unsigned Soroban authorization entry
      signer - a KeyPair which should correspond to the address in the `entry`
      validUntilLedgerSeq - the (exclusive) future ledger sequence number until which this authorization entry should be valid (if `currentLedgerSeq==validUntil`, this is expired)
      network - the network is incorprated into the signature
      Returns:
      a signed Soroban authorization entry
    • authorizeEntry

      public static SorobanAuthorizationEntry authorizeEntry(String entry, Auth.Signer signer, Long validUntilLedgerSeq, Network network)
      Actually authorizes an existing authorization entry using the given the credentials and expiration details, returning a signed copy.

      This "fills out" the authorization entry with a signature, indicating to the InvokeHostFunctionOperation it's attached to that:

      • a particular identity (i.e. signing KeyPair or Auth.Signer)
      • approving the execution of an invocation tree (i.e. a simulation-acquired SorobanAuthorizedInvocation or otherwise built)
      • on a particular network (uniquely identified by its passphrase, see Network)
      • until a particular ledger sequence is reached.
      Parameters:
      entry - a base64 encoded unsigned Soroban authorization entry
      signer - A function which takes a payload (a HashIDPreimage) and returns the signature of the hash of the raw payload bytes, see Auth.Signer
      validUntilLedgerSeq - the (exclusive) future ledger sequence number until which this authorization entry should be valid (if `currentLedgerSeq==validUntil`, this is expired)
      network - the network is incorprated into the signature
      Returns:
      a signed Soroban authorization entry
    • authorizeEntry

      public static SorobanAuthorizationEntry authorizeEntry(SorobanAuthorizationEntry entry, Auth.Signer signer, Long validUntilLedgerSeq, Network network)
      Actually authorizes an existing authorization entry using the given the credentials and expiration details, returning a signed copy.

      This "fills out" the authorization entry with a signature, indicating to the InvokeHostFunctionOperation it's attached to that:

      • a particular identity (i.e. signing KeyPair or Auth.Signer)
      • approving the execution of an invocation tree (i.e. a simulation-acquired SorobanAuthorizedInvocation or otherwise built)
      • on a particular network (uniquely identified by its passphrase, see Network)
      • until a particular ledger sequence is reached.
      Parameters:
      entry - an unsigned Soroban authorization entry
      signer - A function which takes a payload (a HashIDPreimage) and returns the signature of the hash of the raw payload bytes, see Auth.Signer
      validUntilLedgerSeq - the (exclusive) future ledger sequence number until which this authorization entry should be valid (if `currentLedgerSeq==validUntil`, this is expired)
      network - the network is incorprated into the signature
      Returns:
      a signed Soroban authorization entry
    • authorizeInvocation

      public static SorobanAuthorizationEntry authorizeInvocation(KeyPair signer, Long validUntilLedgerSeq, SorobanAuthorizedInvocation invocation, Network network)
      This builds an entry from scratch, allowing you to express authorization as a function of:
      • a particular identity (i.e. signing KeyPair or Auth.Signer)
      • approving the execution of an invocation tree (i.e. a simulation-acquired SorobanAuthorizedInvocation or otherwise built)
      • on a particular network (uniquely identified by its passphrase, see Network)
      • until a particular ledger sequence is reached.

      This is in contrast to authorizeEntry(java.lang.String, org.stellar.sdk.KeyPair, java.lang.Long, org.stellar.sdk.Network), which signs an existing entry "in place".

      Parameters:
      signer - a KeyPair used to sign the entry
      validUntilLedgerSeq - the (exclusive) future ledger sequence number until which this authorization entry should be valid (if `currentLedgerSeq==validUntil`, this is expired)
      invocation - invocation the invocation tree that we're authorizing (likely, this comes from transaction simulation)
      network - the network is incorprated into the signature
      Returns:
      a signed Soroban authorization entry
    • authorizeInvocation

      public static SorobanAuthorizationEntry authorizeInvocation(Auth.Signer signer, String publicKey, Long validUntilLedgerSeq, SorobanAuthorizedInvocation invocation, Network network)
      This builds an entry from scratch, allowing you to express authorization as a function of:
      • a particular identity (i.e. signing KeyPair or Auth.Signer)
      • approving the execution of an invocation tree (i.e. a simulation-acquired SorobanAuthorizedInvocation or otherwise built)
      • on a particular network (uniquely identified by its passphrase, see Network)
      • until a particular ledger sequence is reached.

      This is in contrast to authorizeEntry(java.lang.String, org.stellar.sdk.KeyPair, java.lang.Long, org.stellar.sdk.Network), which signs an existing entry "in place".

      Parameters:
      signer - A function which takes a payload (a HashIDPreimage) and returns the signature of the hash of the raw payload bytes, see Auth.Signer
      publicKey - the public identity of the signer
      validUntilLedgerSeq - the (exclusive) future ledger sequence number until which this authorization entry should be valid (if `currentLedgerSeq==validUntil`, this is expired)
      invocation - invocation the invocation tree that we're authorizing (likely, this comes from transaction simulation)
      network - the network is incorprated into the signature
      Returns:
      a signed Soroban authorization entry