Search in sources :

Example 86 with PasswordCallback

use of javax.security.auth.callback.PasswordCallback in project jmulticard by ctt-gob-es.

the class Ceres method getInternalPasswordCallback.

protected PasswordCallback getInternalPasswordCallback() throws PinException {
    if (this.passwordCallback != null) {
        final int retriesLeft = getPinRetriesLeft();
        if (retriesLeft == 0) {
            throw new AuthenticationModeLockedException();
        }
        return this.passwordCallback;
    }
    if (this.callbackHandler != null) {
        final int retriesLeft = getPinRetriesLeft();
        if (retriesLeft == 0) {
            throw new AuthenticationModeLockedException();
        }
        final PasswordCallback pwc = new PasswordCallback(// $NON-NLS-1$
        CardMessages.getString("Gen.0", Integer.toString(retriesLeft)), false);
        try {
            this.callbackHandler.handle(new Callback[] { pwc });
        } catch (final IOException e) {
            throw new PinException(// $NON-NLS-1$
            "Error obteniendo el PIN del CallbackHandler: " + e, // $NON-NLS-1$
            e);
        } catch (final UnsupportedCallbackException e) {
            throw new PinException(// $NON-NLS-1$
            "El CallbackHandler no soporta pedir el PIN al usuario: " + e, // $NON-NLS-1$
            e);
        }
        return pwc;
    }
    // $NON-NLS-1$
    throw new PinException("No hay ningun metodo para obtener el PIN");
}
Also used : AuthenticationModeLockedException(es.gob.jmulticard.card.AuthenticationModeLockedException) PasswordCallback(javax.security.auth.callback.PasswordCallback) IOException(java.io.IOException) BadPinException(es.gob.jmulticard.card.BadPinException) PinException(es.gob.jmulticard.card.PinException) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException)

Example 87 with PasswordCallback

use of javax.security.auth.callback.PasswordCallback in project jmulticard by ctt-gob-es.

the class SmartCafePkcs15Applet method getInternalPasswordCallback.

private PasswordCallback getInternalPasswordCallback() throws PinException {
    if (this.passwordCallback != null) {
        final int retriesLeft = getPinRetriesLeft();
        if (retriesLeft == 0) {
            throw new AuthenticationModeLockedException();
        }
        return this.passwordCallback;
    }
    if (this.callbackHandler != null) {
        final int retriesLeft = getPinRetriesLeft();
        if (retriesLeft == 0) {
            throw new AuthenticationModeLockedException();
        }
        final PasswordCallback pwc = new PasswordCallback(// $NON-NLS-1$
        CardMessages.getString("Gen.0", Integer.toString(retriesLeft)), false);
        try {
            this.callbackHandler.handle(new Callback[] { pwc });
        } catch (final IOException e) {
            throw new PinException(// $NON-NLS-1$
            "Error obteniendo el PIN del CallbackHandler: " + e, // $NON-NLS-1$
            e);
        } catch (final UnsupportedCallbackException e) {
            throw new PinException(// $NON-NLS-1$
            "El CallbackHandler no soporta pedir el PIN al usuario: " + e, // $NON-NLS-1$
            e);
        }
        return pwc;
    }
    // $NON-NLS-1$
    throw new PinException("No hay ningun metodo para obtener el PIN");
}
Also used : AuthenticationModeLockedException(es.gob.jmulticard.card.AuthenticationModeLockedException) PasswordCallback(javax.security.auth.callback.PasswordCallback) IOException(java.io.IOException) BadPinException(es.gob.jmulticard.card.BadPinException) PinException(es.gob.jmulticard.card.PinException) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException)

Example 88 with PasswordCallback

use of javax.security.auth.callback.PasswordCallback in project jmulticard by ctt-gob-es.

the class Dnie method getInternalPasswordCallback.

