Examples of PasswordValidationCallback


Examples of javax.security.auth.message.callback.PasswordValidationCallback

                    for (String groupName : groupPrincipalCallback.getGroups()) {
                        principalSet.add(new GeronimoGroupPrincipal(groupName));
                    }
                }
            } else if (callback instanceof PasswordValidationCallback) {
                PasswordValidationCallback passwordValidationCallback = (PasswordValidationCallback) callback;
                Subject subject = passwordValidationCallback.getSubject();

                UserIdentity user = loginService.login(passwordValidationCallback.getUsername(), new String(passwordValidationCallback.getPassword()));

                if (user != null) {
                    passwordValidationCallback.setResult(true);
                    subject.getPrincipals().addAll(user.getSubject().getPrincipals());
                    subject.getPrivateCredentials().add(user);
                }
            }
            // server to jaspi communication
View Full Code Here

Examples of javax.security.auth.message.callback.PasswordValidationCallback

        return "JASPIC";
    }

    @Override
    public AuthResult login(String username, String password, Request request) throws ServletException {
        PasswordValidationCallback passwordValidationCallback = new PasswordValidationCallback(new Subject(), username, password.toCharArray());
        try {
            callbackHandler.handle(new Callback[] {passwordValidationCallback});
            if (passwordValidationCallback.getResult()) {
                UserIdentity userIdentity = passwordValidationCallback.getSubject().getPrivateCredentials(UserIdentity.class).iterator().next();
                return new AuthResult(TomcatAuthStatus.SUCCESS, userIdentity, containerCaching);
            }
            return new AuthResult(TomcatAuthStatus.FAILURE, null, false);
        } catch (UnsupportedCallbackException e) {
            throw new ServletException("internal server error");
View Full Code Here

Examples of javax.security.auth.message.callback.PasswordValidationCallback

            if (callback instanceof CallerPrincipalCallback) {
                callerPrincipal = ((CallerPrincipalCallback) callback).getPrincipal();
            } else if (callback instanceof GroupPrincipalCallback) {
                groupsArray = ((GroupPrincipalCallback) callback).getGroups();
            } else if (callback instanceof PasswordValidationCallback) {
                final PasswordValidationCallback passwordValidationCallback = (PasswordValidationCallback) callback;
                final String userName = passwordValidationCallback.getUsername();
                final char[] password = passwordValidationCallback.getPassword();

                final SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
                try {
                    final Object loginObj = securityService.login(securityRealmName, userName, password == null ? "" : new String(password));
                    securityService.associate(loginObj);
                    callerPrincipal = securityService.getCallerPrincipal();
                    passwordValidationCallback.setResult(true);
                } catch (final LoginException e) {
                    passwordValidationCallback.setResult(false);
                }
            }
            // server to jaspi communication
            else if (callback instanceof CertStoreCallback) { //NOPMD
                // TODO implement me
View Full Code Here

Examples of javax.security.auth.message.callback.PasswordValidationCallback

            if (callback instanceof CallerPrincipalCallback) {
                callerPrincipals.set((CallerPrincipalCallback) callback);
            } else if (callback instanceof GroupPrincipalCallback) {
                groupPrincipals.set((GroupPrincipalCallback) callback);
            } else if (callback instanceof PasswordValidationCallback) {
                PasswordValidationCallback passwordValidationCallback = (PasswordValidationCallback) callback;
                Subject subject = passwordValidationCallback.getSubject();

                UserIdentity user = loginService.login(passwordValidationCallback.getUsername(), new String(passwordValidationCallback.getPassword()));

                if (user != null) {
                    passwordValidationCallback.setResult(true);
                    passwordValidationCallback.getSubject().getPrincipals().addAll(user.getSubject().getPrincipals());
                    passwordValidationCallback.getSubject().getPrivateCredentials().add(user);
                }
            }
            // server to jaspi communication
            // TODO implement these
            else if (callback instanceof CertStoreCallback) {
View Full Code Here

Examples of javax.security.auth.message.callback.PasswordValidationCallback

            {
                groupsArray = ((GroupPrincipalCallback)callback).getGroups();
            }
            else if (callback instanceof PasswordValidationCallback)
            {
                PasswordValidationCallback passwordValidationCallback = (PasswordValidationCallback) callback;
                Subject subject = passwordValidationCallback.getSubject();
                final String userName = passwordValidationCallback.getUsername();
                final char[] password = passwordValidationCallback.getPassword();
                try {
                    LoginContext loginContext = ContextManager.login(subject, realm, new CallbackHandler() {
                        public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
                            for (Callback callback: callbacks) {
                                if (callback instanceof NameCallback) {
                                    ((NameCallback)callback).setName(userName);
                                } else if (callback instanceof PasswordCallback) {
                                    ((PasswordCallback)callback).setPassword(password);
                            } else throw new UnsupportedCallbackException(callback);
                            }
                        }
                    });
                    passwordValidationCallback.setResult(true);
                } catch (LoginException e) {
                    passwordValidationCallback.setResult(false);
                }

            }
            //server to jaspi communication
            //TODO implement these
View Full Code Here

Examples of javax.security.auth.message.callback.PasswordValidationCallback

                  char[] cred = workManager.getCallbackSecurity().getCredential(user);
                  String[] roles = workManager.getCallbackSecurity().getRoles(user);

                  GroupPrincipalCallback gpc = new GroupPrincipalCallback(subject, roles);
                  CallerPrincipalCallback cpc = new CallerPrincipalCallback(subject, principal);
                  PasswordValidationCallback pvc = new PasswordValidationCallback(subject, principal.getName(), cred);

                  callbacks.add(gpc);
                  callbacks.add(cpc);
                  callbacks.add(pvc);
               }
View Full Code Here

Examples of javax.security.auth.message.callback.PasswordValidationCallback

        /*
          use PasswordValidationCallback
        */
        char[] pwd = (password == null) ? null : password.toCharArray();
        //PasswordValidationCallback pvCallback = new PasswordValidationCallback(username, pwd);
        PasswordValidationCallback pvCallback = new PasswordValidationCallback(
               this.getRequesterSubject(context),username, pwd);
        Callback[] callbacks = new Callback[] { pvCallback };
        try {
           _handler.handle(callbacks);
        } catch (Exception e) {
           throw new XWSSecurityException(e);
        }

        // zero the password
        if (pwd != null)
           pvCallback.clearPassword();

        return pvCallback.getResult();
    }
View Full Code Here

Examples of javax.security.auth.message.callback.PasswordValidationCallback

        
        /*
          use PasswordValidationCallback
        */
        char[] pwd = (password == null) ? null : password.toCharArray();
        PasswordValidationCallback pvCallback = new PasswordValidationCallback(
                this.getRequesterSubject(context),username, pwd);
        Callback[] callbacks = null;
        if (this.useXWSSCallbacks) {
            RuntimeProperties xwsscb = new RuntimeProperties(context);
            callbacks = new Callback[]{xwsscb, pvCallback};
        } else {
            callbacks = new Callback[]{pvCallback};
        }
        try {
           _handler.handle(callbacks);
        } catch (Exception e) {
            log.log(Level.SEVERE, LogStringsMessages.WSS_0216_CALLBACKHANDLER_HANDLE_EXCEPTION( "Authenticating User against list of Known username-password pairs"),
                    new Object[] { "Authenticating User against list of Known username-password pairs"});
           throw new XWSSecurityException(e);
        }

        // zero the password
        if (pwd != null)
           pvCallback.clearPassword();

        if (log.isLoggable(Level.FINE)) {
            log.log(Level.FINE,"Username Authentication done for " + username);
        }
       
        return pvCallback.getResult();
    }
View Full Code Here

Examples of javax.security.auth.message.callback.PasswordValidationCallback

        }

        // the authentication process has been a success. We need to register the principal, username, password and roles
        // with the container
        if (result) {
            PasswordValidationCallback pvc = cbh.getPasswordValidationCallback();
            CallerPrincipalCallback cpc = cbh.getCallerPrincipalCallback();

            // get the client principal from the callback.
            Principal clientPrincipal = cpc.getPrincipal();
            if (clientPrincipal == null) {
                clientPrincipal = new SimplePrincipal(cpc.getName());
            }

            // if the client principal is not a jboss generic principal, we need to build one before registering.
            if (!(clientPrincipal instanceof JBossGenericPrincipal))
                clientPrincipal = this.buildJBossPrincipal(clientSubject, clientPrincipal);

            this.register(request, response, clientPrincipal, authMethod, pvc.getUsername(),
                    new String(pvc.getPassword()));

            if (this.secureResponse)
                sam.secureResponse(messageInfo, new Subject(), messageLayer, appContext, cbh);
        }
View Full Code Here

Examples of javax.security.auth.message.callback.PasswordValidationCallback

                                callerCallback.getPrincipal());
                    else
                        this.callerPrincipalCallback = new CallerPrincipalCallback(callerCallback.getSubject(),
                                callerCallback.getName());
                } else if (callback instanceof PasswordValidationCallback) {
                    PasswordValidationCallback passCallback = (PasswordValidationCallback) callback;
                    this.passwordValidationCallback = new PasswordValidationCallback(passCallback.getSubject(),
                            passCallback.getUsername(), passCallback.getPassword());
                } else if (callback instanceof GroupPrincipalCallback) {
                    GroupPrincipalCallback groupCallback = (GroupPrincipalCallback) callback;
                    this.groupPrincipalCallback = new GroupPrincipalCallback(groupCallback.getSubject(),
                            groupCallback.getGroups());
                } else
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.