本文整理汇总了Java中org.apache.harmony.javax.security.sasl.SaslClient类的典型用法代码示例。如果您正苦于以下问题:Java SaslClient类的具体用法?Java SaslClient怎么用?Java SaslClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SaslClient类属于org.apache.harmony.javax.security.sasl包,在下文中一共展示了SaslClient类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSaslClient
import org.apache.harmony.javax.security.sasl.SaslClient; //导入依赖的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.sasl.SaslClient; //导入依赖的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.sasl.SaslClient; //导入依赖的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.sasl.SaslClient; //导入依赖的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.sasl.SaslClient; //导入依赖的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: createSaslClient
import org.apache.harmony.javax.security.sasl.SaslClient; //导入依赖的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;
}
示例7: createSaslClient
import org.apache.harmony.javax.security.sasl.SaslClient; //导入依赖的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;
}
示例8: createSaslClient
import org.apache.harmony.javax.security.sasl.SaslClient; //导入依赖的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;
}
示例9: createSaslClient
import org.apache.harmony.javax.security.sasl.SaslClient; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
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;
}
示例10: getClient
import org.apache.harmony.javax.security.sasl.SaslClient; //导入依赖的package包/类
/**
* Creates an DigestMD5SaslClient object using the parameters supplied.
* Assumes that the QOP, STRENGTH, and SERVER_AUTH properties are
* contained in props
*
* @param authorizationId The possibly null protocol-dependent
* identification to be used for authorization. If
* null or empty, the server derives an authorization
* ID from the client's authentication credentials.
* When the SASL authentication completes
* successfully, the specified entity is granted
* access.
*
* @param protocol The non-null string name of the protocol for which
* the authentication is being performed (e.g. "ldap")
*
* @param serverName The non-null fully qualified host name of the server
* to authenticate to
*
* @param props The possibly null set of properties used to select
* the SASL mechanism and to configure the
* authentication exchange of the selected mechanism.
* See the Sasl class for a list of standard properties.
* Other, possibly mechanism-specific, properties can
* be included. Properties not relevant to the selected
* mechanism are ignored.
*
* @param cbh The possibly null callback handler to used by the
* SASL mechanisms to get further information from the
* application/library to complete the authentication.
* For example, a SASL mechanism might require the
* authentication ID, password and realm from the
* caller. The authentication ID is requested by using
* a NameCallback. The password is requested by using
* a PasswordCallback. The realm is requested by using
* a RealmChoiceCallback if there is a list of realms
* to choose from, and by using a RealmCallback if the
* realm must be entered.
*
* @return A possibly null SaslClient created using the
* parameters supplied. If null, this factory cannot
* produce a SaslClient using the parameters supplied.
*
* @exception SaslException If a SaslClient instance cannot be created
* because of an error
*/
public static SaslClient getClient(
String authorizationId,
String protocol,
String serverName,
Map props,
CallbackHandler cbh)
{
String desiredQOP = (String)props.get(Sasl.QOP);
String desiredStrength = (String)props.get(Sasl.STRENGTH);
String serverAuth = (String)props.get(Sasl.SERVER_AUTH);
//only support qop equal to auth
if ((desiredQOP != null) && !"auth".equals(desiredQOP))
return null;
//doesn't support server authentication
if ((serverAuth != null) && !"false".equals(serverAuth))
return null;
//need a callback handler to get the password
if (cbh == null)
return null;
return new DigestMD5SaslClient(authorizationId, protocol,
serverName, props, cbh);
}