Package javax.security.auth.callback

Examples of javax.security.auth.callback.NameCallback


    public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException {
        final SecurityContext context = doPrivileged(securityContext());

        for (final Callback current : callbacks) {
            if (current instanceof NameCallback) {
                final NameCallback ncb = (NameCallback) current;
                if (context != null) {
                    final Set<Identity> identities = context.getSubjectInfo().getIdentities();
                    if (identities.isEmpty()) {
                        ncb.setName(DOLLAR_LOCAL);
                    } else {
                        final Identity identity = identities.iterator().next();
                        ncb.setName(identity.getName());
                    }
                } else {
                    ncb.setName(DOLLAR_LOCAL);
                }
            } else if (current instanceof PasswordCallback) {
                if (context != null) {
                    final PasswordCallback pcb = (PasswordCallback) current;
                    final Set<Identity> identities = context.getSubjectInfo().getIdentities();
View Full Code Here


      }

      try
      {
         Callback[] nameCallback = {new NameCallback("Username")};
         callbackHandler.handle(nameCallback);
         username = ((NameCallback)nameCallback[0]).getName();
      }
      catch (UnsupportedCallbackException e)
      {
View Full Code Here

   {
      String username = null;

      try
      {
         Callback[] nameCallback = {new NameCallback("Username")};
         callbackHandler.handle(nameCallback);
         username = ((NameCallback)nameCallback[0]).getName();
      }
      catch (UnsupportedCallbackException e)
      {
View Full Code Here

      passwordContext.put("nc", (String)mapCallback[0].getInfo("nc"));
      passwordContext.put("realm", (String)mapCallback[0].getInfo("realm"));

      try
      {
         Callback[] nameCallback = {new NameCallback("Username")};
         callbackHandler.handle(nameCallback);
         username = ((NameCallback)nameCallback[0]).getName();
      }
      catch (UnsupportedCallbackException e)
      {
View Full Code Here

   {
      String username = null;

      try
      {
         Callback[] nameCallback = {new NameCallback("Username")};
         callbackHandler.handle(nameCallback);
         username = ((NameCallback)nameCallback[0]).getName();
      }
      catch (UnsupportedCallbackException e)
      {
View Full Code Here

                if (current instanceof RealmCallback) {
                    RealmCallback rcb = (RealmCallback) current;
                    String defaultText = rcb.getDefaultText();
                    rcb.setText(defaultText); // For now just use the realm suggested.
                } else if (current instanceof NameCallback) {
                    NameCallback ncb = (NameCallback) current;
                    ncb.setName(username);
                } else if (current instanceof PasswordCallback) {
                    PasswordCallback pcb = (PasswordCallback) current;
                    if (password != null) {
                        pcb.setPassword(password.toCharArray());
                    }
View Full Code Here

    public static class CallbackHandler implements javax.security.auth.callback.CallbackHandler {

        public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
            for (Callback current : callbacks) {
                if (current instanceof NameCallback) {
                    NameCallback ncb = (NameCallback) current;
                    ncb.setName(username);
                } else if (current instanceof PasswordCallback) {
                    PasswordCallback pcb = (PasswordCallback) current;
                    pcb.setPassword(password.toCharArray());
                } else if (current instanceof RealmCallback) {
                    RealmCallback rcb = (RealmCallback) current;
View Full Code Here

    private static final class AnonymousCallbackHandler implements CallbackHandler {

        public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
            for (Callback current : callbacks) {
                if (current instanceof NameCallback) {
                    NameCallback ncb = (NameCallback) current;
                    ncb.setName("anonymous");
                } else {
                    throw new UnsupportedCallbackException(current);
                }
            }
        }
View Full Code Here

class AnonymousCallbackHandler implements CallbackHandler {

    public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
        for (Callback current : callbacks) {
            if (current instanceof NameCallback) {
                NameCallback ncb = (NameCallback) current;
                ncb.setName("anonymous");
            } else if (current instanceof RealmCallback) {
                RealmCallback rcb = (RealmCallback) current;
                rcb.setText(rcb.getDefaultText());
            } else {
                throw EjbMessages.MESSAGES.unsupportedCallback(current);
View Full Code Here

    private class AnonymousCallbackHandler implements CallbackHandler {

        public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
            for (Callback current : callbacks) {
                if (current instanceof NameCallback) {
                    NameCallback ncb = (NameCallback) current;
                    ncb.setName("anonymous");
                } else {
                    throw MESSAGES.unsupportedCallback(current);
                }
            }
        }
View Full Code Here

TOP

Related Classes of javax.security.auth.callback.NameCallback

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.