Package javax.security.auth.callback

Examples of javax.security.auth.callback.TextInputCallback


         throw new LoginException("No CallbackHandler provied to SRPLoginModule");
     
      NameCallback nc = new NameCallback("Username: ", "guest");
      PasswordCallback pc = new PasswordCallback("Password: ", false);
      ByteArrayCallback bac = new ByteArrayCallback("Public key random number: ");
      TextInputCallback tic = new TextInputCallback("Auxillary challenge token: ");
      ArrayList tmpList = new ArrayList();
      tmpList.add(nc);
      tmpList.add(pc);
      if( externalRandomA == true )
         tmpList.add(bac);
      if( hasAuxChallenge == true )
         tmpList.add(tic);
      Callback[] callbacks = new Callback[tmpList.size()];
      tmpList.toArray(callbacks);
      try
      {
         handler.handle(callbacks);
         username = nc.getName();
         _password = pc.getPassword();
         if( _password != null )
            password = _password;
         pc.clearPassword();
         if( externalRandomA == true )
            abytes = bac.getByteArray();
         if( hasAuxChallenge == true )
            this.auxChallenge = tic.getText();
      }
      catch(java.io.IOException e)
      {
         final LoginException loginException = new LoginException(e.toString());
         loginException.initCause(e);
View Full Code Here


                    default:
                        // do nothing
                }
                System.out.println(cb.getMessage());
            } else if(callbacks[i] instanceof TextInputCallback) {
                TextInputCallback cb = (TextInputCallback)callbacks[i];
                System.out.print(cb.getPrompt());
                if(cb.getDefaultText() != null) {
                    System.out.print(" [" + cb.getDefaultText() + "] ");
                }
                String text = readLine();
                if(text.length() == 0) {
                    text = cb.getDefaultText();
                }
                cb.setText(text);
            } else if(callbacks[i] instanceof PasswordCallback) {
                PasswordCallback cb = (PasswordCallback)callbacks[i];
                cb.setPassword(SGEUtil.getInstance().getPassword(cb.getPrompt()));
            } else {
                throw new UnsupportedCallbackException(callbacks[i]);
            }
        }
    }
View Full Code Here

        if (callbackHandler == null)
            throw new LoginException("No CallbackHandler specified");
        Callback callbacks[] = new Callback[9];
        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");

        // Interact with the user to retrieve the username and password
        String username = null;
        String password = null;
        String nonce = null;
