Update rest-client with additional operations
[aai/rest-client.git] / src / main / java / org / openecomp / restclient / enums / RestAuthenticationMode.java
1 /**
2  * ============LICENSE_START=======================================================
3  * RestClient
4  * ================================================================================
5  * Copyright © 2017 AT&T Intellectual Property.
6  * Copyright © 2017 Amdocs
7  * All rights reserved.
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  * ============LICENSE_END=========================================================
21  *
22  * ECOMP and OpenECOMP are trademarks
23  * and service marks of AT&T Intellectual Property.
24  */
25 package org.openecomp.restclient.enums;
26
27 /**
28  * Authentication Modes:
29  * <li>HTTP_NOAUTH - intended to represent basic HTTP no authentication
30  * <li>SSL_BASIC - HTTP/S with username/password
31  * <li>SSL_CERT - HTTP/S with client cert
32  */
33
34 public enum RestAuthenticationMode {
35   HTTP_NOAUTH("HTTP_NO_AUTH"), SSL_BASIC("SSL_BASIC"), SSL_CERT("SSL_CERT"), UNKNOWN_MODE(
36       "UNKNOWN_MODE");
37
38   private String authenticationModeLabel;
39
40   private RestAuthenticationMode(String authModelLabel) {
41     this.authenticationModeLabel = authModelLabel;
42   }
43
44   public String getAuthenticationModeLabel() {
45     return authenticationModeLabel;
46   }
47
48   public static RestAuthenticationMode getRestAuthenticationMode(String authenticationMode) {
49
50     RestAuthenticationMode mappedMode = RestAuthenticationMode.UNKNOWN_MODE;
51
52     if (authenticationMode == null) {
53       return mappedMode;
54     }
55
56     try {
57       mappedMode = RestAuthenticationMode.valueOf(authenticationMode);
58     } catch (Exception exc) {
59       mappedMode = RestAuthenticationMode.UNKNOWN_MODE;
60     }
61
62     return mappedMode;
63
64   }
65
66 }