View Javadoc
1   // copy of code from apache-httpclient 4.5.13 package org.apache.http.impl.auth
2   // changes:
3   // - package name, this header, imports
4   // - expose Type3 message (package-private) so keys can be gathered
5   
6   /*
7    * ====================================================================
8    * Licensed to the Apache Software Foundation (ASF) under one
9    * or more contributor license agreements.  See the NOTICE file
10   * distributed with this work for additional information
11   * regarding copyright ownership.  The ASF licenses this file
12   * to you under the Apache License, Version 2.0 (the
13   * "License");
14  /*-
15   * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
16   * WinRM Java Client
17   * ჻჻჻჻჻჻
18   * Copyright 2023 - 2024 Metricshub
19   * ჻჻჻჻჻჻
20   * Licensed under the Apache License, Version 2.0 (the "License");
21   * you may not use this file except in compliance with the License.
22   * You may obtain a copy of the License at
23   *
24   *      http://www.apache.org/licenses/LICENSE-2.0
25   *
26   * Unless required by applicable law or agreed to in writing, software
27   * distributed under the License is distributed on an "AS IS" BASIS,
28   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29   * See the License for the specific language governing permissions and
30   * limitations under the License.
31   * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
32   */
33  package org.metricshub.winrm.service.client.auth.ntlm;
34  
35  import org.apache.http.impl.auth.NTLMEngineException;
36  
37  /**
38   * Abstract NTLM authentication engine. The engine can be used to
39   * generate Type1 messages and Type3 messages in response to a Type2 challenge.
40   *
41   * Code from io.cloudsoft.winrm4j.client.ntlm.forks.httpclient.NTLMEngine
42   * release 0.12.3 @link https://github.com/cloudsoft/winrm4j
43   * io.cloudsoft.winrm4j.client.ntlm.forks.httpclient is a fork of apache-httpclient 4.5.13
44   */
45  public interface NTLMEngine {
46  	/**
47  	 * Generates a Type1 message given the domain and workstation.
48  	 *
49  	 * @param domain Optional Windows domain name. Can be {@code null}.
50  	 * @param workstation Optional Windows workstation name. Can be
51  	 *  {@code null}.
52  	 * @return Type1 message
53  	 * @throws NTLMEngineException
54  	 */
55  	String generateType1Msg(final String domain, final String workstation) throws NTLMEngineException;
56  
57  	/**
58  	 * Generates a Type3 message given the user credentials and the
59  	 * authentication challenge.
60  	 *
61  	 * @param username Windows user name
62  	 * @param password Password
63  	 * @param domain Windows domain name
64  	 * @param workstation Windows workstation name
65  	 * @param challenge Type2 challenge.
66  	 * @return Type3 response.
67  	 * @throws NTLMEngineException
68  	 */
69  	String generateType3Msg(
70  		final String username,
71  		final String password,
72  		final String domain,
73  		final String workstation,
74  		final String challenge
75  	) throws NTLMEngineException;
76  
77  	Type3Message generateType3MsgObject(
78  		final String username,
79  		final String password,
80  		final String domain,
81  		final String workstation,
82  		final String challenge
83  	) throws NTLMEngineException;
84  }