0

I am trying add basic authorization for my Rest webservice. on weblogic i have created the same user under default security realm . when i executing my rest client without passing authorization it is returning HTTP 200 means application is consuming the request. however in case i pass authorization then it validates the username password. i want my service to work with authorization only. Can someone please let me know what i am missing or if i am doing anything wrong? in web.xml i have below:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://java.sun.com/xml/ns/javaee"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
        id="WebApp_ID" version="3.0">
        <display-name>PP</display-name>
        <servlet>
            <servlet-name>jersey-servlet</servlet-name>
            <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
            <init-param>
                <param-name>com.sun.jersey.config.property.packages</param-name>
                <param-value>com.att.eddpp.preprocessing</param-value>
            </init-param>
            <init-param>
                <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
                <param-value>true</param-value>
            </init-param>
            <init-param>
            <param-name>wl-dispatch-policy</param-name>
            <param-value>PP-work-manager</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>jersey-servlet</servlet-name>
            <url-pattern>/*</url-pattern>
        </servlet-mapping>
        <security-constraint>
            <web-resource-collection>
                <web-resource-name>PP</web-resource-name>
                <url-pattern>/PP/*</url-pattern>
                <http-method>POST</http-method>

            </web-resource-collection> 
        <auth-constraint>
        <role-name>PPRST</role-name>

        </auth-constraint>
        </security-constraint>
        <login-config>
                  <auth-method>BASIC</auth-method>
                  <realm-name>default</realm-name>
              </login-config>
               <security-role>
                   <role-name>PPRST</role-name>
               </security-role>


    </web-app>


    in weblogic.xml i have added 

    <?xml version="1.0" encoding="UTF-8"?>
    <wls:weblogic-web-app
        xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.7/weblogic-web-app.xsd">
        <wls:weblogic-version>12.1.3</wls:weblogic-version>
        <wls:context-root>PP</wls:context-root>

        <wls:security-role-assignment>
             <wls:role-name>PPRST</wls:role-name>
             <wls:principal-name>PPRST</wls:principal-name>
         </wls:security-role-assignment>
    </wls:weblogic-web-app>

1 Answer 1

1

Your constraint is for /PP/* but you jersey resource is under /* . I think that's the problem.

Sign up to request clarification or add additional context in comments.

1 Comment

i tired this as well. still no luck .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.