org.apache.cxf.phase.PhaseInterceptorChain Java Examples

The following examples show how to use org.apache.cxf.phase.PhaseInterceptorChain. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConfigurationEndpointUtils.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
/**
 * Build the complete URI prepending the user API context without the proxy context path, to the endpoint.
 * Ex: https://localhost:9443/t/<tenant-domain>/api/users/<endpoint>
 *
 * @param endpoint relative endpoint path.
 * @return Fully qualified and complete URI.
 */
public static URI buildURIForHeader(String endpoint) {

    String tenantQualifiedRelativePath =
            String.format(TENANT_CONTEXT_PATH_COMPONENT, getTenantDomainFromContext()) + SERVER_API_PATH_COMPONENT;
    String url = IdentityUtil.getEndpointURIPath(tenantQualifiedRelativePath + endpoint, false, true);

    URI loc = URI.create(url);
    if (!loc.isAbsolute()) {
        Message currentMessage = PhaseInterceptorChain.getCurrentMessage();
        if (currentMessage != null) {
            UriInfo ui = new UriInfoImpl(currentMessage.getExchange().getInMessage(), null);
            try {
                return new URI(ui.getBaseUri().getScheme(), ui.getBaseUri().getAuthority(), url, null, null);
            } catch (URISyntaxException e) {
                log.error("Server encountered an error while building the location URL with scheme: " +
                        ui.getBaseUri().getScheme() + ", authority: " + ui.getBaseUri().getAuthority() +
                        ", url: " + url, e);
            }
        }
    }
    return loc;
}
 
Example #2
Source File: RetransmissionQueueImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * @param endpoint
 * @param cache
 * @return
 */
protected PhaseInterceptorChain buildRetransmitChain(final Endpoint endpoint, PhaseChainCache cache) {
    PhaseInterceptorChain retransmitChain;
    Bus bus = getManager().getBus();
    List<Interceptor<? extends Message>> i1 = bus.getOutInterceptors();
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Interceptors contributed by bus: " + i1);
    }
    List<Interceptor<? extends Message>> i2 = endpoint.getOutInterceptors();
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Interceptors contributed by endpoint: " + i2);
    }
    List<Interceptor<? extends Message>> i3 = endpoint.getBinding().getOutInterceptors();
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Interceptors contributed by binding: " + i3);
    }
    PhaseManager pm = bus.getExtension(PhaseManager.class);
    retransmitChain = cache.get(pm.getOutPhases(), i1, i2, i3);
    return retransmitChain;
}
 
Example #3
Source File: ReceivedTokenCallbackHandler.java    From steady with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void handle(Callback[] callbacks)
    throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof DelegationCallback) {
            DelegationCallback callback = (DelegationCallback) callbacks[i];
            Message message = callback.getCurrentMessage();
            
            if (message != null 
                && message.get(PhaseInterceptorChain.PREVIOUS_MESSAGE) != null) {
                WeakReference<SoapMessage> wr = 
                    (WeakReference<SoapMessage>)
                        message.get(PhaseInterceptorChain.PREVIOUS_MESSAGE);
                SoapMessage previousSoapMessage = wr.get();
                Element token = getTokenFromMessage(previousSoapMessage);
                if (token != null) {
                    callback.setToken(token);
                }
            }
            
        } else {
            throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
        }
    }
}
 
Example #4
Source File: CryptoCoverageCheckerTest.java    From steady with Apache License 2.0 6 votes vote down vote up
@Test
public void testOrder() throws Exception {
    //make sure the interceptors get ordered correctly
    SortedSet<Phase> phases = new TreeSet<Phase>();
    phases.add(new Phase(Phase.PRE_PROTOCOL, 1));
    
    List<Interceptor<? extends Message>> lst = 
        new ArrayList<Interceptor<? extends Message>>();
    lst.add(new MustUnderstandInterceptor());
    lst.add(new WSS4JInInterceptor());
    lst.add(new SAAJInInterceptor());
    lst.add(new CryptoCoverageChecker());
    PhaseInterceptorChain chain = new PhaseInterceptorChain(phases);
    chain.add(lst);
    String output = chain.toString();
    assertTrue(output.contains("MustUnderstandInterceptor, SAAJInInterceptor, "
            + "WSS4JInInterceptor, CryptoCoverageChecker"));
}
 
