当前位置: 首页>>代码示例>>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;未经允许,请勿转载。