d191070cf837e2dbe2f75f74d0c9dff4cc40c798
[dmaap/messagerouter/msgrtr.git] / src / main / java / com / att / dmf / mr / metabroker / Topic.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 com.att.dmf.mr.metabroker;
23
24 import com.att.nsa.configs.ConfigDbException;
25 import com.att.nsa.security.NsaAcl;
26 import com.att.nsa.security.NsaApiKey;
27 import com.att.nsa.security.ReadWriteSecuredResource;
28 /**
29  * This is the interface for topic and all the topic related operations
30  * get topic name, owner, description, transactionEnabled etc.
31  * @author nilanjana.maity
32  *
33  */
34 public interface Topic extends ReadWriteSecuredResource
35 {       
36         /**
37          * User defined exception for access denied while access the topic for Publisher and consumer
38          * @author nilanjana.maity
39          *
40          *//*
41         public class AccessDeniedException extends Exception
42         
43                 *//**
44                  * AccessDenied Description
45                  *//*
46                 
47                 *//**
48                  * AccessDenied Exception for the user while authenticating the user request
49                  * @param user
50                  *//*
51                 
52                 private static final long serialVersionUID = 1L;
53         }*/
54
55         /**
56          * Get this topic's name
57          * @return
58          */
59         String getName ();
60
61         /**
62          * Get the API key of the owner of this topic.
63          * @return
64          */
65         String getOwner ();
66
67         /**
68          * Get a description of the topic, as set by the owner at creation time.
69          * @return
70          */
71         String getDescription ();
72         
73         /**
74          * If the topic is transaction enabled
75          * @return boolean true/false
76          */
77         boolean isTransactionEnabled();
78         
79         /**
80          * Get the ACL for reading on this topic. Can be null.
81          * @return
82          */
83         NsaAcl getReaderAcl ();
84
85         /**
86          * Get the ACL for writing on this topic.  Can be null.
87          * @return
88          */
89         NsaAcl getWriterAcl ();
90
91         /**
92          * Check if this user can read the topic. Throw otherwise. Note that
93          * user may be null.
94          * @param user
95          */
96         void checkUserRead ( NsaApiKey user ) throws AccessDeniedException;
97
98         /**
99          * Check if this user can write to the topic. Throw otherwise. Note
100          * that user may be null.
101          * @param user
102          */
103         void checkUserWrite ( NsaApiKey user ) throws AccessDeniedException;
104
105         /**
106          * allow the given user to publish
107          * @param publisherId
108          * @param asUser
109          */
110         void permitWritesFromUser ( String publisherId, NsaApiKey asUser ) throws AccessDeniedException, ConfigDbException;
111
112         /**
113          * deny the given user from publishing
114          * @param publisherId
115          * @param asUser
116          */
117         void denyWritesFromUser ( String publisherId, NsaApiKey asUser ) throws AccessDeniedException, ConfigDbException;
118
119         /**
120          * allow the given user to read the topic
121          * @param consumerId
122          * @param asUser
123          */
124         void permitReadsByUser ( String consumerId, NsaApiKey asUser ) throws AccessDeniedException, ConfigDbException;
125
126         /**
127          * deny the given user from reading the topic
128          * @param consumerId
129          * @param asUser
130          * @throws ConfigDbException 
131          */
132         void denyReadsByUser ( String consumerId, NsaApiKey asUser ) throws AccessDeniedException, ConfigDbException;
133 }