Skip to content

Commit

Permalink
Merge pull request #77 from biscuit-auth/rename-package
Browse files Browse the repository at this point in the history
rename the package
  • Loading branch information
Geal authored Jan 5, 2024
2 parents cc6cf61 + 7d07ea0 commit 4be971d
Show file tree
Hide file tree
Showing 69 changed files with 652 additions and 690 deletions.
4 changes: 0 additions & 4 deletions src/main/java/com/clevercloud/biscuit/error/package-info.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.clevercloud.biscuit.crypto;
package org.biscuitsec.biscuit.crypto;

import io.vavr.control.Option;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.clevercloud.biscuit.crypto;
package org.biscuitsec.biscuit.crypto;


import biscuit.format.schema.Schema;
import com.clevercloud.biscuit.token.builder.Utils;
import org.biscuitsec.biscuit.token.builder.Utils;
import net.i2p.crypto.eddsa.EdDSAPrivateKey;
import net.i2p.crypto.eddsa.EdDSAPublicKey;
import net.i2p.crypto.eddsa.spec.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package com.clevercloud.biscuit.crypto;
package org.biscuitsec.biscuit.crypto;

import biscuit.format.schema.Schema;
import biscuit.format.schema.Schema.PublicKey.Algorithm;
import com.clevercloud.biscuit.datalog.Scope;
import com.clevercloud.biscuit.error.Error;
import com.clevercloud.biscuit.token.builder.Utils;
import org.biscuitsec.biscuit.error.Error;
import org.biscuitsec.biscuit.token.builder.Utils;
import com.google.protobuf.ByteString;
import io.vavr.control.Either;
import net.i2p.crypto.eddsa.EdDSAPublicKey;
import net.i2p.crypto.eddsa.spec.EdDSAPublicKeySpec;

import static com.clevercloud.biscuit.crypto.KeyPair.ed25519;
import static io.vavr.API.Left;
import static io.vavr.API.Right;
import static org.biscuitsec.biscuit.crypto.KeyPair.ed25519;

