import com.att.dmf.mr.exception.ErrorResponse;
import com.att.dmf.mr.metabroker.Broker.TopicExistsException;
import com.att.dmf.mr.metabroker.Broker1;
import com.att.dmf.mr.exception.ErrorResponse;
import com.att.dmf.mr.metabroker.Broker.TopicExistsException;
import com.att.dmf.mr.metabroker.Broker1;
import com.att.dmf.mr.metabroker.Topic;
import com.att.dmf.mr.security.DMaaPAAFAuthenticator;
import com.att.dmf.mr.security.DMaaPAAFAuthenticatorImpl;
import com.att.dmf.mr.metabroker.Topic;
import com.att.dmf.mr.security.DMaaPAAFAuthenticator;
import com.att.dmf.mr.security.DMaaPAAFAuthenticatorImpl;
private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(TopicServiceImpl.class);
@Autowired
private DMaaPErrorMessages errorMessages;
// @Value("${msgRtr.topicfactory.aaf}")
private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(TopicServiceImpl.class);
@Autowired
private DMaaPErrorMessages errorMessages;
// @Value("${msgRtr.topicfactory.aaf}")
for (Topic topic : getMetaBroker(dmaapContext).getAllTopics()) {
JSONObject obj = new JSONObject();
obj.put("topicName", topic.getName());
for (Topic topic : getMetaBroker(dmaapContext).getAllTopics()) {
JSONObject obj = new JSONObject();
obj.put("topicName", topic.getName());
obj.put("owner", topic.getOwner());
obj.put("txenabled", topic.isTransactionEnabled());
topicsList.put(obj);
obj.put("owner", topic.getOwner());
obj.put("txenabled", topic.isTransactionEnabled());
topicsList.put(obj);
String enfTopicName = com.att.ajsc.beans.PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop,
"enforced.topic.name.AAF");
String enfTopicName = com.att.ajsc.beans.PropertiesMapBean.getProperty(CambriaConstants.msgRtr_prop,
"enforced.topic.name.AAF");
"Failed to create topic: Access Denied.User does not have permission to perform create topic");
LOGGER.info(errRes.toString());
"Failed to create topic: Access Denied.User does not have permission to perform create topic");
LOGGER.info(errRes.toString());
/*else if (user == null && null == dmaapContext.getRequest().getHeader("Authorization")
) {
LOGGER.error("Failed to create topic" + topicBean.getTopicName() + ", Authentication failed.");
/*else if (user == null && null == dmaapContext.getRequest().getHeader("Authorization")
) {
LOGGER.error("Failed to create topic" + topicBean.getTopicName() + ", Authentication failed.");
// ACL authentication is not provided so we will use the aaf
// authentication
/*LOGGER.info("Authorization the topic");
// ACL authentication is not provided so we will use the aaf
// authentication
/*LOGGER.info("Authorization the topic");
permission = mrFactoryVal + nameSpace + "|create";
DMaaPAAFAuthenticator aaf = new DMaaPAAFAuthenticatorImpl();*/
permission = mrFactoryVal + nameSpace + "|create";
DMaaPAAFAuthenticator aaf = new DMaaPAAFAuthenticatorImpl();*/
if (false) {
LOGGER.error("Failed to create topic" + topicBean.getTopicName() + ", Authentication failed.");
ErrorResponse errRes = new ErrorResponse(HttpStatus.SC_UNAUTHORIZED,
DMaaPResponseCode.ACCESS_NOT_PERMITTED.getResponseCode(),
"Failed to create topic: Access Denied.User does not have permission to create topic with perm "
if (false) {
LOGGER.error("Failed to create topic" + topicBean.getTopicName() + ", Authentication failed.");
ErrorResponse errRes = new ErrorResponse(HttpStatus.SC_UNAUTHORIZED,
DMaaPResponseCode.ACCESS_NOT_PERMITTED.getResponseCode(),
"Failed to create topic: Access Denied.User does not have permission to create topic with perm "
final String topicName = topicBean.getTopicName();
final String desc = topicBean.getTopicDescription();
int partition = topicBean.getPartitionCount();
final String topicName = topicBean.getTopicName();
final String desc = topicBean.getTopicDescription();
int partition = topicBean.getPartitionCount();
LOGGER.info("Granting write access to producer [" + producerId + "] for topic " + topicName);
final NsaApiKey user = DMaaPAuthenticatorImpl.getAuthenticatedUser(dmaapContext);
LOGGER.info("Granting write access to producer [" + producerId + "] for topic " + topicName);
final NsaApiKey user = DMaaPAuthenticatorImpl.getAuthenticatedUser(dmaapContext);
// String permission = aaf.aafPermissionString(topicName, "manage");
// if(!aaf.aafAuthentication(dmaapContext.getRequest(), permission))
// {
// LOGGER.error("Failed to permit write access to producer [" +
// producerId + "] for topic " + topicName
// String permission = aaf.aafPermissionString(topicName, "manage");
// if(!aaf.aafAuthentication(dmaapContext.getRequest(), permission))
// {
// LOGGER.error("Failed to permit write access to producer [" +
// producerId + "] for topic " + topicName
// ErrorResponse errRes = new ErrorResponse(HttpStatus.SC_FORBIDDEN,
// DMaaPResponseCode.ACCESS_NOT_PERMITTED.getResponseCode(),
// errorMessages.getNotPermitted1()+" <Grant publish permissions>
// ErrorResponse errRes = new ErrorResponse(HttpStatus.SC_FORBIDDEN,
// DMaaPResponseCode.ACCESS_NOT_PERMITTED.getResponseCode(),
// errorMessages.getNotPermitted1()+" <Grant publish permissions>
LOGGER.info("Revoking write access to producer [" + producerId + "] for topic " + topicName);
final NsaApiKey user = DMaaPAuthenticatorImpl.getAuthenticatedUser(dmaapContext);
LOGGER.info("Revoking write access to producer [" + producerId + "] for topic " + topicName);
final NsaApiKey user = DMaaPAuthenticatorImpl.getAuthenticatedUser(dmaapContext);
// DMaaPAAFAuthenticator aaf = new DMaaPAAFAuthenticatorImpl();
// String permission = aaf.aafPermissionString(topicName, "manage");
// if(!aaf.aafAuthentication(dmaapContext.getRequest(), permission))
// {
// LOGGER.error("Failed to revoke write access to producer [" +
// producerId + "] for topic " + topicName
// DMaaPAAFAuthenticator aaf = new DMaaPAAFAuthenticatorImpl();
// String permission = aaf.aafPermissionString(topicName, "manage");
// if(!aaf.aafAuthentication(dmaapContext.getRequest(), permission))
// {
// LOGGER.error("Failed to revoke write access to producer [" +
// producerId + "] for topic " + topicName
// ErrorResponse errRes = new ErrorResponse(HttpStatus.SC_FORBIDDEN,
// DMaaPResponseCode.ACCESS_NOT_PERMITTED.getResponseCode(),
// errorMessages.getNotPermitted1()+" <Revoke publish permissions>
// ErrorResponse errRes = new ErrorResponse(HttpStatus.SC_FORBIDDEN,
// DMaaPResponseCode.ACCESS_NOT_PERMITTED.getResponseCode(),
// errorMessages.getNotPermitted1()+" <Revoke publish permissions>
LOGGER.info("Granting read access to consumer [" + consumerId + "] for topic " + topicName);
final NsaApiKey user = DMaaPAuthenticatorImpl.getAuthenticatedUser(dmaapContext);
LOGGER.info("Granting read access to consumer [" + consumerId + "] for topic " + topicName);
final NsaApiKey user = DMaaPAuthenticatorImpl.getAuthenticatedUser(dmaapContext);
// DMaaPAAFAuthenticator aaf = new DMaaPAAFAuthenticatorImpl();
// String permission = aaf.aafPermissionString(topicName, "manage");
// if(!aaf.aafAuthentication(dmaapContext.getRequest(), permission))
// {
// LOGGER.error("Failed to permit read access to consumer [" +
// consumerId + "] for topic " + topicName
// DMaaPAAFAuthenticator aaf = new DMaaPAAFAuthenticatorImpl();
// String permission = aaf.aafPermissionString(topicName, "manage");
// if(!aaf.aafAuthentication(dmaapContext.getRequest(), permission))
// {
// LOGGER.error("Failed to permit read access to consumer [" +
// consumerId + "] for topic " + topicName
// ErrorResponse errRes = new ErrorResponse(HttpStatus.SC_FORBIDDEN,
// DMaaPResponseCode.ACCESS_NOT_PERMITTED.getResponseCode(),
// errorMessages.getNotPermitted1()+" <Grant consume permissions>
// ErrorResponse errRes = new ErrorResponse(HttpStatus.SC_FORBIDDEN,
// DMaaPResponseCode.ACCESS_NOT_PERMITTED.getResponseCode(),
// errorMessages.getNotPermitted1()+" <Grant consume permissions>
LOGGER.info("Revoking read access to consumer [" + consumerId + "] for topic " + topicName);
final NsaApiKey user = DMaaPAuthenticatorImpl.getAuthenticatedUser(dmaapContext);
LOGGER.info("Revoking read access to consumer [" + consumerId + "] for topic " + topicName);
final NsaApiKey user = DMaaPAuthenticatorImpl.getAuthenticatedUser(dmaapContext);
// DMaaPAAFAuthenticator aaf = new DMaaPAAFAuthenticatorImpl();
// String permission = aaf.aafPermissionString(topicName, "manage");
// if(!aaf.aafAuthentication(dmaapContext.getRequest(), permission))
// {
// LOGGER.error("Failed to revoke read access to consumer [" +
// consumerId + "] for topic " + topicName
// DMaaPAAFAuthenticator aaf = new DMaaPAAFAuthenticatorImpl();
// String permission = aaf.aafPermissionString(topicName, "manage");
// if(!aaf.aafAuthentication(dmaapContext.getRequest(), permission))
// {
// LOGGER.error("Failed to revoke read access to consumer [" +
// consumerId + "] for topic " + topicName
// ErrorResponse errRes = new ErrorResponse(HttpStatus.SC_FORBIDDEN,
// DMaaPResponseCode.ACCESS_NOT_PERMITTED.getResponseCode(),
// errorMessages.getNotPermitted1()+" <Grant consume permissions>
// ErrorResponse errRes = new ErrorResponse(HttpStatus.SC_FORBIDDEN,
// DMaaPResponseCode.ACCESS_NOT_PERMITTED.getResponseCode(),
// errorMessages.getNotPermitted1()+" <Grant consume permissions>