• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java RequestData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: verifyPlaintextPassword

import org.apache.ws.security.handler.RequestData; //导入依赖的package包/类
@Override
protected void verifyPlaintextPassword(UsernameToken usernameToken, RequestData data) throws WSSecurityException {
	logger.debug("userIdString=" + usernameToken.getName());
	logger.debug("password=" + usernameToken.getPassword());

	try {
		Integer securityUserId = Integer.parseInt(usernameToken.getName());
		Security security = securityDao.find(securityUserId);
		
		// if it's all good just return
		SoapMessage soapMessage = (SoapMessage) data.getMsgContext();
		HttpServletRequest request = (HttpServletRequest) soapMessage.get(AbstractHTTPDestination.HTTP_REQUEST);
		if (WsUtils.checkAuthenticationAndSetLoggedInInfo(request, security, usernameToken.getPassword())) return;
	} catch (NumberFormatException e) {
		logger.error("userIdString is not a number? usernameToken.getName()='" + usernameToken.getName() + '\'');
	}

	throw new WSSecurityException(WSSecurityException.FAILED_AUTHENTICATION);
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:20,代码来源:OscarUsernameTokenValidator.java


示例2: testUsernameTokenWSHandler

import org.apache.ws.security.handler.RequestData; //导入依赖的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);
    }
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:27,代码来源:TestWSSecurityNew5.java


示例3: testUsernameTokenWSHandlerEmptyPassword

import org.apache.ws.security.handler.RequestData; //导入依赖的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);
    }
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:27,代码来源:TestWSSecurityNew5.java


示例4: testGetPasswordRequestContextUnit

import org.apache.ws.security.handler.RequestData; //导入依赖的package包/类
/**
 * A unit test for {@link WSHandler#getPassword(String, int, String, String, RequestData)},
 * where the password is obtained from the Message Context.
 */