Example #5
Source File: CryptoCoverageCheckerTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testOrder() throws Exception {
    //make sure the interceptors get ordered correctly
    SortedSet<Phase> phases = new TreeSet<>();
    phases.add(new Phase(Phase.PRE_PROTOCOL, 1));

    List<Interceptor<? extends Message>> lst = new ArrayList<>();
    lst.add(new MustUnderstandInterceptor());
    lst.add(new WSS4JInInterceptor());
    lst.add(new SAAJInInterceptor());
    lst.add(new CryptoCoverageChecker());
    PhaseInterceptorChain chain = new PhaseInterceptorChain(phases);
    chain.add(lst);
    String output = chain.toString();
    assertTrue(output.contains("MustUnderstandInterceptor, SAAJInInterceptor, "
            + "WSS4JInInterceptor, CryptoCoverageChecker"));
}
 
Example #6
Source File: ReceivedTokenCallbackHandler.java    From steady with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void handle(Callback[] callbacks)
    throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof DelegationCallback) {
            DelegationCallback callback = (DelegationCallback) callbacks[i];
            Message message = callback.getCurrentMessage();
            
            if (message != null 
                && message.get(PhaseInterceptorChain.PREVIOUS_MESSAGE) != null) {
                WeakReference<SoapMessage> wr = 
                    (WeakReference<SoapMessage>)
                        message.get(PhaseInterceptorChain.PREVIOUS_MESSAGE);
                SoapMessage previousSoapMessage = wr.get();
                Element token = getTokenFromMessage(previousSoapMessage);
                if (token != null) {
                    callback.setToken(token);
                }
            }
            
        } else {
            throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
        }
    }
}
 
Example #7
Source File: CryptoCoverageCheckerTest.java    From steady with Apache License 2.0 6 votes vote down vote up
@Test
public void testOrder() throws Exception {
    //make sure the interceptors get ordered correctly
    SortedSet<Phase> phases = new TreeSet<Phase>();
    phases.add(new Phase(Phase.PRE_PROTOCOL, 1));
    
    List<Interceptor<? extends Message>> lst = 
        new ArrayList<Interceptor<? extends Message>>();
    lst.add(new MustUnderstandInterceptor());
    lst.add(new WSS4JInInterceptor());
    lst.add(new SAAJInInterceptor());
    lst.add(new CryptoCoverageChecker());
    PhaseInterceptorChain chain = new PhaseInterceptorChain(phases);
    chain.add(lst);
    String output = chain.toString();
    assertTrue(output.contains("MustUnderstandInterceptor, SAAJInInterceptor, "
            + "WSS4JInInterceptor, CryptoCoverageChecker"));
}
 
Example #8
Source File: RequestImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
private static void addVaryHeader(List<Object> varyValues) {
    // at this point we still have no out-bound message so lets
    // use HttpServletResponse. If needed we can save the header on the exchange
    // and then copy it into the out-bound message's headers
    Message message = PhaseInterceptorChain.getCurrentMessage();
    if (message != null) {
        Object httpResponse = message.get("HTTP.RESPONSE");
        if (httpResponse != null) {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < varyValues.size(); i++) {
                if (i > 0) {
                    sb.append(',');
                }
                sb.append(varyValues.get(i).toString());
            }
            ((javax.servlet.http.HttpServletResponse)httpResponse)
                .setHeader(HttpHeaders.VARY, sb.toString());
        }
    }
}
 
Example #9
Source File: ReceivedTokenCallbackHandler.java    From cxf with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void handle(Callback[] callbacks)
    throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof DelegationCallback) {
            DelegationCallback callback = (DelegationCallback) callbacks[i];
            Message message = callback.getCurrentMessage();

            if (message != null
                && message.get(PhaseInterceptorChain.PREVIOUS_MESSAGE) != null) {
                WeakReference<SoapMessage> wr =
                    (WeakReference<SoapMessage>)
                        message.get(PhaseInterceptorChain.PREVIOUS_MESSAGE);
                SoapMessage previousSoapMessage = wr.get();
                Element token = getTokenFromMessage(previousSoapMessage);
                if (token != null) {
                    callback.setToken(token);
                }
            }

        } else {
            throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
        }
    }
}
 
