String topicName = subscription.getFilterDesc().getFilterValue();
if(EventBrokerUtils.isSecureTopic(topicName)){
UserRealm userRealm = AdminServicesUtil.getUserRealm();
if(!userRealm.getAuthorizationManager().isUserAuthorized(EventBrokerUtils.getLoggedInUserName(),
Utils.getSecureTopicPermissionPath(topicName), "write")){
throw new EventException("User is not authorized to subscribe to Secure topic "+ topicName);
}
}
if (subscription != null && subscription.getId() != null) {
if (log.isDebugEnabled()) {
log.debug("Subscription request recieved : " + subscription.getId());
}
String subID = getBrokerService().subscribe(subscription);
if (subID != null) {
if (log.isDebugEnabled()) {
log.debug("Sending subscription response for Subscription ID : " +
subscription.getId());
}
SOAPEnvelope soapEnvelope = builder.fromSubscription(subscription);
dispatchResponse(soapEnvelope, CommandBuilderConstants.WSE_SUBSCRIBE_RESPONSE, mc, false);
} else {
log.debug("Subscription Failed, sending fault response");
SOAPEnvelope soapEnvelope = BuilderUtils.genFaultResponse(
CommandBuilderConstants.WSE_FAULT_CODE_RECEIVER, "EventSourceUnableToProcess",
"Unable to subscribe ", "", mc.isSOAP11());
dispatchResponse(soapEnvelope, CommandBuilderConstants.WSA_FAULT, mc, true);
}
} else {
log.debug("Subscription Failed, sending fault response");
SOAPEnvelope soapEnvelope = BuilderUtils.genFaultResponse(
CommandBuilderConstants.WSE_FAULT_CODE_RECEIVER, "EventSourceUnableToProcess",
"Unable to subscribe ", "", mc.isSOAP11());
dispatchResponse(soapEnvelope, CommandBuilderConstants.WSA_FAULT, mc, true);
}
}catch(Exception e){
throw new EventException("Error at Subscribing ",e);
}
}