当前位置: 首页>>代码示例>>Java>>正文


Java NameCallback.getName方法代码示例

本文整理汇总了Java中javax.security.auth.callback.NameCallback.getName方法的典型用法代码示例。如果您正苦于以下问题:Java NameCallback.getName方法的具体用法?Java NameCallback.getName怎么用?Java NameCallback.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.security.auth.callback.NameCallback的用法示例。


在下文中一共展示了NameCallback.getName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: newInstance

import javax.security.auth.callback.NameCallback; //导入方法依赖的package包/类
@Override
public SaslMechanism newInstance(CallbackHandler callbackHandler,
                                 Map<String, ?> sharedState,
                                 Map<String, ?> options) {


    NameCallback nameCallback = new NameCallback("Username: ");
    PasswordCallback passwordCallback = new PasswordCallback("Password: ", false);
    try {
        callbackHandler.handle(new Callback[] { nameCallback, passwordCallback });
    } catch (IOException ioe) {
        return null;
    } catch (UnsupportedCallbackException e) {
        return null;
    }

    return new PlainMechanism(nameCallback.getName(), passwordCallback.getPassword());
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:19,代码来源:PlainSaslMechanismFactory.java

示例2: login

import javax.security.auth.callback.NameCallback; //导入方法依赖的package包/类
@Override
public boolean login() throws LoginException {
    if (debug) {
        logger.debug(this.getClass().getName() + " login called.");
    }

    if (Constants.FEDORA_HOME == null || "".equals(Constants.FEDORA_HOME.trim())) {
        logger.error("FEDORA_HOME constant is not set");
        return false;
    }

    final NameCallback nc = new NameCallback("username");
    final PasswordCallback pc = new PasswordCallback("password", false);
    final Callback[] callbacks = new Callback[] {
            nc, pc
    };

    try {
        handler.handle(callbacks);
    } catch (IOException ioe) {
        ioe.printStackTrace();
        throw new LoginException("IOException occured: " + ioe.getMessage());
    } catch (UnsupportedCallbackException ucbe) {
        ucbe.printStackTrace();
        throw new LoginException("UnsupportedCallbackException encountered: "
                + ucbe.getMessage());
    }

    // Grab the username and password from the callbacks.
    final String username = nc.getName();
    final String password = new String(pc.getPassword());

    successLogin = authenticate(username, password);

    return successLogin;
}
 
开发者ID:discoverygarden,项目名称:fcrepo3-security-jaas,代码行数:37,代码来源:XmlUsersFileModule.java

示例3: login

import javax.security.auth.callback.NameCallback; //导入方法依赖的package包/类
@Override
public boolean login() throws LoginException {
    NameCallback userNameCallback = new NameCallback("userName");
    PasswordCallback passwordCallback = new PasswordCallback("password", false);
    Callback[] callbacks = { userNameCallback, passwordCallback };
    try {
        callbackHandler.handle(callbacks);
    } catch (IOException | UnsupportedCallbackException e) {
        throw new BrokerAuthenticationException("Error while handling callback ", e);
    }
    String userName = userNameCallback.getName();
    char[] password = passwordCallback.getPassword();
    return userName.equals("user") && Arrays.equals(password, new char[] { 'p', 'a', 's', 's' });
}
 
开发者ID:wso2,项目名称:message-broker,代码行数:15,代码来源:TestLoginModule.java

示例4: getUsernameAndPassword

import javax.security.auth.callback.NameCallback; //导入方法依赖的package包/类
/**
    * Called by login() to acquire the username and password strings for authentication. This method does no validation
    * of either.
    *
    * @return String[], [0] = username, [1] = password
    */
   private String[] getUsernameAndPassword() throws LoginException {
if (callbackHandler == null) {
    throw new LoginException("No CallbackHandler available to collect authentication information");
}
NameCallback nc = new NameCallback("User name: ", "guest");
PasswordCallback pc = new PasswordCallback("Password: ", false);
Callback[] callbacks = { nc, pc };
String username = null;
String password = null;
try {
    callbackHandler.handle(callbacks);
    username = nc.getName();
    char[] tmpPassword = pc.getPassword();
    if (tmpPassword != null) {
	credential = new char[tmpPassword.length];
	System.arraycopy(tmpPassword, 0, credential, 0, tmpPassword.length);
	pc.clearPassword();
	password = new String(credential);
    }
} catch (IOException ioe) {
    throw new LoginException(ioe.toString());
} catch (UnsupportedCallbackException uce) {
    throw new LoginException("CallbackHandler does not support: " + uce.getCallback());
}
return new String[] { username, password };
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:33,代码来源:UniversalLoginModule.java

示例5: handle

import javax.security.auth.callback.NameCallback; //导入方法依赖的package包/类
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
	iHandler.handle(callbacks);
	if (iRealm != null)
		for (Callback callback : callbacks) {
			if (callback instanceof NameCallback) {
				NameCallback nc = (NameCallback) callback;
				if (nc.getName() != null && !nc.getName().contains("@"))
					nc.setName(nc.getName() + "@" + iRealm);
			}
		}
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:13,代码来源:KerberosAuthenticateModule.java

示例6: setTheAlias

import javax.security.auth.callback.NameCallback; //导入方法依赖的package包/类
/**
 * Set the alias to delete from the key store.
 * <p>
 * Unlike in other keytool handlers, the default value (<i>mykey</i>) for the
 * Alias is not used. Instead, if an alias was not found on the command line,
 * the user is prompted to enter one.
 *
 * @param anAlias a possibly null Alias gleaned from the command line.
 * @throws IOException if an I/O related exception occurs during the process.
 * @throws UnsupportedCallbackException if no implementation of a password
 *           callback handler was found.
 */
private void setTheAlias(String anAlias) throws IOException,
    UnsupportedCallbackException
{
  if (anAlias == null || anAlias.trim().length() == 0)
    {
      String prompt = Messages.getString("DeleteCmd.19"); //$NON-NLS-1$
      NameCallback ncb = new NameCallback(prompt);
      getCallbackHandler().handle(new Callback[] { ncb });
      anAlias = ncb.getName();
      if (anAlias == null || anAlias.trim().length() == 0)
        throw new SecurityException(Messages.getString("DeleteCmd.20")); //$NON-NLS-1$
    }
  alias = anAlias.trim();
}
 
开发者ID:vilie,项目名称:javify,代码行数:27,代码来源:DeleteCmd.java

示例7: setDestinationAlias

import javax.security.auth.callback.NameCallback; //导入方法依赖的package包/类
private void setDestinationAlias(String name) throws IOException,
    UnsupportedCallbackException
{
  if (name == null || name.trim().length() == 0) // ask user to provide one
    {
      NameCallback ncb = new NameCallback(Messages.getString("KeyCloneCmd.26")); //$NON-NLS-1$
      getCallbackHandler().handle(new Callback[] { ncb });
      name = ncb.getName();
      if (name == null || name.trim().length() == 0)
        throw new IllegalArgumentException(Messages.getString("KeyCloneCmd.27")); //$NON-NLS-1$
    }

  destinationAlias = name.trim();
}
 
开发者ID:vilie,项目名称:javify,代码行数:15,代码来源:KeyCloneCmd.java

示例8: isAuthenticatedUsingCerts

import javax.security.auth.callback.NameCallback; //导入方法依赖的package包/类
private boolean isAuthenticatedUsingCerts(List<X509Certificate> certs) throws IOException, UnsupportedCallbackException {
    NameCallback nameHandler = new NameCallback("user:");
    CertificateCallback certificateCallback = new CertificateCallback();
    callbackHandler.handle(new Callback[] { nameHandler, certificateCallback });
    X509Certificate[] certArray = certificateCallback.getCertificates();
    if(certArray != null) {
        certs.addAll(Arrays.asList(certArray));
    }
    return nameHandler.getName() == null && !certs.isEmpty();
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:11,代码来源:SaslDelegatingLogin.java

示例9: login

import javax.security.auth.callback.NameCallback; //导入方法依赖的package包/类
@Override
public boolean login() throws LoginException {
    if (debug) {
        logger.debug(String.format("%s login called.", DrupalMultisiteAuthModule.class.getName()));
        for (String key : sharedState.keySet()) {
            String value = sharedState.get(key).toString();
            logger.debug(key + ": " + value);
        }
    }

    String[] keys = config.keySet().toArray(new String[0]);
    NameCallback nc = new NameCallback("username");
    PasswordCallback pc = new PasswordCallback("password", false);
    KeyChoiceCallback kcc = new KeyChoiceCallback(keys);
    Callback[] callbacks = new Callback[] {
            nc, pc, kcc
    };

    try {
        handler.handle(callbacks);
        username = nc.getName();
        char[] passwordCharArray = pc.getPassword();
        String password = new String(passwordCharArray);
        int[] key_selections = kcc.getSelectedIndexes();

        // Should only be exactly one item in key_selections; however,
        // let's iterate for brevity.
        for (int i : key_selections) {
            findUser(username, password, keys[i]);
        }

    }
    catch (IOException ioe) {
        ioe.printStackTrace();
        throw new LoginException("IOException occured: " + ioe.getMessage());
    }
    catch (MissingCredsException mce) {
        throw new CredentialNotFoundException(
                String.format("Missing \"key\", required for module %s.", this.getClass().getName()));
    }
    catch (UnsupportedCallbackException ucbe) {
        throw new LoginException("UnsupportedCallbackException: " + ucbe.getMessage());
    }

    return successLogin;
}
 
开发者ID:discoverygarden,项目名称:fcrepo3-security-jaas,代码行数:47,代码来源:DrupalMultisiteAuthModule.java

示例10: saveAlias

import javax.security.auth.callback.NameCallback; //导入方法依赖的package包/类
private void saveAlias(NameCallback cb) {
    keyStoreAlias = cb.getName();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:KeyStoreLoginModule.java


注:本文中的javax.security.auth.callback.NameCallback.getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。