Re: [osgi-dev] Apache cxf: add authorization header in Client

2018-03-07 Thread Michael Wirth via osgi-dev
I put a quick hack to GitHub.

https://github.com/mwirth/weatherbit

everyone, feel free to improve/change it (it needs it).

Michael


Am 05.03.2018 um 21:37 schrieb Christian Schneider 
>:

Pretty cool. If you have the chance, maybe you can make a little example as a 
github project.

Christian

2018-03-05 15:37 GMT+01:00 Michael Wirth via osgi-dev 
>:
Now I made it. Here is what I did if someone is interested.

In an IntentsProvider I return a List of Intents (before I implemented two 
IntentsProvider). The first Intent is the JacksonJsonProvider, the second 
implements org.apache.cxf.feature.Freature. In Feature#initialize I register a 
OutInterceptor and in his method handleMessage I add the Authorization header.

Best regards and thanks for the tips.
Michael



Am 02.03.2018 um 07:26 schrieb Christian Schneider 
>:

The cleanest way to add authorization or any other technical capability like 
logging is to add a CXF feature to the client. If you are lucky then there is 
already a suitable feature. If not then you have to create your own feature and 
interceptor for adding the header.

How do you create the client?

Christian

2018-03-01 19:43 GMT+01:00 Michael Wirth via osgi-dev 
>:
I’m using Apache CXF in an OSGi-Application to call REST-Services provided from 
another (spring) application.
I give the path-interface (generated with swagger) to my 
osgi-client-appliation. While runtime, Apache CXF generates the client proxy 
interface, calls the REST-Service and deserialize the returned json to the 
swagger generated objects. All works fine :-)
Now I miss one thing. For Authorization I have to add a header. Because I do 
not have the ‚Client‘-Instanze (WebTarget for instance) I’m not able to add an 
header. Is there some property, configuration or a service which can be used?

Best Regards,
Michael
___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev



--
--
Christian Schneider
http://www.liquid-reality.de

Computer Scientist
http://www.adobe.com



___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev



--
--
Christian Schneider
http://www.liquid-reality.de

Computer Scientist
http://www.adobe.com


___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Re: [osgi-dev] Apache cxf: add authorization header in Client

2018-03-05 Thread Christian Schneider via osgi-dev
Pretty cool. If you have the chance, maybe you can make a little example as
a github project.

Christian

2018-03-05 15:37 GMT+01:00 Michael Wirth via osgi-dev <
osgi-dev@mail.osgi.org>:

> Now I made it. Here is what I did if someone is interested.
>
> In an IntentsProvider I return a List of Intents (before I implemented two
> IntentsProvider). The first Intent is the JacksonJsonProvider, the second
> implements org.apache.cxf.feature.Freature. In Feature#initialize I
> register a OutInterceptor and in his method handleMessage I add the
> Authorization header.
>
> Best regards and thanks for the tips.
> Michael
>
>
>
> Am 02.03.2018 um 07:26 schrieb Christian Schneider <
> ch...@die-schneider.net>:
>
> The cleanest way to add authorization or any other technical capability
> like logging is to add a CXF feature to the client. If you are lucky then
> there is already a suitable feature. If not then you have to create your
> own feature and interceptor for adding the header.
>
> How do you create the client?
>
> Christian
>
> 2018-03-01 19:43 GMT+01:00 Michael Wirth via osgi-dev <
> osgi-dev@mail.osgi.org>:
>
>> I’m using Apache CXF in an OSGi-Application to call REST-Services
>> provided from another (spring) application.
>> I give the path-interface (generated with swagger) to my
>> osgi-client-appliation. While runtime, Apache CXF generates the client
>> proxy interface, calls the REST-Service and deserialize the returned json
>> to the swagger generated objects. All works fine :-)
>> Now I miss one thing. For Authorization I have to add a header. Because I
>> do not have the ‚Client‘-Instanze (WebTarget for instance) I’m not able to
>> add an header. Is there some property, configuration or a service which can
>> be used?
>>
>> Best Regards,
>> Michael
>> ___
>> OSGi Developer Mail List
>> osgi-dev@mail.osgi.org
>> https://mail.osgi.org/mailman/listinfo/osgi-dev
>
>
>
>
> --
> --
> Christian Schneider
> http://www.liquid-reality.de
>
> Computer Scientist
> http://www.adobe.com
>
>
>
> ___
> OSGi Developer Mail List
> osgi-dev@mail.osgi.org
> https://mail.osgi.org/mailman/listinfo/osgi-dev
>



