Using Kerberos S4U extensions (introduced in Java 8) to connect to database using JDBC

后端 未结 1 438
灰色年华
灰色年华 2021-01-03 15:18

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

相关标签:
1条回答
  • 2021-01-03 15:48

    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.

    0 讨论(0)
提交回复
热议问题