Example #10
Source File: RMInInterceptorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testOrdering() {
    control.replay();
    Phase p = new Phase(Phase.PRE_LOGICAL, 1);
    SortedSet<Phase> phases = new TreeSet<>();
    phases.add(p);
    PhaseInterceptorChain chain =
        new PhaseInterceptorChain(phases);
    MAPAggregator map = new MAPAggregator();
    RMInInterceptor rmi = new RMInInterceptor();
    chain.add(rmi);
    chain.add(map);
    Iterator<Interceptor<? extends Message>> it = chain.iterator();
    assertSame("Unexpected order.", rmi, it.next());
    assertSame("Unexpected order.", map, it.next());

}
 
Example #11
Source File: ProtobufClient.java    From fuchsia with Apache License 2.0 6 votes vote down vote up
protected InterceptorChain setupInterceptorChain(Exchange exchange) {
    if (outgoingInterceptorChain != null) {
        return outgoingInterceptorChain;
    }

    Endpoint endpoint = getEndpoint(exchange);

    PhaseManager pm = bus.getExtension(PhaseManager.class);
    @SuppressWarnings("unchecked")
    List<Interceptor<? extends org.apache.cxf.message.Message>> i1 = bus.getOutInterceptors();
    @SuppressWarnings("unchecked")
    List<Interceptor<? extends org.apache.cxf.message.Message>> i2 = endpoint.getOutInterceptors();
    @SuppressWarnings("unchecked")
    List<Interceptor<? extends org.apache.cxf.message.Message>> i3 = getOutInterceptors();
    @SuppressWarnings("unchecked")
    List<Interceptor<? extends org.apache.cxf.message.Message>> i4 = endpoint.getBinding().getOutInterceptors();

    PhaseInterceptorChain phaseInterceptorChain = outboundChainCache.get(pm
            .getOutPhases(), i1, i2, i3, i4);
    return phaseInterceptorChain;
}
 
Example #12
Source File: OAuthRequestFilter.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected String validateAudiences(List<String> audiences) {
    if (StringUtils.isEmpty(audiences) && audience == null) {
        return null;
    }
    if (audience != null) {
        if (audiences.contains(audience)) {
            return audience;
        }
        AuthorizationUtils.throwAuthorizationFailure(supportedSchemes, realm);
    }
    if (!audienceIsEndpointAddress) {
        return null;
    }
    String requestPath = (String)PhaseInterceptorChain.getCurrentMessage().get(Message.REQUEST_URL);
    for (String s : audiences) {
        boolean matched = completeAudienceMatch ? requestPath.equals(s) : requestPath.startsWith(s);
        if (matched) {
            return s;
        }
    }
    AuthorizationUtils.throwAuthorizationFailure(supportedSchemes, realm);
    return null;
}
 
Example #13
Source File: BinaryDataProvider.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void copyInputToOutput(InputStream is, OutputStream os,
        Annotation[] anns, MultivaluedMap<String, Object> outHeaders) throws IOException {
    if (isRangeSupported()) {
        Message inMessage = PhaseInterceptorChain.getCurrentMessage().getExchange().getInMessage();
        handleRangeRequest(is, os, new HttpHeadersImpl(inMessage), outHeaders);
    } else {
        boolean nioWrite = AnnotationUtils.getAnnotation(anns, UseNio.class) != null;
        if (nioWrite) {
            ContinuationProvider provider = getContinuationProvider();
            if (provider != null) {
                copyUsingNio(is, os, provider.getContinuation());
            }
            return;
        }
        if (closeResponseInputStream) {
            IOUtils.copyAndCloseInput(is, os, bufferSize);
        } else {
            IOUtils.copy(is, os, bufferSize);
        }

    }
}
 
