@Override public String generateType1Msg(String domain, String workstation) throws NTLMEngineException { CredHandle credentials = acquireCredentialsHandle(); try { byte[] token = nextToken(credentials, null); return Base64.encodeBase64String(token); } finally { dispose(credentials); } }
private CredHandle acquireCredentialsHandle() { CredHandle handle = new CredHandle(); int rc = Secur32.INSTANCE.AcquireCredentialsHandle(null, "NTLM", SECPKG_CRED_OUTBOUND, null, null, null, null, handle, new TimeStamp()); if (SEC_E_OK != rc) { throw new Win32Exception(rc); } return handle; }
public void dispose(CredHandle credentials) { int rc = Secur32.INSTANCE.FreeCredentialsHandle(credentials); if (SEC_E_OK != rc) { throw new Win32Exception(rc); } }