public AuthorizationInterceptorDefinition generate(Element policy, PolicyMetadata metadata, LogicalOperation operation) throws GenerationException { String[] roles = metadata.get(AUTHORIZATION, String[].class); if (roles == null) { LogicalComponent component = operation.getParent().getParent(); throw new GenerationException("No roles specified for authorization intent on component: " + component.getUri()); } return new AuthorizationInterceptorDefinition(Arrays.asList(roles)); }
private boolean useByReference(LogicalOperation operation, boolean remote) { if (!passByValueEnabled || remote) { // Pass-by-value is disabled or the invocation chain is remote. Pass-by-reference semantics should be used for remote invocation chains // since the binding will enforce pass-by-value implicitly through serialization return true; } LogicalAttachPoint logicalAttachPoint = operation.getParent(); LogicalComponent<?> component = logicalAttachPoint.getParent(); return operation.getIntents().contains(ALLOWS_BY_REFERENCE) || logicalAttachPoint.getIntents().contains(ALLOWS_BY_REFERENCE) || component.getIntents().contains(ALLOWS_BY_REFERENCE) || component.getDefinition().getImplementation().getIntents().contains( ALLOWS_BY_REFERENCE) || component.getDefinition().getImplementation().getComponentType().getIntents().contains(ALLOWS_BY_REFERENCE); } }
if (!operation.getIntents().contains(ONEWAY)) { throw new PolicyResolutionException( "Cannot specify transacted one-way for a request-response operation: " + operation.getParent().getUri()); LogicalOperation operation = (LogicalOperation) artifact; if (!operation.getIntents().contains(ONEWAY)) { throw new PolicyResolutionException("Cannot specify immediate one-way for a request-response operation: " + operation.getParent().getUri());
if (((LogicalOperation) entry).getParent().getParent() == target) { return true;
PhysicalInterceptorDefinition pid = generator.generate(policy.getExpression(), metadata, operation); if (pid != null) { URI contributionClassLoaderId = operation.getParent().getParent().getDefinition().getContributionUri(); pid.setWireClassLoaderId(contributionClassLoaderId); pid.setPolicyClassLoaderId(policy.getContributionUri());
String sourceComponent = parent.getParent().getUri().toString(); throw new OperationNotFoundException("Target operation not found for " + sourceDefinition.getName() + " on source component " + sourceComponent); } else {
public PolicyResult resolvePolicies(LogicalConsumer consumer) throws PolicyResolutionException { LogicalComponent<?> component = consumer.getParent(); if (noPolicy(component)) { return EMPTY_RESULT; } // synthesize an operation and binding PolicyResultImpl policyResult = new PolicyResultImpl(); LogicalOperation operation = new LogicalOperation(DEFINITION, consumer); IntentPair targetOperationIntentPair = interactionResolver.resolveIntents(operation, LocalBindingDefinition.INSTANCE.getType()); policyResult.addTargetProvidedIntents(operation, targetOperationIntentPair.getProvidedIntents()); IntentPair sourceImplementationIntentPair = implementationResolver.resolveIntents(component, operation); policyResult.addSourceProvidedIntents(operation, sourceImplementationIntentPair.getProvidedIntents()); Set<PolicySet> policies = interactionResolver.resolvePolicySets(operation, consumer, LocalBindingDefinition.INSTANCE.getType()); policyResult.addTargetPolicySets(operation, CollectionUtils.filter(policies, PROVIDED)); policyResult.addInterceptedPolicySets(operation, CollectionUtils.filter(policies, INTERCEPTION)); // resolve policies using the target (as opposed to source) operation so target implementation policies are included policies = implementationResolver.resolvePolicySets(component, operation); // add policy metadata to the result PolicyMetadata metadata = policyResult.getMetadata(operation); metadata.addAll(operation.getDefinition().getMetadata()); // add metadata from implementation metadata.addAll(operation.getParent().getParent().getDefinition().getImplementation().getMetadata()); // important: use reference side operation as the key policyResult.addTargetPolicySets(operation, CollectionUtils.filter(policies, PROVIDED)); policyResult.addInterceptedPolicySets(operation, CollectionUtils.filter(policies, INTERCEPTION)); overrideDirectIfExternalAttachedPolicies(policyResult); return policyResult; }
metadata.addAll(targetOperation.getDefinition().getMetadata()); ComponentDefinition<? extends Implementation<?>> parentDefinition = targetOperation.getParent().getParent().getDefinition(); Implementation<?> parentImplementation = parentDefinition.getImplementation(); metadata.addAll(parentImplementation.getMetadata());