Hi,
I am trying to implement a REST web service using Apache ISIS, but unable
to do so.
This is what my implementation looks like:
@DomainService(
nature = NatureOfService.VIEW_REST_ONLY
)
@Path("/authorization")
public class Authorization implements AuthorizationApiInterface{
@Override
@Path("/isAuthorized")
@POST
@Action
public Boolean isAuthorized(JSONObject jObj) {
// some steps
return true;
}
}
Also i have overridden the AuthenticationSessionStrategyBasicAuth so as to
be able to call this method when there is no valid session object:-
public class CustomAuthenticationSessionStrategy extends
AuthenticationSessionStrategyBasicAuth {
@Override
public AuthenticationSession lookupValid(final HttpServletRequest
httpServletRequest, final HttpServletResponse httpServletResponse) {
String requestURI = httpServletRequest.getRequestURI();
if("/admin/restful/authorization/isAuthorized".equalsIgnoreCase(requestURI)){
AuthenticationSessionStrategyTrusted strategy = new
AuthenticationSessionStrategyTrusted();
AuthenticationSession session = strategy.lookupValid(httpServletRequest,
httpServletResponse);
return session;
} else {
return super.lookupValid(httpServletRequest, httpServletResponse);
}
}
}
The new CustomAuthenticationSessionStrategy has replaced
AuthenticationSessionStrategyBasicAuth in web.xml
Also extended RestfulObjectsApplication:-
public class CustomRestfulObjectsApplication extends
RestfulObjectsApplication {
public CustomRestfulObjectsApplication() {
addClass(Authorization.class);
}
}
And replced it in web.xml.
I am calling this api using the HttpURLConnection class. The url passed is
http://localhost:8080/admin/restful/authorization/isAuthorized.
Please let me know where I am going wrong.
Thanks,
Anisha