[DMAAP-CLIENT] First sonar issues review part2
[dmaap/messagerouter/dmaapclient.git] / src / main / java / org / onap / dmaap / mr / client / MRIdentityManager.java
1 /*******************************************************************************
2  *  ============LICENSE_START=======================================================
3  *  org.onap.dmaap
4  *  ================================================================================
5  *  Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  *  ================================================================================
7  *  Modifications Copyright © 2021 Orange.
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  *        http://www.apache.org/licenses/LICENSE-2.0
13  *
14  *  Unless required by applicable law or agreed to in writing, software
15  *  distributed under the License is distributed on an "AS IS" BASIS,
16  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  *  See the License for the specific language governing permissions and
18  *  limitations under the License.
19  *  ============LICENSE_END=========================================================
20  *
21  *  ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  *
23  *******************************************************************************/
24
25 package org.onap.dmaap.mr.client;
26
27 import com.att.nsa.apiClient.credentials.ApiCredential;
28 import com.att.nsa.apiClient.http.HttpException;
29 import com.att.nsa.apiClient.http.HttpObjectNotFoundException;
30
31 import java.io.IOException;
32
33 /**
34  * A client for manipulating API keys.
35  *
36  * @author author
37  */
38 public interface MRIdentityManager extends MRClient {
39     /**
40      * An API Key record.
41      */
42     interface ApiKey {
43         /**
44          * Get the email address associated with the API key.
45          *
46          * @return the email address on the API key or null
47          */
48         String getEmail();
49
50         /**
51          * Get the description associated with the API key.
52          *
53          * @return the description on the API key or null
54          */
55         String getDescription();
56     }
57
58     /**
59      * Create a new API key on the UEB cluster. The returned credential instance
60      * contains the new API key and API secret. This is the only time the secret
61      * is available to the client -- there's no API for retrieving it later -- so
62      * your application must store it securely.
63      *
64      * @param email
65      * @param description
66      * @return a new credential
67      * @throws HttpException
68      * @throws MRApiException
69      * @throws IOException
70      */
71     ApiCredential createApiKey(String email, String description) throws HttpException, MRApiException, IOException;
72
73     /**
74      * Get basic info about a known API key.
75      *
76      * @param apiKey
77      * @return the API key's info or null if it doesn't exist
78      * @throws HttpObjectNotFoundException, HttpException, MRApiException
79      * @throws IOException
80      */
81     ApiKey getApiKey(String apiKey) throws HttpObjectNotFoundException, HttpException, MRApiException, IOException;
82
83     /**
84      * Update the record for the API key used to authenticate this request. The UEB
85      * API requires that you authenticate with the same key you're updating, so the
86      * API key being changed is the one used for setApiCredentials.
87      *
88      * @param email       use null to keep the current value
89      * @param description use null to keep the current value
90      * @throws IOException
91      * @throws HttpException
92      * @throws HttpObjectNotFoundException
93      */
94     void updateCurrentApiKey(String email, String description) throws HttpObjectNotFoundException, HttpException, IOException;
95
96     /**
97      * Delete the *current* API key. After this call returns, the API key
98      * used to authenticate will no longer be valid.
99      *
100      * @throws IOException
101      * @throws HttpException
102      */
103     void deleteCurrentApiKey() throws HttpException, IOException;
104 }