Re: [basex-talk] Make use of external Identity Management for BaseX

2021-04-30 Thread Adam Law
 XQuery (or XSLT). In order to get BaseX to pick up a modified version of
> the jar file I'm building, I'm restarting the BaseX http server.
> >> >
> >> > This makes it slower to turn around testing the changes. Is there a
> better way of doing this?
> >> >
> >> > Kind regards,
> >> > Reece
>
>
> --
>
> Message: 6
> Date: Fri, 30 Apr 2021 08:55:49 +0200
> From: Christian Gr?n 
> To: Reece Dunn 
> Cc: BaseX 
> Subject: Re: [basex-talk] Getting profile information in server
> responses.
> Message-ID:
> <
> cap94bnmcyzqryvmejg7ekon+fjns0fsgwwx-_2eqrzzypv-...@mail.gmail.com>
> Content-Type: text/plain; charset="UTF-8"
>
> A good idea; I?ll think of ways to get this included. One challenge
> might be that the response is streamed to the client. This means that
> when creating the HTTP request headers, it will not be known yet how
> long the evaluation will take (and the time for evaluation may also
> depend on the connection speed). The time for parsing and compiling
> the query should be known at that time, though. ? Maybe we could
> suppress result streaming when timings are requested.
>
>
> On Thu, Apr 29, 2021 at 9:50 PM Reece Dunn  wrote:
> >
> > Hi all,
> >
> > In BaseX, is there a way to get the profile timings (compile, run,
> print, etc.) in the response of a HTTP request via the Server-Timing header
> (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Server-Timing)?
> >
> > Kind regards,
> > Reece
>
>
> --
>
> Message: 7
> Date: Fri, 30 Apr 2021 08:14:21 +0100
> From: Reece Dunn 
> To: Christian Gr?n 
> Cc: BaseX 
> Subject: Re: [basex-talk] Reloading jars on a running http server.
> Message-ID:
>  2c6pwjcz1kgqqz...@mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Hi Christian,
>
> I'm not seeing any exceptions in the console window, even when enabling the
> debug setting. I'm using the AdoptOpenJDK 1.8. I also have AdoptOpenJDK 11,
> but I assume that will have the issue you described.
>
> It's a custom-built jar using Kotlin, built via gradle.
>
> One thing that it could be is that I'm using Kotlin objects (not classes),
> e.g.:
>
> package test
> object Test { fun f(): String = "test" }
>
> and using it like:
>
> declare namespace Test = "java:test.Test";
>
> declare function test:f() as xs:string {
> Test::f(Test::INSTANCE())
> };
>
> The build.gradle file is simple. It looks something like this (removing
> things like the junit configuration):
>
> -
> buildscript {
> ext.kotlin_version = "1.4.32"
> ext.kotlin_stdlib = "kotlin-stdlib"
> ext.java_version = "1.8"
>
> repositories { mavenCentral() }
> dependencies { classpath
> "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" }
> }
>
> apply plugin: 'kotlin'
>
> repositories {
> mavenCentral()
> mavenLocal()
> }
>
> compileKotlin { kotlinOptions { jvmTarget = java_version } }
> compileTestKotlin { kotlinOptions { jvmTarget = java_version } }
>
> dependencies {
> implementation "org.jetbrains.kotlin:$kotlin_stdlib:$kotlin_version"
> }
> -
>
> You'll need to copy the kotlin-stdlib-1.4.32.jar file in addition to the
> test.jar file to BaseX's lib directory.
>
> Kind regards,
> Reece
>
> On Fri, 30 Apr 2021 at 07:48, Christian Gr?n 
> wrote:
>
> > Hi Reece,
> >
> > I?m sorry to hear that. Did you build a custom JAR file, or do you
> > encounter problems with the JDK?
> >
> > Cheers,
> > Christian
> >
> >
> >
> > On Thu, Apr 29, 2021 at 9:48 PM Reece Dunn 
> wrote:
> > >
> > > Hi Christian,
> > >
> > > Thanks for the response. Unfortunately, I've not been able to get the
> > reloading working.
> > >
> > > Kind regards,
> > > Reece
> > >
> > > On Wed, 21 Apr 2021 at 18:49, Christian Gr?n <
> christian.gr...@gmail.com>
> > wrote:
> > >>
> > >> Hi Reece,
> > >>
> > >> If you install your Java code as JAR file in the repository [1], the
> > >> code will be loaded and unloaded every time when your query is
> > >> executed. If you get an error message?
> > >>
> > >>   java.lang.reflect.InaccessibleObjectException: Unable to make field
> > >> private final jdk.internal.loader.URLClassPath
> > >> 

Re: [basex-talk] Make use of external Identity Management for BaseX

