本文整理汇总了Java中org.apache.ws.security.handler.WSHandlerConstants类的典型用法代码示例。如果您正苦于以下问题:Java WSHandlerConstants类的具体用法?Java WSHandlerConstants怎么用?Java WSHandlerConstants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WSHandlerConstants类属于org.apache.ws.security.handler包,在下文中一共展示了WSHandlerConstants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initStub
import org.apache.ws.security.handler.WSHandlerConstants; //导入依赖的package包/类
private void initStub(Stub stub) throws AxisFault
{
if( stub != null )
{
final ServiceClient client = stub._getServiceClient();
final Options options = client.getOptions();
options.setProperty(WSHandlerConstants.PW_CALLBACK_REF, this);
options.setProperty(WSSHandlerConstants.OUTFLOW_SECURITY, ofc.getProperty());
options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, "true");
options.setProperty(HTTPConstants.HTTP_PROTOCOL_VERSION, HTTPConstants.HEADER_PROTOCOL_11);
URI uri = URI.create(bbUrl);
if( uri.getScheme().toLowerCase().startsWith("https") )
{
Protocol myhttps = new Protocol("https", new EasySSLProtocolSocketFactory(), 443);
options.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER, myhttps);
}
client.engageModule("rampart-1.5.1");
}
}
示例2: getUsernameTokenPrincipal
import org.apache.ws.security.handler.WSHandlerConstants; //导入依赖的package包/类
/**
* Returns the UsernameTokenPrincipal from the security results.
*
* @param mc The message context of the message
* @return the UsernameTokenPrincipal from the security results as an
* <code>org.apache.ws.security.WSUsernameTokenPrincipal</code>.
* If a wsse:UsernameToken was not present in the wsse:Security header then
* <code>null</code> will be returned.
* @throws Exception If there are no security results.
* @see org.apache.ws.security.WSUsernameTokenPrincipal
*/
public static WSUsernameTokenPrincipal getUsernameTokenPrincipal(
MessageContext mc) throws Exception {
Vector results;
if ((results = (Vector) mc.getProperty(WSHandlerConstants.RECV_RESULTS)) == null) {
throw new Exception("No security results available in the message context");
} else {
for (int i = 0; i < results.size(); i++) {
WSHandlerResult rResult = (WSHandlerResult) results.get(i);
Vector wsSecEngineResults = rResult.getResults();
for (int j = 0; j < wsSecEngineResults.size(); j++) {
WSSecurityEngineResult wser =
(WSSecurityEngineResult) wsSecEngineResults.get(j);
Integer actInt = (Integer) wser
.get(WSSecurityEngineResult.TAG_ACTION);
if (actInt.intValue() == WSConstants.UT) {
return (WSUsernameTokenPrincipal) wser
.get(WSSecurityEngineResult.TAG_PRINCIPAL);
}
}
}
}
return null;
}
示例3: CredentialsOutHandler
import org.apache.ws.security.handler.WSHandlerConstants; //导入依赖的package包/类
public CredentialsOutHandler(final CredentialsSource credentialsSource,
final ServiceConfiguration serviceConfiguration) {
Assert.notNull(credentialsSource, "credentialsSource cannot be null.");
Assert.notNull(serviceConfiguration, "serviceConfiguration cannot be null.");
this.credentialsSource = credentialsSource;
this.serviceConfiguration = serviceConfiguration;
final Credentials credentials = this.credentialsSource
.getCredentials(this.serviceConfiguration.getEndpointUrl().toString());
Assert.isTrue(credentials instanceof UsernamePasswordCredentials,
"Credentials must be of type usernamepassword.");
final UsernamePasswordCredentials c = (UsernamePasswordCredentials) credentials;
setProperty(WSHandlerConstants.USER, c.getUsername());
}
示例4: setSignatureParts
import org.apache.ws.security.handler.WSHandlerConstants; //导入依赖的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));
}
}
示例5: addSecurity
import org.apache.ws.security.handler.WSHandlerConstants; //导入依赖的package包/类
@Override
public void addSecurity(WSSecurityCredential credential) {
setAction(credential, WSHandlerConstants.ENCRYPT);
// if null defaults to USER property
if (this.encryptionUser != null) {
credential.getRequestPropterties().put(WSHandlerConstants.ENCRYPTION_USER, this.encryptionUser);
}
//Configuration of public key used to encrypt message goes to properties file.
credential.getRequestPropterties().put(WSHandlerConstants.ENC_PROP_REF_ID, this.encryptionProperties);
if (this.encryptionKeyIdentifier != null) {
credential.getRequestPropterties().put(WSHandlerConstants.ENC_KEY_ID, this.encryptionKeyIdentifier);
}
if (this.encryptionParts != null) {
credential.getRequestPropterties().put(WSHandlerConstants.ENCRYPTION_PARTS, this.encryptionParts);
}
if (this.encryptionSymAlgorithm != null) {
credential.getRequestPropterties().put(WSHandlerConstants.ENC_SYM_ALGO, this.encryptionSymAlgorithm);
}
if (this.encryptionKeyTransportAlgorithm != null) {
credential.getRequestPropterties().put(WSHandlerConstants.ENC_KEY_TRANSPORT, this.encryptionKeyTransportAlgorithm);
}
}
示例6: overrideCallbackHandler
import org.apache.ws.security.handler.WSHandlerConstants; //导入依赖的package包/类
/**
* Override WSAS callback handler to be able to auth users with usermanager.
*
* @param axisConfig
* @throws AxisFault
*/
public static void overrideCallbackHandler(AxisConfiguration axisConfig, String service) throws AxisFault {
AxisService sts = axisConfig.getService(service);
Parameter cbHandlerParam = sts.getParameter(WSHandlerConstants.PW_CALLBACK_REF);
if (cbHandlerParam != null) {
sts.removeParameter(cbHandlerParam);
if (log.isDebugEnabled()) {
log.debug("removedParameter");
}
}
Parameter param = getPasswordCallBackRefParameter();
sts.addParameter(param);
if (log.isDebugEnabled()) {
log.debug("addedParameter");
}
}
示例7: testUsernameTokenWSHandler
import org.apache.ws.security.handler.WSHandlerConstants; //导入依赖的package包/类
/**
* Test that adds a UserNameToken via WSHandler
*/
public void testUsernameTokenWSHandler() throws Exception {
MyHandler handler = new MyHandler();
Document doc = unsignedEnvelope.getAsDocument();
RequestData reqData = new RequestData();
java.util.Map config = new java.util.TreeMap();
config.put("password", "verySecret");
config.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
reqData.setUsername("wernerd");
reqData.setMsgContext(config);
java.util.Vector actions = new java.util.Vector();
actions.add(new Integer(WSConstants.UT));
handler.send(WSConstants.UT, doc, reqData, actions, true);
if (LOG.isDebugEnabled()) {
LOG.debug("Username Token via WSHandler");
String outputString =
org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
LOG.debug(outputString);
}
}
示例8: testUsernameTokenWSHandlerEmptyPassword
import org.apache.ws.security.handler.WSHandlerConstants; //导入依赖的package包/类
/**
* Test that adds a UserNameToken with an empty password via WSHandler
*/
public void testUsernameTokenWSHandlerEmptyPassword() throws Exception {
MyHandler handler = new MyHandler();
Document doc = unsignedEnvelope.getAsDocument();
RequestData reqData = new RequestData();
java.util.Map config = new java.util.TreeMap();
config.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
config.put(WSHandlerConstants.PW_CALLBACK_REF, this);
reqData.setUsername("emptyuser");
reqData.setMsgContext(config);
java.util.Vector actions = new java.util.Vector();
actions.add(new Integer(WSConstants.UT));
handler.send(WSConstants.UT, doc, reqData, actions, true);
if (LOG.isDebugEnabled()) {
LOG.debug("Username Token with an empty password via WSHandler");
String outputString =
org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
LOG.debug(outputString);
}
}
示例9: UltraAPIClientImpl
import org.apache.ws.security.handler.WSHandlerConstants; //导入依赖的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());
}
}
示例10: appendAuth
import org.apache.ws.security.handler.WSHandlerConstants; //导入依赖的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());
}
示例11: getWsClientProxy
import org.apache.ws.security.handler.WSHandlerConstants; //导入依赖的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);
}
// Envio chunked
httpClientPolicy.setAllowChunking(isWsClientChunked());
httpConduit.setClient(httpClientPolicy);
if (disableCnCheck) {
TLSClientParameters tlsParams = new TLSClientParameters();
tlsParams.setDisableCNCheck(true);
httpConduit.setTlsClientParameters(tlsParams);
}
return c;
}
示例12: UsernameTokenAuthorizationInterceptor
import org.apache.ws.security.handler.WSHandlerConstants; //导入依赖的package包/类
public UsernameTokenAuthorizationInterceptor(Map<String, Object> properties) {
super(properties);
try{
// Verificamos si esta marcado la activacion mediante xml o es mediante propiedades
if ( properties.get("activar") != null) {
// Activacion mediante XML
activar = Boolean.parseBoolean((String) properties.get("activar"));
generarTimestamp = Boolean.parseBoolean((String) properties.get("generarTimestamp"));
} else {
// Activacion mediante propiedades (para SISTRA)
Properties props = ConfigurationUtil.getInstance().obtenerPropiedades();
String auth = props.getProperty("sistra.ws.authenticacion");
activar = "USERNAMETOKEN".equals(auth);
String timestamp = props.getProperty("sistra.ws.authenticacion.usernameToken.generateTimestamp");
generarTimestamp = "true".equals(timestamp);
}
if (activar && generarTimestamp){
properties.put( "action", WSHandlerConstants.TIMESTAMP + " " + properties.get("action"));
} else {
properties.put( "action", WSHandlerConstants.NO_SECURITY);
}
}catch (Exception ex){
throw new Fault(ex);
}
}
示例13: UsernameTokenAuthorizationInterceptorOut
import org.apache.ws.security.handler.WSHandlerConstants; //导入依赖的package包/类
public UsernameTokenAuthorizationInterceptorOut(Map<String, Object> properties) {
super(properties);
try{
// Verificamos si esta marcado la activacion mediante xml o es mediante propiedades
if ( properties.get("activar") != null) {
// Activacion mediante XML
activar = Boolean.parseBoolean((String) properties.get("activar"));
generarTimestamp = Boolean.parseBoolean((String) properties.get("generarTimestamp"));
} else {
// Activacion mediante propiedades (para SISTRA)
Properties props = ConfigurationUtil.getInstance().obtenerPropiedades();
String auth = props.getProperty("sistra.ws.authenticacion");
activar = "USERNAMETOKEN".equals(auth);
String timestamp = props.getProperty("sistra.ws.authenticacion.usernameToken.generateTimestamp");
generarTimestamp = "true".equals(timestamp);
}
if (activar && generarTimestamp){
properties.put( "action", WSHandlerConstants.TIMESTAMP + " " + properties.get("action"));
} else {
properties.put( "action", WSHandlerConstants.NO_SECURITY);
}
}catch (Exception ex){
throw new Fault(ex);
}
}
示例14: AuthenticationOutWSS4JInterceptorForIntegrator
import org.apache.ws.security.handler.WSHandlerConstants; //导入依赖的package包/类
public AuthenticationOutWSS4JInterceptorForIntegrator(String user, String password, String oscarProviderNo) {
this.password = password;
this.oscarProviderNo=oscarProviderNo;
HashMap<String, Object> properties = new HashMap<String, Object>();
properties.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
properties.put(WSHandlerConstants.USER, user);
properties.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
properties.put(WSHandlerConstants.PW_CALLBACK_REF, this);
setProperties(properties);
}
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:13,代码来源:AuthenticationOutWSS4JInterceptorForIntegrator.java
示例15: AuthenticationInWSS4JInterceptor
import org.apache.ws.security.handler.WSHandlerConstants; //导入依赖的package包/类
public AuthenticationInWSS4JInterceptor()
{
HashMap<String, Object> properties = new HashMap<String, Object>();
properties.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
properties.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
properties.put(WSHandlerConstants.PW_CALLBACK_REF, this);
setProperties(properties);
}