Java 类javax.security.auth.callback.NameCallback 实例源码

项目:boutique-de-jus    文件:LoginModuleAuthSupport.java   
@Override
public Optional<Subject> map(final Optional<Object> wrapper) {
    try {
        LOG.info("logging in user as {}", username);
        LoginContext lc = new LoginContext("PropertyFile", callbacks -> {
            LOG.info("Callback Handler invoked ");
            Stream.of(callbacks).forEach(cb -> {
                if (cb instanceof NameCallback) {
                    ((NameCallback) cb).setName(username);
                } else if (cb instanceof PasswordCallback) {
                    ((PasswordCallback) cb).setPassword(password.toCharArray());
                }
            });
        });
        lc.login();
        return Optional.of(lc.getSubject());
    } catch (LoginException e) {
        LOG.error("Authentication failed", e);
        return Optional.empty();
    }
}
项目:fcrepo3-security-jaas    文件:AuthFilterJAAS.java   
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (Callback c: callbacks) {
        if (c instanceof NameCallback) {
            ((NameCallback) c).setName(username);
        } else if (c instanceof PasswordCallback) {
            ((PasswordCallback) c).setPassword(password.toCharArray());
        }
        else if (c instanceof KeyChoiceCallback) {
            KeyChoiceCallback kcc = (KeyChoiceCallback)c;
            try {
                int idx = kcc.lookupKey(key);
                kcc.setSelectedIndex(idx);
            }
            catch (IllegalArgumentException e) {
                throw new MissingCredsException(kcc);
            }
        }
        else {
            throw new UnsupportedCallbackException(c);
        }
    }
}
项目:springboot-shiro-cas-mybatis    文件:MockLoginModule.java   
@Override
public boolean login() throws LoginException {
    final Callback[] callbacks = new Callback[] {new NameCallback("f"), new PasswordCallback("f", false)};
    try {
        this.callbackHandler.handle(callbacks);
    } catch (final Exception e) {
        throw new LoginException();
    }

    final String userName = ((NameCallback) callbacks[0]).getName();
    final String password = new String(((PasswordCallback) callbacks[1]).getPassword());

    if ("test".equals(userName) && "test".equals(password)) {
        return true;
    }

    throw new LoginException();
}
项目:springboot-shiro-cas-mybatis    文件:MockLoginModule.java   
public boolean login() throws LoginException {
    final Callback[] callbacks = new Callback[] {new NameCallback("f"), new PasswordCallback("f", false)};
    try {
        this.callbackHandler.handle(callbacks);
    } catch (final Exception e) {
        throw new LoginException();
    }

    final String userName = ((NameCallback) callbacks[0]).getName();
    final String password = new String(((PasswordCallback) callbacks[1]).getPassword());

    if ("test".equals(userName) && "test".equals(password)) {
        return true;
    }

    throw new LoginException();
}
项目:OpenDiabetes    文件:JaasAuthBean.java   
public void handle(Callback[] callbacks)
        throws UnsupportedCallbackException {
    boolean didSetName = false;
    boolean didSetPassword = false;
    for (Callback cb : callbacks)
        if (cb instanceof NameCallback) {
            ((NameCallback) cb).setName(u);
            didSetName = true;
        } else if (cb instanceof PasswordCallback) {
            ((PasswordCallback) cb).setPassword(p);
            didSetPassword = true;
        } else {
            throw new UnsupportedCallbackException(cb,
                    "Unsupported Callback type: "
                    + cb.getClass().getName());
        }
    if (!didSetName)
        throw new IllegalStateException(
                "Supplied Callbacks does not include a NameCallback");
    if (!didSetPassword)
        throw new IllegalStateException("Supplied Callbacks "
                + "does not include a PasswordCallback");
}
项目:cas-5.1.0    文件:JaasAuthenticationHandler.java   
@Override
public void handle(final Callback[] callbacks) throws UnsupportedCallbackException {
    Arrays.stream(callbacks).filter(callback -> {
        if (callback.getClass().equals(NameCallback.class)) {
            ((NameCallback) callback).setName(this.userName);
            return false;
        }
        if (callback.getClass().equals(PasswordCallback.class)) {
            ((PasswordCallback) callback).setPassword(this.password.toCharArray());
            return false;
        }
        return true;
    }).findFirst().ifPresent(callback -> {
        throw new RuntimeException(new UnsupportedCallbackException(callback, "Unrecognized Callback"));
    });
}
项目:cas-5.1.0    文件:MockLoginModule.java   
@Override
public boolean login() throws LoginException {
    final Callback[] callbacks = new Callback[] {new NameCallback("f"), new PasswordCallback("f", false)};
    try {
        this.callbackHandler.handle(callbacks);
    } catch (final Exception e) {
        throw new LoginException();
    }

    final String userName = ((NameCallback) callbacks[0]).getName();
    final String password = new String(((PasswordCallback) callbacks[1]).getPassword());

    if ("test".equals(userName) && "test".equals(password)) {
        return true;
    }

    throw new LoginException();
}
项目:neoscada    文件:JavaCallbackHandler.java   
private void fillResultFromCallback ( final Callback cb, final javax.security.auth.callback.Callback jcb )
{
    if ( cb instanceof TextCallback && jcb instanceof TextInputCallback )
    {
        ( (TextCallback)cb ).setValue ( ( (TextInputCallback)jcb ).getText () );
    }
    else if ( cb instanceof UserNameCallback && jcb instanceof NameCallback )
    {
        ( (UserNameCallback)cb ).setValue ( ( (NameCallback)jcb ).getName () );
    }
    else if ( cb instanceof PasswordCallback && jcb instanceof javax.security.auth.callback.PasswordCallback )
    {
        ( (PasswordCallback)cb ).setPassword ( String.valueOf ( ( (javax.security.auth.callback.PasswordCallback)jcb ).getPassword () ) );
    }
    else
    {
        cb.cancel ();
    }
}
项目:neoscada    文件:JavaCallbackHandler.java   
private javax.security.auth.callback.Callback convert ( final Callback cb )
{
    if ( cb instanceof UserNameCallback )
    {
        return new NameCallback ( ( (UserNameCallback)cb ).getLabel () );
    }
    else if ( cb instanceof TextCallback )
    {
        return new TextInputCallback ( ( (TextCallback)cb ).getLabel () );
    }
    if ( cb instanceof PasswordCallback )
    {
        return new javax.security.auth.callback.PasswordCallback ( ( (PasswordCallback)cb ).getLabel (), false );
    }
    return null;
}
项目:cas4.0.x-server-wechat    文件:MockLoginModule.java   
public boolean login() throws LoginException {
    final Callback[] callbacks = new Callback[] {new NameCallback("f"), new PasswordCallback("f", false)};
    try {
        this.callbackHandler.handle(callbacks);
    } catch (final Exception e) {
        throw new LoginException();
    }

    final String userName = ((NameCallback) callbacks[0]).getName();
    final String password = new String(((PasswordCallback) callbacks[1]).getPassword());

    if (userName.equals("test") && password.equals("test")) {
        return true;
    }

    throw new LoginException();
}
项目:message-broker    文件:PlainSaslCallbackHandler.java   
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    if (callbacks != null) {
        for (Callback callback : callbacks) {
            if (callback instanceof NameCallback) {
                ((NameCallback) callback).setName(username);
            } else if (callback instanceof PasswordCallback) {
                ((PasswordCallback) callback).setPassword(password);
            } else {
                throw new UnsupportedCallbackException(callback);

            }
        }
        clearCredentials();
    }
}
项目:oscm    文件:UserCredentialsHandler.java   
/**
 * Retrieve or display the information requested in the provided Callbacks.
 * 
 * @param callbacks
 *            an array of <code>Callback</code> objects provided by an
 *            underlying security service which contains the information
 *            requested to be retrieved or displayed.
 * 
 * @throws IOException
 *             if an input or output error occurs.
 * 
 * @throws UnsupportedCallbackException
 *             if the implementation of this method does not support one or
 *             more of the Callbacks specified in the <code>callbacks</code>
 *             parameter.
 */
@Override
public void handle(Callback[] callbacks) throws IOException,
        UnsupportedCallbackException {
    for (Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            ((NameCallback) callback).setName(wsProxyInfo
                    .getUserCredentials().getUser());
        } else if (callback instanceof PasswordCallback) {
            ((PasswordCallback) callback).setPassword(wsProxyInfo
                    .getUserCredentials().getPassword().toCharArray());
        } else {
            throw new UnsupportedCallbackException(callback,
                    "Unrecognized Callback");
        }
    }
}
项目:oscm    文件:WSCallbackHandler.java   
public void handle(Callback[] callbacks)
        throws IOException, UnsupportedCallbackException {
    System.out.println("Callback Handler - handle called");
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof NameCallback) {
            NameCallback nameCallback = (NameCallback) callbacks[i];
            nameCallback.setName(name);
        } else if (callbacks[i] instanceof PasswordCallback) {
            PasswordCallback passwordCallback = (PasswordCallback) callbacks[i];
            passwordCallback.setPassword(password.toCharArray());
        } else {
            throw new UnsupportedCallbackException(callbacks[i],
                    "The submitted Callback is unsupported");
        }
    }
}
项目:cas-server-4.2.1    文件:MockLoginModule.java   
@Override
public boolean login() throws LoginException {
    final Callback[] callbacks = new Callback[] {new NameCallback("f"), new PasswordCallback("f", false)};
    try {
        this.callbackHandler.handle(callbacks);
    } catch (final Exception e) {
        throw new LoginException();
    }

    final String userName = ((NameCallback) callbacks[0]).getName();
    final String password = new String(((PasswordCallback) callbacks[1]).getPassword());

    if ("test".equals(userName) && "test".equals(password)) {
        return true;
    }

    throw new LoginException();
}
项目:mongosql-auth-java    文件:Plain.java   
static SaslClient createSaslClient(final String user, final String password) throws SaslException {
    return Sasl.createSaslClient(new String[]{"PLAIN"}, user, null, null, null,
            new CallbackHandler() {
                @Override
                public void handle(final Callback[] callbacks)
                        throws IOException, UnsupportedCallbackException {
                    for (final Callback callback : callbacks) {
                        if (callback instanceof PasswordCallback) {
                            ((PasswordCallback) callback).setPassword(password.toCharArray());
                        } else if (callback instanceof NameCallback) {
                            ((NameCallback) callback).setName(user);
                        }
                    }
                }
            });
}
项目:Transwarp-Sample-Code    文件:KerberosAuthenticator2.java   
public void handle(Callback[] callbacks) throws IOException,
        UnsupportedCallbackException {
    for (Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            NameCallback ncb = (NameCallback) callback;
            ncb.setName(username);
        } else if (callback instanceof PasswordCallback) {
            PasswordCallback pwcb = (PasswordCallback) callback;
            pwcb.setPassword(password.toCharArray());
        } else {
            throw new UnsupportedCallbackException(
                    callback,
                    "We got a "
                            + callback.getClass().getCanonicalName()
                            + ", but only NameCallback and PasswordCallback is supported");
        }
    }
}
项目:dev-courses    文件:JaasAuthBean.java   
public void handle(Callback[] callbacks)
        throws UnsupportedCallbackException {
    boolean didSetName = false;
    boolean didSetPassword = false;
    for (Callback cb : callbacks)
        if (cb instanceof NameCallback) {
            ((NameCallback) cb).setName(u);
            didSetName = true;
        } else if (cb instanceof PasswordCallback) {
            ((PasswordCallback) cb).setPassword(p);
            didSetPassword = true;
        } else {
            throw new UnsupportedCallbackException(cb,
                    "Unsupported Callback type: "
                    + cb.getClass().getName());
        }
    if (!didSetName)
        throw new IllegalStateException(
                "Supplied Callbacks does not include a NameCallback");
    if (!didSetPassword)
        throw new IllegalStateException("Supplied Callbacks "
                + "does not include a PasswordCallback");
}
项目:OpenJSharp    文件:NegotiateCallbackHandler.java   
public void handle(Callback[] callbacks) throws
        UnsupportedCallbackException, IOException {
    for (int i=0; i<callbacks.length; i++) {
        Callback callBack = callbacks[i];

        if (callBack instanceof NameCallback) {
            getAnswer();
            ((NameCallback)callBack).setName(username);
        } else if (callBack instanceof PasswordCallback) {
            getAnswer();
            ((PasswordCallback)callBack).setPassword(password);
            if (password != null) Arrays.fill(password, ' ');
        } else {
            throw new UnsupportedCallbackException(callBack,
                    "Call back not supported");
        }
    }
}
项目:jerrydog    文件:JAASCallbackHandler.java   
/**
 * Retrieve the information requested in the provided Callbacks.  This
 * implementation only recognizes <code>NameCallback</code> and
 * <code>PasswordCallback</code> instances.
 *
 * @param callbacks The set of callbacks to be processed
 *
 * @exception IOException if an input/output error occurs
 * @exception UnsupportedCallbackException if the login method requests
 *  an unsupported callback type
 */
