当前位置: 首页>>代码示例>>Java>>正文


Java WSS4JOutInterceptor类代码示例

本文整理汇总了Java中org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor的典型用法代码示例。如果您正苦于以下问题:Java WSS4JOutInterceptor类的具体用法?Java WSS4JOutInterceptor怎么用?Java WSS4JOutInterceptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


WSS4JOutInterceptor类属于org.apache.cxf.ws.security.wss4j包,在下文中一共展示了WSS4JOutInterceptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendMessageWithUsernameToken

import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; //导入依赖的package包/类
protected String sendMessageWithUsernameToken(String username, String password, String message) throws Exception {
    final javax.xml.ws.Service svc = javax.xml.ws.Service.create(WSDL_LOC, SERVICE_QNAME);
    final Greeter greeter = svc.getPort(PORT_QNAME, Greeter.class);

    Client client = ClientProxy.getClient(greeter);        
    Map<String, Object> props = new HashMap<String, Object>();
    props.put("action", "UsernameToken");
    props.put("user", username);
    // Set the the password type to be plain text, 
    // so we can keep using the password to authenticate with spring security
    props.put("passwordType", "PasswordText");       
    WSS4JOutInterceptor wss4jOut = new WSS4JOutInterceptor(props);

    client.getOutInterceptors().add(wss4jOut);
    ((BindingProvider)greeter).getRequestContext().put("password", password);
    return greeter.greetMe(message);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:GreeterClientTest.java

示例2: handleMessage

import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; //导入依赖的package包/类
/**
 * This is the actual implementation for our interceptor - we define the necessary properties for doing the authentication
 * and then iterate over the rest of the interceptor chain to find the WSS4J interceptor and configure it properly.
 */
public void handleMessage(Message message) throws Fault {
    /*
     * Define the configuration properties
     */
    Map<String, Object> outProps = new HashMap<String, Object>();
    outProps.put("action", "UsernameToken");
    outProps.put("passwordType", "PasswordText");

    /*
     * The username ('admin') is provided as a literal, the corresponding password will be determined by the client
     * password callback object.
     */
    outProps.put("user", "admin");
    outProps.put("passwordCallbackClass", ClientPasswordCallback.class.getName());

    /*
     * Find the WSS4J interceptor in the interceptor chain and set the configuration properties
     */
    for (Interceptor interceptor : message.getInterceptorChain()) {
        //set properties for WSS4JOutInterceptor
        if (interceptor.getClass().getName().equals("org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor")) {
            ((WSS4JOutInterceptor) interceptor).setProperties(outProps);
        }
    }
}
 
开发者ID:jboss-fuse,项目名称:fuse-karaf,代码行数:30,代码来源:CustomSecurityInterceptor.java

示例3: createCXFClient

import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; //导入依赖的package包/类
protected static ReportIncidentEndpoint createCXFClient(String url) {
    List<Interceptor<? extends Message>> outInterceptors = new ArrayList<Interceptor<? extends Message>>();

    // Define WSS4j properties for flow outgoing
    Map<String, Object> outProps = new HashMap<String, Object>();
    outProps.put("action", "UsernameToken Timestamp");

    outProps.put("passwordType", "PasswordDigest");
    outProps.put("user", "charles");
    outProps.put("passwordCallbackClass", "org.apache.camel.example.reportincident.UTPasswordCallback");

    WSS4JOutInterceptor wss4j = new WSS4JOutInterceptor(outProps);

    // Add LoggingOutInterceptor
    LoggingOutInterceptor loggingOutInterceptor = new LoggingOutInterceptor();

    outInterceptors.add(wss4j);
    outInterceptors.add(loggingOutInterceptor);

    // we use CXF to create a client for us as its easier than JAXWS and works
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setOutInterceptors(outInterceptors);
    factory.setServiceClass(ReportIncidentEndpoint.class);
    factory.setAddress(url);
    return (ReportIncidentEndpoint) factory.create();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:ReportIncidentRoutesTest.java

示例4: createCXFClient

import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; //导入依赖的package包/类
protected static OrderEndpoint createCXFClient(String url, String user, String passwordCallbackClass) {
    List<Interceptor<? extends Message>> outInterceptors = new ArrayList();

    // Define WSS4j properties for flow outgoing
    Map<String, Object> outProps = new HashMap<String, Object>();
    outProps.put("action", "UsernameToken Timestamp");
    outProps.put("user", user);
    outProps.put("passwordCallbackClass", passwordCallbackClass);

    WSS4JOutInterceptor wss4j = new WSS4JOutInterceptor(outProps);
    // Add LoggingOutInterceptor
    LoggingOutInterceptor loggingOutInterceptor = new LoggingOutInterceptor();

    outInterceptors.add(wss4j);
    outInterceptors.add(loggingOutInterceptor);

    // we use CXF to create a client for us as its easier than JAXWS and works
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setOutInterceptors(outInterceptors);
    factory.setServiceClass(OrderEndpoint.class);
    factory.setAddress(url);
    return (OrderEndpoint) factory.create();
}
 
开发者ID:camelinaction,项目名称:camelinaction2,代码行数:24,代码来源:WssAuthTest.java

示例5: setSignatureParts

import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; //导入依赖的package包/类
/**
 * Sets the signature parts for the outbound interceptor. Sets the property
 * directly on a new instance of the interceptor and replaces the current
 * interceptor if {@code interceptor} is not {@code null}. Sets the property
 * on the message if {@code inerceptor} is {@code null}.
 * 
 * @param message the current message
 * @param interceptor the optional interceptor, replaced if not null 
 * @param signatureParts the value of the property to set
 */
private void setSignatureParts(Message message, WSS4JOutInterceptor interceptor,
        String signatureParts) {

    if (interceptor == null) {
        message.put(WSHandlerConstants.SIGNATURE_PARTS, signatureParts);
    }
    else {
        Map<String, Object> properties = new HashMap<>(
                interceptor.getProperties());
        properties.put(WSHandlerConstants.SIGNATURE_PARTS, signatureParts);
        
        message.getInterceptorChain().remove(interceptor);
        message.getInterceptorChain().add(new WSS4JOutInterceptor(properties));
    }
}
 
开发者ID:beemsoft,项目名称:techytax-zk,代码行数:26,代码来源:DynamicWsaSignaturePartsInterceptor.java

示例6: sendRequest

import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; //导入依赖的package包/类
public void sendRequest() throws Exception {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setServiceClass(HelloWorld.class);
    factory.setAddress("http://localhost:8181/cxf/HelloWorldSecurity");
    HelloWorld client = (HelloWorld) factory.create();
    
    Map<String, Object> outProps = new HashMap<String, Object>();
    outProps.put("action", "UsernameToken");

    //add a CustomerSecurityInterceptor for client side to init wss4j staff
    //retrieve and set user/password,  users can easily add this interceptor
    //through spring configuration also
    ClientProxy.getClient(client).getOutInterceptors().add(new CustomerSecurityInterceptor());
    ClientProxy.getClient(client).getOutInterceptors().add(new WSS4JOutInterceptor());
    String ret = client.sayHi("ffang");
    System.out.println(ret);
}
 
开发者ID:apache,项目名称:servicemix,代码行数:18,代码来源:Client.java

示例7: UltraAPIClientImpl

import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; //导入依赖的package包/类
public UltraAPIClientImpl(String username, String password, String url) {
    try {
        Service service = UltraWebServiceV01Service.create(new URL(url), UltraWebServiceV01Service.SERVICE);
        _ultraDNS1 = service.getPort(UltraDNS1.class);
        Client cxfClient = ClientProxy.getClient(_ultraDNS1);
        WSS4JOutInterceptor wss4JOutInterceptor = new WSS4JOutInterceptor();
        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put(WSHandlerConstants.ACTION, "UsernameToken");
        properties.put(WSHandlerConstants.USER, "dummy");
        properties.put(WSHandlerConstants.PASSWORD_TYPE, "PasswordText");
        properties.put(WSHandlerConstants.PW_CALLBACK_REF, new ClientPasswordCallback(username, password));
        wss4JOutInterceptor.setProperties(properties);

        cxfClient.getOutInterceptors().add(new org.apache.cxf.interceptor.LoggingOutInterceptor());
        cxfClient.getOutInterceptors().add(wss4JOutInterceptor);
    } catch (MalformedURLException e) {
        e.printStackTrace();
        throw new UltraAPIException(9999, e.getMessage());
    }
}
 
开发者ID:ultradns,项目名称:ultra-java-api,代码行数:21,代码来源:UltraAPIClientImpl.java

示例8: setupWSS4JChain

import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; //导入依赖的package包/类
public static final void setupWSS4JChain(InterceptorProvider endpoint, Map<String, Object> inProps, Map<String, Object> outProps) {

        if (null != inProps && !inProps.isEmpty()) {
            endpoint.getInInterceptors().add(new SAAJInInterceptor());
            endpoint.getInInterceptors().add(new WSS4JInInterceptor(inProps));

            // if WS Security is used with a JAX-WS handler (See EjbInterceptor), we have to deal with mustUnderstand flag
            // in WS Security headers. So, let's add an interceptor
            endpoint.getInInterceptors().add(new WSSPassThroughInterceptor());
        }

        if (null != outProps && !outProps.isEmpty()) {
            endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
            endpoint.getOutInterceptors().add(new WSS4JOutInterceptor(outProps));
        }

    }
 
开发者ID:apache,项目名称:tomee,代码行数:18,代码来源:ConfigureCxfSecurity.java

示例9: testPortWithFeature

import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; //导入依赖的package包/类
private void testPortWithFeature(final Client client) {
    assertNotNull(client);
    assertEquals(4, client.getOutInterceptors().size());
    assertEquals(3, client.getInInterceptors().size());
    final Iterator<Interceptor<? extends Message>> Out = client.getOutInterceptors().iterator();
    assertTrue(MAPAggregatorImpl.class.isInstance(Out.next()));
    assertTrue(MAPCodec.class.isInstance(Out.next()));
    assertTrue(LoggingOutInterceptor.class.isInstance(Out.next()));
    final Interceptor<? extends Message> wss4jout = Out.next();
    assertTrue(WSS4JOutInterceptor.class.isInstance(wss4jout));

    final Iterator<Interceptor<? extends Message>> iteratorIn = client.getInInterceptors().iterator();
    assertTrue(MAPAggregatorImpl.class.isInstance(iteratorIn.next()));
    assertTrue(MAPCodec.class.isInstance(iteratorIn.next()));
    assertTrue(WSS4JInInterceptor.class.isInstance(iteratorIn.next()));
}
 
开发者ID:apache,项目名称:tomee,代码行数:17,代码来源:WebServiceInjectionTest.java

示例10: props

import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; //导入依赖的package包/类
@ApplicationConfiguration
public Properties props() {
    // return new PropertiesBuilder().p("cxf.jaxws.client.out-interceptors", LoggingOutInterceptor.class.getName()).build();
    // return new PropertiesBuilder().p("cxf.jaxws.client.{http://cxf.server.openejb.apache.org/}MyWebservicePort.out-interceptors", LoggingOutInterceptor.class.getName()).build();
    return new PropertiesBuilder()
            .p("cxf.jaxws.client.{http://cxf.server.openejb.apache.org/}MyWebservicePort.in-interceptors", "wss4jin")
            .p("cxf.jaxws.client.{http://cxf.server.openejb.apache.org/}MyWebservicePort.out-interceptors", "loo,wss4jout")

            .p("cxf.jaxws.client.{http://cxf.server.openejb.apache.org/}myWebservice.in-interceptors", "wss4jin")
            .p("cxf.jaxws.client.{http://cxf.server.openejb.apache.org/}myWebservice.out-interceptors", "loo,wss4jout")

            .p("loo", "new://Service?class-name=" + LoggingOutInterceptor.class.getName())

            .p("wss4jin", "new://Service?class-name=" + WSS4JInInterceptorFactory.class.getName() + "&factory-name=create")
            .p("wss4jin.a", "b")

            .p("wss4jout", "new://Service?class-name=" + WSS4JOutInterceptor.class.getName() + "&constructor=properties")
            .p("wss4jout.properties", "$properties")

            .p("properties", "new://Service?class-name=" + MapFactory.class.getName())
            .p("properties.c", "d")

            .build();
}
 
开发者ID:apache,项目名称:tomee,代码行数:25,代码来源:WebServiceInjectionTest.java

示例11: appendAuth

import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; //导入依赖的package包/类
/**
 * 添加用户名和密码信息
 * 
 * @param jw
 */
public void appendAuth(JaxWsProxyFactoryBean jw, String nodeId) {
	Map<String, Object> outProps = new HashMap<String, Object>();
	outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
	outProps.put(WSHandlerConstants.USER, RmClusterConfig.getSingleton().getAuth(nodeId).keySet().toArray(new String[0])[0]);
	outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
	outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, RmPasswordCallback.class.getName());

	Map<String, Object> mProp = new HashMap<String, Object>();
	mProp.put(FaultListener.class.getName(), new FaultListener() {
		public boolean faultOccurred(Exception exception, String description, Message message) {
			RmCacheHandler.logCache.error("fail: " + exception.toString() + " cause:" + exception.getCause());
			return false;
		}
	});
	jw.setProperties(mProp);

	WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
	jw.getOutInterceptors().add(wssOut);
	jw.getOutInterceptors().add(new SAAJOutInterceptor());
}
 
开发者ID:quickbundle,项目名称:qb-archetype,代码行数:26,代码来源:RmCacheHandler.java

示例12: getWsClientProxy

import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; //导入依赖的package包/类
public static Object getWsClientProxy(
		Class<?> clientClass,
		String wsUrl,
		String wsUserName,
		String wsPassword,
		String authType,
		boolean generateTimestamp,
		boolean logCalls,
		boolean disableCnCheck,
		Integer timeout) {
	ClientProxyFactoryBean factory = new JaxWsProxyFactoryBean();
	factory.setAddress(wsUrl);
	factory.setServiceClass(clientClass);
	if (logCalls) {
		factory.getInInterceptors().add(new LoggingInInterceptor());
		factory.getOutInterceptors().add(new LoggingOutInterceptor());
	}
	String authTypeBo = authType;
	if (authTypeBo == null || authTypeBo.length() == 0) {
		if (wsUserName != null && wsUserName.length() > 0)
			authTypeBo = "BASIC";
	}
	if ("BASIC".equalsIgnoreCase(authTypeBo)) {
		factory.setUsername(wsUserName);
		factory.setPassword(wsPassword);
	} else if ("USERNAMETOKEN".equalsIgnoreCase(authTypeBo)) {
		Map<String, Object> wss4jInterceptorProps = new HashMap<String, Object>();
		if (generateTimestamp) {
			wss4jInterceptorProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.USERNAME_TOKEN);
		} else {
			wss4jInterceptorProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
		}
		wss4jInterceptorProps.put(WSHandlerConstants.USER, wsUserName);
		wss4jInterceptorProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
		ClientPasswordCallback cp = new ClientPasswordCallback(wsPassword);
		wss4jInterceptorProps.put(WSHandlerConstants.PW_CALLBACK_REF, cp);
		factory.getOutInterceptors().add(new WSS4JOutInterceptor(wss4jInterceptorProps));
	}
	Object c = factory.create();
	
	Client client = ClientProxy.getClient(c);
       HTTPConduit httpConduit = (HTTPConduit)client.getConduit();
       HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
       if (timeout != null) {
       	httpClientPolicy.setConnectionTimeout(timeout);
       	httpClientPolicy.setReceiveTimeout(timeout);
       }
       // Envi­o chunked
	httpClientPolicy.setAllowChunking(isWsClientChunked());
       httpConduit.setClient(httpClientPolicy);
       
	if (disableCnCheck) {
        TLSClientParameters tlsParams = new TLSClientParameters();
        tlsParams.setDisableCNCheck(true);
        httpConduit.setTlsClientParameters(tlsParams);
	}
	return c;
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:59,代码来源:WsClientUtils.java

示例13: configureWSSecurity

import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; //导入依赖的package包/类
public static <T extends CallbackHandler> void configureWSSecurity(Object wsPort, String user, T passwordCallbackInstance)
{
	Client cxfClient = ClientProxy.getClient(wsPort);
	Endpoint cxfEndpoint = cxfClient.getEndpoint();

	Map<String, Object> outProps = new HashMap<String, Object>();
	outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);

	outProps.put(WSHandlerConstants.USER, user);
	outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
	outProps.put(WSHandlerConstants.PW_CALLBACK_REF, passwordCallbackInstance);

	WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
	cxfEndpoint.getOutInterceptors().add(wssOut);
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:16,代码来源:CxfClientUtilsOld.java

示例14: createModelPort

import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; //导入依赖的package包/类
public static ModelPortType createModelPort(CommandLine cmdLine) {
	String endpointUrl = cmdLine.getOptionValue(OPT_URL, DEFAULT_ENDPOINT_URL);
       String user = cmdLine.getOptionValue(OPT_USER, ADM_USERNAME);
	ClientPasswordHandler.setPassword(cmdLine.getOptionValue(OPT_PASSWORD, ADM_PASSWORD));
	System.out.println("Endpoint URL: " + endpointUrl);
	
	ModelService modelService = new ModelService();
	ModelPortType modelPort = modelService.getModelPort();
	BindingProvider bp = (BindingProvider)modelPort;
	Map<String, Object> requestContext = bp.getRequestContext();
	requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointUrl);
	
	org.apache.cxf.endpoint.Client client = ClientProxy.getClient(modelPort);
	org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();
	
	Map<String,Object> outProps = new HashMap<>();
	
	outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
	outProps.put(WSHandlerConstants.USER, user);
	outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
	outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, ClientPasswordHandler.class.getName());
	
	WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
	cxfEndpoint.getOutInterceptors().add(wssOut);

	return modelPort;
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:28,代码来源:Upload.java

