本文整理汇总了Java中org.apache.ws.security.WSPasswordCallback.getIdentifier方法的典型用法代码示例。如果您正苦于以下问题:Java WSPasswordCallback.getIdentifier方法的具体用法?Java WSPasswordCallback.getIdentifier怎么用?Java WSPasswordCallback.getIdentifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ws.security.WSPasswordCallback
的用法示例。
在下文中一共展示了WSPasswordCallback.getIdentifier方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
WSPasswordCallback pwcb = (WSPasswordCallback) callbacks[0];
String id = pwcb.getIdentifier();
int usage = pwcb.getUsage();
if (usage == WSPasswordCallback.USERNAME_TOKEN) {
if ("admin".equals(id)) {
pwcb.setPassword("admin");
} else if ("[email protected]".equals(id)) {
pwcb.setPassword("admin123");
}
} else if (usage == WSPasswordCallback.SIGNATURE || usage == WSPasswordCallback.DECRYPT) {
if ("wso2carbon".equals(id)) {
pwcb.setPassword("wso2carbon");
}
}
}
示例2: handle
import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks)
throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof WSPasswordCallback) {
WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
String id = pc.getIdentifier();
if (keystorePassword.get(id) != null) {
pc.setPassword(keystorePassword.get(id));
} else {
throw new UnsupportedCallbackException(callbacks[i], "no password found for " + id);
}
}
}
}
示例3: 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);
}
}
示例4: handle
import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
protected void handle(WSPasswordCallback callback) throws IOException, UnsupportedCallbackException {
String identifier = callback.getIdentifier();
NameCallback usernameCallback = new NameCallback("Username: ");
PasswordCallback passwordCallback = new PasswordCallback("Password: ", false);
callbackHandler.handle(new Callback[] { usernameCallback, passwordCallback });
String username = usernameCallback.getName();
if (username == null) {
throw new UnsupportedCallbackException(callback, "Username not set in client. Call constructor method " + ProgrammedPasswordCallback.class.getName()
+ "(\"<your username>\", \"<your password>\")");
}
// set the password for our outgoing message.
if (username.equals(identifier)) {
callback.setPassword(new String(passwordCallback.getPassword()));
} else {
throw new UnsupportedCallbackException(callback, "Password not set in client. Call constructor method " + ProgrammedPasswordCallback.class.getName()
+ "(\"<your username>\", \"<your password>\")");
}
}
示例5: handle
import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
WSPasswordCallback pwcb = (WSPasswordCallback) callbacks[0];
String id = pwcb.getIdentifier();
int usage = pwcb.getUsage();
if (usage == WSPasswordCallback.SIGNATURE || usage == WSPasswordCallback.DECRYPT) {
// Logic to get the private key password for signture or decryption
if ("client".equals(id)) {
pwcb.setPassword("automation");
} else if ("service".equals(id)) {
pwcb.setPassword("automation");
} else if ("wso2carbon".equals(id)) {
pwcb.setPassword("wso2carbon");
} else if ("alice".equals(id)) {
pwcb.setPassword("password");
} else if ("bob".equals(id)) {
pwcb.setPassword("password");
}
}
}
示例6: handle
import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks) throws IOException,
UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof WSPasswordCallback) {
WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
String id = pc.getIdentifier();
if (keystorePassword.get(id) != null) {
pc.setPassword(keystorePassword.get(id));
} else {
throw new UnsupportedCallbackException(callbacks[i], "no password found for " + id);
}
}
}
}
示例7: handle
import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
@Override
public void handle(Callback[] arg0) throws IOException,
UnsupportedCallbackException {
WSPasswordCallback pc = (WSPasswordCallback) arg0[0];
String user = pc.getIdentifier();
try {
if (!adapter.containsName(user)) {
} else {
if (adapter.isAdministrator(user)) {
pc.setPassword(adapter.getPassword(user));
}
}
} catch (ActionException e) {
}
}
示例8: handle
import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
/**
* Here, we attempt to get the password from the private alias/passwords map.
*/
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
String user = "";
for (int i = 0; i < callbacks.length; i++) {
WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
user = pc.getIdentifier();
String pass = passwords.get(user);
if (pass != null) {
pc.setPassword(pass);
return;
}
}
// Password not found
throw new IOException("Password does not exist for the user : " + user);
}
示例9: handleUsernameToken
import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
@Override
protected void handleUsernameToken(WSPasswordCallback callback)
throws IOException, UnsupportedCallbackException {
String identifier = callback.getIdentifier();
UserDetails user = loadUserDetails(identifier);
if (user != null) {
SpringSecurityUtils.checkUserValidity(user);
callback.setPassword(user.getPassword());
}
}
示例10: handle
import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
try{
validarUsuario(pc.getIdentifier(),pc.getPassword());
}catch(Exception ex){
throw new IOException("No se ha podido autenticar a usuario " + pc.getIdentifier() + ": " + ex.getMessage());
}
}
示例11: 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!");
}
}
示例12: checkAutentication
import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
/**
* Confronta usu�rio e senha com base de dados de usu�rios
*
* @param pc
* @throws IOException
*/
@SuppressWarnings("unused")
private void checkAutentication(WSPasswordCallback pc) throws IOException {
// Implementa��o para validar se a aplica��o tem acesso ao servi�o e se
// a senha est� correta
if (pc.getIdentifier() == null) {
throw new IOException("Chamada n�o autorizada.");
}
String codAplicacao = pc.getIdentifier().toUpperCase();
// try {
// codAplicacao = Integer.parseInt(pc.getIdentifier());
// } catch (NumberFormatException nfe) {
// throw new IOException("C�digo de aplica��o inv�lido");
// }
PreparedStatement stmt = null;
Connection connection = null;
ResultSet rs = null;
try {
connection = getConnection();
stmt = connection.prepareStatement(MockPasswordCallback.sql);
stmt.setString(1, pc.getPassword());
stmt.setString(2, codAplicacao);
stmt.setString(3, codServico);
rs = stmt.executeQuery();
if (rs != null && rs.next()) {
return;
} else {
throw new IOException("Chamada n�o autorizada.");
}
} catch (SQLException sqle) {
sqle.printStackTrace();
throw new IOException("Erro na validacao.");
} finally {
closeConnection(stmt, connection, rs);
}
}
示例13: handle
import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
// Implementa��o para validar se a aplica��o tem acesso ao servi�o e se
// a senha est� correta
if (pc.getIdentifier() == null) {
throw new IOException("Chamada n�o autorizada.");
}
String codAplicacao = pc.getIdentifier().toUpperCase();
// try {
// codAplicacao = Integer.parseInt(pc.getIdentifier());
// } catch (NumberFormatException nfe) {
// throw new IOException("C�digo de aplica��o inv�lido");
// }
PreparedStatement stmt = null;
Connection connection = null;
ResultSet rs = null;
try {
connection = getConnection();
stmt = connection.prepareStatement(sql);
stmt.setString(1, pc.getPassword());
stmt.setString(2, codAplicacao);
stmt.setString(3, codServico);
rs = stmt.executeQuery();
if (rs != null && rs.next()) {
return;
} else {
throw new IOException("Chamada n�o autorizada.");
}
} catch (SQLException sqle) {
sqle.printStackTrace();
throw new IOException("Erro na validacao.");
} finally {
closeConnection(stmt, connection, rs);
}
}
示例14: 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!");
}
}
示例15: checkAutentication
import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
/**
* Confronta usuário e senha com base de dados de usuários
*
* @param pc
* @throws IOException
*/
@SuppressWarnings("unused")
private void checkAutentication(WSPasswordCallback pc) throws IOException {
// Implementa��o para validar se a aplica��o tem acesso ao servi�o e se
// a senha est� correta
if (pc.getIdentifier() == null) {
throw new IOException("Chamada n�o autorizada.");
}
String codAplicacao = pc.getIdentifier().toUpperCase();
// try {
// codAplicacao = Integer.parseInt(pc.getIdentifier());
// } catch (NumberFormatException nfe) {
// throw new IOException("C�digo de aplica��o inv�lido");
// }
PreparedStatement stmt = null;
Connection connection = null;
ResultSet rs = null;
try {
connection = getConnection();
stmt = connection.prepareStatement(MockPasswordCallback.sql);
stmt.setString(1, pc.getPassword());
stmt.setString(2, codAplicacao);
stmt.setString(3, codServico);
rs = stmt.executeQuery();
if (rs != null && rs.next()) {
return;
} else {
throw new IOException("Chamada n�o autorizada.");
}
} catch (SQLException sqle) {
sqle.printStackTrace();
throw new IOException("Erro na validacao.");
} finally {
closeConnection(stmt, connection, rs);
}
}