Java - user authentication access file

I have a server where I work with a database and files using a java application. When I launch my application, I give a report on access to the file on the server using:

public static boolean folderExists(String folderPath) {
    File folderToCheck = new File(folderPath);
    return folderToCheck.exists();
}

Every time I start my application (after a new restart of my computer) I get a false response, even if the server is turned on. The reason is that I have to give authentication as another user. What I'm doing is accessing the server through Windows where they ask me for a username / password, and after that I get a true answer about accessing the file on the server.

Is there a way to provide a username / password for authentication through Java and not through Windows?

thank

+3
2

Windows 'native' Java IO (, java.io.File) , JVM. , Java Windows .

JCIFS CIFS ( SMB Windows) /.

. API.

+2

, fileaccess java Windows-Call.

cacls file.log /e /t /p Everyone:f, .

: ACL Windows, SID?

Java7 .

+1

Source: https://habr.com/ru/post/1786381/


All Articles