本文整理汇总了Java中javax.security.sasl.RealmCallback.getDefaultText方法的典型用法代码示例。如果您正苦于以下问题:Java RealmCallback.getDefaultText方法的具体用法?Java RealmCallback.getDefaultText怎么用?Java RealmCallback.getDefaultText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.security.sasl.RealmCallback
的用法示例。
在下文中一共展示了RealmCallback.getDefaultText方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import javax.security.sasl.RealmCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
for (Callback current : callbacks) {
if (current instanceof RealmCallback) {
RealmCallback rcb = (RealmCallback) current;
String defaultText = rcb.getDefaultText();
rcb.setText(defaultText); // For now just use the realm suggested.
} else if (current instanceof RealmChoiceCallback) {
throw DomainManagementLogger.ROOT_LOGGER.realmNotSupported(current);
} else if (current instanceof OptionalNameCallback) {
// Do nothing as we don't want to set a name for local authentication.
} else if (current instanceof NameCallback) {
NameCallback ncb = (NameCallback) current;
ncb.setName(userName);
} else if (current instanceof PasswordCallback) {
PasswordCallback pcb = (PasswordCallback) current;
pcb.setPassword(password);
} else {
throw new UnsupportedCallbackException(current);
}
}
}
示例2: handle
import javax.security.sasl.RealmCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
for (Callback current : callbacks) {
if (current instanceof RealmCallback) {
RealmCallback rcb = (RealmCallback) current;
String defaultText = rcb.getDefaultText();
rcb.setText(defaultText); // For now just use the realm suggested.
} else if (current instanceof RealmChoiceCallback) {
throw new UnsupportedCallbackException(current, "Realm choice not currently supported.");
} else if (current instanceof NameCallback) {
NameCallback ncb = (NameCallback) current;
ncb.setName(userName);
} else if (current instanceof PasswordCallback) {
PasswordCallback pcb = (PasswordCallback) current;
pcb.setPassword(authKey.toCharArray());
} else {
throw new UnsupportedCallbackException(current);
}
}
}
示例3: handle
import javax.security.sasl.RealmCallback; //导入方法依赖的package包/类
/**
*
*/
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof NameCallback) {
NameCallback ncb = (NameCallback)callbacks[i];
ncb.setName(authenticationId);
} else if(callbacks[i] instanceof PasswordCallback) {
PasswordCallback pcb = (PasswordCallback)callbacks[i];
pcb.setPassword(password.toCharArray());
} else if(callbacks[i] instanceof RealmCallback) {
RealmCallback rcb = (RealmCallback)callbacks[i];
//Retrieve the REALM from the challenge response that the server returned when the client initiated the authentication
//exchange. If this value is not null or empty, *this value* has to be sent back to the server in the client's response
//to the server's challenge
String text = rcb.getDefaultText();
//The SASL client (sc) created in smack uses rcb.getText when creating the negotiatedRealm to send it back to the server
//Make sure that this value matches the server's realm
rcb.setText(text);
} else if(callbacks[i] instanceof RealmChoiceCallback){
//unused
//RealmChoiceCallback rccb = (RealmChoiceCallback)callbacks[i];
} else {
throw new UnsupportedCallbackException(callbacks[i]);
}
}
}
示例4: handle
import javax.security.sasl.RealmCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
for (Callback current : callbacks) {
if (current instanceof RealmCallback) {
RealmCallback realmCallback = (RealmCallback) current;
if (realm == null || realm.trim().length() == 0) {
String defaultRealm = realmCallback.getDefaultText();
realmCallback.setText(defaultRealm);
} else {
realmCallback.setText(realm);
}
} else if (current instanceof NameCallback) {
NameCallback nameCallback = (NameCallback) current;
nameCallback.setName(username);
} else if (current instanceof PasswordCallback) {
PasswordCallback passwordCallback = (PasswordCallback) current;
passwordCallback.setPassword(password);
} else {
throw new UnsupportedCallbackException(current);
}
}
}
开发者ID:techblue,项目名称:jboss-controller-operation-executor,代码行数:22,代码来源:AuthenticationCallbackHandler.java
示例5: handle
import javax.security.sasl.RealmCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
// Special case for anonymous authentication to avoid prompting user for their name.
if (callbacks.length == 1 && callbacks[0] instanceof NameCallback) {
((NameCallback)callbacks[0]).setName("anonymous CLI user"); //$NON-NLS-1$
return;
}
for (Callback current : callbacks) {
if (current instanceof RealmCallback) {
RealmCallback rcb = (RealmCallback) current;
String defaultText = rcb.getDefaultText();
rcb.setText(defaultText); // For now just use the realm suggested.
if (this.realmShown == false) {
this.realmShown = true;
}
} else if (current instanceof RealmChoiceCallback) {
throw new UnsupportedCallbackException(current, "Realm choice not currently supported."); //$NON-NLS-1$
} else if (current instanceof NameCallback) {
NameCallback ncb = (NameCallback) current;
ncb.setName(this.userName);
} else if (current instanceof PasswordCallback) {
PasswordCallback pcb = (PasswordCallback) current;
pcb.setPassword(this.password);
} else {
throw new UnsupportedCallbackException(current);
}
}
}
示例6: assertDeserialized
import javax.security.sasl.RealmCallback; //导入方法依赖的package包/类
public void assertDeserialized(Serializable oref, Serializable otest) {
RealmCallback ref = (RealmCallback) oref;
RealmCallback test = (RealmCallback) otest;
String dText = ref.getDefaultText();
String text = ref.getText();
String prompt = ref.getPrompt();
assertEquals(dText, test.getDefaultText());
assertEquals(text, test.getText());
assertEquals(prompt, test.getPrompt());
}
示例7: handle
import javax.security.sasl.RealmCallback; //导入方法依赖的package包/类
/**
*
*/
public void handle(Callback[] callbacks) throws IOException,
UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof NameCallback) {
NameCallback ncb = (NameCallback) callbacks[i];
ncb.setName(authenticationId);
} else if (callbacks[i] instanceof PasswordCallback) {
PasswordCallback pcb = (PasswordCallback) callbacks[i];
pcb.setPassword(password.toCharArray());
} else if (callbacks[i] instanceof RealmCallback) {
RealmCallback rcb = (RealmCallback) callbacks[i];
// Retrieve the REALM from the challenge response that the
// server returned when the client initiated the authentication
// exchange. If this value is not null or empty, *this value*
// has to be sent back to the server in the client's response
// to the server's challenge
String text = rcb.getDefaultText();
// The SASL client (sc) created in smack uses rcb.getText when
// creating the negotiatedRealm to send it back to the server
// Make sure that this value matches the server's realm
rcb.setText(text);
} else if (callbacks[i] instanceof RealmChoiceCallback) {
// unused
// RealmChoiceCallback rccb = (RealmChoiceCallback)callbacks[i];
} else {
throw new UnsupportedCallbackException(callbacks[i]);
}
}
}
示例8: handle
import javax.security.sasl.RealmCallback; //导入方法依赖的package包/类
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
// Special case for anonymous authentication to avoid prompting user for their name.
if (callbacks.length == 1 && callbacks[0] instanceof NameCallback) {
((NameCallback) callbacks[0]).setName("anonymous demo user");
return;
}
for (Callback current : callbacks) {
if (current instanceof RealmCallback) {
final RealmCallback rcb = (RealmCallback) current;
final String defaultText = rcb.getDefaultText();
rcb.setText(defaultText); // For now just use the realm suggested.
prompt(defaultText);
} else if (current instanceof RealmChoiceCallback) {
throw new UnsupportedCallbackException(current, "Realm choice not currently supported.");
} else if (current instanceof NameCallback) {
final NameCallback ncb = (NameCallback) current;
final String userName = obtainUsername("Username:");
ncb.setName(userName);
} else if (current instanceof PasswordCallback) {
PasswordCallback pcb = (PasswordCallback) current;
char[] password = obtainPassword("Password:");
pcb.setPassword(password);
} else {
throw new UnsupportedCallbackException(current);
}
}
}
示例9: handle
import javax.security.sasl.RealmCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks)
throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof NameCallback) {
((NameCallback)callbacks[i]).setName(authenticationID);
} else if (callbacks[i] instanceof PasswordCallback) {
((PasswordCallback)callbacks[i]).setPassword(passwd);
} else if (callbacks[i] instanceof RealmChoiceCallback) {
/* Deals with a choice of realms */
String[] choices =
((RealmChoiceCallback)callbacks[i]).getChoices();
int selected = 0;
if (authRealm != null && authRealm.length() > 0) {
selected = -1; // no realm chosen
for (int j = 0; j < choices.length; j++) {
if (choices[j].equals(authRealm)) {
selected = j;
}
}
if (selected == -1) {
StringBuffer allChoices = new StringBuffer();
for (int j = 0; j < choices.length; j++) {
allChoices.append(choices[j] + ",");
}
throw new IOException("Cannot match " +
"'java.naming.security.sasl.realm' property value, '" +
authRealm + "' with choices " + allChoices +
"in RealmChoiceCallback");
}
}
((RealmChoiceCallback)callbacks[i]).setSelectedIndex(selected);
} else if (callbacks[i] instanceof RealmCallback) {
/* 1 or 0 realms specified in challenge */
RealmCallback rcb = (RealmCallback) callbacks[i];
if (authRealm != null) {
rcb.setText(authRealm); // Use what user supplied
} else {
String defaultRealm = rcb.getDefaultText();
if (defaultRealm != null) {
rcb.setText(defaultRealm); // Use what server supplied
} else {
rcb.setText(""); // Specify no realm
}
}
} else {
throw new UnsupportedCallbackException(callbacks[i]);
}
}
}
示例10: handle
import javax.security.sasl.RealmCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks)
throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof NameCallback) {
((NameCallback)callbacks[i]).setName(authenticationID);
} else if (callbacks[i] instanceof PasswordCallback) {
((PasswordCallback)callbacks[i]).setPassword(passwd);
} else if (callbacks[i] instanceof RealmChoiceCallback) {
/* Deals with a choice of realms */
String[] choices =
((RealmChoiceCallback)callbacks[i]).getChoices();
int selected = 0;
if (authRealm != null && authRealm.length() > 0) {
selected = -1; // no realm chosen
for (int j = 0; j < choices.length; j++) {
if (choices[j].equals(authRealm)) {
selected = j;
}
}
if (selected == -1) {
StringBuilder allChoices = new StringBuilder();
for (int j = 0; j < choices.length; j++) {
allChoices.append(choices[j]).append(',');
}
throw new IOException("Cannot match " +
"'java.naming.security.sasl.realm' property value, '" +
authRealm + "' with choices " + allChoices +
"in RealmChoiceCallback");
}
}
((RealmChoiceCallback)callbacks[i]).setSelectedIndex(selected);
} else if (callbacks[i] instanceof RealmCallback) {
/* 1 or 0 realms specified in challenge */
RealmCallback rcb = (RealmCallback) callbacks[i];
if (authRealm != null) {
rcb.setText(authRealm); // Use what user supplied
} else {
String defaultRealm = rcb.getDefaultText();
if (defaultRealm != null) {
rcb.setText(defaultRealm); // Use what server supplied
} else {
rcb.setText(""); // Specify no realm
}
}
} else {
throw new UnsupportedCallbackException(callbacks[i]);
}
}
}