本文整理汇总了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);
}
}
示例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!");
}
}
示例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!");
}
}
示例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());
}