Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You might want to use some form of transport layer security such as SSL to secure your service.</p> <p>Also, REST tries to make use of HTTP features, so you could put a Authorization header in the HTTP request.</p> <p>Edit: a simple example</p> <p><strong>Transport Layer Security</strong><br> Go to one of the many companies that sell SSL certificates, for example Verisign. Buy a certificate. Install it on your web server. You web server will have documentation on how to install it.</p> <p><strong>Using HTTP authorisation</strong><br> Get the client of your web service to use BASIC authorization (they are passed in plaintext so you've got to be using SSL for this to be effective). This involves putting the BASE64 encoded username and password in the <a href="http://en.wikipedia.org/wiki/Basic_access_authentication" rel="nofollow">Authorisation header</a>. Write a security <code>Filter</code> and configure your web app to pass all requests to your RESTful service through the filter. Your security filter should extract the username and password from the request Authorisation header and check them. If the credentials are invalid you reject the request with a 403 status code. If the credentials are OK, just propogate up the filter chain.</p> <pre><code>public MySecurityFilter implements Filter { public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) { //Get the Authorizatiuon header String auth = ((HttpServletRequest)request).getHeader("Authorization"); //Extract the username and password if (checkCredentialsOnMyDatabase(credentials[0], credentials[1])) { chain.doFilter(request, response); } else { //Reject the request with status code 403 } } } </code></pre> <p>Also note that if you are using one of the popular frameworks like Jersey then it has a lot of security functions built in that may help you.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload