final String text = inputCallback.getText(); if (text == null) { final String defaultText = inputCallback.getDefaultText(); if (defaultText != null) { inputCallback.setText(defaultText); } else { CallbackUtil.unsupported(callback);
@SuppressWarnings("unchecked") public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { this.subject = subject; try { TextInputCallback textCallback = new TextInputCallback("prompt"); NameCallback nameCallback = new NameCallback("prompt"); PasswordCallback passwordCallback = new PasswordCallback("prompt", false); callbackHandler.handle(new Callback[] { textCallback, nameCallback, passwordCallback }); password = new String(passwordCallback.getPassword()); user = nameCallback.getName(); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (final Callback cb : callbacks) { if (cb instanceof TextInputCallback) { final TextInputCallback ticb = (TextInputCallback)cb; final String prompt = ticb.getPrompt(); log.info("Got prompt: {}", prompt); if (prompt == "clientID") { ticb.setText(clientID); } else if (prompt == "clientSecret") { ticb.setText(clientSecret); } else if (prompt == "accessToken") { ticb.setText(accessToken); } else if (prompt == "refreshToken") { ticb.setText(refreshToken); } else { throw new UnsupportedCallbackException(ticb, "Unrecognized prompt: " + ticb.getPrompt()); } } else { throw new UnsupportedCallbackException(cb, "Unsupported callback type."); } } }
private String getCatalinaBase() { // Have to get this via a callback as that is the only link we have back // to the defining Realm. Can't use the system property as that may not // be set/correct in an embedded scenario if (callbackHandler == null) { return null; } Callback callbacks[] = new Callback[1]; callbacks[0] = new TextInputCallback("catalinaBase"); String result = null; try { callbackHandler.handle(callbacks); result = ((TextInputCallback) callbacks[0]).getText(); } catch (IOException | UnsupportedCallbackException e) { return null; } return result; } }
public void handle(Callback callback, Authentication auth) throws IOException, UnsupportedCallbackException { if (callback instanceof TextInputCallback) { TextInputCallback tic = (TextInputCallback) callback; tic.setText(auth.getPrincipal().toString()); } } }
TextInputCallback call = (TextInputCallback)callbacks[i]; label = new Label(shell,SWT.NONE); label.setText(call.getPrompt()); control = new Text(shell,SWT.BORDER); if(call.getDefaultText()!=null) { ((Text)control).setText(call.getDefaultText());
@Override public boolean identify(final Subject subject) throws LoginException { if (restSessionManager == null) { return false; } boolean result = false; final String token = restTokenCB.getText(); final String remoteAddr = remoteAddrCB.getText(); if (token != null && remoteAddr != null) { final Subject s = restSessionManager.authenticate(token, remoteAddr); if (s != null) { result = true; updateFromSubject(subject, s); logger.log(PROGRESS_LEVEL, "Detected ReST token"); } } return result; } }
@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); } else if (callback instanceof TextInputCallback) { final TextInputCallback cb = TextInputCallback.class.cast(callback); if (cb.getPrompt().equals("authMethod")) { cb.setText(authenticationMethod); } else if (cb.getPrompt().equals("algorithm")) { cb.setText(algorithm); } else if (cb.getPrompt().equals("signature")) { cb.setText(clientSignature); } else { throw new UnsupportedCallbackException(callback); } } else { throw new UnsupportedCallbackException(callback); } } } });
private String getCatalinaBase() { // Have to get this via a callback as that is the only link we have back // to the defining Realm. Can't use the system property as that may not // be set/correct in an embedded scenario if (callbackHandler == null) { return null; } Callback callbacks[] = new Callback[1]; callbacks[0] = new TextInputCallback("catalinaBase"); String result = null; try { callbackHandler.handle(callbacks); result = ((TextInputCallback) callbacks[0]).getText(); } catch (IOException | UnsupportedCallbackException e) { return null; } return result; } }
tc.setText(text);
TextInputCallback call = (TextInputCallback)callbacks[i]; label = new Label(shell,SWT.NONE); label.setText(call.getPrompt()); control = new Text(shell,SWT.BORDER); if(call.getDefaultText()!=null) { ((Text)control).setText(call.getDefaultText());
@Override public boolean identify(Subject subject) throws LoginException { if (secureAdmin == null) { return false; } final String providedIndicator = textCB.getText(); final SpecialAdminIndicatorChecker checker = new SpecialAdminIndicatorChecker( providedIndicator, secureAdmin.getSpecialAdminIndicator(), remoteHostAuth.textCB.getText()); if (checker.result() == SpecialAdminIndicatorChecker.Result.MISMATCHED) { throw new LoginException(); } /* * Either there was no special indicator or there was one and * it matched what we expect. */ if (checker.result() == SpecialAdminIndicatorChecker.Result.MATCHED) { /* * Add a principal indicating that this subject represents * another server in the domain and so we * can trust it completely, even if the request is remote and secure * admin is disabled. */ subject.getPrincipals().add(new AdminIndicatorPrincipal(providedIndicator)); return true; } return false; } }
@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); } else if (callback instanceof TextInputCallback) { final TextInputCallback cb = TextInputCallback.class.cast(callback); if (cb.getPrompt().equals("authMethod")) { cb.setText(HttpServletRequest.CLIENT_CERT_AUTH); } else { throw new UnsupportedCallbackException(callback); } } else { throw new UnsupportedCallbackException(callback); } } } }
final String text = inputCallback.getText(); if (text == null) { final String defaultText = inputCallback.getDefaultText(); if (defaultText != null) { inputCallback.setText(defaultText); } else { CallbackUtil.unsupported(callback);
callbacks[0] = new NameCallback("Username: "); callbacks[1] = new PasswordCallback("Password: ", false); callbacks[2] = new TextInputCallback("nonce"); callbacks[3] = new TextInputCallback("nc"); callbacks[4] = new TextInputCallback("cnonce"); callbacks[5] = new TextInputCallback("qop"); callbacks[6] = new TextInputCallback("realmName"); callbacks[7] = new TextInputCallback("md5a2"); callbacks[8] = new TextInputCallback("authMethod"); password = new String(((PasswordCallback) callbacks[1]).getPassword()); nonce = ((TextInputCallback) callbacks[2]).getText(); nc = ((TextInputCallback) callbacks[3]).getText(); cnonce = ((TextInputCallback) callbacks[4]).getText(); qop = ((TextInputCallback) callbacks[5]).getText(); realmName = ((TextInputCallback) callbacks[6]).getText(); md5a2 = ((TextInputCallback) callbacks[7]).getText(); authMethod = ((TextInputCallback) callbacks[8]).getText(); } catch (IOException e) { throw new LoginException(e.toString());
tc.setText(text);
@Override public boolean identify(Subject subject) throws LoginException { if (authTokenManager == null) { return false; } Subject s = null; final String token = textCB.getText(); if (token != null) { s = authTokenManager.findToken(token); if (s != null) { /* * The token manager knows which Subject was effective when the token * was created. We add those to the lists we'll add if this module's * commit is invoked. */ logger.log(PROGRESS_LEVEL, "Recognized valid limited-use token"); updateFromSubject(subject, s); /* * Add an additional principal indicating that we trust this * subject to make remote requests. Otherwise we would * reject attempts to use a token from off-node, and that's * partly the whole point of tokens. */ subject.getPrincipals().add(new AdminTokenPrincipal(token)); } } return s != null; } }
TextAuthenticator(final AuthenticatorType type) { super(type, new TextInputCallback(type.name())); textCB = (TextInputCallback) cb; } }
} else if (callback instanceof TextInputCallback) { final TextInputCallback cb = TextInputCallback.class.cast(callback); if (cb.getPrompt().equals("nonce")) { cb.setText(nonce); } else if (cb.getPrompt().equals("nc")) { cb.setText(nc); } else if (cb.getPrompt().equals("cnonce")) { cb.setText(cnonce); } else if (cb.getPrompt().equals("qop")) { cb.setText(qop); } else if (cb.getPrompt().equals("realmName")) { cb.setText(realmName); } else if (cb.getPrompt().equals("md5a2")) { cb.setText(md5a2); } else if (cb.getPrompt().equals("authMethod")) { cb.setText(HttpServletRequest.DIGEST_AUTH); } else { throw new UnsupportedCallbackException(callback);
final String text = inputCallback.getText(); if (text == null) { final String defaultText = inputCallback.getDefaultText(); if (defaultText != null) { inputCallback.setText(defaultText); } else { CallbackUtil.unsupported(callback);