Re: Problems with Jetty Session Managemenent?

2019-06-11 Thread lechlukasz
OK great, I've updated Karaf and tested, ans everything is fine 



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html


Re: Adding Jackson to Karaf startup.properties file to enable JSON logging

2019-06-11 Thread Noobtube Account
Thanks JB! I've got the following config for appender to try out the field
exclude:

# File
filename=${karaf.data}/log/karaf-json.log

# Marshaller
marshaller.target=(dataFormat=json)

# Append file
append=true

# Fields Excluded by Name
event.property.name.exclude=MDC


This seems to stop the appender from producing any json log. Removing
the event.property.name.exclude=MDC

Also I couldn't find these properties documented anywhere nor could I
find them in karaf decanter source code. Is the format I used correct?



On Sun, 9 Jun 2019 at 02:58, Jean-Baptiste Onofré  wrote:

> Yes, you can create your own marshaller is you want to ;)
>
> By default, Decanter collectors send a Map to the Decanter appenders.
> Then the appenders use eventually marshaller to convert the Map to
> something else. You can control the keys or values in this map that you
> want to include/exclude by directly configuring in the appender
> configuration (with
>
> event.property.name.exclude/event.property.name.include/event.property.value.exclude/event.property.value.include
> properties).
> By default, the JSON Marshaller convert the map as a json using jackson.
> If you want a full control, you can also create your own Marshaller
> service. But I think that just the filtering on the appender should be
> OK for you.
> Let me know if you need help about that.
>
> Regards
> JB
>
> On 08/06/2019 18:52, Noobtube Account wrote:
> > Great! Are we also able to control the format or turn fields off?
> >
> >
> > On Sun, 9 Jun 2019 at 2:51 am, Jean-Baptiste Onofré  > > wrote:
> >
> > Yes, Decanter Log Collector is a global Pax Logging "sniffer". So it
> > takes messages from any bundle by default.
> >
> > However, you can configure this directly in
> > etc/org.ops4j.pax.logging.cfg.
> >
> > Regards
> > JB
> >
> > On 08/06/2019 18:07, Noobtube Account wrote:
> > > Oh, scratch that. Uncommenting the filename in
> > > etc/org.apache.karaf.decanter.appender.file.cfg seemed to have
> made it
> > > work. It probably wasn't due to that though and likely something
> > else I
> > > did. Anyway, thanks for pointing out karaf decanter.
> > >
> > > Will the log collector collect log executions made through any
> > bundle?
> > >
> > >
> > > On Sun, 9 Jun 2019 at 01:55, Noobtube Account  > 
> > > >> wrote:
> > >
> > > Thanks JB. I'm trying the decanter as you mentioned.
> > >
> > > I've done:
> > > feature:repo-add decanter
> > > feature:install decanter-collector-log
> > > feature:install decanter-appender-file
> > >
> > > Then I edited etc/org.apache.karaf.decanter.appender.file.cfg
> and
> > > added:
> > > # Marshaller
> > > marshaller.target=(dataFormat=json)
> > >
> > > But I don't see any logs created. Do we need to install the
> > marshaller?
> > >
> > > On Sun, 9 Jun 2019 at 00:33, Jean-Baptiste Onofré
> > mailto:j...@nanthrax.net>
> > > >> wrote:
> > >
> > > By the way, instead of doing that, you can use regular
> logging
> > > and use
> > > Decanter with the log collector and the json marshaller to
> > > create json
> > > output (to log, file, elasticsearch or whatever).
> > >
> > > Regards
> > > JB
> > >
> > > On 08/06/2019 16:30, Jean-Baptiste Onofré wrote:
> > > > Hi
> > > >
> > > > You don't have to add logback-core as pax-logging-logback
> > > bundle already
> > > > embed it.
> > > >
> > > > Secondly it seems jackson is not imported correctly. The
> > root
> > > cause is:
> > > >
> > > > Caused by: java.lang.ClassNotFoundException:
> > > >> com.fasterxml.jackson.databind.ObjectMapper not found by
> > > >> org.ops4j.pax.logging.pax-logging-logback
> > > >
> > > > You can try a dynamic import on pax-logging-logback.
> > > >
> > > > Else a simple workaround is to create a fragment with
> > > > pax-logging-logback as host and embedding
> (private-package)
> > > the classes
> > > > you need.
> > > >
> > > > I did that for json layout with pax-logging-log4j2.
> > > >
> > > > Regards
> > > > JB
> > > >
> > > > On 08/06/2019 16:17, Noobtube Account wrote:
> > > >> I'm trying to get JSON format logging enabled in Karaf.
> > > Trying to do
> > > >> something similar to what's described
> > > >> in https://ops4j1.jira.com/browse/

