use of javax.security.auth.callback.UnsupportedCallbackException 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.UnsupportedCallbackException 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.UnsupportedCallbackException 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.UnsupportedCallbackException 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.UnsupportedCallbackException in project activemq-artemis by apache.
the class GSSAPIServerSASL method processSASL.
@Override
public byte[] processSASL(byte[] bytes) {
try {
if (jaasId == null) {
// populate subject with acceptor private credentials
LoginContext loginContext = new LoginContext(loginConfigScope);
loginContext.login();
jaasId = loginContext.getSubject();
}
if (saslServer == null) {
saslServer = Subject.doAs(jaasId, (PrivilegedExceptionAction<SaslServer>) () -> Sasl.createSaslServer(NAME, null, null, new HashMap<String, String>(), new CallbackHandler() {
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
for (Callback callback : callbacks) {
if (callback instanceof AuthorizeCallback) {
AuthorizeCallback authorizeCallback = (AuthorizeCallback) callback;
// only ok to authenticate as self
authorizeCallback.setAuthorized(authorizeCallback.getAuthenticationID().equals(authorizeCallback.getAuthorizationID()));
}
}
}
}));
}
byte[] challenge = Subject.doAs(jaasId, (PrivilegedExceptionAction<byte[]>) () -> saslServer.evaluateResponse(bytes));
if (saslServer.isComplete()) {
result = new PrincipalSASLResult(true, new KerberosPrincipal(saslServer.getAuthorizationID()));
}
return challenge;
} catch (Exception outOfHere) {
log.info("Error on sasl input: " + outOfHere.toString(), outOfHere);
result = new PrincipalSASLResult(false, null);
}
return null;
}
Aggregations