users@jersey.java.net

[Jersey] Re: glassfish 4.1 & jersey client 2.16

From: Tomaz Majerhold <tomaz.majerhold_at_arnes.si>
Date: Tue, 10 Mar 2015 10:34:31 +0100

Dne 9.3.2015 ob 10:19 je Tomaz Majerhold zapisal(a):
> I'm trying to call with Auth but in my
> glassfish[glassfish-embedded-all:4.1](for my JUnit tests) I see that
> principal is null:
>
> FINE: [Web-Security] Checking Web Permission with Principals : null
> mar 09, 2015 9:56:40 AM
> com.sun.enterprise.security.web.integration.WebSecurityManager
> checkPermissionWithoutCache
> FINE: [Web-Security] Web Permission =
> ("javax.security.jacc.WebResourcePermission" "/api/idm" "HEAD")
> mar 09, 2015 9:56:40 AM
> com.sun.enterprise.security.web.integration.WebSecurityManager
> hasResourcePermission
> FINE: [Web-Security] hasResource isGranted: false
>
>
> I try 2 ways:
>
> 1) Approach:
> Response.StatusType status = webTarget.path("idm").request()
> .property(HTTP_AUTHENTICATION_BASIC_USERNAME, adminNetId)
> .property(HTTP_AUTHENTICATION_BASIC_PASSWORD, "test")
> .head().getStatusInfo();
>
>
> 2) Approach:
> HttpAuthenticationFeature feature =
> HttpAuthenticationFeature.basic(adminNetId, "test");
> client.register(feature);
> Response.StatusType status = webTarget.path("idm").request()
> .property(HTTP_AUTHENTICATION_BASIC_USERNAME, adminNetId)
> .property(HTTP_AUTHENTICATION_BASIC_PASSWORD, "test")
> .head().getStatusInfo();
>
>
>
> Is there any anther approach?
>
>
> Regards, Tomaz
The problem was that I was trying to register HttpAuthenticationFeature
after building a target.

Regards, Tomaz