public class PublicKey {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.clevercloud.biscuit.crypto;
package org.biscuitsec.biscuit.crypto;

import com.clevercloud.biscuit.error.Error;
import org.biscuitsec.biscuit.error.Error;
import io.vavr.control.Either;
import net.i2p.crypto.eddsa.EdDSAEngine;

Expand All @@ -9,7 +9,6 @@
import java.security.*;
import java.util.ArrayList;

import static com.clevercloud.biscuit.crypto.KeyPair.ed25519;
import static io.vavr.API.Left;
import static io.vavr.API.Right;

Expand All @@ -20,7 +19,7 @@ class Token {
public final KeyPair next;

public Token(KeyPair rootKeyPair, byte[] message, KeyPair next) throws NoSuchAlgorithmException, InvalidKeyException, SignatureException {
Signature sgr = new EdDSAEngine(MessageDigest.getInstance(ed25519.getHashAlgorithm()));
Signature sgr = new EdDSAEngine(MessageDigest.getInstance(KeyPair.ed25519.getHashAlgorithm()));
ByteBuffer algo_buf = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN);
algo_buf.putInt(Integer.valueOf(next.public_key().algorithm.getNumber()));
algo_buf.flip();
Expand Down Expand Up @@ -49,7 +48,7 @@ public Token(final ArrayList<byte[]> blocks, final ArrayList<PublicKey> keys, fi
}

public Token append(KeyPair keyPair, byte[] message) throws NoSuchAlgorithmException, SignatureException, InvalidKeyException {
Signature sgr = new EdDSAEngine(MessageDigest.getInstance(ed25519.getHashAlgorithm()));
Signature sgr = new EdDSAEngine(MessageDigest.getInstance(KeyPair.ed25519.getHashAlgorithm()));
sgr.initSign(this.next.private_key);
ByteBuffer algo_buf = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN);
algo_buf.putInt(Integer.valueOf(next.public_key().algorithm.getNumber()));
Expand Down Expand Up @@ -77,7 +76,7 @@ public Either<Error, Void> verify(PublicKey root) throws NoSuchAlgorithmExceptio
byte[] signature = this.signatures.get(i);

System.out.println("verifying block "+i+" with current key "+current_key.toHex()+" block "+block+" next key "+next_key.toHex()+" signature "+signature);
Signature sgr = new EdDSAEngine(MessageDigest.getInstance(ed25519.getHashAlgorithm()));
Signature sgr = new EdDSAEngine(MessageDigest.getInstance(KeyPair.ed25519.getHashAlgorithm()));
ByteBuffer algo_buf = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN);
algo_buf.putInt(Integer.valueOf(next.public_key().algorithm.getNumber()));
algo_buf.flip();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
package com.clevercloud.biscuit.crypto;
package org.biscuitsec.biscuit.crypto;

import biscuit.format.schema.Schema;
import com.clevercloud.biscuit.error.Error;
import com.google.protobuf.ByteString;
import io.vavr.control.Either;

import java.security.MessageDigest;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.List;

import static io.vavr.API.Left;
import static io.vavr.API.Right;
import org.biscuitsec.biscuit.token.builder.Utils;

/**
* Signature aggregation
Expand Down Expand Up @@ -191,6 +180,6 @@ static public String hex(byte[] byteArray) {
}

public static byte[] fromHex(String s) {
return com.clevercloud.biscuit.token.builder.Utils.hexStringToByteArray(s);
return Utils.hexStringToByteArray(s);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
* Cryptographic operations for Biscuit tokens
*/
package com.clevercloud.biscuit.crypto;
package org.biscuitsec.biscuit.crypto;
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package com.clevercloud.biscuit.datalog;
package org.biscuitsec.biscuit.datalog;

import biscuit.format.schema.Schema;
import com.clevercloud.biscuit.error.Error;
import org.biscuitsec.biscuit.error.Error;
import io.vavr.control.Either;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import static biscuit.format.schema.Schema.CheckV2.Kind.All;
import static biscuit.format.schema.Schema.CheckV2.Kind.One;
import static io.vavr.API.Left;
import static io.vavr.API.Right;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.clevercloud.biscuit.datalog;
package org.biscuitsec.biscuit.datalog;

import io.vavr.Tuple2;
import io.vavr.control.Option;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.clevercloud.biscuit.datalog;
package org.biscuitsec.biscuit.datalog;

import biscuit.format.schema.Schema;
import com.clevercloud.biscuit.error.Error;
import org.biscuitsec.biscuit.error.Error;
import io.vavr.control.Either;

import java.io.Serializable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.clevercloud.biscuit.datalog;
package org.biscuitsec.biscuit.datalog;

import io.vavr.Tuple2;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.clevercloud.biscuit.datalog;
package org.biscuitsec.biscuit.datalog;

import com.clevercloud.biscuit.datalog.expressions.Expression;
import org.biscuitsec.biscuit.datalog.expressions.Expression;
import io.vavr.control.Option;

import java.io.Serializable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.clevercloud.biscuit.datalog;
package org.biscuitsec.biscuit.datalog;

import java.util.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.clevercloud.biscuit.datalog;
package org.biscuitsec.biscuit.datalog;

import biscuit.format.schema.Schema;
import com.clevercloud.biscuit.error.Error;
import org.biscuitsec.biscuit.error.Error;
import io.vavr.control.Either;

import java.io.Serializable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.clevercloud.biscuit.datalog;
package org.biscuitsec.biscuit.datalog;

import biscuit.format.schema.Schema;
import com.clevercloud.biscuit.datalog.expressions.Expression;
import com.clevercloud.biscuit.error.Error;
import com.clevercloud.biscuit.error.Error.InvalidType;
import org.biscuitsec.biscuit.datalog.expressions.Expression;
import org.biscuitsec.biscuit.error.Error;
import io.vavr.Tuple2;
import io.vavr.Tuple3;
import io.vavr.control.Either;
Expand Down Expand Up @@ -66,7 +65,7 @@ public Stream<Either<Error, Tuple2<Origin, Fact>>> apply(
}
// continue evaluating if true
} else {
return Either.left(new InvalidType());
return Either.left(new Error.InvalidType());
}
}
}
Expand Down Expand Up @@ -131,7 +130,7 @@ public boolean find_match(final FactSet facts, Long origin, TrustedOrigins scope
}

