maybe debug and check http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html#isUserInRole(java.lang.String)
Romain Manni-Bucau @rmannibucau <https://twitter.com/rmannibucau> | Blog <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> | LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber <http://www.tomitribe.com> 2015-08-13 13:51 GMT-07:00 sgjava <[email protected]>: > Forgot client: > > // Set up web client with logging filter > final Client client = ClientBuilder.newClient().register( > ClientRequestLoggingFilter.class).register( > new ClientRequestAuthFilter("tomcat", "password")); > > public class ClientRequestAuthFilter implements ClientRequestFilter { > > /** > * User. > */ > private final String user; > /** > * Password. > */ > private final String password; > > public ClientRequestAuthFilter(String user, String password) { > this.user = user; > this.password = password; > } > > /** > * > * @param requestContext > * @throws IOException > */ > public void filter(ClientRequestContext requestContext) throws > IOException { > MultivaluedMap<String, Object> headers = > requestContext.getHeaders(); > final String basicAuthentication = getBasicAuthentication(); > headers.add("Authorization", basicAuthentication); > > } > > /** > * > * @return > */ > private String getBasicAuthentication() { > String token = this.user + ":" + this.password; > try { > return "BASIC " + DatatypeConverter.printBase64Binary(token. > getBytes("UTF-8")); > } catch (UnsupportedEncodingException ex) { > throw new IllegalStateException("Cannot encode with UTF-8", > ex); > } > } > } > > > > > -- > View this message in context: > http://tomee-openejb.979440.n4.nabble.com/Using-basic-auth-with-tomee-embedded-tp4675786p4675874.html > Sent from the TomEE Users mailing list archive at Nabble.com. >
