0

I've a Java Application based on Java Swing, so I've a panel with 2 input (username and password), and a submit button.

This java application have an "execute" method who made an HTTP POST request to my servlet,lets call it "LoginServlet", also, there's the web.xml integration:

<security-role>
    <role-name>WEBUSER</role-name>
</security-role>
<login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>b2cSecurityDomain</realm-name>
</login-config>
<security-constraint>
    <display-name>ApiSecurity</display-name>
    <web-resource-collection>
        <web-resource-name>user</web-resource-name>
        <url-pattern>/LoginServlet</url-pattern>
        <http-method>GET</http-method>
        <http-method>POST</http-method>
        <http-method>PUT</http-method>
        <http-method>DELETE</http-method>
    </web-resource-collection>
    <auth-constraint>
        <role-name>WEBUSER</role-name>
    </auth-constraint>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>

In this HTTP POST call, I'm adding some request "header" to try the basic authentication:

urlConn.setRequestMethod("POST");
String userPassword = "username:password";
String encoding = Base64.getEncoder().encodeToString(userPassword.getBytes());
urlConn.setRequestProperty  ("Authorization", "Basic " + encoding);

For some reason i'm not reaching my "LoginServlet" and I'm getting an EOFException.

Can someone provide an example? Thank you

Alex
  • 676
  • 9
  • 20
DarioS
  • 11
  • 1

0 Answers0