• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to give UNC path using username and password

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, I want to access a file from a server folder that is not shared using admin username and password. here is my code

public class App {

public App (){

}

public static void main (String [] args){
App a = new App ();
mainapp s = new mainapp (); // mainapp is another program which contains the begin method
s.begin("C:/images/abcd.jpeg");
}
}

here is the main app begin method

public void begin (String args)
{
// We need one argument: the image filename.
if (args.length() == 0)
{
System.err.println("Usage: java operators.Scale image");
System.exit(0);
}
// Read the image.
PlanarImage image = JAI.create("fileload", args);
// Create the GUI and start the application.
new mainapp(args,image);
}
}

In the above program instead of giving C:/images/abcd.gif, i need to access this file from a server folder using username and password. Any help would be appreciated

thanks
david
 
Ranch Hand
Posts: 43
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Danny,

Welcome to the Ranch!

You should be able to provide the username/password as part of the URL:
E.g.
https://username:password@example.com/secure/myfile.pdf

This does assume that the site is using standard HTTP authentication.

If some sort of custom authentication is being done you may need to supply a per-generated cookie containing authentication information or possibly do a separate log-in request before trying to download your file. This will all depend on the setup of the remote server.
 
Rancher
Posts: 1044
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might consider attaching the network drive (say with "net use..." on Windows or with Samba on Unix) prior to running your program and then using the network drive from there.

 
danny denzoppa
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi vimal, can you throw some light on or show me the material related to how to configure the standard http authentication. Hi ivan i dont want to access the file using mapping method.

thank you
david
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

danny denzoppa wrote:hi, I want to access a file from a server folder that is not shared using admin username and password.


Just off the top of my head, I'd say that's a very bad way to do it. For one thing, even with obfuscation, Java is not secure, so you certainly don't want to store that ID/password anywhere in your program. Obtaining it via prompting might be OK, but I'd say that even requiring an admin password for a server folder is not good design.

Winston (old sysadmin )
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic