Announcement Announcement Module
No announcement yet.
Spring Equivalent to Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Equivalent to

    I have a method that looks like this, and is used by the client in the manner shown in the 2nd code snippet. I am using Spring beans in my app, so I am wondering if Spring has their own way of doing this? I can inject the username/password easily enough, but I am wondering if there is a Spring-centric approach.

    The client is accessing a password protected URL that is hosting a web service on a private network

    public class MyAuthenticator extends Authenticator {
        protected PasswordAuthentication getPasswordAuthentication() {
            String promptString = getRequestingPrompt();
            String hostname = getRequestingHost();
            InetAddress ipaddr = getRequestingSite();
            int port = getRequestingPort();
            String username = "myusername";
            String password = "mypassword";
            return new PasswordAuthentication(username, password.toCharArray());

    Client code:

    Authenticator.setDefault(new MyAuthenticator());

  • #2
    Did it worked for you?
    I am also having the same issue. I wanted to access the spring secured URL from my application. When i try from browser after login it is working perfectly. But when i am accessing the url with application with, the authentication object is not passed. How can i pass the Spring authentication with

    Otherwise Is there any equalant for

    some one please help me.