本文整理汇总了Java中org.apache.ws.security.WSPasswordCallback类的典型用法代码示例。如果您正苦于以下问题:Java WSPasswordCallback类的具体用法?Java WSPasswordCallback怎么用?Java WSPasswordCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WSPasswordCallback类属于org.apache.ws.security包,在下文中一共展示了WSPasswordCallback类的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包/类
/**
* (non-Javadoc)
*
* @see CallbackHandler#handle(javax.security.auth.callback.Callback[])
*/
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];
// set the password given a username
String identifier = pc.getIdentifer();
UserIdentifier userIdentifier = new UserIdentifier(identifier);
String userName = userIdentifier.getUserName();
String password = mUsernamePwd.get(userName);
pc.setPassword(password);
} else {
throw new UnsupportedCallbackException(callbacks[i],
"Client: Unrecognized Callback");
}
}
}
示例4: 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);
}
}
示例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.getIdentifer();
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++) {
//When the server side need to authenticate the user
WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
if (pwcb.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN) {
if(pwcb.getIdentifer().equals("alice") && pwcb.getPassword().equals("bobPW")) {
return;
} else {
throw new UnsupportedCallbackException(callbacks[i], "check failed");
}
}
//When the client requests for the password to be added in to the
//UT element
pwcb.setPassword("bobPW");
}
}
示例7: handle
import org.apache.ws.security.WSPasswordCallback; //导入依赖的package包/类
/**
* The implementation of the passwrod call back used by the WS Security
*
* @see javax.security.auth.callback.CallbackHandler#handle(javax.security.auth.callback.Callback[])
*/
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 ticket = AuthenticationUtils.getTicket();
if (ticket == null)
{
throw new WebServiceException("Ticket could not be found when calling callback handler.");
}
pc.setPassword(ticket);
}
else
{
throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
}
}
}
示例8: 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>\")");
}
}
示例9: atribuiSenha
import org.apache.ws.security.WSPasswordCallback; //导入依赖的package包/类
/**
* Atribui senha para o c�digo de aplica��o cadastrado
*
* @param pc
* @throws IOException
*/
protected void atribuiSenha(WSPasswordCallback pc) throws IOException {
PreparedStatement stmt = null;
Connection connection = null;
ResultSet rs = null;
try {
connection = getConnection();
stmt = connection.prepareStatement(MockPasswordCallbackClient.sql);
stmt.setString(1, pc.getIdentifier().toUpperCase());
rs = stmt.executeQuery();
if (rs != null && rs.next()) {
pc.setPassword(rs.getString("nm_senha"));
return;
} else {
throw new IOException("Aplicativo n�o cadastrado.");
}
} catch (SQLException sqle) {
sqle.printStackTrace();
throw new IOException("Erro ao buscar senha.");
} finally {
closeConnection(stmt, connection, rs);
}
}
示例10: atribuiSenha
import org.apache.ws.security.WSPasswordCallback; //导入依赖的package包/类
/**
* Atribui senha para o código de aplicação cadastrado
*
* @param pc
* @throws IOException
*/
protected void atribuiSenha(WSPasswordCallback pc) throws IOException {
PreparedStatement stmt = null;
Connection connection = null;
ResultSet rs = null;
try {
connection = getConnection();
stmt = connection.prepareStatement(MockPasswordCallbackClient.sql);
stmt.setString(1, pc.getIdentifier().toUpperCase());
rs = stmt.executeQuery();
if (rs != null && rs.next()) {
pc.setPassword(rs.getString("nm_senha"));
return;
} else {
throw new IOException("Aplicativo n�o cadastrado.");
}
} catch (SQLException sqle) {
sqle.printStackTrace();
throw new IOException("Erro ao buscar senha.");
} finally {
closeConnection(stmt, connection, rs);
}
}
示例11: handle
import org.apache.ws.security.WSPasswordCallback; //导入依赖的package包/类
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
if ((this.signatureUser != null) && (this.signaturePassword != null)) {
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof WSPasswordCallback) {
WSPasswordCallback pc = (WSPasswordCallback)callbacks[i];
pc.setPassword(this.signaturePassword);
}
else {
throw new UnsupportedCallbackException(callbacks[i], "unrecognized_callback"); //$NON-NLS-1$
}
}
}
else {
super.handleCallback(callbacks);
}
}
示例12: 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];
if ("myclientkey".equals(pc.getIdentifier())) {
pc.setPassword("ckpass");
break;
} else if ("alice".equals(pc.getIdentifier())) {
pc.setPassword("clarinet");
break;
} else if ("bob".equals(pc.getIdentifier())) {
pc.setPassword("trombone");
break;
} else if ("eve".equals(pc.getIdentifier())) {
pc.setPassword("evekpass");
break;
}
}
}
}
示例13: handle
import org.apache.ws.security.WSPasswordCallback; //导入依赖的package包/类
@Override
public void handle(Callback[] callbacks) throws IOException,
UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
final Callback c = callbacks[i];
if (c != null && c instanceof WSPasswordCallback) {
final WSPasswordCallback pc = (WSPasswordCallback) c;
String pass = passwords.get(pc.getIdentifier());
if (pass != null) {
pc.setPassword(pass);
return;
}
}
}
}
示例14: 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];
/*
* here call a function/method to lookup the password for
* the given identifier (e.g. a user name or keystore alias)
* e.g.: pc.setPassword(passStore.getPassword(pc.getIdentfifier))
* for testing we supply a fixed name/fixed key here.
*/
if (pc.getUsage() == WSPasswordCallback.KEY_NAME) {
pc.setKey(key);
}
else {
pc.setPassword("security");
}
} else {
throw new UnsupportedCallbackException(
callbacks[i], "Unrecognized Callback");
}
}
}
示例15: 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");
}
}
}