clientCredentials = WindowsCredentialsHandleImpl.getCurrent(securityPackage); clientCredentials.initialize(); } catch (Win32Exception ex) {
/** * Returns the current credentials handle. * * @param securityPackage * Security package, eg. "Negotiate". * @return A windows credentials handle */ public static IWindowsCredentialsHandle getCurrent(final String securityPackage) { final IWindowsCredentialsHandle handle = new WindowsCredentialsHandleImpl(null, Sspi.SECPKG_CRED_OUTBOUND, securityPackage); handle.initialize(); return handle; }
/** * Returns the current credentials handle. * * @param securityPackage * Security package, eg. "Negotiate". * @return A windows credentials handle */ public static IWindowsCredentialsHandle getCurrent(final String securityPackage) { final IWindowsCredentialsHandle handle = new WindowsCredentialsHandleImpl(null, Sspi.SECPKG_CRED_OUTBOUND, securityPackage); handle.initialize(); return handle; }
clientCredentials = WindowsCredentialsHandleImpl.getCurrent(securityPackage); clientCredentials.initialize();
/** * Returns the current credentials handle. * * @param securityPackage * Security package, eg. "Negotiate". * @return A windows credentials handle */ public static IWindowsCredentialsHandle getCurrent(final String securityPackage) { final IWindowsCredentialsHandle handle = new WindowsCredentialsHandleImpl(null, Sspi.SECPKG_CRED_OUTBOUND, securityPackage); handle.initialize(); return handle; }
/** * Get the current Windows security context for a given SSPI package. * * @param securityPackage * SSPI package. * @param targetName * The target of the context. The string contents are security-package specific. * @return Windows security context. */ public static IWindowsSecurityContext getCurrent(final String securityPackage, final String targetName) { IWindowsCredentialsHandle credentialsHandle = WindowsCredentialsHandleImpl.getCurrent(securityPackage); credentialsHandle.initialize(); try { final WindowsSecurityContextImpl ctx = new WindowsSecurityContextImpl(); ctx.setPrincipalName(WindowsAccountImpl.getCurrentUsername()); ctx.setCredentialsHandle(credentialsHandle); ctx.setSecurityPackage(securityPackage); ctx.initialize(null, null, targetName); // Starting from here ctx 'owns' the credentials handle, so let's null out the // variable. This will prevent the finally block below from disposing it right away. credentialsHandle = null; return ctx; } finally { if (credentialsHandle != null) { credentialsHandle.dispose(); } } }
serverCredential = continueContext.serverCredential; } else { serverCredential = new WindowsCredentialsHandleImpl(null, Sspi.SECPKG_CRED_INBOUND, securityPackage); serverCredential.initialize();
/** * Get the current Windows security context for a given SSPI package. * * @param securityPackage * SSPI package. * @param targetName * The target of the context. The string contents are security-package specific. * @return Windows security context. */ public static IWindowsSecurityContext getCurrent(final String securityPackage, final String targetName) { IWindowsCredentialsHandle credentialsHandle = WindowsCredentialsHandleImpl.getCurrent(securityPackage); credentialsHandle.initialize(); try { final WindowsSecurityContextImpl ctx = new WindowsSecurityContextImpl(); ctx.setPrincipalName(WindowsAccountImpl.getCurrentUsername()); ctx.setCredentialsHandle(credentialsHandle); ctx.setSecurityPackage(securityPackage); ctx.initialize(null, null, targetName); // Starting from here ctx 'owns' the credentials handle, so let's null out the // variable. This will prevent the finally block below from disposing it right away. credentialsHandle = null; return ctx; } finally { if (credentialsHandle != null) { credentialsHandle.dispose(); } } }
serverCredential = continueContext.serverCredential; } else { serverCredential = new WindowsCredentialsHandleImpl(null, Sspi.SECPKG_CRED_INBOUND, securityPackage); serverCredential.initialize();
clientCredentials = WindowsCredentialsHandleImpl.getCurrent(securityPackage); clientCredentials.initialize();
serverCredential = continueContext.serverCredential; } else { serverCredential = new WindowsCredentialsHandleImpl(null, Sspi.SECPKG_CRED_INBOUND, securityPackage); serverCredential.initialize();
/** * Get the current Windows security context for a given SSPI package. * * @param securityPackage * SSPI package. * @param targetName * The target of the context. The string contents are security-package specific. * @return Windows security context. */ public static IWindowsSecurityContext getCurrent(final String securityPackage, final String targetName) { IWindowsCredentialsHandle credentialsHandle = WindowsCredentialsHandleImpl.getCurrent(securityPackage); credentialsHandle.initialize(); try { final WindowsSecurityContextImpl ctx = new WindowsSecurityContextImpl(); ctx.setPrincipalName(WindowsAccountImpl.getCurrentUsername()); ctx.setCredentialsHandle(credentialsHandle); ctx.setSecurityPackage(securityPackage); ctx.initialize(null, null, targetName); // Starting from here ctx 'owns' the credentials handle, so let's null out the // variable. This will prevent the finally block below from disposing it right away. credentialsHandle = null; return ctx; } finally { if (credentialsHandle != null) { credentialsHandle.dispose(); } } }