2021-04-30 Thread Marco Lettere

Hi Christian and Rob,
as the authors of the code you point to we confirm that interacting with 
Keycloak in XQuery and in particular RestXQ is rather comfortable.
That example is mostly a demonstration code for a tool that scrapes a 
site index and registers sites named gateways as public clients (in 
Oauth2 sense) into a Keycloak instance.
It is a proof of concept (as you can see from the credentials  :-D) that 
has been used as a batch one-time migration in a particular setting.


We have also a RestXQ module that in combination with basex:perm 
annotations protects access to a GUI implementing the Oauth2 Code-grant 
flow. If Rob is interested we could share.


If there should be any plan of integrating Oauth2/OIDC flows more 
tightly into BaseX we could also be available for helping out.


Regards,
Marco.

On 30/04/21 08:47, Christian Grün wrote:

Hi Rob,

There is no prepackaged module for Keycloak (at least I’m aware of
none), but you can write your own code with XQuery. See [1] for an
example how this might look like.

Are you using RESTXQ?

Best,
Christian

[1] 
https://code-repo.d4science.org/gCubeSystem/d4science-keycloak-themes/src/branch/master/src/utils/xquery



On Thu, Apr 29, 2021 at 3:54 PM Rob  wrote:

Hi,

I have a question.
Can BaseX make use of an Identity Management application like Keycloak for 
Users?

I can’t find anything about it :)

With kind regards,
Rob Tjalma





Re: [basex-talk] Reloading jars on a running http server.

2021-04-30 Thread Christian Grün
Hi Reece,

> You'll need to copy the kotlin-stdlib-1.4.32.jar file in addition to the 
> test.jar file to BaseX's lib directory.

Please note that JAR libraries will only be unregistered after query
evalution if they are moved into the repo directory. If a library is
copied into the lib directory, it will be added to the static
classpath.

In the given case, you could probably keep kotlin-stdlib-1.4.32.jar in
the lib directory, but you’ll need to keep your development code in
the repository (as described in the Wiki). It’s no problem, though, to
directly modify the repo code (you don’t have to use REPO INSTALL or
repo:install for that).

If the problem persists, feel free to send me a little test.jar, I can
then do further testing.

Hope this helps,
Christian


On Fri, Apr 30, 2021 at 9:14 AM Reece Dunn  wrote:
>
> Hi Christian,
>
> I'm not seeing any exceptions in the console window, even when enabling the 
> debug setting. I'm using the AdoptOpenJDK 1.8. I also have AdoptOpenJDK 11, 
> but I assume that will have the issue you described.
>
> It's a custom-built jar using Kotlin, built via gradle.
>
> One thing that it could be is that I'm using Kotlin objects (not classes), 
> e.g.:
>
> package test
> object Test { fun f(): String = "test" }
>
> and using it like:
>
> declare namespace Test = "java:test.Test";
>
> declare function test:f() as xs:string {
> Test::f(Test::INSTANCE())
> };
>
> The build.gradle file is simple. It looks something like this (removing 
> things like the junit configuration):
>
> -
> buildscript {
> ext.kotlin_version = "1.4.32"
> ext.kotlin_stdlib = "kotlin-stdlib"
> ext.java_version = "1.8"
>
> repositories { mavenCentral() }
> dependencies { classpath 
> "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" }
> }
>
> apply plugin: 'kotlin'
>
> repositories {
> mavenCentral()
> mavenLocal()
> }
>
> compileKotlin { kotlinOptions { jvmTarget = java_version } }
> compileTestKotlin { kotlinOptions { jvmTarget = java_version } }
>
> dependencies {
> implementation "org.jetbrains.kotlin:$kotlin_stdlib:$kotlin_version"
> }
> -
>
> You'll need to copy the kotlin-stdlib-1.4.32.jar file in addition to the 
> test.jar file to BaseX's lib directory.
>
> Kind regards,
> Reece
>
> On Fri, 30 Apr 2021 at 07:48, Christian Grün  
> wrote:
>>
>> Hi Reece,
>>
>> I’m sorry to hear that. Did you build a custom JAR file, or do you
>> encounter problems with the JDK?
>>
>> Cheers,
>> Christian
>>
>>
>>
>> On Thu, Apr 29, 2021 at 9:48 PM Reece Dunn  wrote:
>> >
>> > Hi Christian,
>> >
>> > Thanks for the response. Unfortunately, I've not been able to get the 
>> > reloading working.
>> >
>> > Kind regards,
>> > Reece
>> >
>> > On Wed, 21 Apr 2021 at 18:49, Christian Grün  
>> > wrote:
>> >>
>> >> Hi Reece,
>> >>
>> >> If you install your Java code as JAR file in the repository [1], the
>> >> code will be loaded and unloaded every time when your query is
>> >> executed. If you get an error message…
>> >>
>> >>   java.lang.reflect.InaccessibleObjectException: Unable to make field
>> >> private final jdk.internal.loader.URLClassPath
>> >> java.net.URLClassLoader.ucp accessible: module java.base does not
>> >> "opens java.net" to unnamed module @79e2c065
>> >>
>> >> …unloading fails [2], as you’re probably using a more recent version
>> >> of the JDK, which restricts reflective access to internal variables.
>> >> You can get around this by adding Java flags at startup time:
>> >>
>> >>  --add-opens java.base/java.net=ALL-UNNAMED
>> >>  --add-opens java.base/jdk.internal.loader=ALL-UNNAMED
>> >>
>> >> Maybe there are better solutions to unload JAR files today.
>> >> Suggestions are welcome!
>> >>
>> >> Hope this helps,
>> >> Christian
>> >>
>> >> [1] https://docs.basex.org/wiki/Repository#Java
>> >> [2] 
>> >> https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/util/JarLoader.java#L34
>> >>
>> >>
>> >>
>> >> On Tue, Apr 20, 2021 at 6:44 PM Reece Dunn  wrote:
>> >> >
>> >> > Hi all,
>> >> >
>> >> > I'm working on a Java class that I'm importing into an XQuery, so I can 
>> >> > do additional processing on the data that isn't easily expressible in 
>> >> > XQuery (or XSLT). In order to get BaseX to pick up a modified version 
>> >> > of the jar file I'm building, I'm restarting the BaseX http server.
>> >> >
>> >> > This makes it slower to turn around testing the changes. Is there a 
>> >> > better way of doing this?
>> >> >
>> >> > Kind regards,
>> >> > Reece


