String getToken( final CtxtHandle continueCtx, final SecBufferDesc continueToken, final String targetName) { final IntByReference attr = new IntByReference(); final ManagedSecBufferDesc token = new ManagedSecBufferDesc( Sspi.SECBUFFER_TOKEN, Sspi.MAX_TOKEN_SIZE); sspiContext = new CtxtHandle(); final int rc = Secur32.INSTANCE.InitializeSecurityContext(clientCred, continueCtx, targetName, Sspi.ISC_REQ_DELEGATE | Sspi.ISC_REQ_MUTUAL_AUTH, 0, Sspi.SECURITY_NATIVE_DREP, continueToken, 0, sspiContext, token, attr, null); switch (rc) { case WinError.SEC_I_CONTINUE_NEEDED: continueNeeded = true; break; case WinError.SEC_E_OK: dispose(); // Don't keep the context continueNeeded = false; break; default: dispose(); throw new Win32Exception(rc); } return Base64.encodeBase64String(token.getBuffer(0).getBytes()); }
@Override public void initialize(final CtxtHandle continueCtx, final SecBufferDesc continueToken, final String targetName) { this.attr = new IntByReference(); this.ctx = new CtxtHandle(); int tokenSize = Sspi.MAX_TOKEN_SIZE; int rc; do { this.token = new SecBufferDesc(Sspi.SECBUFFER_TOKEN, tokenSize); rc = Secur32.INSTANCE.InitializeSecurityContext(this.credentials.getHandle(), continueCtx, targetName, Sspi.ISC_REQ_CONNECTION, 0, Sspi.SECURITY_NATIVE_DREP, continueToken, 0, this.ctx, this.token, this.attr, null); switch (rc) { case WinError.SEC_E_INSUFFICIENT_MEMORY: tokenSize += Sspi.MAX_TOKEN_SIZE; break; case WinError.SEC_E_BUFFER_TOO_SMALL: tokenSize += Sspi.MAX_TOKEN_SIZE; break; case WinError.SEC_I_CONTINUE_NEEDED: this.continueFlag = true; break; case WinError.SEC_E_OK: this.continueFlag = false; break; default: throw new Win32Exception(rc); } } while (rc == WinError.SEC_E_INSUFFICIENT_MEMORY || rc == WinError.SEC_E_BUFFER_TOO_SMALL); }
String getToken( final CtxtHandle continueCtx, final SecBufferDesc continueToken, final String targetName) { final IntByReference attr = new IntByReference(); final SecBufferDesc token = new SecBufferDesc( Sspi.SECBUFFER_TOKEN, Sspi.MAX_TOKEN_SIZE); sspiContext = new CtxtHandle(); final int rc = Secur32.INSTANCE.InitializeSecurityContext(clientCred, continueCtx, targetName, Sspi.ISC_REQ_DELEGATE | Sspi.ISC_REQ_MUTUAL_AUTH, 0, Sspi.SECURITY_NATIVE_DREP, continueToken, 0, sspiContext, token, attr, null); switch (rc) { case WinError.SEC_I_CONTINUE_NEEDED: continueNeeded = true; break; case WinError.SEC_E_OK: dispose(); // Don't keep the context continueNeeded = false; break; default: dispose(); throw new Win32Exception(rc); } return Base64.encodeBase64String(token.getBytes()); }
@Override public void initialize(final CtxtHandle continueCtx, final SecBufferDesc continueToken, final String targetName) { final IntByReference attr = new IntByReference(); this.ctx = new CtxtHandle(); int tokenSize = Sspi.MAX_TOKEN_SIZE; int rc; do { this.token = new ManagedSecBufferDesc(Sspi.SECBUFFER_TOKEN, tokenSize); rc = Secur32.INSTANCE.InitializeSecurityContext(this.credentials.getHandle(), continueCtx, targetName, Sspi.ISC_REQ_CONNECTION, 0, Sspi.SECURITY_NATIVE_DREP, continueToken, 0, this.ctx, this.token, attr, null); switch (rc) { case WinError.SEC_E_INSUFFICIENT_MEMORY: case WinError.SEC_E_BUFFER_TOO_SMALL: tokenSize += Sspi.MAX_TOKEN_SIZE; break; case WinError.SEC_I_CONTINUE_NEEDED: this.continueFlag = true; break; case WinError.SEC_E_OK: this.continueFlag = false; break; default: throw new Win32Exception(rc); } } while (rc == WinError.SEC_E_INSUFFICIENT_MEMORY || rc == WinError.SEC_E_BUFFER_TOO_SMALL); }
@Override public void initialize(final CtxtHandle continueCtx, final SecBufferDesc continueToken, final String targetName) { final IntByReference attr = new IntByReference(); this.ctx = new CtxtHandle(); int tokenSize = Sspi.MAX_TOKEN_SIZE; int rc; do { this.token = new SecBufferDesc(Sspi.SECBUFFER_TOKEN, tokenSize); rc = Secur32.INSTANCE.InitializeSecurityContext(this.credentials.getHandle(), continueCtx, targetName, Sspi.ISC_REQ_CONNECTION, 0, Sspi.SECURITY_NATIVE_DREP, continueToken, 0, this.ctx, this.token, attr, null); switch (rc) { case WinError.SEC_E_INSUFFICIENT_MEMORY: case WinError.SEC_E_BUFFER_TOO_SMALL: tokenSize += Sspi.MAX_TOKEN_SIZE; break; case WinError.SEC_I_CONTINUE_NEEDED: this.continueFlag = true; break; case WinError.SEC_E_OK: this.continueFlag = false; break; default: throw new Win32Exception(rc); } } while (rc == WinError.SEC_E_INSUFFICIENT_MEMORY || rc == WinError.SEC_E_BUFFER_TOO_SMALL); }
String getToken( final Sspi.CtxtHandle continueCtx, final Sspi.SecBufferDesc continueToken, final String targetName) { final IntByReference attr = new IntByReference(); final ManagedSecBufferDesc token = new ManagedSecBufferDesc( Sspi.SECBUFFER_TOKEN, Sspi.MAX_TOKEN_SIZE); sspiContext = new Sspi.CtxtHandle(); final int rc = Secur32.INSTANCE.InitializeSecurityContext(clientCred, continueCtx, targetName, Sspi.ISC_REQ_DELEGATE | Sspi.ISC_REQ_MUTUAL_AUTH, 0, Sspi.SECURITY_NATIVE_DREP, continueToken, 0, sspiContext, token, attr, null); switch(rc) { case WinError.SEC_I_CONTINUE_NEEDED: continueNeeded = true; break; case WinError.SEC_E_OK: dispose(); // Don't keep the context continueNeeded = false; break; default: dispose(); throw new Win32Exception(rc); } return Base64.encodeBase64String(token.getBuffer(0).getBytes()); }
String getToken( final CtxtHandle continueCtx, final SecBufferDesc continueToken, final String targetName) { final IntByReference attr = new IntByReference(); final ManagedSecBufferDesc token = new ManagedSecBufferDesc( Sspi.SECBUFFER_TOKEN, Sspi.MAX_TOKEN_SIZE); sspiContext = new CtxtHandle(); final int rc = Secur32.INSTANCE.InitializeSecurityContext(clientCred, continueCtx, targetName, Sspi.ISC_REQ_DELEGATE | Sspi.ISC_REQ_MUTUAL_AUTH, 0, Sspi.SECURITY_NATIVE_DREP, continueToken, 0, sspiContext, token, attr, null); switch (rc) { case WinError.SEC_I_CONTINUE_NEEDED: continueNeeded = true; break; case WinError.SEC_E_OK: dispose(); // Don't keep the context continueNeeded = false; break; default: dispose(); throw new Win32Exception(rc); } return Base64.encodeBase64String(token.getBuffer(0).getBytes()); }