Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update mapping to latest spec #8

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions cx/policy/specs/policy.mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ In an example a policy constraint requiring the "pcf" credential in version 0.4.
```json
{
"constraint": {
"leftOperand": "FrameworkAgreement.pcf",
"leftOperand": "FrameworkAgreement",
"operator": "eq",
"rightOperand": "active:0.4.2"
"rightOperand": "pcf:0.4.2"
}
}
```
Expand All @@ -51,23 +51,26 @@ If no contract version is specified in the policy constraint, then the policy **

### 3.1 Mapping Policy Constraint -> Credential Type

Use case credentials are identified by their left operand with is prefixed with the `FrameworkAgreement.` term.
Formally, a policy expression left-operand, that requires a use case credential, is defined by the following EBNF:
Use case credentials are identified by their left operand, which is always `FrameworkAgreement`, and their right operand
which contains the use case identifier and optionally a version.
Formally, a policy expression, that requires a use case credential, is defined by the following EBNF:

```ebnf
POLICYLEFTOP ::= FRAMEWORKLITERAL, DOT, USECASEIDENT ;
POLICYLEFTOPERAND ::= FRAMEWORKLITERAL ;
POLICYOPERATOR ::= "eq"
FRAMEWORKLITERAL ::= "FrameworkAgreement" ;
POLICYRIGHTOPERAND::= USECASEIDENT [COLON SEMVERSTRING]
USECASEIDENT ::= #'[a-z][a-zA-Z0-9]+' ;
DOT ::= "." ;
COLON ::= ":" ;
SEMVERSTRING ::= <any_semantic_version_string> ;
```

For example: `FrameworkAgreement.pcf`.

In order to reconstruct the actual credential type, which in the example would be `PcfCredential`, we perform relatively
simple String manipulation:

- remove `FrameworkAgreement.`
- capitalize the remainder (i.e. `pcf --> Pcf`)
- remove `FrameworkAgreement`. Hint: use it to trigger the transformation.
- capitalize the right-operand (i.e. `pcf --> Pcf`)
- append the `Credential` literal

Formally, that transformation must adhere to the following EBNF:
Expand Down