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


Java WSPasswordCallback.getPassword方法代码示例

本文整理汇总了Java中org.apache.ws.security.WSPasswordCallback.getPassword方法的典型用法代码示例。如果您正苦于以下问题:Java WSPasswordCallback.getPassword方法的具体用法?Java WSPasswordCallback.getPassword怎么用?Java WSPasswordCallback.getPassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ws.security.WSPasswordCallback的用法示例。


在下文中一共展示了WSPasswordCallback.getPassword方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handle

import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
	log.info("handle({})", callbacks);
	WSPasswordCallback pwdCallback = (WSPasswordCallback) callbacks[0];

	log.debug("identifier: " + pwdCallback.getIdentifier());
	log.debug("usage: " + pwdCallback.getUsage());
	int usage = pwdCallback.getUsage();

	if (usage == WSPasswordCallback.USERNAME_TOKEN) {
		String password = pwdCallback.getPassword();
		Authentication authentication = new UsernamePasswordAuthenticationToken(pwdCallback.getIdentifier(), password);
		authentication = authenticationManager.authenticate(authentication);
		SecurityContextHolder.getContext().setAuthentication(authentication);

		// Return the password to the caller
		pwdCallback.setPassword(password);
	}
}
 
开发者ID:openkm,项目名称:document-management-system,代码行数:20,代码来源:ClientPasswordCallback.java

示例2: handle

import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
	WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
	
	String usuario = pc.getIdentifier();
	String senha = pc.getPassword();
	
	if (!(usuario.equals("usuario") && senha.equals("senha"))) {
		throw new IOException("O usu�rio ou senha inv�lidos!");
	}
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:12,代码来源:MockPasswordCallback.java

示例3: handle

import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
	WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
	
	String usuario = pc.getIdentifier();
	String senha = pc.getPassword();
	
	if (!(usuario.equals("usuario") && senha.equals("senha"))) {
		throw new IOException("O usuário ou senha inválidos!");
	}
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:12,代码来源:MockPasswordCallback.java

示例4: execute

import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的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


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