當前位置: 首頁>>代碼示例>>Java>>正文


Java CallbackHandler.handle方法代碼示例

本文整理匯總了Java中javax.security.auth.callback.CallbackHandler.handle方法的典型用法代碼示例。如果您正苦於以下問題:Java CallbackHandler.handle方法的具體用法?Java CallbackHandler.handle怎麽用?Java CallbackHandler.handle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.security.auth.callback.CallbackHandler的用法示例。


在下文中一共展示了CallbackHandler.handle方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: openSession

import javax.security.auth.callback.CallbackHandler; //導入方法依賴的package包/類
@Override
public ExchangeSession openSession(ExchangeLogin login) {
    ApiKeyCallback apiKey = new ApiKeyCallback();
    ApiSecretCallback apiSecret = new ApiSecretCallback();
    PasswordCallback password = new PasswordCallback("GDAX passphrase", false);

    Callback[] callbacks = new Callback[]{
            apiKey,
            apiSecret,
            password
    };
    CallbackHandler callbackHandler = login.getCallbackHandler();
    try {
        callbackHandler.handle(callbacks);
    } catch (IOException | UnsupportedCallbackException e) {
        throw new RuntimeException(e);
    }

    String apiKeyTxt = apiKey.getApiKey();
    char[] passphrase = password.getPassword();
    SecretKeySpec keySpec = new SecretKeySpec(apiSecret.getSecretData(), "HmacSHA256");
    return new GdaxExchangeSession(this, apiKeyTxt, keySpec, passphrase);
}
 
開發者ID:cloudwall,項目名稱:libcwfincore,代碼行數:24,代碼來源:GdaxExchangeConnection.java

示例2: initialize

import javax.security.auth.callback.CallbackHandler; //導入方法依賴的package包/類
public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState,
		Map<String, ?> options) {

	try {
		NameCallback nameCallback = new NameCallback("prompt");
		PasswordCallback passwordCallback = new PasswordCallback("prompt", false);

		callbackHandler.handle(new Callback[] { nameCallback, passwordCallback });
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
開發者ID:Taskana,項目名稱:taskana,代碼行數:13,代碼來源:SampleLoginModule.java

示例3: login

import javax.security.auth.callback.CallbackHandler; //導入方法依賴的package包/類
@Override
protected List<Principal> login(final Subject subject, final CallbackHandler callbackHandler,
                                final Map<String, ?> sharedState, final Map<String, ?> options) throws LoginException {
    // Retrieve username and password
    if (callbackHandler == null) {
        throw new LoginException("Could not retrieve credentials: no callback handler");
    }

    final Callback[] callbacks = new Callback[2];
    callbacks[0] = new NameCallback("username");
    callbacks[1] = new PasswordCallback("password", false);

    final String username;
    final char[] password;
    try {
        callbackHandler.handle(callbacks);
        username = ((NameCallback) callbacks[0]).getName();
        final char[] tmpPassword = ((PasswordCallback) callbacks[1]).getPassword();
        password = new char[tmpPassword.length];
        System.arraycopy(tmpPassword, 0,
                password, 0, tmpPassword.length);
        ((PasswordCallback) callbacks[1]).clearPassword();

    } catch (final UnsupportedCallbackException | IOException e) {
        final LoginException le = new LoginException("Could not retrieve credentials");
        le.initCause(e);
        throw le;
    }

    // Validate username and password
    final Properties properties = loadProperties(options);
    if (validateCredentials(properties, username, password)) {
        final Principal userPrincipal = new JMXPrincipal(username);
        return Collections.singletonList(userPrincipal);
    } else {
        throw new FailedLoginException("Invalid credentials");
    }
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:39,代碼來源:PropertiesLoginModule.java


注:本文中的javax.security.auth.callback.CallbackHandler.handle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。