1 /* Copyright 2002-2025 CS GROUP
2 * Licensed to CS GROUP (CS) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * CS licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.orekit.gnss.metric.ntrip;
18
19 import java.util.HashMap;
20 import java.util.Map;
21
22 import org.orekit.errors.OrekitException;
23 import org.orekit.errors.OrekitMessages;
24
25 /** Enumerate for authentication method in {@link DataStreamRecord}.
26 * @author Luc Maisonobe
27 * @since 11.0
28 */
29 public enum Authentication {
30
31 /** None. */
32 NONE("N"),
33
34 /** Basic. */
35 BASIC("B"),
36
37 /** Digest. */
38 DIGEST("D");
39
40 /** Keywords map. */
41 private static final Map<String, Authentication> KEYWORDS_MAP = new HashMap<>();
42 static {
43 for (final Authentication type : values()) {
44 KEYWORDS_MAP.put(type.getKeyword(), type);
45 }
46 }
47
48 /** Keyword. */
49 private final String keyword;
50
51 /** Simple constructor.
52 * @param keyword keyword in the sourcetable records
53 */
54 Authentication(final String keyword) {
55 this.keyword = keyword;
56 }
57
58 /** Get keyword.
59 * @return keyword
60 */
61 private String getKeyword() {
62 return keyword;
63 }
64
65 /** Get the authentication type corresponding to a keyword.
66 * @param keyword authentication keyword
67 * @return the authentication type corresponding to the keyword
68 */
69 public static Authentication getAuthentication(final String keyword) {
70 final Authentication authentication = KEYWORDS_MAP.get(keyword);
71 if (authentication == null) {
72 throw new OrekitException(OrekitMessages.UNKNOWN_AUTHENTICATION_METHOD, keyword);
73 }
74 return authentication;
75 }
76
77 }