1 /*
2 * SPDX-License-Identifier: MIT
3 * See LICENSE file for details.
4 *
5 * Copyright 2010-2026 The Waffle Project Contributors: https://github.com/Waffle/waffle/graphs/contributors
6 */
7 package waffle.windows.auth;
8
9 import com.sun.jna.platform.win32.Sspi;
10 import com.sun.jna.platform.win32.Sspi.CtxtHandle;
11 import com.sun.jna.platform.win32.Sspi.SecBufferDesc;
12
13 /**
14 * A Windows security context.
15 */
16 public interface IWindowsSecurityContext {
17
18 /**
19 * Security package name.
20 *
21 * @return String.
22 */
23 String getSecurityPackage();
24
25 /**
26 * Principal name.
27 *
28 * @return String.
29 */
30 String getPrincipalName();
31
32 /**
33 * Token.
34 *
35 * @return Array of bytes.
36 */
37 byte[] getToken();
38
39 /**
40 * True if protocol requires continuation.
41 *
42 * @return True or false.
43 */
44 boolean isContinue();
45
46 /**
47 * Windows Identity.
48 *
49 * @return Windows Identity.
50 */
51 IWindowsIdentity getIdentity();
52
53 /**
54 * Context handle.
55 *
56 * @return Handle.
57 */
58 Sspi.CtxtHandle getHandle();
59
60 /**
61 * Initialize the security context, continuing from a previous one.
62 *
63 * @param continueCtx
64 * Continue context.
65 * @param continueToken
66 * Continue token.
67 * @param targetName
68 * The target of the context. The string contents are security-package specific.
69 */
70 void initialize(final CtxtHandle continueCtx, final SecBufferDesc continueToken, final String targetName);
71
72 /**
73 * Impersonate this security context.
74 *
75 * @return A Windows Impersonation Context.
76 */
77 IWindowsImpersonationContext impersonate();
78
79 /**
80 * Disposes of the context.
81 */
82 void dispose();
83 }