1 /** 2 * Waffle (https://github.com/dblock/waffle) 3 * 4 * Copyright (c) 2010 - 2015 Application Security, Inc. 5 * 6 * All rights reserved. This program and the accompanying materials 7 * are made available under the terms of the Eclipse Public License v1.0 8 * which accompanies this distribution, and is available at 9 * http://www.eclipse.org/legal/epl-v10.html 10 * 11 * Contributors: 12 * Application Security, Inc. 13 */ 14 package waffle.windows.auth; 15 16 import com.sun.jna.platform.win32.Sspi; 17 import com.sun.jna.platform.win32.Sspi.CtxtHandle; 18 import com.sun.jna.platform.win32.Sspi.SecBufferDesc; 19 20 /** 21 * A Windows security context. 22 * 23 * @author dblock[at]dblock[dot]org 24 */ 25 public interface IWindowsSecurityContext { 26 27 /** 28 * Security package name. 29 * 30 * @return String. 31 */ 32 String getSecurityPackage(); 33 34 /** 35 * Principal name. 36 * 37 * @return String. 38 */ 39 String getPrincipalName(); 40 41 /** 42 * Token. 43 * 44 * @return Array of bytes. 45 */ 46 byte[] getToken(); 47 48 /** 49 * True if protocol requires continuation. 50 * 51 * @return True or false. 52 */ 53 boolean isContinue(); 54 55 /** 56 * Windows Identity. 57 * 58 * @return Windows Identity. 59 */ 60 IWindowsIdentity getIdentity(); 61 62 /** 63 * Context handle. 64 * 65 * @return Handle. 66 */ 67 Sspi.CtxtHandle getHandle(); 68 69 /** 70 * Initialize the security context, continuing from a previous one. 71 * 72 * @param continueCtx 73 * Continue context. 74 * @param continueToken 75 * Continue token. 76 * @param targetName 77 * The target of the context. The string contents are security-package specific. 78 */ 79 void initialize(final CtxtHandle continueCtx, final SecBufferDesc continueToken, final String targetName); 80 81 /** 82 * Impersonate this security context. 83 * 84 * @return A Windows Impersonation Context. 85 */ 86 IWindowsImpersonationContext impersonate(); 87 88 /** 89 * Disposes of the context. 90 */ 91 void dispose(); 92 }