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

Babashka: Unable to resolve classname: java.security.KeyFactory (java.security.Key) #176

Open
srenatus opened this issue Nov 1, 2023 · 5 comments

Comments

@srenatus
Copy link

srenatus commented Nov 1, 2023

I'd like to parse some plan JSON into the structures that Jarl provides -- without actually evaluating it. However, it fails:

bb.edn

{:deps {boregby/jarl 
         {:git/url "https://github.com/borgeby/jarl.git" 
          :deps/root "core" 
          :sha "f20a80c599e0a482900ea3889a0b2fa3eab39681"}}}

test

#!/usr/bin/env -S bb
(require '[babashka.process :refer [process shell]]
		 '[jarl.parser :as parser])

(defn plan []
  (-> (apply shell {:out :string} "irdump" "-f" *command-line-args*)
      :out))

(let [plan-out (plan)
	  p0 (parser/parse-json plan-out)]
  (prn p0))

I don't know if that script would actually work, because it fails early:

% ./test foo.rego x/p  
----- Error --------------------------------------------------------------------
Type:     java.lang.Exception
Message:  Unable to resolve classname: java.security.KeyFactory
Location: /Users/stephan/.gitlibs/libs/boregby/jarl/f20a80c599e0a482900ea3889a0b2fa3eab39681/core/src/main/cljc/jarl/builtins/crypto.cljc:9:3

----- Context ------------------------------------------------------------------
 5:             #?(:clj  [clojure.string :as str])
 6:             #?(:cljs [goog.crypt :as crypt]))
 7:   #?(:cljs
 8:      (:import (goog.crypt Md5 Sha1 Sha256 Sha512 Hmac)))
 9:   #?(:clj
      ^--- Unable to resolve classname: java.security.KeyFactory
10:      (:import (javax.crypto.spec SecretKeySpec)
11:               (javax.crypto Mac)
12:               (java.security MessageDigest KeyFactory Key)
13:               (org.jose4j.jwk JsonWebKey$Factory JsonWebKey$OutputControlLevel)
14:               (java.security.spec PKCS8EncodedKeySpec)

----- Stack trace --------------------------------------------------------------
jarl.builtins.crypto   - /Users/stephan/.gitlibs/libs/boregby/jarl/f20a80c599e0a482900ea3889a0b2fa3eab39681/core/src/main/cljc/jarl/builtins/crypto.cljc:9:3
jarl.builtins.registry - /Users/stephan/.gitlibs/libs/boregby/jarl/f20a80c599e0a482900ea3889a0b2fa3eab39681/core/src/main/cljc/jarl/builtins/registry.cljc:2:3
jarl.parser            - /Users/stephan/.gitlibs/libs/boregby/jarl/f20a80c599e0a482900ea3889a0b2fa3eab39681/core/src/main/cljc/jarl/parser.cljc:2:3
user                   - /Users/stephan/Scratch/bb-diff/./test:2:1
@srenatus srenatus changed the title Babashka: Unable to resolve classname: java.security.KeyFactory Babashka: Unable to resolve classname: java.security.KeyFactory (java.security.Key) Nov 1, 2023
@srenatus
Copy link
Author

srenatus commented Nov 1, 2023

Running with the latest snapshot, which has

Add java.security.KeyFactory, java.security.spec.PKCS8EncodedKeySpec, java.net.URISyntaxException

in its CHANGELOG, I do get past that, but hit another error:

----- Error --------------------------------------------------------------------
Type:     java.lang.Exception
Message:  Unable to resolve classname: java.security.Key
Location: /Users/stephan/.gitlibs/libs/boregby/jarl/f20a80c599e0a482900ea3889a0b2fa3eab39681/core/src/main/cljc/jarl/builtins/crypto.cljc:9:3

----- Context ------------------------------------------------------------------
 5:             #?(:clj  [clojure.string :as str])
 6:             #?(:cljs [goog.crypt :as crypt]))
 7:   #?(:cljs
 8:      (:import (goog.crypt Md5 Sha1 Sha256 Sha512 Hmac)))
 9:   #?(:clj
      ^--- Unable to resolve classname: java.security.Key
10:      (:import (javax.crypto.spec SecretKeySpec)
11:               (javax.crypto Mac)
12:               (java.security MessageDigest KeyFactory Key)
13:               (org.jose4j.jwk JsonWebKey$Factory JsonWebKey$OutputControlLevel)
14:               (java.security.spec PKCS8EncodedKeySpec)

----- Stack trace --------------------------------------------------------------
jarl.builtins.crypto   - /Users/stephan/.gitlibs/libs/boregby/jarl/f20a80c599e0a482900ea3889a0b2fa3eab39681/core/src/main/cljc/jarl/builtins/crypto.cljc:9:3
jarl.builtins.registry - /Users/stephan/.gitlibs/libs/boregby/jarl/f20a80c599e0a482900ea3889a0b2fa3eab39681/core/src/main/cljc/jarl/builtins/registry.cljc:2:3
jarl.parser            - /Users/stephan/.gitlibs/libs/boregby/jarl/f20a80c599e0a482900ea3889a0b2fa3eab39681/core/src/main/cljc/jarl/parser.cljc:2:3

@srenatus
Copy link
Author

srenatus commented Nov 1, 2023

Looking into this a bit more, I think my premise was flawed. There's not much to operate on in jarl, as the plan is basically parsed into functions operating on state, am I right?

@anderseknert
Copy link
Collaborator

Correct!

@srenatus
Copy link
Author

srenatus commented Nov 1, 2023

OK so while my original intention was misguided, I believe being able to run Jarl in Babashka would still be kinda cool. Let's keep this open for tracking, shall we?

@anderseknert
Copy link
Collaborator

Indeed, that sounds good to me 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants