use of com.webauthn4j.util.exception.UnexpectedCheckedException in project webauthn4j by webauthn4j.
the class DeviceCheckManagerSample method getAppleAppAttestCertFileTrustAnchorsProvider.
private CertFileTrustAnchorsProvider getAppleAppAttestCertFileTrustAnchorsProvider() {
CertFileTrustAnchorsProvider certFileTrustAnchorsProvider = new CertFileTrustAnchorsProvider();
try {
Path path = Paths.get(ClassLoader.getSystemResource("apple-app-attest/Apple_App_Attestation_Root_CA.pem").toURI());
certFileTrustAnchorsProvider.setCertificates(Collections.singletonList(path));
return certFileTrustAnchorsProvider;
} catch (URISyntaxException e) {
throw new UnexpectedCheckedException(e);
}
}
use of com.webauthn4j.util.exception.UnexpectedCheckedException in project webauthn4j by webauthn4j.
the class X509CertificateSerializer method serialize.
/**
* {@inheritDoc}
*/
@Override
public void serialize(@NonNull X509Certificate value, @NonNull JsonGenerator gen, @NonNull SerializerProvider provider) throws IOException {
try {
String str = Base64Util.encodeToString(value.getEncoded());
gen.writeString(str);
} catch (CertificateEncodingException e) {
throw new UnexpectedCheckedException(e);
}
}
use of com.webauthn4j.util.exception.UnexpectedCheckedException in project webauthn4j by webauthn4j.
the class JWSHeaderSerializer method serialize.
@Override
public void serialize(JWSHeader value, JsonGenerator gen, SerializerProvider provider) throws IOException {
try {
gen.writeStartObject();
gen.writeObjectField("alg", value.getAlg());
gen.writeFieldName("x5c");
gen.writeStartArray();
if (value.getX5c() != null) {
for (Certificate certificate : value.getX5c().getCertificates()) {
// x5c must be Base64, not Base64Url
gen.writeString(Base64Util.encodeToString(certificate.getEncoded()));
}
}
gen.writeEndArray();
} catch (CertificateEncodingException e) {
throw new UnexpectedCheckedException(e);
}
}
use of com.webauthn4j.util.exception.UnexpectedCheckedException in project webauthn4j by webauthn4j.
the class ECUtil method createECParameterSpec.
@NonNull
private static ECParameterSpec createECParameterSpec(@NonNull String name) {
try {
AlgorithmParameters parameters;
parameters = AlgorithmParameters.getInstance("EC");
parameters.init(new ECGenParameterSpec(name));
return parameters.getParameterSpec(ECParameterSpec.class);
} catch (NoSuchAlgorithmException | InvalidParameterSpecException e) {
throw new UnexpectedCheckedException(e);
}
}
use of com.webauthn4j.util.exception.UnexpectedCheckedException in project webauthn4j by webauthn4j.
the class ECUtil method createKeyPair.
@NonNull
public static KeyPair createKeyPair(@Nullable byte[] seed, @NonNull ECParameterSpec ecParameterSpec) {
KeyPairGenerator keyPairGenerator = createKeyPairGenerator();
SecureRandom random;
try {
if (seed != null) {
// to make it deterministic
random = SecureRandom.getInstance("SHA1PRNG");
random.setSeed(seed);
} else {
random = secureRandom;
}
keyPairGenerator.initialize(ecParameterSpec, random);
return keyPairGenerator.generateKeyPair();
} catch (NoSuchAlgorithmException | InvalidAlgorithmParameterException e) {
throw new UnexpectedCheckedException(e);
}
}
Aggregations