View Javadoc
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   /**
10   * Implements Windows authentication functions.
11   */
12  public interface IWindowsAuthProvider {
13  
14      /**
15       * The LogonUser function attempts to log a user on to the local computer using a network logon type and the default
16       * authentication provider.
17       *
18       * @param username
19       *            A string that specifies the name of the user in the UPN format.
20       * @param password
21       *            A string that specifies the plaintext password for the user account specified by username.
22       *
23       * @return Windows identity.
24       */
25      IWindowsIdentity logonUser(String username, String password);
26  
27      /**
28       * The LogonDomainUser function attempts to log a user on to the local computer using a network logon type and the
29       * default authentication provider.
30       *
31       * @param username
32       *            A string that specifies the name of the user. This is the name of the user account to log on to. If
33       *            you use the user principal name (UPN) format, user@DNS_domain_name, the domain parameter must be NULL.
34       * @param domain
35       *            A string that specifies the name of the domain or server whose account database contains the username
36       *            account. If this parameter is NULL, the user name must be specified in UPN format. If this parameter
37       *            is ".", the function validates the account by using only the local account database.
38       * @param password
39       *            A string that specifies the plaintext password for the user account specified by username.
40       *
41       * @return Windows identity.
42       */
43      IWindowsIdentity logonDomainUser(String username, String domain, String password);
44  
45      /**
46       * The LogonDomainUserEx function attempts to log a user on to the local computer. The local computer is the
47       * computer from which LogonUser was called. You cannot use LogonUser to log on to a remote computer. You specify
48       * the user with a user name and domain and authenticate the user with a plaintext password.
49       *
50       * @param username
51       *            A string that specifies the name of the user. This is the name of the user account to log on to. If
52       *            you use the user principal name (UPN) format, user@DNS_domain_name, the domain parameter must be NULL.
53       * @param domain
54       *            A string that specifies the name of the domain or server whose account database contains the username
55       *            account. If this parameter is NULL, the user name must be specified in UPN format. If this parameter
56       *            is ".", the function validates the account by using only the local account database.
57       * @param password
58       *            A string that specifies the plaintext password for the user account specified by username.
59       * @param logonType
60       *            The type of logon operation to perform.
61       * @param logonProvider
62       *            Specifies the logon provider.
63       *
64       * @return Windows identity.
65       */
66      IWindowsIdentity logonDomainUserEx(String username, String domain, String password, int logonType,
67              int logonProvider);
68  
69      /**
70       * Retrieve a security identifier (SID) for the account and the name of the domain or local computer on which the
71       * account was found.
72       *
73       * @param username
74       *            Fully qualified or partial username.
75       *
76       * @return Windows account.
77       */
78      IWindowsAccount lookupAccount(String username);
79  
80      /**
81       * Retrieve the current computer information.
82       *
83       * @return Current computer information.
84       */
85      IWindowsComputer getCurrentComputer();
86  
87      /**
88       * Retrieve a list of domains (Active Directory) on the local server.
89       *
90       * @return A list of domains.
91       */
92      IWindowsDomain[] getDomains();
93  
94      /**
95       * Attempts to validate the user using an SSPI token. This token is generated by the client via the
96       * InitializeSecurityContext(package) method described in
97       * https://msdn.microsoft.com/en-us/library/aa375509(VS.85).aspx
98       *
99       * @param connectionId
100      *            A unique connection id.
101      * @param token
102      *            The security token generated by the client wishing to logon.
103      * @param securityPackage
104      *            The name of the security package to use. Can be any security package supported by both the client and
105      *            the server. This is usually set to "Negotiate" which will use SPNEGO to determine which security
106      *            package to use. Other common values are "Kerberos" and "NTLM".
107      *
108      * @return Windows account.
109      */
110     IWindowsSecurityContext acceptSecurityToken(String connectionId, byte[] token, String securityPackage);
111 
112     /**
113      * Reset a previously saved continuation security token for a given connection id.
114      *
115      * @param connectionId
116      *            Connection id.
117      */
118     void resetSecurityToken(String connectionId);
119 }