rippled
Loading...
Searching...
No Matches
CredentialHelpers.h
1#ifndef XRPL_APP_MISC_CREDENTIALHELPERS_H_INCLUDED
2#define XRPL_APP_MISC_CREDENTIALHELPERS_H_INCLUDED
3
4#include <xrpl/basics/Log.h>
5#include <xrpl/basics/base_uint.h>
6#include <xrpl/beast/utility/Journal.h>
7#include <xrpl/ledger/ApplyView.h>
8#include <xrpl/ledger/ReadView.h>
9#include <xrpl/protocol/AccountID.h>
10#include <xrpl/protocol/STArray.h>
11#include <xrpl/protocol/STTx.h>
12#include <xrpl/protocol/TER.h>
13
14namespace ripple {
15namespace credentials {
16
17// These function will be used by the code that use DepositPreauth / Credentials
18// (and any future preauthorization modes) as part of authorization (all the
19// transfer funds transactions)
20
21// Check if credential sfExpiration field has passed ledger's parentCloseTime
22bool
24 std::shared_ptr<SLE const> const& sleCredential,
25 NetClock::time_point const& closed);
26
27// Return true if any expired credential was found in arr (and deleted)
28bool
29removeExpired(ApplyView& view, STVector256 const& arr, beast::Journal const j);
30
31// Actually remove a credentials object from the ledger
32TER
34 ApplyView& view,
35 std::shared_ptr<SLE> const& sleCredential,
37
38// Amendment and parameters checks for sfCredentialIDs field
40checkFields(STTx const& tx, beast::Journal j);
41
42// Accessing the ledger to check if provided credentials are valid. Do not use
43// in doApply (only in preclaim) since it does not remove expired credentials.
44// If you call it in prelaim, you also must call verifyDepositPreauth in doApply
45TER
46valid(
47 STTx const& tx,
48 ReadView const& view,
49 AccountID const& src,
51
52// Check if subject has any credential maching the given domain. If you call it
53// in preclaim and it returns tecEXPIRED, you should call verifyValidDomain in
54// doApply. This will ensure that expired credentials are deleted.
55TER
56validDomain(ReadView const& view, uint256 domainID, AccountID const& subject);
57
58// This function is only called when we about to return tecNO_PERMISSION
59// because all the checks for the DepositPreauth authorization failed.
60TER
62 ApplyView const& view,
63 STVector256 const& ctx,
64 AccountID const& dst);
65
66// Sort credentials array, return empty set if there are duplicates
68makeSorted(STArray const& credentials);
69
70// Check credentials array passed to DepositPreauth/PermissionedDomainSet
71// transactions
73checkArray(STArray const& credentials, unsigned maxSize, beast::Journal j);
74
75} // namespace credentials
76
77// Check expired credentials and for credentials maching DomainID of the ledger
78// object
79TER
81 ApplyView& view,
82 AccountID const& account,
83 uint256 domainID,
85
86// Check expired credentials and for existing DepositPreauth ledger object
87TER
89 STTx const& tx,
90 ApplyView& view,
91 AccountID const& src,
92 AccountID const& dst,
93 std::shared_ptr<SLE> const& sleDst,
95
96} // namespace ripple
97
98#endif
A generic endpoint for log messages.
Definition Journal.h:41
Writeable view to a ledger, for applying a transaction.
Definition ApplyView.h:124
A view into a ledger.
Definition ReadView.h:32
NotTEC checkFields(STTx const &tx, beast::Journal j)
TER deleteSLE(ApplyView &view, std::shared_ptr< SLE > const &sleCredential, beast::Journal j)
bool removeExpired(ApplyView &view, STVector256 const &arr, beast::Journal const j)
TER validDomain(ReadView const &view, uint256 domainID, AccountID const &subject)
TER valid(STTx const &tx, ReadView const &view, AccountID const &src, beast::Journal j)
NotTEC checkArray(STArray const &credentials, unsigned maxSize, beast::Journal j)
bool checkExpired(std::shared_ptr< SLE const > const &sleCredential, NetClock::time_point const &closed)
TER authorizedDepositPreauth(ApplyView const &view, STVector256 const &ctx, AccountID const &dst)
std::set< std::pair< AccountID, Slice > > makeSorted(STArray const &credentials)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
TER verifyDepositPreauth(STTx const &tx, ApplyView &view, AccountID const &src, AccountID const &dst, std::shared_ptr< SLE > const &sleDst, beast::Journal j)
TER verifyValidDomain(ApplyView &view, AccountID const &account, uint256 domainID, beast::Journal j)