public void
testGetPasswordRequestContextUnit() throws Exception {
    
    final WSSConfig cfg = WSSConfig.getNewInstance();
    final RequestData reqData = new RequestData();
    reqData.setWssConfig(cfg);
    java.util.Map messageContext = new java.util.TreeMap();
    messageContext.put("password", "securityPassword");
    reqData.setMsgContext(messageContext);
    
    WSHandler handler = new MyHandler();
    WSPasswordCallback callback = 
        handler.getPassword(
            "bob", 
            WSConstants.UT, 
            "SomeCallbackTag", 
            "SomeCallbackRef",
            reqData
        );
    assertTrue("bob".equals(callback.getIdentifier()));
    assertTrue("securityPassword".equals(callback.getPassword()));
    assertTrue(WSPasswordCallback.USERNAME_TOKEN == callback.getUsage());
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:28,代码来源:TestWSSecurityGetPassword.java


示例5: testCustomAction

import org.apache.ws.security.handler.RequestData; //导入依赖的package包/类
/**
 * Test to see that a custom action configured through a
 * WSSConfig instance is called
 */
public void
testCustomAction() throws Exception {
    
    final WSSConfig cfg = WSSConfig.getNewInstance();
    final int action = 0xDEADF000;
    cfg.setAction(action, "wssec.MyAction");
    final RequestData reqData = new RequestData();
    reqData.setWssConfig(cfg);
    reqData.setMsgContext(new java.util.TreeMap());
    
    final java.util.Vector actions = new java.util.Vector();
    actions.add(new Integer(action));
    final Document doc = unsignedEnvelope.getAsDocument();
    MyHandler handler = new MyHandler();
    reqData.setMsgContext("bread");
    assertEquals(reqData.getMsgContext(), "bread");
    handler.doit(
        action, 
        doc, 
        reqData, 
        actions
    );
    assertEquals(reqData.getMsgContext(), "crumb");
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:29,代码来源:TestWSSecurityUserProcessor.java


示例6: testCustomActionObject

import org.apache.ws.security.handler.RequestData; //导入依赖的package包/类
/**
 * Test to see that a custom action object configured through a
 * WSSConfig instance is called
 */
public void
testCustomActionObject() throws Exception {
    
    final WSSConfig cfg = WSSConfig.getNewInstance();
    final int action = 0xDEADF000;
    cfg.setAction(action, new wssec.MyAction());
    final RequestData reqData = new RequestData();
    reqData.setWssConfig(cfg);
    reqData.setMsgContext(new java.util.TreeMap());
    
    final java.util.Vector actions = new java.util.Vector();
    actions.add(new Integer(action));
    final Document doc = unsignedEnvelope.getAsDocument();
    MyHandler handler = new MyHandler();
    reqData.setMsgContext("bread");
    assertEquals(reqData.getMsgContext(), "bread");
    handler.doit(
        action, 
        doc, 
        reqData, 
        actions
    );
    assertEquals(reqData.getMsgContext(), "crumb");
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:29,代码来源:TestWSSecurityUserProcessor.java


示例7: verifyPlaintextPassword

import org.apache.ws.security.handler.RequestData; //导入依赖的package包/类
@Override
protected void verifyPlaintextPassword(UsernameToken usernameToken, RequestData data) throws WSSecurityException {
	logger.debug("userIdString=" + usernameToken.getName());
	logger.debug("password=" + usernameToken.getPassword());

	try {
		Integer securityUserId = Integer.parseInt(usernameToken.getName());
		Security security = securityDao.findById(securityUserId);
		
		// if it's all good just return
		if (WsUtils.checkAuthenticationAndSetLoggedInInfo(security, usernameToken.getPassword())) return;
	} catch (NumberFormatException e) {
		logger.error("userIdString is not a number? usernameToken.getName()='" + usernameToken.getName() + '\'');
	}

	throw new WSSecurityException(WSSecurityException.FAILED_AUTHENTICATION);
}
 
开发者ID:oscarservice,项目名称:oscar-old,代码行数:18,代码来源:OscarUsernameTokenValidator.java


示例8: loadCryptoFromPropertiesFile

import org.apache.ws.security.handler.RequestData; //导入依赖的package包/类
/**
 * Attempts to resolve the resourcePath using the Spring {@link ResourceLoader}. 
 * If the resource was not resolved by the {@link ResourceLoader}, falls back to the super implementation (reads
 * the resourcePath location as on the classpath).
 * 
 * @see CryptoFactory#getInstance(Properties)
 * @see org.apache.cxf.ws.security.wss4j.AbstractWSS4JInterceptor#loadCryptoFromPropertiesFile(java.lang.String, org.apache.ws.security.handler.RequestData)
 * @param resourcePath
 * @param requestData
 * @return the initialized {@link Crypto}
 */
@Override
protected Crypto loadCryptoFromPropertiesFile(String resourcePath, RequestData requestData)
		throws WSSecurityException {
	Resource resource = resourceLoader.getResource(resourcePath);
	if(resource.exists()) {
		log.debug("resourceLoader successfully located resource " + resourcePath);
		Properties properties = new Properties();
		try {
			properties.load(resource.getInputStream());
			log.debug(resourcePath + " loaded");
			return CryptoFactory.getInstance(properties);
		} catch (IOException e) {
			throw new WSSecurityException("caught IOException while loading resource at " + resourcePath, e);
		}
	} else {
		log.debug("resourceLoader unable to find resource " + resourcePath);
		return super.loadCryptoFromPropertiesFile(resourcePath, requestData);
	}
}
 
开发者ID:nblair,项目名称:mule-ws-security-proxy,代码行数:31,代码来源:ResourceLoaderAwareWSS4JInInterceptor.java


示例9: getPassword

import org.apache.ws.security.handler.RequestData; //导入依赖的package包/类
public WSPasswordCallback getPassword(final String username,
		final int doAction, final String clsProp, final String refProp,
		final RequestData reqData) throws WSSecurityException {
	final UsernamePasswordCredentials c = (UsernamePasswordCredentials) this.credentialsSource
			.getCredentials(this.serviceConfiguration.getEndpointUrl().toString());

	return new WSPasswordCallback(c.getUsername(), c.getPassword(), null,
			WSPasswordCallback.USERNAME_TOKEN);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:10,代码来源:CredentialsOutHandler.java


示例10: loadSignatureCrypto

import org.apache.ws.security.handler.RequestData; //导入依赖的package包/类
@Override
public Crypto loadSignatureCrypto(RequestData reqData) {
	try {
		return new Merlin(getMerlinProperties(), ClassLoaderUtils.getDefaultClassLoader());
	} catch (Exception e) {
		throw new RiceRuntimeException(e);
	}
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:9,代码来源:CXFWSS4JInInterceptor.java


示例11: verifyPlaintextPassword

import org.apache.ws.security.handler.RequestData; //导入依赖的package包/类
@Override
protected void verifyPlaintextPassword(UsernameToken usernameToken,
		RequestData data) throws WSSecurityException {
	String username = String.valueOf(usernameToken.getName());
	String password = String.valueOf(usernameToken.getPassword());
	Authentication authentication = new UsernamePasswordAuthenticationToken(
			username, password);
	authentication = authenticationManager.authenticate(authentication);
	if (!authentication.isAuthenticated()) {
		throw new WSSecurityException(
				WSSecurityException.FAILED_AUTHENTICATION);
	}

	SecurityContextHolder.getContext().setAuthentication(authentication);
}
 
开发者ID:cmis4j,项目名称:cmis4j-ws,代码行数:16,代码来源:CmisUsernameTokenValidator.java


示例12: execute

import org.apache.ws.security.handler.RequestData; //导入依赖的package包/类
public void execute(WSHandler handler, int actionToDo, Document doc, RequestData reqData)
        throws WSSecurityException {
    
    // Always call the callback for the username. We mis-use the configured password callback class and callback methods for this.
    String providedUsername = reqData.getUsername();
    WSPasswordCallback callbackData = handler.getPassword(reqData.getUsername(),
                    actionToDo,
                    WSHandlerConstants.PW_CALLBACK_CLASS,
                    WSHandlerConstants.PW_CALLBACK_REF, reqData);
    providedUsername = callbackData.getIdentifier();
    String password = callbackData.getPassword();

    WSSecUsernameToken builder = new WSSecUsernameToken();
    builder.setWsConfig(reqData.getWssConfig());
    builder.setPasswordType(reqData.getPwType());
    builder.setPasswordsAreEncoded(reqData.getWssConfig().getPasswordsAreEncoded());
    builder.setUserInfo(providedUsername, password);

    if (reqData.getUtElements() != null && reqData.getUtElements().length > 0) {
        for (int j = 0; j < reqData.getUtElements().length; j++) {
            reqData.getUtElements()[j].trim();
            if (reqData.getUtElements()[j].equals("Nonce")) {
                builder.addNonce();
            }
            if (reqData.getUtElements()[j].equals("Created")) {
                builder.addCreated();
            }
            reqData.getUtElements()[j] = null;
        }
    }
    builder.build(doc, reqData.getSecHeader());        
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:33,代码来源:UsernameTokenAction.java


示例13: execute

import org.apache.ws.security.handler.RequestData; //导入依赖的package包/类
public void execute(WSHandler handler, int actionToDo, Document doc, RequestData reqData)
        throws WSSecurityException {
    WSSecSAMLToken builder = new WSSecSAMLToken();
    builder.setWsConfig(reqData.getWssConfig());

    SAMLIssuer saml = loadSamlIssuer(handler, reqData);
    saml.setUsername(reqData.getUsername());
    SAMLAssertion assertion = saml.newAssertion();

    // add the SAMLAssertion Token to the SOAP Envelope
    builder.build(doc, assertion, reqData.getSecHeader());
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:13,代码来源:SAMLTokenUnsignedAction.java


示例14: loadSamlIssuer

import org.apache.ws.security.handler.RequestData; //导入依赖的package包/类
protected SAMLIssuer loadSamlIssuer(WSHandler handler, 
                RequestData reqData) {
    String samlPropFile = 
        handler.getString(WSHandlerConstants.SAML_PROP_FILE,
            reqData.getMsgContext());
    return SAMLIssuerFactory.getInstance(samlPropFile);
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:8,代码来源:SAMLTokenSignedAction.java


示例15: execute

import org.apache.ws.security.handler.RequestData; //导入依赖的package包/类
public void execute(WSHandler handler, int actionToDo, Document doc, RequestData reqData)
        throws WSSecurityException {
    WSSecTimestamp timeStampBuilder =
            new WSSecTimestamp();
    timeStampBuilder.setWsConfig(reqData.getWssConfig());
    timeStampBuilder.setTimeToLive(handler.decodeTimeToLive(reqData));
    // add the Timestamp to the SOAP Envelope
    timeStampBuilder.build(doc, reqData.getSecHeader());
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:10,代码来源:TimestampAction.java


示例16: execute

import org.apache.ws.security.handler.RequestData; //导入依赖的package包/类
public void execute(WSHandler handler, int actionToDo, Document doc, RequestData reqData)
        throws WSSecurityException {
    WSPasswordCallback pwcb =
        handler.getPassword(
            reqData.getSignatureUser(),
            actionToDo,
            WSHandlerConstants.PW_CALLBACK_CLASS,
            WSHandlerConstants.PW_CALLBACK_REF, reqData
        );

    WSSecSignature wsSign = new WSSecSignature();
    wsSign.setWsConfig(reqData.getWssConfig());

    if (reqData.getSigKeyId() != 0) {
        wsSign.setKeyIdentifierType(reqData.getSigKeyId());
    }
    if (reqData.getSigAlgorithm() != null) {
        wsSign.setSignatureAlgorithm(reqData.getSigAlgorithm());
    }
    if (reqData.getSigDigestAlgorithm() != null) {
        wsSign.setDigestAlgo(reqData.getSigDigestAlgorithm());
    }

    wsSign.setUserInfo(reqData.getSignatureUser(), pwcb.getPassword());
    wsSign.setUseSingleCertificate(reqData.isUseSingleCert());
    if (reqData.getSignatureParts().size() > 0) {
        wsSign.setParts(reqData.getSignatureParts());
    }
    
    if (pwcb.getKey() != null) {
        wsSign.setSecretKey(pwcb.getKey());
    }

    try {
        wsSign.build(doc, reqData.getSigCrypto(), reqData.getSecHeader());
        reqData.getSignatureValues().add(wsSign.getSignatureValue());
    } catch (WSSecurityException e) {
        throw new WSSecurityException("Error during Signature: ", e);
    }
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:41,代码来源:SignatureAction.java


示例17: send

import org.apache.ws.security.handler.RequestData; //导入依赖的package包/类
public void send(
    int action, 
    Document doc,
    RequestData reqData, 
    java.util.Vector actions,
    boolean request
) throws org.apache.ws.security.WSSecurityException {
    doSenderAction(
        action, 
        doc, 
        reqData, 
        actions,
        request
    );
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:16,代码来源:MyHandler.java


示例18: receive

import org.apache.ws.security.handler.RequestData; //导入依赖的package包/类
public void receive(
    int action, 
    RequestData reqData
) throws org.apache.ws.security.WSSecurityException {
    doReceiverAction(
        action, 
        reqData
    );
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:10,代码来源:MyHandler.java


示例19: execute

import org.apache.ws.security.handler.RequestData; //导入依赖的package包/类
public void 
execute(
    WSHandler handler, 
    int actionToDo, 
    org.w3c.dom.Document doc,
    RequestData reqData
) throws WSSecurityException {
    //
    // leave a breadcrumb, if asked...
    //
    if (reqData.getMsgContext().equals("bread")) {
        reqData.setMsgContext("crumb");
    }
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:15,代码来源:MyAction.java


示例20: testEncryptionSHA1SymmetricBytesHandler

import org.apache.ws.security.handler.RequestData; //导入依赖的package包/类
/**
 * Test that encrypts using EncryptedKeySHA1, where it uses a symmetric key, rather than a 
 * generated session key which is then encrypted using a public key. The request is generated
 * using WSHandler, instead of coding it.
 * 
 * @throws java.lang.Exception Thrown when there is any problem in encryption or decryption
 * 
 */
public void testEncryptionSHA1SymmetricBytesHandler() throws Exception {
    final WSSConfig cfg = WSSConfig.getNewInstance();
    final RequestData reqData = new RequestData();
    reqData.setWssConfig(cfg);
    java.util.Map messageContext = new java.util.TreeMap();
    messageContext.put(WSHandlerConstants.ENC_SYM_ENC_KEY, "false");
    messageContext.put(WSHandlerConstants.ENC_KEY_ID, "EncryptedKeySHA1");
    messageContext.put(WSHandlerConstants.PW_CALLBACK_REF, this);
    reqData.setMsgContext(messageContext);
    reqData.setUsername("");
    
    final java.util.Vector actions = new java.util.Vector();
    actions.add(new Integer(WSConstants.ENCR));
    
    Document doc = unsignedEnvelope.getAsDocument();
    MyHandler handler = new MyHandler();
    handler.send(
        WSConstants.ENCR, 
        doc, 
        reqData, 
        actions,
        true
    );
    
    String outputString = 
        org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
    if (LOG.isDebugEnabled()) {
        LOG.debug(outputString);
    }
    
    verify(doc);
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:41,代码来源:TestWSSecurityNew14.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AccessibilityInjector类代码示例发布时间:2022-05-22
下一篇:
Java AuthenticationResultCode类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap