Skip to content

Commit

Permalink
properly construct the public keys interning
Browse files Browse the repository at this point in the history
  • Loading branch information
Geal committed Jan 4, 2024
1 parent 916accb commit 715eeee
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/main/java/com/clevercloud/biscuit/datalog/Scope.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,12 @@ static public Either<Error.FormatError, Scope> deserialize(Schema.Scope scope) {
}
return Left(new Error.FormatError.DeserializationError("invalid Scope"));
}

@Override
public String toString() {
return "Scope{" +
"kind=" + kind +
", publicKey=" + publicKey +
'}';
}
}
13 changes: 10 additions & 3 deletions src/main/java/com/clevercloud/biscuit/datalog/SymbolTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private String fromEpochIsoDate(long epochSec) {
"query"
);
public final List<String> symbols;
public final List<PublicKey> publicKeys;
private final List<PublicKey> publicKeys;

public long insert(final String symbol) {
int index = this.defaultSymbols.indexOf(symbol);
Expand All @@ -81,6 +81,13 @@ public long insert(final String symbol) {
public int currentOffset() {
return this.symbols.size();
}
public int currentPublicKeyOffset() {
return this.publicKeys.size();
}

public List<PublicKey> publicKeys() {
return publicKeys;
}

public long insert(final PublicKey publicKey) {
int index = this.publicKeys.indexOf(publicKey);
Expand Down Expand Up @@ -280,9 +287,9 @@ public SymbolTable(SymbolTable s) {

public SymbolTable(List<String> symbols, List<PublicKey> publicKeys) {
this.symbols = new ArrayList<>();
symbols.addAll(symbols);
this.symbols.addAll(symbols);
this.publicKeys = new ArrayList<>();
publicKeys.addAll(publicKeys);
this.publicKeys.addAll(publicKeys);
}

public List<String> getAllSymbols() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,11 @@ public static TrustedOrigins fromScopes(List<Scope> ruleScopes,
public boolean contains(Origin factOrigin) {
return this.inner.inner.containsAll(factOrigin.inner);
}

@Override
public String toString() {
return "TrustedOrigins{" +
"inner=" + inner +
'}';
}
}

0 comments on commit 715eeee

Please sign in to comment.