Example #14
Source File: TestBase.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    SortedSet<Phase> phases = new TreeSet<>();
    Phase phase1 = new Phase("phase1", 1);
    Phase phase2 = new Phase("phase2", 2);
    Phase phase3 = new Phase("phase3", 3);
    phases.add(phase1);
    phases.add(phase2);
    phases.add(phase3);
    chain = new PhaseInterceptorChain(phases);

    Exchange exchange = new ExchangeImpl();
    MessageImpl messageImpl = new MessageImpl();
    messageImpl.setInterceptorChain(chain);
    messageImpl.setExchange(exchange);
    xmlMessage = messageImpl;
}
 
Example #15
Source File: AbstractSignatureInFilter.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void verifySignature(MultivaluedMap<String, String> headers, String uriPath,
                               String httpMethod) {
    if (!enabled) {
        LOG.fine("Verify signature filter is disabled");
        return;
    }

    if (messageVerifier == null) {
        messageVerifier = createMessageVerifier();
    }

    LOG.fine("Starting filter message verification process");
    try {
        messageVerifier.verifyMessage(headers, httpMethod, uriPath, PhaseInterceptorChain.getCurrentMessage());
    } catch (DifferentAlgorithmsException | InvalidSignatureHeaderException
        | InvalidDataToVerifySignatureException | InvalidSignatureException
        | MultipleSignatureHeaderException | MissingSignatureHeaderException ex) {
        LOG.warning(ex.getMessage());
        handleException(ex);
    }
    LOG.fine("Finished filter message verification process");
}
 
Example #16
Source File: AbstractTracingProvider.java    From cxf with Apache License 2.0 6 votes vote down vote up
private static String getHeaderOrDefault(final String property, final String fallback) {
    final Message message = PhaseInterceptorChain.getCurrentMessage();

    if (message != null) {
        final Object header = message.getContextualProperty(property);

        if (header instanceof String) {
            final String name = (String)header;
            if (!StringUtils.isEmpty(name)) {
                return name;
            }
        }
    }

    return fallback;
}
 
Example #17
Source File: LocatorServiceImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
public javax.xml.ws.wsaddressing.W3CEndpointReference lookupEndpoint(
    javax.xml.namespace.QName serviceQname)
    throws EndpointNotExistFault {
    LOG.info("Executing operation lookupEndpoint");
    W3CEndpointReferenceBuilder eprBuilder = new  W3CEndpointReferenceBuilder();
    eprBuilder.address("http://bar");
    eprBuilder.serviceName(serviceQname);
    eprBuilder.wsdlDocumentLocation("wsdlLoc");

    // just in case, for backward compatibility, the builder may be asked to
    // create a wsdlLocation attribute with a location only
    if (serviceQname.getNamespaceURI().endsWith("2")) {
        Message m = PhaseInterceptorChain.getCurrentMessage();
        m.put("org.apache.cxf.wsa.metadata.wsdlLocationOnly", "true");
    }

    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());

        return eprBuilder.build();
    } finally {
        Thread.currentThread().setContextClassLoader(cl);
    }
}
 
Example #18
Source File: JwtUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static void validateTokenClaims(JwtClaims claims, int timeToLive, int clockOffset,
                                       boolean validateAudienceRestriction) {
    // If we have no issued time then we need to have an expiry
    boolean expiredRequired = claims.getIssuedAt() == null;
    validateJwtExpiry(claims, clockOffset, expiredRequired);

    validateJwtNotBefore(claims, clockOffset, false);

    // If we have no expiry then we must have an issued at
    boolean issuedAtRequired = claims.getExpiryTime() == null;
    validateJwtIssuedAt(claims, timeToLive, clockOffset, issuedAtRequired);

    if (validateAudienceRestriction) {
        validateJwtAudienceRestriction(claims, PhaseInterceptorChain.getCurrentMessage());
    }
}
 
Example #19
Source File: ReceivedTokenCallbackHandler.java    From steady with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void handle(Callback[] callbacks)
    throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof DelegationCallback) {
            DelegationCallback callback = (DelegationCallback) callbacks[i];
            Message message = callback.getCurrentMessage();
            
            if (message != null 
                && message.get(PhaseInterceptorChain.PREVIOUS_MESSAGE) != null) {
                WeakReference<SoapMessage> wr = 
                    (WeakReference<SoapMessage>)
                        message.get(PhaseInterceptorChain.PREVIOUS_MESSAGE);
                SoapMessage previousSoapMessage = wr.get();
                Element token = getTokenFromMessage(previousSoapMessage);
                if (token != null) {
                    callback.setToken(token);
                }
            }
            
        } else {
            throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
        }
    }
}
 
Example #20
Source File: WebApplicationExceptionMapper.java    From cxf with Apache License 2.0 5 votes vote down vote up
public Response toResponse(WebApplicationException ex) {

        Response r = ex.getResponse();
        if (r == null) {
            r = Response.serverError().build();
        }
        boolean doAddMessage = r.getEntity() == null && addMessageToResponse;


        Message msg = PhaseInterceptorChain.getCurrentMessage();
        FaultListener flogger = null;
        if (msg != null) {
            flogger = (FaultListener)PhaseInterceptorChain.getCurrentMessage()
                .getContextualProperty(FaultListener.class.getName());
        }
        String errorMessage = doAddMessage || flogger != null
            ? buildErrorMessage(r, ex) : null;
        if (flogger == null
            || !flogger.faultOccurred(ex, errorMessage, msg)) {
            Level level = printStackTrace ? getStackTraceLogLevel(msg, r) : Level.FINE;
            LOG.log(level, ExceptionUtils.getStackTrace(ex));
        }

        if (doAddMessage) {
            r = JAXRSUtils.copyResponseIfNeeded(r);
            r = buildResponse(r, errorMessage);
        }
        return r;
    }
 
Example #21
Source File: AbstractJAXBProvider.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected <X> X getStreamHandlerFromCurrentMessage(Class<X> staxCls) {
    Message m = PhaseInterceptorChain.getCurrentMessage();
    if (m != null) {
        return staxCls.cast(m.getContent(staxCls));
    }
    return null;
}
 
Example #22
Source File: MEXUtils.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static Map<String, String> getSchemaLocations(Server server) {
    Message message = PhaseInterceptorChain.getCurrentMessage();

    String base = (String)message.get(Message.REQUEST_URL);
    String ctxUri = (String)message.get(Message.PATH_INFO);

    WSDLGetUtils utils = new WSDLGetUtils();
    EndpointInfo info = server.getEndpoint().getEndpointInfo();
    return utils.getSchemaLocations(message, base, ctxUri, info);
}
 
Example #23
Source File: AttachmentUtils.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static MultivaluedMap<String, String> populateFormMap(MessageContext mc,
                                                            boolean errorIfMissing) {
    MultivaluedMap<String, String> data = new MetadataMap<>();
    FormUtils.populateMapFromMultipart(data,
                                       AttachmentUtils.getMultipartBody(mc),
                                       PhaseInterceptorChain.getCurrentMessage(),
                                       true);
    return data;
}
 
Example #24
Source File: JAXRSBeanValidationOutInterceptor.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Override
public void filter(ContainerRequestContext in, ContainerResponseContext out) throws IOException {
    Message message = PhaseInterceptorChain.getCurrentMessage();
    if (Boolean.TRUE != message.get(OUT_VALIDATION_DONE)
        || supportMultipleValidations) {
        try {
            super.handleMessage(message);
        } finally {
            message.put(OUT_VALIDATION_DONE, Boolean.TRUE);
        }
    }
}
 
Example #25
Source File: WSDiscoveryServiceImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void updateOutputAction(String append) {
    AddressingProperties p = ContextUtils.retrieveMAPs(PhaseInterceptorChain.getCurrentMessage(),
                                                       false, false);
    AddressingProperties pout = new AddressingProperties();
    AttributedURIType action = new AttributedURIType();
    action.setValue(p.getAction().getValue() + append);
    pout.exposeAs(p.getNamespaceURI());
    pout.setAction(action);
    ContextUtils.storeMAPs(pout, PhaseInterceptorChain.getCurrentMessage(), true);

}
 
Example #26
Source File: RESTSecurityTokenServiceImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static int getDeflateLevel() {
    Integer level = null;

    Message m = PhaseInterceptorChain.getCurrentMessage();
    if (m != null) {
        level = PropertyUtils.getInteger(m, "deflate.level");
    }
    if (level == null) {
        level = Deflater.DEFLATED;
    }
    return level;
}
 
Example #27
Source File: RMManager.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Clones and saves the interceptor chain the first time this is called, so that it can be used for retransmission.
 * Calls after the first are ignored.
 *
 * @param msg
 */
public void initializeInterceptorChain(Message msg) {
    Endpoint ep = msg.getExchange().getEndpoint();
    synchronized (ep) {
        if (ep.get(WSRM_RETRANSMIT_CHAIN) == null) {
            LOG.info("Setting retransmit chain from message");
            PhaseInterceptorChain chain = (PhaseInterceptorChain)msg.getInterceptorChain();
            chain = chain.cloneChain();
            ep.put(WSRM_RETRANSMIT_CHAIN, chain);
        }
    }
}
 
Example #28
Source File: JAXRSIntermediaryPortTypeImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
public int doubleIt(int numberToDouble) {
    URL wsdl = JAXRSIntermediaryPortTypeImpl.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2Port");
    DoubleItPortType transportPort =
        service.getPort(portQName, DoubleItPortType.class);
    try {
        updateAddressPort(transportPort, KerberosDelegationTokenTest.PORT);
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    // Retrieve delegated credential + set it on the outbound message
    SecurityContext securityContext =
        PhaseInterceptorChain.getCurrentMessage().get(SecurityContext.class);
    if (securityContext instanceof KerberosSecurityContext) {
        KerberosSecurityContext ksc = (KerberosSecurityContext)securityContext;
        try {
            GSSCredential delegatedCredential = ksc.getGSSContext().getDelegCred();
            Map<String, Object> context = ((BindingProvider)transportPort).getRequestContext();
            context.put(SecurityConstants.DELEGATED_CREDENTIAL, delegatedCredential);
        } catch (GSSException e) {
            e.printStackTrace();
        }
    }

    return transportPort.doubleIt(numberToDouble);
}
 
Example #29
Source File: RedeliveryQueueImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static InterceptorChain getRedeliveryInterceptorChain(Message m, String phase) {
    Exchange exchange = m.getExchange();
    Endpoint ep = exchange.getEndpoint();
    Bus bus = exchange.getBus();

    PhaseManager pm = bus.getExtension(PhaseManager.class);
    SortedSet<Phase> phases = new TreeSet<>(pm.getInPhases());
    for (Iterator<Phase> it = phases.iterator(); it.hasNext();) {
        Phase p = it.next();
        if (phase.equals(p.getName())) {
            break;
        }
        it.remove();
    }
    PhaseInterceptorChain chain = new PhaseInterceptorChain(phases);
    List<Interceptor<? extends Message>> il = ep.getInInterceptors();
    addInterceptors(chain, il);
    il = ep.getService().getInInterceptors();
    addInterceptors(chain, il);
    il = ep.getBinding().getInInterceptors();
    addInterceptors(chain, il);
    il = bus.getInInterceptors();
    addInterceptors(chain, il);
    if (ep.getService().getDataBinding() instanceof InterceptorProvider) {
        il = ((InterceptorProvider)ep.getService().getDataBinding()).getInInterceptors();
        addInterceptors(chain, il);
    }

    return chain;
}
 
Example #30
Source File: AbstractClient.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected static PhaseInterceptorChain setupInInterceptorChain(ClientConfiguration cfg) {
    PhaseManager pm = cfg.getBus().getExtension(PhaseManager.class);
    List<Interceptor<? extends Message>> i1 = cfg.getBus().getInInterceptors();
    List<Interceptor<? extends Message>> i2 = cfg.getInInterceptors();
    List<Interceptor<? extends Message>> i3 = cfg.getConduitSelector().getEndpoint().getInInterceptors();
    PhaseInterceptorChain chain = new PhaseChainCache().get(pm.getInPhases(), i1, i2, i3);
    chain.add(new ClientResponseFilterInterceptor());
    chain.setFaultObserver(setupInFaultObserver(cfg));
    return chain;
}