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");
}
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");
}
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");
}
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);
}
}
});
}
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());
}
}
}
Aggregations