i'm trying implement authentication on current java restful api (jersey) following this tutorial. put new authentication classes inside "auth" package. when run jquery example code, says "demobusinessrestresourceproxy interface , cannot instantiated". research , decided put jersey annotations on demobusinessrestresource , delete demobusinessrestresourceproxy:
@local @path("access/") @stateless(name = "demobusinessrestresource", mappedname = "ejb/demobusinessrestresource") public class demobusinessrestresource { private static final long serialversionuid = -6663599014192066936l; @post @path("/login") @produces(mediatype.application_json) public response login(@context httpheaders httpheaders, @formparam("username") string username, @formparam("password") string password) { authenticator authenticator = authenticator.getinstance(); string servicekey = httpheaders .getheaderstring(httpheadernames.service_key); try { string authtoken = authenticator.login(servicekey, username, password); jsonobjectbuilder jsonobjbuilder = json.createobjectbuilder(); jsonobjbuilder.add("auth_token", authtoken); jsonobject jsonobj = jsonobjbuilder.build(); return getnocacheresponsebuilder(response.status.ok).entity( jsonobj.tostring()).build(); } catch (final loginexception ex) { jsonobjectbuilder jsonobjbuilder = json.createobjectbuilder(); jsonobjbuilder.add("message", "problem matching service key, username , password"); jsonobject jsonobj = jsonobjbuilder.build(); return getnocacheresponsebuilder(response.status.unauthorized) .entity(jsonobj.tostring()).build(); } } @get @path("/demo-get-method") @produces(mediatype.application_json) public response demogetmethod() { jsonobjectbuilder jsonobjbuilder = json.createobjectbuilder(); jsonobjbuilder.add("message", "executed demogetmethod"); jsonobject jsonobj = jsonobjbuilder.build(); return getnocacheresponsebuilder(response.status.ok).entity( jsonobj.tostring()).build(); } @post @path("/demo-post-method") @produces(mediatype.application_json) public response demopostmethod() { jsonobjectbuilder jsonobjbuilder = json.createobjectbuilder(); jsonobjbuilder.add("message", "executed demopostmethod"); jsonobject jsonobj = jsonobjbuilder.build(); return getnocacheresponsebuilder(response.status.accepted).entity( jsonobj.tostring()).build(); } @post @path("/logout") public response logout(@context httpheaders httpheaders) { try { authenticator authenticator = authenticator.getinstance(); string servicekey = httpheaders .getheaderstring(httpheadernames.service_key); string authtoken = httpheaders .getheaderstring(httpheadernames.auth_token); authenticator.logout(servicekey, authtoken); return getnocacheresponsebuilder(response.status.no_content) .build(); } catch (final generalsecurityexception ex) { return getnocacheresponsebuilder( response.status.internal_server_error).build(); } } private response.responsebuilder getnocacheresponsebuilder( response.status status) { cachecontrol cc = new cachecontrol(); cc.setnocache(true); cc.setmaxage(-1); cc.setmustrevalidate(true); return response.status(status).cachecontrol(cc); } } now, i'm getting error:
a system exception occurred during invocation on ejb businessrestresource, method: public javax.ws.rs.core.response com.rest.auth.demobusinessrestresource.login(javax.ws.rs.core.httpheaders,java.lang.string,java.lang.string), caused by: java.lang.abstractmethoderror: com.sun.jersey.spi.container.containerrequest.getheaderstring(ljava/lang/string;)ljava/lang/string;

i'm new in java ws , i'm totally lost.
i found problem. problem jar version files.
Comments
Post a Comment