It\'s been a while since I coded in Java, so I may be missing something obvious. I want to connect to the database (I need to support many - SQL Server, MySQL, etc.) via JDB
This is the code I arrived at after a lot of spelunking online:
GSSManager manager = GSSManager.getInstance();
GSSCredential self = manager.createCredential(GSSCredential.INITIATE_ONLY);
GSSName user = manager.createName("myuser", GSSName.NT_USER_NAME);
GSSCredential impCred = ((ExtendedGSSCredential)self).impersonate(user);
Subject mySubject = new Subject();
mySubject.getPrivateCredentials().add(impCred);
PrivilegedAction action = new ClientAction();
Subject.doAs(mySubject, action);
I now get "GSSException: Failure unspecified at GSS-API level (Mechanism level: Attempt to obtain S4U2self credentials failed!)" on the impersonate call, which I am still investigating.