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


Java RequestData类代码示例

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


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


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