示例15: createModelPort

import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; //导入依赖的package包/类
public static ModelPortType createModelPort(String[] args) {
	String endpointUrl = DEFAULT_ENDPOINT_URL;
	
	if (args.length > 0) {
		endpointUrl = args[0];
	}

	System.out.println("Endpoint URL: "+endpointUrl);

       // uncomment this if you want to use Fiddler or any other proxy
       //ProxySelector.setDefault(new MyProxySelector("127.0.0.1", 8888));
	
	ModelService modelService = new ModelService();
	ModelPortType modelPort = modelService.getModelPort();
	BindingProvider bp = (BindingProvider)modelPort;
	Map<String, Object> requestContext = bp.getRequestContext();
	requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointUrl);
	
	org.apache.cxf.endpoint.Client client = ClientProxy.getClient(modelPort);
	org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();
	
	Map<String,Object> outProps = new HashMap<String,Object>();
	
	outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
	outProps.put(WSHandlerConstants.USER, ADM_USERNAME);
	outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
	outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, ClientPasswordHandler.class.getName());
	
	WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
	cxfEndpoint.getOutInterceptors().add(wssOut);
       // enable the following to get client-side logging of outgoing requests and incoming responses
       cxfEndpoint.getOutInterceptors().add(new LoggingOutInterceptor());
       cxfEndpoint.getInInterceptors().add(new LoggingInInterceptor());

	return modelPort;
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:37,代码来源:Main.java


注:本文中的org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。