-- 
-- 
Christian Schneider
http://www.liquid-reality.de

Computer Scientist
http://www.adobe.com
___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Re: [osgi-dev] Apache cxf: add authorization header in Client

2018-03-05 Thread Michael Wirth via osgi-dev
Now I made it. Here is what I did if someone is interested.

In an IntentsProvider I return a List of Intents (before I implemented two 
IntentsProvider). The first Intent is the JacksonJsonProvider, the second 
implements org.apache.cxf.feature.Freature. In Feature#initialize I register a 
OutInterceptor and in his method handleMessage I add the Authorization header.

Best regards and thanks for the tips.
Michael



Am 02.03.2018 um 07:26 schrieb Christian Schneider 
>:

The cleanest way to add authorization or any other technical capability like 
logging is to add a CXF feature to the client. If you are lucky then there is 
already a suitable feature. If not then you have to create your own feature and 
interceptor for adding the header.

How do you create the client?

Christian

2018-03-01 19:43 GMT+01:00 Michael Wirth via osgi-dev 
>:
I’m using Apache CXF in an OSGi-Application to call REST-Services provided from 
another (spring) application.
I give the path-interface (generated with swagger) to my 
osgi-client-appliation. While runtime, Apache CXF generates the client proxy 
interface, calls the REST-Service and deserialize the returned json to the 
swagger generated objects. All works fine :-)
Now I miss one thing. For Authorization I have to add a header. Because I do 
not have the ‚Client‘-Instanze (WebTarget for instance) I’m not able to add an 
header. Is there some property, configuration or a service which can be used?

Best Regards,
Michael
___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev



--
--
Christian Schneider
http://www.liquid-reality.de

Computer Scientist
http://www.adobe.com


___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Re: [osgi-dev] Apache cxf: add authorization header in Client

2018-03-01 Thread Michael Wirth via osgi-dev
enclosed some snippets about the client.


The path interface, created with swagger from a yaml-file via 'java -jar 
swagger-codegen-cli.jar generate -l jaxrs-cxf-client -i ...'

import javax.ws.rs.POST;
import javax.ws.rs.Path;
…
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
...

@Path("/")
@Api(value = "/", description = "")
public interface IsybaseApi {
@GET
@Path("/rncs/cnt")
@Produces({ "application/json" })
@ApiOperation(value = "returns total number of rncs", tags = {})
@ApiResponses(value = { @ApiResponse(code = 200, message = "number of RNCs", 
response = Count.class) })
public Count getCount();
}

The IntentsProvider:

@Component(property = 
"org.apache.cxf.dosgi.IntentName=com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider")
public class JacksonIntent implements IntentsProvider{
@Override
public List getIntents(){
return Arrays.asList((Object) new JacksonJsonProvider());
}
}

The class count, also generated from swagger:

public class Count  {



  @ApiModelProperty(value = "")
  private Long count = null;

  public Long getCount() {
return count;
  }

  public void setCount(Long count) {
this.count = count;
  }

  public Count count(Long count) {
this.count = count;
return this;
  }

  @Override
  public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Count {\n");



sb.append("count: ").append(toIndentedString(count)).append("\n");
sb.append("}");
return sb.toString();
  }

  private static String toIndentedString(java.lang.Object o) {
if (o == null) {
  return "null";
}
return o.toString().replace("\n", "\n");
  }
}

The client, for example a gogo command:

@Component(service = IsybaseApiCommands.class, property =
{
Debug.COMMAND_SCOPE + "=omnisybase",
Debug.COMMAND_FUNCTION + "=count"
}, name = "de.apollon.restclient.omn.isybase.command")
public class IsybaseApiCommands{

@Reference
private IsybaseApi omnapi;

@Descriptor("gets the number of RNCs")
public Count count() throws Exception{
return omnapi.getCount();
}
}
}

The client can do valid rest calls and de deserialization is running.
As I told I am not able to set the authorization header.


Kind regards,
Michael

Am 02.03.2018 um 07:26 schrieb Christian Schneider 
>:

The cleanest way to add authorization or any other technical capability like 
logging is to add a CXF feature to the client. If you are lucky then there is 
already a suitable feature. If not then you have to create your own feature and 
interceptor for adding the header.

How do you create the client?

Christian