View Full Code Here

            PasswordCallback pc = (PasswordCallback) c;
            pc.setPassword(password);
         }
         else if( c instanceof TextInputCallback )
         {
            TextInputCallback tc = (TextInputCallback) c;
            tc.setText(text);
         }
         else if( c instanceof ByteArrayCallback )
         {
            ByteArrayCallback bac = (ByteArrayCallback) c;
            bac.setByteArray(data);
View Full Code Here

      while (elementIterator.hasNext())
      {
         element = elementIterator.next();
         try
         {
            digestCallback[0] = new TextInputCallback(element);
            callbackHandler.handle(digestCallback);
            passwordContext.put(element, ((TextInputCallback)digestCallback[0]).getText());
         }
         catch (UnsupportedCallbackException e)
         {
View Full Code Here

    * @throws IOException
    * @throws UnsupportedCallbackException
    */
   private boolean digestAuthenticationIsUsed() throws IOException, UnsupportedCallbackException
   {
      Callback[] authCallback = {new TextInputCallback("authMethod")};
      callbackHandler.handle(authCallback);
      String authMethod = (String)(((TextInputCallback)authCallback[0]).getText());

      return "DIGEST".equalsIgnoreCase(authMethod);
   }
View Full Code Here

        if (callbackHandler == null)
            throw new LoginException("No CallbackHandler specified");
        Callback callbacks[] = new Callback[9];
        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");

        // Interact with the user to retrieve the username and password
        String username = null;
        String password = null;
        String nonce = null;
View Full Code Here

                       "TextInputCallback");
                logger.log(logger.ERROR,  emsg);
                throw new UnsupportedCallbackException(callbacks[i], emsg);
            }

            TextInputCallback cb = (TextInputCallback)callbacks[i];
            String text =  null;
            if (cb.getPrompt().equals(AccessController.PROP_AUTHENTICATION_TYPE)) {
                text = (String)authProps.getProperty(AccessController.PROP_AUTHENTICATION_TYPE);
            } else if (cb.getPrompt().equals(AccessController.PROP_ACCESSCONTROL_TYPE)) {
                text = (String)authProps.getProperty(AccessController.PROP_ACCESSCONTROL_TYPE);
            } else if (cb.getPrompt().equals(AccessController.PROP_CLIENTIP)) {
                text = (String)authProps.getProperty(AccessController.PROP_CLIENTIP);
            } else if (cb.getPrompt().equals(AccessController.PROP_SERVICE_NAME)) {
                text = (String)authProps.getProperty(AccessController.PROP_SERVICE_NAME);
            } else if (cb.getPrompt().equals(AccessController.PROP_SERVICE_TYPE)) {
                text = (String)authProps.getProperty(AccessController.PROP_SERVICE_TYPE);
            } else {
                String emsg = Globals.getBrokerResources().getKString(
                              BrokerResources.W_JAAS_UNSUPPORTED_TEXTINPUTCALLBACK,
                              cb.getClass().getName(), cb.getPrompt());
                logger.log(logger.WARNING, emsg);
                throw new UnsupportedCallbackException(callbacks[i], emsg);
            }
            if (DEBUG) {
                logger.log(logger.INFO, "JAAS CallbackHander handle TextInputCallback prompt: "+
                       ((TextInputCallback)callbacks[i]).getPrompt()+ " - returning " +text);
            }
            cb.setText(text);
            continue;
        }
        if (callbacks[i] instanceof TextOutputCallback) {
        int level = logger.OFF;
            TextOutputCallback cb = (TextOutputCallback) callbacks[i];

            switch (cb.getMessageType()) {
            case TextOutputCallback.INFORMATION:
                 level = logger.INFO;
                 break;
            case TextOutputCallback.WARNING:
                 level = logger.WARNING;
                 break;
            case TextOutputCallback.ERROR:
                 level = logger.ERROR;
                 break;
            default:
                String emsg = Globals.getBrokerResources().getKString(
                              BrokerResources.W_JAAS_UNSUPPORTED_TEXTOUTPUTCALLBACK,
                              cb.getClass().getName(), Integer.valueOf(cb.getMessageType()));
                logger.log(logger.WARNING, emsg);
                throw new UnsupportedCallbackException(callbacks[i], emsg);
        }
            logger.log(level, cb.getClass().getName()+": "+ cb.getMessage());
          continue
        }
        String emsg = Globals.getBrokerResources().getKString(
                      BrokerResources.W_JAAS_UNSUPPORTED_CALLBACK,
                      callbacks[i].getClass().getName());
View Full Code Here

    //~ Methods ========================================================================================================

    public void handle(Callback callback, Authentication auth)
        throws IOException, UnsupportedCallbackException {
        if (callback instanceof TextInputCallback) {
            TextInputCallback tic = (TextInputCallback) callback;
            tic.setText(auth.getPrincipal().toString());
        }
    }
View Full Code Here

                    passwordcontents = new char[0];
                }
                ((PasswordCallback) callbacks[i]).setPassword
                    (passwordcontents);
            } else if (callbacks[i] instanceof TextInputCallback) {
                TextInputCallback cb = ((TextInputCallback) callbacks[i]);
                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(authMethod);
                } else {
                    throw new UnsupportedCallbackException(callbacks[i]);
                }
            } else {
                throw new UnsupportedCallbackException(callbacks[i]);
View Full Code Here

TOP

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

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.