protected PasswordCallback getInternalPasswordCallback() throws PinException {
    if (this.passwordCallback != null) {
        final int retriesLeft = getPinRetriesLeft();
        if (retriesLeft == 0) {
            throw new AuthenticationModeLockedException();
        }
        return this.passwordCallback;
    }
    if (this.callbackHandler != null) {
        final int retriesLeft = getPinRetriesLeft();
        if (retriesLeft == 0) {
            throw new AuthenticationModeLockedException();
        }
        final PasswordCallback pwc = new PasswordCallback(getPinMessage(retriesLeft), false);
        try {
            this.callbackHandler.handle(new Callback[] { pwc });
        } catch (final IOException e) {
            throw new PinException(// $NON-NLS-1$
            "Error obteniendo el PIN del CallbackHandler: " + e, // $NON-NLS-1$
            e);
        } catch (final UnsupportedCallbackException e) {
            throw new PinException(// $NON-NLS-1$
            "El CallbackHandler no soporta pedir el PIN al usuario: " + e, // $NON-NLS-1$
            e);
        }
        if (pwc.getPassword() == null || pwc.getPassword().toString().isEmpty()) {
            throw new PinException(// $NON-NLS-1$
            "El PIN no puede ser nulo ni vacio");
        }
        return pwc;
    }
    // $NON-NLS-1$
    throw new PinException("No hay ningun metodo para obtener el PIN");
}
Also used : AuthenticationModeLockedException(es.gob.jmulticard.card.AuthenticationModeLockedException) PasswordCallback(javax.security.auth.callback.PasswordCallback) IOException(java.io.IOException) BadPinException(es.gob.jmulticard.card.BadPinException) PinException(es.gob.jmulticard.card.PinException) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException)

Example 89 with PasswordCallback

use of javax.security.auth.callback.PasswordCallback in project drill by axbaretto.

the class PlainFactory method createSaslClient.

@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);
            }
        }
    });
}
Also used : CallbackHandler(javax.security.auth.callback.CallbackHandler) PasswordCallback(javax.security.auth.callback.PasswordCallback) NameCallback(javax.security.auth.callback.NameCallback) Callback(javax.security.auth.callback.Callback) NameCallback(javax.security.auth.callback.NameCallback) PasswordCallback(javax.security.auth.callback.PasswordCallback) IOException(java.io.IOException) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException)

Example 90 with PasswordCallback

use of javax.security.auth.callback.PasswordCallback in project polymap4-core by Polymap4.

the class ServicesCallbackHandler method handle.

// instance *******************************************
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    String[] userPasswd = challenge.get();
    challenge.set(null);
    for (Callback callback : callbacks) {
        if (callback instanceof NameCallback) {
            ((NameCallback) callback).setName(userPasswd[0]);
        } else if (callback instanceof PasswordCallback) {
            ((PasswordCallback) callback).setPassword(userPasswd[1].toCharArray());
        }
    }
}
Also used : PasswordCallback(javax.security.auth.callback.PasswordCallback) NameCallback(javax.security.auth.callback.NameCallback) Callback(javax.security.auth.callback.Callback) NameCallback(javax.security.auth.callback.NameCallback) PasswordCallback(javax.security.auth.callback.PasswordCallback)

Aggregations

PasswordCallback (javax.security.auth.callback.PasswordCallback)316 NameCallback (javax.security.auth.callback.NameCallback)255 Callback (javax.security.auth.callback.Callback)207 UnsupportedCallbackException (javax.security.auth.callback.UnsupportedCallbackException)167 IOException (java.io.IOException)102 LoginException (javax.security.auth.login.LoginException)72 CallbackHandler (javax.security.auth.callback.CallbackHandler)66 LoginContext (javax.security.auth.login.LoginContext)39 FailedLoginException (javax.security.auth.login.FailedLoginException)35 RealmCallback (javax.security.sasl.RealmCallback)35 Subject (javax.security.auth.Subject)31 Test (org.junit.Test)28 ConfirmationCallback (javax.security.auth.callback.ConfirmationCallback)26 AuthorizeCallback (javax.security.sasl.AuthorizeCallback)26 ChoiceCallback (javax.security.auth.callback.ChoiceCallback)24 Principal (java.security.Principal)21 AuthLoginException (com.sun.identity.authentication.spi.AuthLoginException)18 TextOutputCallback (javax.security.auth.callback.TextOutputCallback)18 HashMap (java.util.HashMap)16 Test (org.testng.annotations.Test)15