rippled
Loading...
Searching...
No Matches
CredentialHelpers.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2024 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_APP_MISC_CREDENTIALHELPERS_H_INCLUDED
21#define RIPPLE_APP_MISC_CREDENTIALHELPERS_H_INCLUDED
22
23#include <xrpld/app/tx/detail/Transactor.h>
24
25namespace ripple {
26namespace credentials {
27
28// These function will be used by the code that use DepositPreauth / Credentials
29// (and any future preauthorization modes) as part of authorization (all the
30// transfer funds transactions)
31
32// Check if credential sfExpiration field has passed ledger's parentCloseTime
33bool
35 std::shared_ptr<SLE const> const& sleCredential,
36 NetClock::time_point const& closed);
37
38// Return true if any expired credential was found in arr (and deleted)
39bool
40removeExpired(ApplyView& view, STVector256 const& arr, beast::Journal const j);
41
42// Actually remove a credentials object from the ledger
43TER
45 ApplyView& view,
46 std::shared_ptr<SLE> const& sleCredential,
48
49// Amendment and parameters checks for sfCredentialIDs field
51checkFields(PreflightContext const& ctx);
52
53// Accessing the ledger to check if provided credentials are valid. Do not use
54// in doApply (only in preclaim) since it does not remove expired credentials.
55// If you call it in prelaim, you also must call verifyDepositPreauth in doApply
56TER
57valid(PreclaimContext const& ctx, AccountID const& src);
58
59// Check if subject has any credential maching the given domain. If you call it
60// in preclaim and it returns tecEXPIRED, you should call verifyValidDomain in
61// doApply. This will ensure that expired credentials are deleted.
62TER
63validDomain(ReadView const& view, uint256 domainID, AccountID const& subject);
64
65// This function is only called when we about to return tecNO_PERMISSION
66// because all the checks for the DepositPreauth authorization failed.
67TER
69 ApplyView const& view,
70 STVector256 const& ctx,
71 AccountID const& dst);
72
73// Sort credentials array, return empty set if there are duplicates
75makeSorted(STArray const& credentials);
76
77// Check credentials array passed to DepositPreauth/PermissionedDomainSet
78// transactions
80checkArray(STArray const& credentials, unsigned maxSize, beast::Journal j);
81
82} // namespace credentials
83
84// Check expired credentials and for credentials maching DomainID of the ledger
85// object
86TER
88 ApplyView& view,
89 AccountID const& account,
90 uint256 domainID,
92
93// Check expired credentials and for existing DepositPreauth ledger object
94TER
96 ApplyContext& ctx,
97 AccountID const& src,
98 AccountID const& dst,
99 std::shared_ptr<SLE> const& sleDst);
100
101} // namespace ripple
102
103#endif
A generic endpoint for log messages.
Definition: Journal.h:60
std::chrono::time_point< NetClock > time_point
Definition: chrono.h:69
NotTEC checkFields(PreflightContext const &ctx)
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(PreclaimContext const &ctx, AccountID const &src)
TER authorizedDepositPreauth(ApplyView const &view, STVector256 const &credIDs, AccountID const &dst)
NotTEC checkArray(STArray const &credentials, unsigned maxSize, beast::Journal j)
bool checkExpired(std::shared_ptr< SLE const > const &sleCredential, NetClock::time_point const &closed)
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:26
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition: AccountID.h:49
base_uint< 256 > uint256
Definition: base_uint.h:558
TER verifyDepositPreauth(ApplyContext &ctx, AccountID const &src, AccountID const &dst, std::shared_ptr< SLE > const &sleDst)
TER verifyValidDomain(ApplyView &view, AccountID const &account, uint256 domainID, beast::Journal j)
TERSubset< CanCvtToTER > TER
Definition: TER.h:643
TERSubset< CanCvtToNotTEC > NotTEC
Definition: TER.h:603