Re: [basex-talk] Reloading jars on a running http server.

2021-04-30 Thread Reece Dunn
Hi Christian,

I'm not seeing any exceptions in the console window, even when enabling the
debug setting. I'm using the AdoptOpenJDK 1.8. I also have AdoptOpenJDK 11,
but I assume that will have the issue you described.

It's a custom-built jar using Kotlin, built via gradle.

One thing that it could be is that I'm using Kotlin objects (not classes),
e.g.:

package test
object Test { fun f(): String = "test" }

and using it like:

declare namespace Test = "java:test.Test";

declare function test:f() as xs:string {
Test::f(Test::INSTANCE())
};

The build.gradle file is simple. It looks something like this (removing
things like the junit configuration):

-
buildscript {
ext.kotlin_version = "1.4.32"
ext.kotlin_stdlib = "kotlin-stdlib"
ext.java_version = "1.8"

repositories { mavenCentral() }
dependencies { classpath
"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" }
}

apply plugin: 'kotlin'

repositories {
mavenCentral()
mavenLocal()
}

compileKotlin { kotlinOptions { jvmTarget = java_version } }
compileTestKotlin { kotlinOptions { jvmTarget = java_version } }

dependencies {
implementation "org.jetbrains.kotlin:$kotlin_stdlib:$kotlin_version"
}
-

You'll need to copy the kotlin-stdlib-1.4.32.jar file in addition to the
test.jar file to BaseX's lib directory.

Kind regards,
Reece

On Fri, 30 Apr 2021 at 07:48, Christian Grün 
wrote:

> Hi Reece,
>
> I’m sorry to hear that. Did you build a custom JAR file, or do you
> encounter problems with the JDK?
>
> Cheers,
> Christian
>
>
>
> On Thu, Apr 29, 2021 at 9:48 PM Reece Dunn  wrote:
> >
> > Hi Christian,
> >
> > Thanks for the response. Unfortunately, I've not been able to get the
> reloading working.
> >
> > Kind regards,
> > Reece
> >
> > On Wed, 21 Apr 2021 at 18:49, Christian Grün 
> wrote:
> >>
> >> Hi Reece,
> >>
> >> If you install your Java code as JAR file in the repository [1], the
> >> code will be loaded and unloaded every time when your query is
> >> executed. If you get an error message…
> >>
> >>   java.lang.reflect.InaccessibleObjectException: Unable to make field
> >> private final jdk.internal.loader.URLClassPath
> >> java.net.URLClassLoader.ucp accessible: module java.base does not
> >> "opens java.net" to unnamed module @79e2c065
> >>
> >> …unloading fails [2], as you’re probably using a more recent version
> >> of the JDK, which restricts reflective access to internal variables.
> >> You can get around this by adding Java flags at startup time:
> >>
> >>  --add-opens java.base/java.net=ALL-UNNAMED
> >>  --add-opens java.base/jdk.internal.loader=ALL-UNNAMED
> >>
> >> Maybe there are better solutions to unload JAR files today.
> >> Suggestions are welcome!
> >>
> >> Hope this helps,
> >> Christian
> >>
> >> [1] https://docs.basex.org/wiki/Repository#Java
> >> [2]
> https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/util/JarLoader.java#L34
> >>
> >>
> >>
> >> On Tue, Apr 20, 2021 at 6:44 PM Reece Dunn 
> wrote:
> >> >
> >> > Hi all,
> >> >
> >> > I'm working on a Java class that I'm importing into an XQuery, so I
> can do additional processing on the data that isn't easily expressible in
> XQuery (or XSLT). In order to get BaseX to pick up a modified version of
> the jar file I'm building, I'm restarting the BaseX http server.
> >> >
> >> > This makes it slower to turn around testing the changes. Is there a
> better way of doing this?
> >> >
> >> > Kind regards,
> >> > Reece
>


Re: [basex-talk] Getting profile information in server responses.

2021-04-30 Thread Christian Grün
A good idea; I’ll think of ways to get this included. One challenge
might be that the response is streamed to the client. This means that
when creating the HTTP request headers, it will not be known yet how
long the evaluation will take (and the time for evaluation may also
depend on the connection speed). The time for parsing and compiling
the query should be known at that time, though. – Maybe we could
suppress result streaming when timings are requested.


On Thu, Apr 29, 2021 at 9:50 PM Reece Dunn  wrote:
>
> Hi all,
>
> In BaseX, is there a way to get the profile timings (compile, run, print, 
> etc.) in the response of a HTTP request via the Server-Timing header 
> (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Server-Timing)?
>
> Kind regards,
> Reece


Re: [basex-talk] Reloading jars on a running http server.

2021-04-30 Thread Christian Grün
Hi Reece,

I’m sorry to hear that. Did you build a custom JAR file, or do you
encounter problems with the JDK?

Cheers,
Christian



On Thu, Apr 29, 2021 at 9:48 PM Reece Dunn  wrote:
>
> Hi Christian,
>
> Thanks for the response. Unfortunately, I've not been able to get the 
> reloading working.
>
> Kind regards,
> Reece
>
> On Wed, 21 Apr 2021 at 18:49, Christian Grün  
> wrote:
>>
>> Hi Reece,
>>
>> If you install your Java code as JAR file in the repository [1], the
>> code will be loaded and unloaded every time when your query is
>> executed. If you get an error message…
>>
>>   java.lang.reflect.InaccessibleObjectException: Unable to make field
>> private final jdk.internal.loader.URLClassPath
>> java.net.URLClassLoader.ucp accessible: module java.base does not
>> "opens java.net" to unnamed module @79e2c065
>>
>> …unloading fails [2], as you’re probably using a more recent version
>> of the JDK, which restricts reflective access to internal variables.
>> You can get around this by adding Java flags at startup time:
>>
>>  --add-opens java.base/java.net=ALL-UNNAMED
>>  --add-opens java.base/jdk.internal.loader=ALL-UNNAMED
>>
>> Maybe there are better solutions to unload JAR files today.
>> Suggestions are welcome!
>>
>> Hope this helps,
>> Christian
>>
>> [1] https://docs.basex.org/wiki/Repository#Java
>> [2] 
>> https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/util/JarLoader.java#L34
>>
>>
>>
>> On Tue, Apr 20, 2021 at 6:44 PM Reece Dunn  wrote:
>> >
>> > Hi all,
>> >
>> > I'm working on a Java class that I'm importing into an XQuery, so I can do 
>> > additional processing on the data that isn't easily expressible in XQuery 
>> > (or XSLT). In order to get BaseX to pick up a modified version of the jar 
>> > file I'm building, I'm restarting the BaseX http server.
>> >
>> > This makes it slower to turn around testing the changes. Is there a better 
>> > way of doing this?
>> >
>> > Kind regards,
>> > Reece


Re: [basex-talk] Make use of external Identity Management for BaseX

2021-04-30 Thread Christian Grün
Hi Rob,

There is no prepackaged module for Keycloak (at least I’m aware of
none), but you can write your own code with XQuery. See [1] for an
example how this might look like.

Are you using RESTXQ?

Best,
Christian

[1] 
https://code-repo.d4science.org/gCubeSystem/d4science-keycloak-themes/src/branch/master/src/utils/xquery



On Thu, Apr 29, 2021 at 3:54 PM Rob  wrote:
>
> Hi,
>
> I have a question.
> Can BaseX make use of an Identity Management application like Keycloak for 
> Users?
>
> I can’t find anything about it :)
>
> With kind regards,
> Rob Tjalma