2018-03-01 19:43 GMT+01:00 Michael Wirth via osgi-dev 
>:
I’m using Apache CXF in an OSGi-Application to call REST-Services provided from 
another (spring) application.
I give the path-interface (generated with swagger) to my 
osgi-client-appliation. While runtime, Apache CXF generates the client proxy 
interface, calls the REST-Service and deserialize the returned json to the 
swagger generated objects. All works fine :-)
Now I miss one thing. For Authorization I have to add a header. Because I do 
not have the ‚Client‘-Instanze (WebTarget for instance) I’m not able to add an 
header. Is there some property, configuration or a service which can be used?

Best Regards,
Michael
___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev



--
--
Christian Schneider
http://www.liquid-reality.de

Computer Scientist
http://www.adobe.com


___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Re: [osgi-dev] Apache cxf: add authorization header in Client

2018-03-01 Thread Christian Schneider via osgi-dev
The cleanest way to add authorization or any other technical capability
like logging is to add a CXF feature to the client. If you are lucky then
there is already a suitable feature. If not then you have to create your
own feature and interceptor for adding the header.

How do you create the client?

Christian

2018-03-01 19:43 GMT+01:00 Michael Wirth via osgi-dev <
osgi-dev@mail.osgi.org>:

> I’m using Apache CXF in an OSGi-Application to call REST-Services provided
> from another (spring) application.
> I give the path-interface (generated with swagger) to my
> osgi-client-appliation. While runtime, Apache CXF generates the client
> proxy interface, calls the REST-Service and deserialize the returned json
> to the swagger generated objects. All works fine :-)
> Now I miss one thing. For Authorization I have to add a header. Because I
> do not have the ‚Client‘-Instanze (WebTarget for instance) I’m not able to
> add an header. Is there some property, configuration or a service which can
> be used?
>
> Best Regards,
> Michael
> ___
> OSGi Developer Mail List
> osgi-dev@mail.osgi.org
> https://mail.osgi.org/mailman/listinfo/osgi-dev




-- 
-- 
Christian Schneider
http://www.liquid-reality.de

Computer Scientist
http://www.adobe.com
___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Re: [osgi-dev] Apache cxf: add authorization header in Client

2018-03-01 Thread Raymond Auge via osgi-dev
On Mar 1, 2018 3:49 PM, "Łukasz Dywicki"  wrote:

While this mailing list is not CXF specific, there are other OSGI-related
things which are discussed here such enroute.


Granted! I'm just trying to manage expectations. :)

Sincerely,
- Ray


@Michael - it really depends on how you create client - if you have any
factory bean? Maybe a bus instance? In general all CXF invocations, whether
its server or client side, are surrounded by interceptors and you can
modify request/response using them. If you use JAX-RS stub you can also use
client side filter to append headers (using jaxrs providers).

For more detailed answers - you may need to look cxf mailing list. Hope
that this helps you to move forward.

Cheers,
Lukasz


On 1 Mar 2018, at 20:45, Raymond Auge via osgi-dev 
wrote:

In an effort to not let your question go unanswered I'm going to just say
that this list is unlikely to be the place to find your answer.

This sounds like a CXF specific question. Have you asked this over at the
CXF user mailing list?

Sincerely,
- Ray

On Thu, Mar 1, 2018 at 1:43 PM, Michael Wirth via osgi-dev <
osgi-dev@mail.osgi.org> wrote:

> I’m using Apache CXF in an OSGi-Application to call REST-Services provided
> from another (spring) application.
> I give the path-interface (generated with swagger) to my
> osgi-client-appliation. While runtime, Apache CXF generates the client
> proxy interface, calls the REST-Service and deserialize the returned json
> to the swagger generated objects. All works fine :-)
> Now I miss one thing. For Authorization I have to add a header. Because I
> do not have the ‚Client‘-Instanze (WebTarget for instance) I’m not able to
> add an header. Is there some property, configuration or a service which can
> be used?
>
> Best Regards,
> Michael
> ___
> OSGi Developer Mail List
> osgi-dev@mail.osgi.org
> https://mail.osgi.org/mailman/listinfo/osgi-dev




-- 
*Raymond Augé* 
 (@rotty3000)
Senior Software Architect *Liferay, Inc.* 
 (@Liferay)
Board Member & EEG Co-Chair, OSGi Alliance 
(@OSGiAlliance)
___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev
___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Re: [osgi-dev] Apache cxf: add authorization header in Client

