@Override public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception { // don't track selectors for advisory topics or temp destinations if (!AdvisorySupport.isAdvisoryTopic(info.getDestination()) && !info.getDestination().isTemporary()) { String destinationName = info.getDestination().getQualifiedName(); LOG.debug("Caching consumer selector [{}] on '{}'", info.getSelector(), destinationName); String selector = info.getSelector() == null ? MATCH_EVERYTHING : info.getSelector(); if (!(ignoreWildcardSelectors && hasWildcards(selector))) { Set<String> selectors = subSelectorCache.get(destinationName); if (selectors == null) { selectors = Collections.synchronizedSet(new HashSet<String>()); } else if (singleSelectorPerDestination && !MATCH_EVERYTHING.equals(selector)) { // in this case, we allow only ONE selector. But we don't count the catch-all "null/TRUE" selector // here, we always allow that one. But only one true selector. boolean containsMatchEverything = selectors.contains(MATCH_EVERYTHING); selectors.clear(); // put back the MATCH_EVERYTHING selector if (containsMatchEverything) { selectors.add(MATCH_EVERYTHING); } } LOG.debug("adding new selector: into cache " + selector); selectors.add(selector); LOG.debug("current selectors in cache: " + selectors); subSelectorCache.put(destinationName, selectors); } } return super.addConsumer(context, info); }
return super.addConsumer(context, info);
@Override public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception { Subscription answer = super.addConsumer(context, info);
return super.addConsumer(context, info);
@Override public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception { // don't track selectors for advisory topics or temp destinations if (!AdvisorySupport.isAdvisoryTopic(info.getDestination()) && !info.getDestination().isTemporary()) { String destinationName = info.getDestination().getQualifiedName(); LOG.debug("Caching consumer selector [{}] on '{}'", info.getSelector(), destinationName); String selector = info.getSelector() == null ? MATCH_EVERYTHING : info.getSelector(); if (!(ignoreWildcardSelectors && hasWildcards(selector))) { Set<String> selectors = subSelectorCache.get(destinationName); if (selectors == null) { selectors = Collections.synchronizedSet(new HashSet<String>()); } else if (singleSelectorPerDestination && !MATCH_EVERYTHING.equals(selector)) { // in this case, we allow only ONE selector. But we don't count the catch-all "null/TRUE" selector // here, we always allow that one. But only one true selector. boolean containsMatchEverything = selectors.contains(MATCH_EVERYTHING); selectors.clear(); // put back the MATCH_EVERYTHING selector if (containsMatchEverything) { selectors.add(MATCH_EVERYTHING); } } LOG.debug("adding new selector: into cache " + selector); selectors.add(selector); LOG.debug("current selectors in cache: " + selectors); subSelectorCache.put(destinationName, selectors); } } return super.addConsumer(context, info); }
@Override public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception { // don't track selectors for advisory topics or temp destinations if (!AdvisorySupport.isAdvisoryTopic(info.getDestination()) && !info.getDestination().isTemporary()) { String destinationName = info.getDestination().getQualifiedName(); LOG.debug("Caching consumer selector [{}] on '{}'", info.getSelector(), destinationName); String selector = info.getSelector() == null ? MATCH_EVERYTHING : info.getSelector(); if (!(ignoreWildcardSelectors && hasWildcards(selector))) { Set<String> selectors = subSelectorCache.get(destinationName); if (selectors == null) { selectors = Collections.synchronizedSet(new HashSet<String>()); } else if (singleSelectorPerDestination && !MATCH_EVERYTHING.equals(selector)) { // in this case, we allow only ONE selector. But we don't count the catch-all "null/TRUE" selector // here, we always allow that one. But only one true selector. boolean containsMatchEverything = selectors.contains(MATCH_EVERYTHING); selectors.clear(); // put back the MATCH_EVERYTHING selector if (containsMatchEverything) { selectors.add(MATCH_EVERYTHING); } } LOG.debug("adding new selector: into cache " + selector); selectors.add(selector); LOG.debug("current selectors in cache: " + selectors); subSelectorCache.put(destinationName, selectors); } } return super.addConsumer(context, info); }
@Override public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception { // don't track selectors for advisory topics or temp destinations if (!AdvisorySupport.isAdvisoryTopic(info.getDestination()) && !info.getDestination().isTemporary()) { String destinationName = info.getDestination().getQualifiedName(); LOG.debug("Caching consumer selector [{}] on '{}'", info.getSelector(), destinationName); String selector = info.getSelector() == null ? MATCH_EVERYTHING : info.getSelector(); if (!(ignoreWildcardSelectors && hasWildcards(selector))) { Set<String> selectors = subSelectorCache.get(destinationName); if (selectors == null) { selectors = Collections.synchronizedSet(new HashSet<String>()); } else if (singleSelectorPerDestination && !MATCH_EVERYTHING.equals(selector)) { // in this case, we allow only ONE selector. But we don't count the catch-all "null/TRUE" selector // here, we always allow that one. But only one true selector. boolean containsMatchEverything = selectors.contains(MATCH_EVERYTHING); selectors.clear(); // put back the MATCH_EVERYTHING selector if (containsMatchEverything) { selectors.add(MATCH_EVERYTHING); } } LOG.debug("adding new selector: into cache " + selector); selectors.add(selector); LOG.debug("current selectors in cache: " + selectors); subSelectorCache.put(destinationName, selectors); } } return super.addConsumer(context, info); }
return super.addConsumer(context, info);
@Override public Subscription addConsumer(final ConnectionContext context, final ConsumerInfo info) throws Exception { assert info != null : "ConsumerInfo must not be null"; assert context != null : "ConnectionContext must not be null"; if (shouldCheck(info)){ boolean checkPassed = false; try { checkPassed = isOwnerAllowedToConsume(context, info); } catch (Exception e){ throw new SecurityException("could not perform access control check for consumer " + info.getConsumerId() +" and destination "+ info.getDestination()); } if (!checkPassed) throw new SecurityException("consumer " + info.getConsumerId() +" not allowed to consume from destination "+ info.getDestination()); } logger.debug("consumer added. destination: {}, consumerId: {}", info.getDestination(), info.getConsumerId()); return super.addConsumer(context, info); }
return super.addConsumer(context, info);
return super.addConsumer(context, info);
return super.addConsumer(context, info);
public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception { final SecurityContext subject = context.getSecurityContext(); if (subject == null) throw new SecurityException("User is not authenticated."); if (info.getDestination().getPhysicalName().equals(Constants.NOTIFICATION_UPDATES_QUEUE)) { if (!subject.getPrincipals().contains(Constants.defaultSystemRole)) { throw new SecurityException("User " + subject.getUserName() + " is not authorized to read from: " + info.getDestination()); } } else if (info.getDestination().getPhysicalName().equals(Constants.NOTIFICATION_CONTROL_QUEUE)) { if (!subject.getPrincipals().contains(Constants.defaultSystemRole)) { throw new SecurityException("User " + subject.getUserName() + " is not authorized to read from: " + info.getDestination()); } } if (info.getDestination().isTemporary() && !((ActiveMQTempDestination) info.getDestination()).getConnectionId().equals(context.getConnectionId().getValue())) { throw new SecurityException("User " + subject.getUserName() + " is not authorized to read from: " + info.getDestination()); } subject.getAuthorizedReadDests().put(info.getDestination(), info.getDestination()); return super.addConsumer(context, info); }
return super.addConsumer(context, info);
@Override public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception { Subscription answer = super.addConsumer(context, info);
@Override public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception { Subscription answer = super.addConsumer(context, info);
return super.addConsumer(context, info);
return super.addConsumer(context, info);
return super.addConsumer(context, info);
return super.addConsumer(context, info);