1 package org.sentrysoftware.winrm.service.client.auth; 2 3 /*- 4 * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲ 5 * WinRM Java Client 6 * ჻჻჻჻჻჻ 7 * Copyright 2023 - 2024 Sentry Software 8 * ჻჻჻჻჻჻ 9 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * you may not use this file except in compliance with the License. 11 * You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱ 21 */ 22 23 import java.util.Map; 24 import java.util.Optional; 25 import java.util.function.Function; 26 import java.util.stream.Collectors; 27 import java.util.stream.Stream; 28 29 public enum AuthenticationEnum { 30 31 NTLM, 32 KERBEROS; 33 34 private static final Map<String, AuthenticationEnum> VALUES_OF = 35 Stream.of(values()).collect(Collectors.toMap(AuthenticationEnum::name, Function.identity())); 36 37 /** 38 * Get the value of the enum Name regardless the cardinality. 39 * 40 * @param name The enum value name 41 * 42 * @return An optional with the enum value if found empty otherwise 43 */ 44 public static Optional<AuthenticationEnum> getValueOf(final String name) { 45 return name != null ? Optional.ofNullable(VALUES_OF.get(name.trim().toUpperCase())) : Optional.empty(); 46 } 47 }