2018-03-01 Thread Łukasz Dywicki via osgi-dev
While this mailing list is not CXF specific, there are other OSGI-related 
things which are discussed here such enroute.

@Michael - it really depends on how you create client - if you have any factory 
bean? Maybe a bus instance? In general all CXF invocations, whether its server 
or client side, are surrounded by interceptors and you can modify 
request/response using them. If you use JAX-RS stub you can also use client 
side filter to append headers (using jaxrs providers).

For more detailed answers - you may need to look cxf mailing list. Hope that 
this helps you to move forward.

Cheers,
Lukasz

> On 1 Mar 2018, at 20:45, Raymond Auge via osgi-dev  
> wrote:
> 
> In an effort to not let your question go unanswered I'm going to just say 
> that this list is unlikely to be the place to find your answer.
> 
> This sounds like a CXF specific question. Have you asked this over at the CXF 
> user mailing list?
> 
> Sincerely,
> - Ray
> 
> On Thu, Mar 1, 2018 at 1:43 PM, Michael Wirth via osgi-dev 
> > wrote:
> I’m using Apache CXF in an OSGi-Application to call REST-Services provided 
> from another (spring) application.
> I give the path-interface (generated with swagger) to my 
> osgi-client-appliation. While runtime, Apache CXF generates the client proxy 
> interface, calls the REST-Service and deserialize the returned json to the 
> swagger generated objects. All works fine :-)
> Now I miss one thing. For Authorization I have to add a header. Because I do 
> not have the ‚Client‘-Instanze (WebTarget for instance) I’m not able to add 
> an header. Is there some property, configuration or a service which can be 
> used?
> 
> Best Regards,
> Michael
> ___
> OSGi Developer Mail List
> osgi-dev@mail.osgi.org 
> https://mail.osgi.org/mailman/listinfo/osgi-dev 
> 
> 
> 
> -- 
> Raymond Augé  (@rotty3000)
> Senior Software Architect Liferay, Inc.  (@Liferay)
> Board Member & EEG Co-Chair, OSGi Alliance  (@OSGiAlliance)
> ___
> OSGi Developer Mail List
> osgi-dev@mail.osgi.org
> https://mail.osgi.org/mailman/listinfo/osgi-dev

___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Re: [osgi-dev] Apache cxf: add authorization header in Client

2018-03-01 Thread Raymond Auge via osgi-dev
In an effort to not let your question go unanswered I'm going to just say
that this list is unlikely to be the place to find your answer.

This sounds like a CXF specific question. Have you asked this over at the
CXF user mailing list?

Sincerely,
- Ray

On Thu, Mar 1, 2018 at 1:43 PM, Michael Wirth via osgi-dev <
osgi-dev@mail.osgi.org> wrote:

> I’m using Apache CXF in an OSGi-Application to call REST-Services provided
> from another (spring) application.
> I give the path-interface (generated with swagger) to my
> osgi-client-appliation. While runtime, Apache CXF generates the client
> proxy interface, calls the REST-Service and deserialize the returned json
> to the swagger generated objects. All works fine :-)
> Now I miss one thing. For Authorization I have to add a header. Because I
> do not have the ‚Client‘-Instanze (WebTarget for instance) I’m not able to
> add an header. Is there some property, configuration or a service which can
> be used?
>
> Best Regards,
> Michael
> ___
> OSGi Developer Mail List
> osgi-dev@mail.osgi.org
> https://mail.osgi.org/mailman/listinfo/osgi-dev




-- 
*Raymond Augé* 
 (@rotty3000)
Senior Software Architect *Liferay, Inc.* 
 (@Liferay)
Board Member & EEG Co-Chair, OSGi Alliance  (@OSGiAlliance)
___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

[osgi-dev] Apache cxf: add authorization header in Client

2018-03-01 Thread Michael Wirth via osgi-dev
I’m using Apache CXF in an OSGi-Application to call REST-Services provided from 
another (spring) application.
I give the path-interface (generated with swagger) to my 
osgi-client-appliation. While runtime, Apache CXF generates the client proxy 
interface, calls the REST-Service and deserialize the returned json to the 
swagger generated objects. All works fine :-)
Now I miss one thing. For Authorization I have to add a header. Because I do 
not have the ‚Client‘-Instanze (WebTarget for instance) I’m not able to add an 
header. Is there some property, configuration or a service which can be used? 

Best Regards,
Michael
___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev