Package javax.security.auth.callback

Examples of javax.security.auth.callback.UnsupportedCallbackException


                pcb.setPassword(ppCredential.getPassword());
            } else if (current instanceof RealmCallback) {
                RealmCallback rcb = (RealmCallback) current;
                rcb.setText(rcb.getDefaultText());
            } else {
                UnsupportedCallbackException e = new UnsupportedCallbackException(current);
                e.printStackTrace();
                throw e;
            }
        }
    }
View Full Code Here


            for (Callback current : callbacks) {
                if (current instanceof NameCallback) {
                    NameCallback ncb = (NameCallback) current;
                    ncb.setName("anonymous");
                } else {
                    throw new UnsupportedCallbackException(current);
                }
            }
        }
View Full Code Here

        if (ANONYMOUS.equals(mechanismName) && realm == null) {
            return new CallbackHandler() {

                public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
                    for (Callback current : callbacks) {
                        throw new UnsupportedCallbackException(current, "ANONYMOUS mechanism so not expecting a callback");
                    }
                }
            };
        }

        // For now for the JBOSS_LOCAL_USER we are only supporting the $local user and not allowing for
        // an alternative authorizationID.
        if (JBOSS_LOCAL_USER.equals(mechanismName)) {
            return new CallbackHandler() {

                @Override
                public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
                    for (Callback current : callbacks) {
                        if (current instanceof NameCallback) {
                            NameCallback ncb = (NameCallback) current;
                            if (DOLLAR_LOCAL.equals(ncb.getDefaultName()) == false) {
                                throw new SaslException("Only " + DOLLAR_LOCAL + " user is acceptable.");
                            }
                        } else if (current instanceof AuthorizeCallback) {
                            AuthorizeCallback acb = (AuthorizeCallback) current;
                            acb.setAuthorized(acb.getAuthenticationID().equals(acb.getAuthorizationID()));
                        } else {
                            throw new UnsupportedCallbackException(current);
                        }
                    }

                }
            };
        }

        // In this calls only the AuthorizeCallback is needed, we are not making use if an authorization ID just yet
        // so don't need to be linked back to the realms.
        if (EXTERNAL.equals(mechanismName)) {
            return new CallbackHandler() {

                @Override
                public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
                    for (Callback current : callbacks) {
                        if (current instanceof AuthorizeCallback) {
                            AuthorizeCallback acb = (AuthorizeCallback) current;
                            acb.setAuthorized(acb.getAuthenticationID().equals(acb.getAuthorizationID()));
                        } else {
                            throw new UnsupportedCallbackException(current);
                        }
                    }

                }
            };
View Full Code Here

                    }
                } else if (callbacks[i] instanceof ConfirmationCallback) {
                    ConfirmationCallback cb = (ConfirmationCallback) callbacks[i];
                    cb.setSelectedIndex(cb.getDefaultOption());
                } else {
                    throw new UnsupportedCallbackException(callbacks[i]);
                }
            }
        }
View Full Code Here

                  break;
               case TextOutputCallback.ERROR:
                  text = "Error: ";
                  break;
               default:
                  throw new UnsupportedCallbackException(
                          callbacks[i], "Unrecognized message type");
            }
           
            String message = tc.getMessage();
            if (message != null) {
               text += message;
            }
            if (text != null) {
               System.err.println(text);
            }
           
         } else if (callbacks[i] instanceof NameCallback) {
            NameCallback nc = (NameCallback) callbacks[i];
           
            if (nc.getDefaultName() == null) {
               System.err.print(nc.getPrompt());
            } else {
               System.err.print(nc.getPrompt() +
                       " [" + nc.getDefaultName() + "] ");
            }
            System.err.flush();
           
            String result = readLine();
            if (result.equals("")) {
               result = nc.getDefaultName();
            }
           
            nc.setName(result);
           
         } else if (callbacks[i] instanceof PasswordCallback) {
            PasswordCallback pc = (PasswordCallback) callbacks[i];
           
            System.err.print(pc.getPrompt());
            System.err.flush();
           
            pc.setPassword(readPassword(System.in));
           
         } else if (callbacks[i] instanceof ConfirmationCallback) {
            confirmation = (ConfirmationCallback) callbacks[i];
           
         } else {
            throw new UnsupportedCallbackException(
                    callbacks[i], "Unrecognized Callback");
         }
      }
     
      /* Do the confirmation callback last. */
 
View Full Code Here

            break;
         case ConfirmationCallback.INFORMATION:
            prefix = "";
            break;
         default:
            throw new UnsupportedCallbackException(
                    confirmation, "Unrecognized message type: " + messageType);
      }
     
      class OptionInfo {
         String name;
         int value;
         OptionInfo(String name, int value) {
            this.name = name;
            this.value = value;
         }
      }
     
      OptionInfo[] options;
      int optionType = confirmation.getOptionType();
      switch (optionType) {
         case ConfirmationCallback.YES_NO_OPTION:
            options = new OptionInfo[] {
               new OptionInfo("Yes", ConfirmationCallback.YES),
               new OptionInfo("No", ConfirmationCallback.NO)
            };
            break;
         case ConfirmationCallback.YES_NO_CANCEL_OPTION:
            options = new OptionInfo[] {
               new OptionInfo("Yes", ConfirmationCallback.YES),
               new OptionInfo("No", ConfirmationCallback.NO),
               new OptionInfo("Cancel", ConfirmationCallback.CANCEL)
            };
            break;
         case ConfirmationCallback.OK_CANCEL_OPTION:
            options = new OptionInfo[] {
               new OptionInfo("OK", ConfirmationCallback.OK),
               new OptionInfo("Cancel", ConfirmationCallback.CANCEL)
            };
            break;
         case ConfirmationCallback.UNSPECIFIED_OPTION:
            String[] optionStrings = confirmation.getOptions();
            options = new OptionInfo[optionStrings.length];
            for (int i = 0; i < options.length; i++) {
               options[i].value = i;
            }
            break;
         default:
            throw new UnsupportedCallbackException(
                    confirmation, "Unrecognized option type: " + optionType);
      }
     
      int defaultOption = confirmation.getDefaultOption();
     
View Full Code Here

                    if (cb.getPrompt().indexOf("alias") >= 0) {
                        logger.fine("handle alias callback: " + cluster.getUser());
                        cb.setName(cluster.getUser());
                    } else {
                        throw new UnsupportedCallbackException(callbacks[i]);
                    }
                } else if (callbacks[i] instanceof PasswordCallback) {

                    PasswordCallback cb = (PasswordCallback) callbacks[i];

                    String prompt = cb.getPrompt().toLowerCase();
                    logger.fine("handle password callback " + prompt);
                    if (prompt.indexOf("keystore password") >= 0) {
                        logger.fine("found keystore password callback");
                        cb.setPassword(cluster.getKeystorePassword());
                    } else if (prompt.indexOf("key password") >= 0) {
                        logger.fine("found key password callback");
                        cb.setPassword(cluster.getPrivateKeyPassword());
                    } else {
                        throw new UnsupportedCallbackException(callbacks[i]);
                    }
                } else if (callbacks[i] instanceof ConfirmationCallback) {
                    logger.fine("handle confirm callback");
                    ConfirmationCallback cb = (ConfirmationCallback) callbacks[i];
                    cb.setSelectedIndex(cb.getDefaultOption());
                } else {
                    throw new UnsupportedCallbackException(callbacks[i]);
                }
            }
        }
View Full Code Here

                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

                    passwordcontents = new char[0];
                }
                ((PasswordCallback) callbacks[i]).setPassword
                    (passwordcontents);
            } else {
                throw new UnsupportedCallbackException(callbacks[i]);
            }
        }
    }
View Full Code Here

                        // Note that this is not secure! Just doing this to test a NPE
                        return;
                    }
                }
            } else {
                throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
            }
        }
    }
View Full Code Here

TOP

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

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.