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