public void handle(Callback callbacks[])
    throws IOException, UnsupportedCallbackException {

    for (int i = 0; i < callbacks.length; i++) {

        if (callbacks[i] instanceof NameCallback) {
            if (realm.getDebug() >= 3)
                realm.log("Returning username " + username);
            ((NameCallback) callbacks[i]).setName(username);
        } else if (callbacks[i] instanceof PasswordCallback) {
            if (realm.getDebug() >= 3)
                realm.log("Returning password " + password);
            ((PasswordCallback) callbacks[i]).setPassword
                (password.toCharArray());
        } else {
            throw new UnsupportedCallbackException(callbacks[i]);
        }


    }

}
项目:OperatieBRP    文件:JMXCallbackHandler.java   
/**
 * Handles the callbacks; only supports {@link NameCallback} and {@link PasswordCallback}.
 * @throws UnsupportedCallbackException if an unsupported callback is encountered
 */
@Override
public void handle(final Callback[] callbacks)
        throws UnsupportedCallbackException {

    for (final Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            ((NameCallback) callback).setName(username);

        } else if (callback instanceof PasswordCallback) {
            ((PasswordCallback) callback)
                    .setPassword(password.toCharArray());

        } else {
            throw new UnsupportedCallbackException
                    (callback, "Unrecognized Callback");
        }
    }
}
项目:kafka-0.11.0.0-src-with-comment    文件:TestDigestLoginModule.java   
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            NameCallback nameCallback = (NameCallback) callback;
            nameCallback.setName(nameCallback.getDefaultName());
        } else if (callback instanceof PasswordCallback) {
            PasswordCallback passwordCallback = (PasswordCallback) callback;
            passwordCallback.setPassword(TestJaasConfig.PASSWORD.toCharArray());
        } else if (callback instanceof RealmCallback) {
            RealmCallback realmCallback = (RealmCallback) callback;
            realmCallback.setText(realmCallback.getDefaultText());
        } else if (callback instanceof AuthorizeCallback) {
            AuthorizeCallback authCallback = (AuthorizeCallback) callback;
            if (TestJaasConfig.USERNAME.equals(authCallback.getAuthenticationID())) {
                authCallback.setAuthorized(true);
                authCallback.setAuthorizedID(authCallback.getAuthenticationID());
            }
        }
    }
}
项目:jdk8u-jdk    文件:NegotiateCallbackHandler.java   
public void handle(Callback[] callbacks) throws
        UnsupportedCallbackException, IOException {
    for (int i=0; i<callbacks.length; i++) {
        Callback callBack = callbacks[i];

        if (callBack instanceof NameCallback) {
            getAnswer();
            ((NameCallback)callBack).setName(username);
        } else if (callBack instanceof PasswordCallback) {
            getAnswer();
            ((PasswordCallback)callBack).setPassword(password);
            if (password != null) Arrays.fill(password, ' ');
        } else {
            throw new UnsupportedCallbackException(callBack,
                    "Call back not supported");
        }
    }
}
项目:jdk8u-jdk    文件:DynamicConfigurationTest.java   
@Override
public void handle(Callback[] callbacks) throws IOException,
        UnsupportedCallbackException {
    for (Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            NameCallback nc = (NameCallback) callback;
            nc.setName(userName);
        } else if (callback instanceof PasswordCallback) {
            PasswordCallback pc = (PasswordCallback) callback;
            pc.setPassword(password);
        } else {
            throw new UnsupportedCallbackException(callback,
                    "Unrecognized Callback");
        }
    }
}
项目:openjdk-jdk10    文件:NegotiateCallbackHandler.java   
public void handle(Callback[] callbacks) throws
        UnsupportedCallbackException, IOException {
    for (int i=0; i<callbacks.length; i++) {
        Callback callBack = callbacks[i];

        if (callBack instanceof NameCallback) {
            getAnswer();
            ((NameCallback)callBack).setName(username);
        } else if (callBack instanceof PasswordCallback) {
            getAnswer();
            ((PasswordCallback)callBack).setPassword(password);
            if (password != null) Arrays.fill(password, ' ');
        } else {
            throw new UnsupportedCallbackException(callBack,
                    "Call back not supported");
        }
    }
}
项目:openjdk-jdk10    文件:TestCallbackHandler.java   
@Override
public void handle(Callback[] callbacks) throws IOException,
        UnsupportedCallbackException {
    System.out.println("TestCallbackHandler will get resolved through"
            + " auth.login.defaultCallbackHandler property.");
    for (Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            ((NameCallback) callback).setName(USER_NAME);
        } else if (callback instanceof PasswordCallback) {
            ((PasswordCallback) callback).setPassword(
                    PASSWORD.toCharArray());
        } else {
            throw new UnsupportedCallbackException(callback);
        }
    }
}
项目:openjdk-jdk10    文件:DynamicConfigurationTest.java   
@Override
public void handle(Callback[] callbacks) throws IOException,
        UnsupportedCallbackException {
    for (Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            NameCallback nc = (NameCallback) callback;
            nc.setName(userName);
        } else if (callback instanceof PasswordCallback) {
            PasswordCallback pc = (PasswordCallback) callback;
            pc.setPassword(password);
        } else {
            throw new UnsupportedCallbackException(callback,
                    "Unrecognized Callback");
        }
    }
}
项目:ditb    文件:TestHBaseSaslRpcClient.java   
@Test
public void testSaslClientCallbackHandler() throws UnsupportedCallbackException {
  final Token<? extends TokenIdentifier> token = createTokenMock();
  when(token.getIdentifier()).thenReturn(DEFAULT_USER_NAME.getBytes());
  when(token.getPassword()).thenReturn(DEFAULT_USER_PASSWORD.getBytes());

  final NameCallback nameCallback = mock(NameCallback.class);
  final PasswordCallback passwordCallback = mock(PasswordCallback.class);
  final RealmCallback realmCallback = mock(RealmCallback.class);
  final RealmChoiceCallback realmChoiceCallback = mock(RealmChoiceCallback.class);

  Callback[] callbackArray = {nameCallback, passwordCallback,
      realmCallback, realmChoiceCallback};
  final SaslClientCallbackHandler saslClCallbackHandler = new SaslClientCallbackHandler(token);
  saslClCallbackHandler.handle(callbackArray);
  verify(nameCallback).setName(anyString());
  verify(realmCallback).setText(anyString());
  verify(passwordCallback).setPassword(any(char[].class));
}
项目:openjdk9    文件:NegotiateCallbackHandler.java   
public void handle(Callback[] callbacks) throws
        UnsupportedCallbackException, IOException {
    for (int i=0; i<callbacks.length; i++) {
        Callback callBack = callbacks[i];

        if (callBack instanceof NameCallback) {
            getAnswer();
            ((NameCallback)callBack).setName(username);
        } else if (callBack instanceof PasswordCallback) {
            getAnswer();
            ((PasswordCallback)callBack).setPassword(password);
            if (password != null) Arrays.fill(password, ' ');
        } else {
            throw new UnsupportedCallbackException(callBack,
                    "Call back not supported");
        }
    }
}
项目:drill    文件:PlainFactory.java   
@Override
public SaslClient createSaslClient(final UserGroupInformation ugi, final Map<String, ?> properties)
    throws SaslException {
  final String userName = (String) properties.get(DrillProperties.USER);
  final String password = (String) properties.get(DrillProperties.PASSWORD);

  return FastSaslClientFactory.getInstance().createSaslClient(new String[]{SIMPLE_NAME},
      null /** authorization ID */, null, null, properties, new CallbackHandler() {
        @Override
        public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException {
          for (final Callback callback : callbacks) {
            if (callback instanceof NameCallback) {
              NameCallback.class.cast(callback).setName(userName);
              continue;
            }
            if (callback instanceof PasswordCallback) {
              PasswordCallback.class.cast(callback).setPassword(password.toCharArray());
              continue;
            }
            throw new UnsupportedCallbackException(callback);
          }
        }
      });
}
项目:openjdk9    文件:DynamicConfigurationTest.java   
@Override
public void handle(Callback[] callbacks) throws IOException,
        UnsupportedCallbackException {
    for (Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            NameCallback nc = (NameCallback) callback;
            nc.setName(userName);
        } else if (callback instanceof PasswordCallback) {
            PasswordCallback pc = (PasswordCallback) callback;
            pc.setPassword(password);
        } else {
            throw new UnsupportedCallbackException(callback,
                    "Unrecognized Callback");
        }
    }
}
项目:cloud-meter    文件:KerberosManager.java   
@Override
public void handle(Callback[] callbacks) throws IOException,
        UnsupportedCallbackException {
    for (Callback callback : callbacks) {
        if (callback instanceof NameCallback && username != null) {
            NameCallback nc = (NameCallback) callback;
            nc.setName(username);
        } else if (callback instanceof PasswordCallback) {
            PasswordCallback pc = (PasswordCallback) callback;
            pc.setPassword(password.toCharArray());
        } else {
            throw new UnsupportedCallbackException( callback,
                    "Unrecognized Callback"); //$NON-NLS-1$
        }
    }
}
项目:ipst    文件:OfflineApplicationSecurity.java   
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            // prompt the user for a username
            NameCallback nameCallback = (NameCallback) callback;
            nameCallback.setName(username);
        } else if (callback instanceof PasswordCallback) {
            // prompt the user for a password
            PasswordCallback passwordCallback = (PasswordCallback) callback;
            passwordCallback.setPassword(password.toCharArray());
        } else {
            throw new UnsupportedCallbackException(callback, "Unrecognized Callback");
        }
    }
}
项目:helium    文件:EjbUtil.java   
public void handle(
        Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof NameCallback) {
            NameCallback ncb = (NameCallback) callbacks[i];
            ncb.setName(username);
        } else if (callbacks[i] instanceof PasswordCallback) {
            PasswordCallback pcb = (PasswordCallback) callbacks[i];
            pcb.setPassword(password.toCharArray());
        } else {
            throw new UnsupportedCallbackException(
                    callbacks[i],
                    "Unrecognized Callback");
        }
    }
}
项目:kafka    文件:AbstractLogin.java   
@Override
public void handle(Callback[] callbacks) throws UnsupportedCallbackException {
    for (Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            NameCallback nc = (NameCallback) callback;
            nc.setName(nc.getDefaultName());
        } else if (callback instanceof PasswordCallback) {
            String errorMessage = "Could not login: the client is being asked for a password, but the Kafka" +
                         " client code does not currently support obtaining a password from the user.";
            throw new UnsupportedCallbackException(callback, errorMessage);
        } else if (callback instanceof RealmCallback) {
            RealmCallback rc = (RealmCallback) callback;
            rc.setText(rc.getDefaultText());
        } else {
            throw new UnsupportedCallbackException(callback, "Unrecognized SASL Login callback");
        }
    }
}
项目:kafka    文件:TestDigestLoginModule.java   
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            NameCallback nameCallback = (NameCallback) callback;
            nameCallback.setName(nameCallback.getDefaultName());
        } else if (callback instanceof PasswordCallback) {
            PasswordCallback passwordCallback = (PasswordCallback) callback;
            passwordCallback.setPassword(TestJaasConfig.PASSWORD.toCharArray());
        } else if (callback instanceof RealmCallback) {
            RealmCallback realmCallback = (RealmCallback) callback;
            realmCallback.setText(realmCallback.getDefaultText());
        } else if (callback instanceof AuthorizeCallback) {
            AuthorizeCallback authCallback = (AuthorizeCallback) callback;
            if (TestJaasConfig.USERNAME.equals(authCallback.getAuthenticationID())) {
                authCallback.setAuthorized(true);
                authCallback.setAuthorizedID(authCallback.getAuthenticationID());
            }
        }
    }
}
项目:sistra    文件:UsernamePasswordCallbackHandler.java   
public void handle(Callback[] callbacks)
        throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof NameCallback) {
            NameCallback ncb = (NameCallback) callbacks[i];
            ncb.setName(username);
        }
        else if (callbacks[i] instanceof PasswordCallback) {
            PasswordCallback pcb = (PasswordCallback) callbacks[i];
            pcb.setPassword(password.toCharArray());
        }
        else {
            throw new UnsupportedCallbackException
                    (callbacks[i], "Unrecognized Callback");
        }
    }
}
项目:sistra    文件:UsernamePasswordCallbackHandler.java   
public void handle(Callback[] callbacks)
        throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof NameCallback) {
            NameCallback ncb = (NameCallback) callbacks[i];
            ncb.setName(username);
        }
        else if (callbacks[i] instanceof PasswordCallback) {
            PasswordCallback pcb = (PasswordCallback) callbacks[i];
            pcb.setPassword(password.toCharArray());
        }
        else {
            throw new UnsupportedCallbackException
                    (callbacks[i], "Unrecognized Callback");
        }
    }
}
项目:sistra    文件:UsernamePasswordCallbackHandler.java   
public void handle(Callback[] callbacks)
        throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof NameCallback) {
            NameCallback ncb = (NameCallback) callbacks[i];
            ncb.setName(username);
        }
        else if (callbacks[i] instanceof PasswordCallback) {
            PasswordCallback pcb = (PasswordCallback) callbacks[i];
            pcb.setPassword(password.toCharArray());
        }
        else {
            throw new UnsupportedCallbackException
                    (callbacks[i], "Unrecognized Callback");
        }
    }
}
项目:sistra    文件:UsernamePasswordCallbackHandler.java   
public void handle(Callback[] callbacks)
        throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof NameCallback) {
            NameCallback ncb = (NameCallback) callbacks[i];
            ncb.setName(username);
        }
        else if (callbacks[i] instanceof PasswordCallback) {
            PasswordCallback pcb = (PasswordCallback) callbacks[i];
            pcb.setPassword(password.toCharArray());
        }
        else {
            throw new UnsupportedCallbackException
                    (callbacks[i], "Unrecognized Callback");
        }
    }
}
项目:sistra    文件:UsernamePasswordCallbackHandler.java   
public void handle(Callback[] callbacks)
        throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof NameCallback) {
            NameCallback ncb = (NameCallback) callbacks[i];
            ncb.setName(username);
        }
        else if (callbacks[i] instanceof PasswordCallback) {
            PasswordCallback pcb = (PasswordCallback) callbacks[i];
            pcb.setPassword(password.toCharArray());
        }
        else {
            throw new UnsupportedCallbackException
                    (callbacks[i], "Unrecognized Callback");
        }
    }
}