Search code examples
restful-urljaas

Access secure RESTful url from another application


Am using resteasy-servlet and secured url with JASS authentication eg:

<login-config>
        <auth-method>FORM</auth-method>
        <realm-name>WebSecurityDomain</realm-name>
        <form-login-config>
            <form-login-page>Login.jsp</form-login-page>
            <form-error-page>error.jsp</form-error-page>
        </form-login-config>                                           
   </login-config>   
   <security-role>
        <role-name>
            SecurityAdmin
        </role-name>
    </security-role> 

    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Secure Pages</web-resource-name>
            <url-pattern>/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>SecurityAdmin</role-name>
        </auth-constraint>
    </security-constraint>

Now if I want to access some url from above application using externa resource. Url response returns Login.jsp.

How can I authenticate and access url.

I have even tried SecurityInterceptor but its not even accessing this function. eg:

public ServerResponse preProcess(HttpRequest request, ResourceMethodInvoker methodInvoked)
            throws Failure, WebApplicationException {
... 
return null;
    }

Solution

  • Well as am using FORM-based authentication I can't use rest calls from backend. To use rest call I need to pass SESSIONID which is generated inside Browser.

    So am doing a POST call to login to service I need and after that if I use any call from Browser it automatically adds correct SESSIONID and let me use call