Re: Authentication in a custom web application in karaf

2019-06-11 Thread Francois Papon
Hi,

You have to add the war feature in your bootFeatures.

regards,

François
fpa...@apache.org

Le 11/06/2019 à 22:50, Francois Papon a écrit :
> Hi,
>
> Let me try with your repo.
>
> regards,
>
> François
> fpa...@apache.org
>
> Le 11/06/2019 à 19:16, cooshal a écrit :
>> Hi again fpapon,
>>
>> As I have pointed out in my previous post, I have configured the web.xml
>> (https://github.com/cooshal/karaf-assembly-jms/blob/master/modules/web-console/src/main/webapp/WEB-INF/web.xml#L24)
>> to use the karaf realm. But, I am still not able to get the authentication
>> functionality working.
>>
>> Do you have any suggestions on this ? My demo project is available at:
>> https://github.com/cooshal/karaf-assembly-jms/blob/master/modules/web-console
>>
>> Regards,
>> Cooshal.
>>
>>
>>
>> --
>> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html


Re: Authentication in a custom web application in karaf

2019-06-11 Thread Francois Papon
Hi,

Let me try with your repo.

regards,

François
fpa...@apache.org

Le 11/06/2019 à 19:16, cooshal a écrit :
> Hi again fpapon,
>
> As I have pointed out in my previous post, I have configured the web.xml
> (https://github.com/cooshal/karaf-assembly-jms/blob/master/modules/web-console/src/main/webapp/WEB-INF/web.xml#L24)
> to use the karaf realm. But, I am still not able to get the authentication
> functionality working.
>
> Do you have any suggestions on this ? My demo project is available at:
> https://github.com/cooshal/karaf-assembly-jms/blob/master/modules/web-console
>
> Regards,
> Cooshal.
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html


Re: Debugging Itests

2019-06-11 Thread Łukasz Dywicki
Hey Paul,
Within pax exam there are several processes which gets started. One
which you need to debug is Karaf one. All steps you mentioned seems to
be correct.

Debugging of option creation is not subject of debugConfiguration. This
code is executed by maven (surefire) or IDE you run. In order to debug
calculation of runtime configurations you need to debug process which
does that, namely junit executor.
General guide - @Configuration method is called before managed process
is launched thus can't be subject of standard Karaf debugging.
Keep in mind that surefire debugging might be tricky, but IntelliJ
should be rather smooth. Just remember to swap debugger ports.

In terms of exam debug configuration - pax allows you to specify port
but also "hold" flag to wait for debugger to be attached:
See:
org.ops4j.pax.exam.karaf.options.KarafDistributionOption#debugConfiguration(java.lang.String,
boolean)
If you will set second argument to true runtime won't be started until
you attach your debugger. Sometimes it is necessary to catch events
associated with bundles which are starting early.
>From what I observed IntelliJ can also skip breakpoints which have
signature mismatches. Make sure you have all versions in sync.

Kind regards,
Łukasz
--
Code-House http://code-house.org

On 11.06.2019 12:07, Paul Fraser wrote:
> Hi Again,
> 
> Is it possible in an itest to debug into the inner karaf runtime?
> 
> To try and debug into the "listBundleCommand" test in the Karaf Itest
> example I tried
> 
>  1. Set breakpoint on "String httpPort = ..." in the "public Option[]
> config()" method in the itest code.
>  2. Set breakpoint at first line  in "listBundleCommand" test.
>  3. Set a remote configuration in Intellij with port 5005.
>  4. start karaf with bin/karaf debug.
>  5. console displays "Listening for transport dt at address: 5005
>  6. Karaf starts up with branding and prompt.
>  7. Shift-F9 in intellij starts a debug session.
>  8. Debug console displays "Connected to the target VM, address:
> 'localhost:5005", transport: 'socket'
>  9. Run test (debug)
> 10. Debugger stops at breakpoint '1' above.
> 11. Does not stop at breakpoint '2' above.
> 12. "listBundleCommand" test runs to completion and output as expected.
> 
> If it can be done, what am I missing?
> 
> Paul Fraser
> 
> 
> 
> 
> 
> 
> 
> 
> 


Re: Authentication in a custom web application in karaf

2019-06-11 Thread cooshal
Hi again fpapon,

As I have pointed out in my previous post, I have configured the web.xml
(https://github.com/cooshal/karaf-assembly-jms/blob/master/modules/web-console/src/main/webapp/WEB-INF/web.xml#L24)
to use the karaf realm. But, I am still not able to get the authentication
functionality working.

Do you have any suggestions on this ? My demo project is available at:
https://github.com/cooshal/karaf-assembly-jms/blob/master/modules/web-console

Regards,
Cooshal.



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html


Re: feature for jetty proxy

2019-06-11 Thread Łukasz Dywicki
I've used JettyProxyServlet too, and it works with openHAB out of the box:
https://github.com/ConnectorIO/connectorio-io-http :-)

At least for openHAB it wasn't a problem cause jetty-proxy is present at
runtime.

Anyhow - there is bunch of advanced features Jetty's proxy servlet
enables. I been using it to transform on the fly response from proxied
services. It's quite powerful. If you need a sample of this - I will be
able to cut it from somewhere.

Cheers,
Łukasz
--
Code-House http://code-house.org


On 10.06.2019 18:35, Jean-Baptiste Onofré wrote:
> Hi Markus,
> 
> I'm already added jetty-proxy in the Pax Web and Karaf features.
> 
> I just mentioned a workaround waiting for new Pax Web/Karaf releases.
> 
> Regards
> JB
> 
> On 10/06/2019 17:55, Markus Rathgeb wrote:
>> Hi JB,
>>
>>> First, you can use the ProxyService directly to programmatically create
>>> the proxies you need.
>>
>> I read the proxy service of the Karaf project but this does not fit to
>> my use-case.
>> I use a subclass of Jetty's proxy servlet because the "proxyTo" is not fixed.
>> It depends on the caller of the URL which backend is used to generate
>> the response for the request.
>>
>> Think about a system where an user needs to be logged in first.
>> The login credentials are used to choose the real backend system.
>>
>> If user 1 calls httsp://some.thing/foo/bar the "reverse proxy"
>> redirects the request to https://10.10.10.101/foo/bar
>> If user 2 calls httsp://some.thing/foo/bar the "reverse proxy"
>> redirects the request to https://10.10.10.102/foo/bar
>> ...
>>
>> So my servlet is a subclass of the proxy servlet that generated the
>> URL for the rewrite target in a very dynamic way.
>>
>> And it is already working it is just some additional work to align the
>> Jetty version on every Karaf bump.
>>
>>> About the version, it's actually the opposite: the Jetty proxy is a pure
>>> servlet, and a version of Jetty proxy can work with other Jetty version.
>>
>> Sure, the proxy is just a servlet but the implementation is using a
>> e.g. Jetty HttpClient:
>>
>> * 
>> https://github.com/eclipse/jetty.project/blob/jetty-9.4.18.v20190429/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java#L43
>> * 
>> https://github.com/eclipse/jetty.project/blob/jetty-9.4.18.v20190429/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java#L129
>> * 
>> https://github.com/eclipse/jetty.project/blob/jetty-9.4.18.v20190429/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java#L273
>>
>> If the Jetty proxy servlet implementation is newer then the Jetty HTTP
>> Client the proxy servlet implementation could potentially use
>> functions that are not yet present in the provided HttpClient
>> implementation.
>> If strong semver is used a newer HTTP Client should still support all
>> stuff used by the proxy servlet but how knows...
>>
>>
>> The Jetty proxy artifact is already an OSGi bundle, so what's the "big
>> win" to add its classes to every bundle as private package instead of
>> adding the jetty-proxy bundle to the OSGi runtime?
>>
>> Thank you for your patient,
>> Markus
>>
> 


Re: Authentication in a custom web application in karaf

2019-06-11 Thread cooshal
Hi:

yes ! and I have already configured that in web.xml as well.

https://github.com/cooshal/karaf-assembly-jms/blob/master/modules/web-console/src/main/webapp/WEB-INF/web.xml#L24

Regards,
Cooshal.



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html


Re: Authentication in a custom web application in karaf

2019-06-11 Thread Francois Papon
Hi,

Do you want to use Karaf realm?

regards,

François
fpa...@apache.org

Le 11/06/2019 à 14:07, cooshal a écrit :
> Hi:
>
> I have a sample web application, which I need to be protected by
> authentication, just the way it does for Hawtio or other similar
> applications.
>
> I have my sample code here
> (https://github.com/cooshal/karaf-assembly-jms/tree/master/modules/web-console).
> t's an extremely basic web app with an index.html. The endpoint will be
> exposed to /management/. I am trying to use it with the maven-bundle-plugin.
> I had followed few examples from pax-web project. 
>
> I tried with 'war' packaging. The authentication works in that case, but I
> was not able to serve my index.html (for example). Could be some config
> issues.
>
> It would be great, if anyone could provide me some info on this.
>
> Regards,
> Cooshal.
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html


Re: Debugging Itests

2019-06-11 Thread Paul Fraser

Hi Again,

Is it possible in an itest to debug into the inner karaf runtime?

To try and debug into the "listBundleCommand" test in the Karaf Itest example I 
tried

1. Set breakpoint on "String httpPort = ..." in the "public Option[] config()" 
method in the itest
   code.
2. Set breakpoint at first line  in "listBundleCommand" test.
3. Set a remote configuration in Intellij with port 5005.
4. start karaf with bin/karaf debug.
5. console displays "Listening for transport dt at address: 5005
6. Karaf starts up with branding and prompt.
7. Shift-F9 in intellij starts a debug session.
8. Debug console displays "Connected to the target VM, address: 
'localhost:5005", transport: 'socket'
9. Run test (debug)
10. Debugger stops at breakpoint '1' above.
11. Does not stop at breakpoint '2' above.
12. "listBundleCommand" test runs to completion and output as expected.

If it can be done, what am I missing?

Paul Fraser











Authentication in a custom web application in karaf

2019-06-11 Thread cooshal
Hi:

I have a sample web application, which I need to be protected by
authentication, just the way it does for Hawtio or other similar
applications.

I have my sample code here
(https://github.com/cooshal/karaf-assembly-jms/tree/master/modules/web-console).
t's an extremely basic web app with an index.html. The endpoint will be
exposed to /management/. I am trying to use it with the maven-bundle-plugin.
I had followed few examples from pax-web project. 

I tried with 'war' packaging. The authentication works in that case, but I
was not able to serve my index.html (for example). Could be some config
issues.

It would be great, if anyone could provide me some info on this.

Regards,
Cooshal.



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html


Re: Debugging Itests

2019-06-11 Thread Paul Fraser

Hi,

On 2/06/2019 7:20 am, Paul Fraser wrote:

Hmm,
Over thinking the problem..I was looking in the wrong place.

When setting up MavenArtifactUrlReference I had the artifact "type" being set AFTER 
"versionAsInProject"

Fixed this and the Karaf magic worked.

My comments (above) are rubbish.
The order of the build of the MavenArtifactUrlReference does not matter.

Paul Fraser



Re: Problems with Jetty Session Managemenent?

2019-06-11 Thread Jean-Baptiste Onofré
Correction: it's fixed ;)

Here's the fix I did:

https://ops4j1.jira.com/browse/PAXWEB-1197

Regards
JB

On 11/06/2019 10:16, lechlukasz wrote:
> Hello,
> 
> Is it fixed in Karaf 4.2.6?
> I can't find the issue in the release notes for pax web. What is the issue
> number?
> 
> Best regards,
> Lukasz Lech
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> 

-- 
Jean-Baptiste Onofré
jbono...@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com


Re: Problems with Jetty Session Managemenent?

2019-06-11 Thread Jean-Baptiste Onofré
Hi Lukasz,

I did a change but I don't think it's enough. I will create a Jira to
track this (at Karaf) and I will cut 4.2.7 soon.

Regards
JB

On 11/06/2019 10:16, lechlukasz wrote:
> Hello,
> 
> Is it fixed in Karaf 4.2.6?
> I can't find the issue in the release notes for pax web. What is the issue
> number?
> 
> Best regards,
> Lukasz Lech
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> 

-- 
Jean-Baptiste Onofré
jbono...@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com


Re: Problems with Jetty Session Managemenent?

2019-06-11 Thread lechlukasz
Hello,

Is it fixed in Karaf 4.2.6?
I can't find the issue in the release notes for pax web. What is the issue
number?

Best regards,
Lukasz Lech



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html