@Override public AuthorizationContext getAuthorizationContext() { return delegate.getAuthorizationContext(); }
@Override public AuthorizationContext getAuthorizationContext() { return delegate.getAuthorizationContext(); }
/** * If no context is set on connection level each target and source must have its own context. */ private void checkAuthorizationContextsAreValid() { // if the auth context on connection level is empty, // an auth context is required to be set on each source/target final Set<String> sourcesWithoutAuthContext = sources.stream() .filter(source -> source.getAuthorizationContext().isEmpty()) .flatMap(source -> source.getAddresses().stream()) .collect(Collectors.toSet()); final Set<String> targetsWithoutAuthContext = targets.stream() .filter(target -> target.getAuthorizationContext().isEmpty()) .map(Target::getAddress) .collect(Collectors.toSet()); if (!sourcesWithoutAuthContext.isEmpty() || !targetsWithoutAuthContext.isEmpty()) { final StringBuilder message = new StringBuilder("The "); if (!sourcesWithoutAuthContext.isEmpty()) { message.append("Sources ").append(sourcesWithoutAuthContext); } if (!sourcesWithoutAuthContext.isEmpty() && !targetsWithoutAuthContext.isEmpty()) { message.append(" and "); } if (!targetsWithoutAuthContext.isEmpty()) { message.append("Targets ").append(targetsWithoutAuthContext); } message.append(" are missing an authorization context."); throw ConnectionConfigurationInvalidException.newBuilder(message.toString()).build(); } }
/** * If no context is set on connection level each target and source must have its own context. */ private void checkAuthorizationContextsAreValid() { // if the auth context on connection level is empty, // an auth context is required to be set on each source/target final Set<String> sourcesWithoutAuthContext = sources.stream() .filter(source -> source.getAuthorizationContext().isEmpty()) .flatMap(source -> source.getAddresses().stream()) .collect(Collectors.toSet()); final Set<String> targetsWithoutAuthContext = targets.stream() .filter(target -> target.getAuthorizationContext().isEmpty()) .map(Target::getAddress) .collect(Collectors.toSet()); if (!sourcesWithoutAuthContext.isEmpty() || !targetsWithoutAuthContext.isEmpty()) { final StringBuilder message = new StringBuilder("The "); if (!sourcesWithoutAuthContext.isEmpty()) { message.append("Sources ").append(sourcesWithoutAuthContext); } if (!sourcesWithoutAuthContext.isEmpty() && !targetsWithoutAuthContext.isEmpty()) { message.append(" and "); } if (!targetsWithoutAuthContext.isEmpty()) { message.append("Targets ").append(targetsWithoutAuthContext); } message.append(" are missing an authorization context."); throw ConnectionConfigurationInvalidException.newBuilder(message.toString()).build(); } }
private AmqpConsumerActor(final String sourceAddress, final MessageConsumer messageConsumer, final ActorRef messageMappingProcessor, final Source source) { this.sourceAddress = checkNotNull(sourceAddress, "sourceAddress"); this.messageConsumer = checkNotNull(messageConsumer); this.messageMappingProcessor = checkNotNull(messageMappingProcessor, "messageMappingProcessor"); checkNotNull(source, "source"); authorizationContext = source.getAuthorizationContext(); final Enforcement enforcement = source.getEnforcement().orElse(null); headerMapping = source.getHeaderMapping().orElse(null); addressMetric = ConnectivityModelFactory.newAddressMetric(ConnectionStatus.OPEN, "Started at " + Instant.now(), 0, null); headerEnforcementFilterFactory = enforcement != null ? EnforcementFactoryFactory.newEnforcementFilterFactory(enforcement, PlaceholderFactory.newHeadersPlaceholder()) : input -> null; }
private AmqpConsumerActor(final String sourceAddress, final MessageConsumer messageConsumer, final ActorRef messageMappingProcessor, final Source source) { this.sourceAddress = checkNotNull(sourceAddress, "sourceAddress"); this.messageConsumer = checkNotNull(messageConsumer); this.messageMappingProcessor = checkNotNull(messageMappingProcessor, "messageMappingProcessor"); checkNotNull(source, "source"); authorizationContext = source.getAuthorizationContext(); final Enforcement enforcement = source.getEnforcement().orElse(null); headerMapping = source.getHeaderMapping().orElse(null); addressMetric = ConnectivityModelFactory.newAddressMetric(ConnectionStatus.OPEN, "Started at " + Instant.now(), 0, null); headerEnforcementFilterFactory = enforcement != null ? EnforcementFactoryFactory.newEnforcementFilterFactory(enforcement, PlaceholderFactory.newHeadersPlaceholder()) : input -> null; }
private void startConsumers(final Channel channel) { final Optional<ActorRef> messageMappingProcessor = getMessageMappingProcessorActor(); if (messageMappingProcessor.isPresent()) { getSourcesOrEmptySet().forEach(source -> source.getAddresses().forEach(sourceAddress -> { for (int i = 0; i < source.getConsumerCount(); i++) { final String addressWithIndex = sourceAddress + "-" + i; final AuthorizationContext authorizationContext = source.getAuthorizationContext(); final Enforcement enforcement = source.getEnforcement().orElse(null); final HeaderMapping headerMapping = source.getHeaderMapping().orElse(null); final ActorRef consumer = startChildActorConflictFree( CONSUMER_ACTOR_PREFIX + addressWithIndex, RabbitMQConsumerActor.props(sourceAddress, messageMappingProcessor.get(), authorizationContext, enforcement, headerMapping)); consumerByAddressWithIndex.put(addressWithIndex, consumer); try { final String consumerTag = channel.basicConsume(sourceAddress, false, new RabbitMQMessageConsumer(consumer, channel)); log.debug("Consuming queue <{}>, consumer tag is <{}>.", addressWithIndex, consumerTag); consumedTagsToAddresses.put(consumerTag, addressWithIndex); } catch (final IOException e) { log.warning("Failed to consume queue <{}>: <{}>", addressWithIndex, e.getMessage()); } } }) ); } else { log.warning("The MessageMappingProcessor was not available and therefore no consumers were started!"); } }
private void startConsumers(final Channel channel) { final Optional<ActorRef> messageMappingProcessor = getMessageMappingProcessorActor(); if (messageMappingProcessor.isPresent()) { getSourcesOrEmptySet().forEach(source -> source.getAddresses().forEach(sourceAddress -> { for (int i = 0; i < source.getConsumerCount(); i++) { final String addressWithIndex = sourceAddress + "-" + i; final AuthorizationContext authorizationContext = source.getAuthorizationContext(); final Enforcement enforcement = source.getEnforcement().orElse(null); final HeaderMapping headerMapping = source.getHeaderMapping().orElse(null); final ActorRef consumer = startChildActorConflictFree( CONSUMER_ACTOR_PREFIX + addressWithIndex, RabbitMQConsumerActor.props(sourceAddress, messageMappingProcessor.get(), authorizationContext, enforcement, headerMapping)); consumerByAddressWithIndex.put(addressWithIndex, consumer); try { final String consumerTag = channel.basicConsume(sourceAddress, false, new RabbitMQMessageConsumer(consumer, channel)); log.debug("Consuming queue <{}>, consumer tag is <{}>.", addressWithIndex, consumerTag); consumedTagsToAddresses.put(consumerTag, addressWithIndex); } catch (final IOException e) { log.warning("Failed to consume queue <{}>: <{}>", addressWithIndex, e.getMessage()); } } }) ); } else { log.warning("The MessageMappingProcessor was not available and therefore no consumers were started!"); } }
MqttConsumerActor.props(messageMappingProcessorActor, source.getAuthorizationContext(), source.getEnforcement().orElse(null), dryRun);
MqttConsumerActor.props(messageMappingProcessorActor, source.getAuthorizationContext(), source.getEnforcement().orElse(null), dryRun);