// verifies that the expressions return true for every matching set of facts
public boolean check_match_all(final FactSet facts, TrustedOrigins scope, SymbolTable symbols) throws InvalidType {
public boolean check_match_all(final FactSet facts, TrustedOrigins scope, SymbolTable symbols) throws Error.InvalidType {
MatchedVariables variables = variablesSet();

if(this.body.isEmpty()) {
Expand Down Expand Up @@ -159,7 +158,7 @@ public boolean check_match_all(final FactSet facts, TrustedOrigins scope, Symbol
}
// continue evaluating if true
} else {
throw new InvalidType();
throw new Error.InvalidType();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.clevercloud.biscuit.datalog;
package org.biscuitsec.biscuit.datalog;

import io.vavr.Tuple2;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.clevercloud.biscuit.datalog;
package org.biscuitsec.biscuit.datalog;

import java.time.Duration;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.clevercloud.biscuit.datalog;
package org.biscuitsec.biscuit.datalog;

import com.clevercloud.biscuit.datalog.expressions.Expression;
import com.clevercloud.biscuit.datalog.expressions.Op;
import com.clevercloud.biscuit.error.Error;
import org.biscuitsec.biscuit.datalog.expressions.Expression;
import org.biscuitsec.biscuit.datalog.expressions.Op;
import org.biscuitsec.biscuit.error.Error;
import io.vavr.control.Either;
import org.biscuitsec.biscuit.token.format.SerializedBiscuit;

import java.util.List;

import static com.clevercloud.biscuit.datalog.Check.Kind.All;
import static com.clevercloud.biscuit.token.format.SerializedBiscuit.MIN_SCHEMA_VERSION;
import static io.vavr.API.Left;
import static io.vavr.API.Right;

Expand Down Expand Up @@ -41,7 +40,7 @@ public SchemaVersion(List<Fact> facts, List<Rule> rules, List<Check> checks, Lis

containsCheckAll = false;
for (Check check : checks) {
if (check.kind() == All) {
if (check.kind() == Check.Kind.All) {
containsCheckAll = true;
break;
}
Expand All @@ -62,7 +61,7 @@ public int version() {
if (containsScopes || containsV4 || containsCheckAll) {
return 4;
} else {
return MIN_SCHEMA_VERSION;
return SerializedBiscuit.MIN_SCHEMA_VERSION;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.clevercloud.biscuit.datalog;
package org.biscuitsec.biscuit.datalog;

import biscuit.format.schema.Schema;
import com.clevercloud.biscuit.error.Error;
import org.biscuitsec.biscuit.error.Error;
import io.vavr.control.Either;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.clevercloud.biscuit.datalog;
package org.biscuitsec.biscuit.datalog;

import com.clevercloud.biscuit.crypto.PublicKey;
import com.clevercloud.biscuit.crypto.TokenSignature;
import com.clevercloud.biscuit.datalog.expressions.Expression;
import com.clevercloud.biscuit.token.builder.Utils;
import org.biscuitsec.biscuit.crypto.PublicKey;
import org.biscuitsec.biscuit.crypto.TokenSignature;
import org.biscuitsec.biscuit.datalog.expressions.Expression;
import org.biscuitsec.biscuit.token.builder.Utils;
import io.vavr.control.Option;

import java.io.Serializable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.clevercloud.biscuit.datalog;
package org.biscuitsec.biscuit.datalog;

import io.vavr.control.Option;

import java.util.ArrayList;
import java.util.List;

import static com.clevercloud.biscuit.datalog.SymbolTable.DEFAULT_SYMBOLS_OFFSET;
import static org.biscuitsec.biscuit.datalog.SymbolTable.DEFAULT_SYMBOLS_OFFSET;

public class TemporarySymbolTable {
SymbolTable base;
Expand Down
Loading

0 comments on commit 4be971d

Please sign in to comment.