本文整理汇总了Java中org.apache.harmony.javax.security.auth.callback.CallbackHandler类的典型用法代码示例。如果您正苦于以下问题:Java CallbackHandler类的具体用法?Java CallbackHandler怎么用?Java CallbackHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CallbackHandler类属于org.apache.harmony.javax.security.auth.callback包,在下文中一共展示了CallbackHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSaslClient
import org.apache.harmony.javax.security.auth.callback.CallbackHandler; //导入依赖的package包/类
@Override
public SaslClient createSaslClient(String[] mechanisms,
String authorizationId, String protocol, String serverName,
Map<String, ?> props, CallbackHandler cbh) throws SaslException {
for (String mech: mechanisms) {
if ("PLAIN".equals(mech)) {
return new PlainSaslClient(authorizationId, cbh);
} else
if ("DIGEST-MD5".equals(mech)) {
return DigestMD5SaslClient.getClient(
authorizationId,
protocol,
serverName,
props,
cbh
);
}
}
return null;
}
示例2: createSaslClient
import org.apache.harmony.javax.security.auth.callback.CallbackHandler; //导入依赖的package包/类
public SaslClient createSaslClient(String[] mechanisms, String authorizationId, String protocol,
String serverName, Map<String, ?> props, CallbackHandler cbh)
throws SaslException
{
for (int i = 0; i < mechanisms.length; i++)
{
if (mechanisms[i].equals(MECHANISM))
{
if (cbh == null)
{
throw new SaslException("CallbackHandler must not be null");
}
String[] mechs = {"CRAM-MD5"};
return Sasl.createSaslClient(mechs, authorizationId, protocol, serverName, props, cbh);
}
}
return null;
}
示例3: createSaslClient
import org.apache.harmony.javax.security.auth.callback.CallbackHandler; //导入依赖的package包/类
public static SaslClient createSaslClient(String[] mechanisms,
String authanticationID, String protocol, String serverName,
Map<String, ?> prop, CallbackHandler cbh) throws SaslException {
if (mechanisms == null) {
throw new NullPointerException("auth.33"); //$NON-NLS-1$
}
SaslClientFactory fact = getSaslClientFactories().nextElement();
String[] mech = fact.getMechanismNames(null);
boolean is = false;
if (mech != null) {
for (int j = 0; j < mech.length; j++) {
for (int n = 0; n < mechanisms.length; n++) {
if (mech[j].equals(mechanisms[n])) {
is = true;
break;
}
}
}
}
if (is) {
return fact.createSaslClient(mechanisms, authanticationID,
protocol, serverName, prop, cbh);
}
return null;
}
示例4: createSaslClient
import org.apache.harmony.javax.security.auth.callback.CallbackHandler; //导入依赖的package包/类
public SaslClient createSaslClient(String[] mechanisms,
String authorizationId, String protocol, String serverName,
Map<String, ?> props, CallbackHandler cbh) throws SaslException {
for (int i = 0; i < mechanisms.length; i++) {
if (mechanisms[i].equals(MECHANISM)) {
if (cbh == null) {
throw new SaslException("CallbackHandler must not be null");
}
String[] mechs = { "CRAM-MD5" };
return Sasl.createSaslClient(mechs, authorizationId, protocol,
serverName, props, cbh);
}
}
return null;
}
示例5: createSaslClient
import org.apache.harmony.javax.security.auth.callback.CallbackHandler; //导入依赖的package包/类
public static SaslClient createSaslClient(String[] mechanisms, String authanticationID,
String protocol, String serverName, Map<String, ?> prop, CallbackHandler cbh)
throws SaslException {
if (mechanisms == null) {
throw new NullPointerException("auth.33"); //$NON-NLS-1$
}
SaslClientFactory fact = getSaslClientFactories().nextElement();
String[] mech = fact.getMechanismNames(null);
boolean is = false;
if (mech != null) {
for (int j = 0; j < mech.length; j++) {
for (int n = 0; n < mechanisms.length; n++) {
if (mech[j].equals(mechanisms[n])) {
is = true;
break;
}
}
}
}
if (is) {
return fact.createSaslClient(
mechanisms,
authanticationID,
protocol,
serverName,
prop,
cbh
);
}
return null;
}
示例6: authenticate
import org.apache.harmony.javax.security.auth.callback.CallbackHandler; //导入依赖的package包/类
public String authenticate(String username, String resource, CallbackHandler cbh) throws XMPPException {
//Use the callback handler to determine the password, and continue on.
PasswordCallback pcb = new PasswordCallback("Password: ",false);
try {
cbh.handle(new Callback[]{pcb});
return authenticate(username, String.valueOf(pcb.getPassword()),resource);
} catch (Exception e) {
throw new XMPPException("Unable to determine password.",e);
}
}
示例7: createSaslServer
import org.apache.harmony.javax.security.auth.callback.CallbackHandler; //导入依赖的package包/类
public static SaslServer createSaslServer(String mechanism, String protocol,
String serverName, Map<String, ?> prop, CallbackHandler cbh) throws SaslException {
if (mechanism == null) {
throw new NullPointerException("auth.32"); //$NON-NLS-1$
}
Collection<?> res = findFactories(SERVERFACTORYSRV);
if (res.isEmpty()) {
return null;
}
Iterator<?> iter = res.iterator();
while (iter.hasNext()) {
SaslServerFactory fact = (SaslServerFactory) iter.next();
String[] mech = fact.getMechanismNames(null);
boolean is = false;
if (mech != null) {
for (int j = 0; j < mech.length; j++) {
if (mech[j].equals(mechanism)) {
is = true;
break;
}
}
}
if (is) {
SaslServer saslS = fact.createSaslServer(mechanism, protocol, serverName, prop,
cbh);
if (saslS != null) {
return saslS;
}
}
}
return null;
}
示例8: createSaslClient
import org.apache.harmony.javax.security.auth.callback.CallbackHandler; //导入依赖的package包/类
public static SaslClient createSaslClient(String[] mechanisms, String authanticationID,
String protocol, String serverName, Map<String, ?> prop, CallbackHandler cbh)
throws SaslException {
if (mechanisms == null) {
throw new NullPointerException("auth.33"); //$NON-NLS-1$
}
Collection<?> res = findFactories(CLIENTFACTORYSRV);
if (res.isEmpty()) {
return null;
}
Iterator<?> iter = res.iterator();
while (iter.hasNext()) {
SaslClientFactory fact = (SaslClientFactory) iter.next();
String[] mech = fact.getMechanismNames(null);
boolean is = false;
if (mech != null) {
for (int j = 0; j < mech.length; j++) {
for (int n = 0; n < mechanisms.length; n++) {
if (mech[j].equals(mechanisms[n])) {
is = true;
break;
}
}
}
}
if (is) {
SaslClient saslC = fact.createSaslClient(mechanisms, authanticationID,
protocol, serverName, prop, cbh);
if (saslC != null) {
return saslC;
}
}
}
return null;
}
示例9: LoginContext
import org.apache.harmony.javax.security.auth.callback.CallbackHandler; //导入依赖的package包/类
public LoginContext(String name, CallbackHandler cbHandler) throws LoginException {
super();
if (cbHandler == null) {
throw new LoginException("auth.34"); //$NON-NLS-1$
}
init(name, null, cbHandler, null);
}
示例10: PlainSaslClient
import org.apache.harmony.javax.security.auth.callback.CallbackHandler; //导入依赖的package包/类
public PlainSaslClient(String authorizationID, CallbackHandler cbh) throws SaslException
{
completed = false;
this.cbh = cbh;
Object[] userInfo = getUserInfo();
this.authorizationID = authorizationID;
this.authenticationID = (String) userInfo[0];
this.password = (byte[]) userInfo[1];
if (authenticationID == null || password == null)
{
throw new SaslException("PLAIN: authenticationID and password must be specified");
}
}
示例11: createSaslClient
import org.apache.harmony.javax.security.auth.callback.CallbackHandler; //导入依赖的package包/类
public SaslClient createSaslClient(String[] mechs, String authorizationId, String protocol,
String serverName, Map props, CallbackHandler cbh)
throws SaslException
{
for (int i = 0; i < mechs.length; i++)
{
if (mechs[i].equals("PLAIN"))
{
return new PlainSaslClient(authorizationId, cbh);
}
}
return null;
}
示例12: createSaslClient
import org.apache.harmony.javax.security.auth.callback.CallbackHandler; //导入依赖的package包/类
@Override
public SaslClient createSaslClient(String[] mechanisms,
String authorizationId, String protocol, String serverName,
Map<String, ?> props, CallbackHandler cbh) throws SaslException {
for (String mech: mechanisms) {
if ("PLAIN".equals(mech)) {
return new PlainSaslClient(authorizationId, cbh);
} else
if ("DIGEST-MD5".equals(mech)) {
return DigestMD5SaslClient.getClient(
authorizationId,
protocol,
serverName,
props,
cbh
);
}
if ("EXTERNAL".equals(mech)) {
return ExternalSaslClient.getClient(
authorizationId,
protocol,
serverName,
props,
cbh
);
}
}
return null;
}
示例13: authenticate
import org.apache.harmony.javax.security.auth.callback.CallbackHandler; //导入依赖的package包/类
public void authenticate(String username, String host, CallbackHandler cbh)
throws IOException, XMPPException {
String[] mechanisms = { "DIGEST-MD5" };
Map<String, String> props = new HashMap<String, String>();
sc = Sasl.createSaslClient(mechanisms, null, "xmpp", host, props, cbh);
authenticate();
}
示例14: createSaslClient
import org.apache.harmony.javax.security.auth.callback.CallbackHandler; //导入依赖的package包/类
@Override
public SaslClient createSaslClient(String[] mechanisms,
String authorizationId, String protocol, String serverName,
Map<String, ?> props, CallbackHandler cbh) throws SaslException {
for (String mech : mechanisms) {
if ("PLAIN".equals(mech)) {
return new PlainSaslClient(authorizationId, cbh);
} else if ("DIGEST-MD5".equals(mech)) {
return DigestMD5SaslClient.getClient(authorizationId, protocol,
serverName, props, cbh);
}
}
return null;
}
示例15: authenticate
import org.apache.harmony.javax.security.auth.callback.CallbackHandler; //导入依赖的package包/类
public void authenticate(String username, String host, CallbackHandler cbh)
throws IOException, XMPPException {
String[] mechanisms = { "DIGEST-MD5" };
Map<String, String> props = new HashMap<String, String>();
sc = Sasl.createSaslClient(mechanisms, null, "xmpp", host, props, cbh);
authenticate();
}