Package javax.security.auth.message.callback

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


        }

        // 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();
            GroupPrincipalCallback gpc = cbh.getGroupPrincipalCallback();

            // 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, gpc);

            String passwordString = (pvc != null && pvc.getPassword() != null) ? new String(pvc.getPassword()) : null;
            String passwordUsername = (pvc != null && pvc.getUsername() != null) ? pvc.getUsername() : null;
            this.register(request, response, clientPrincipal, authMethod, passwordUsername, passwordString);

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

                            this.callerPrincipalCallback = new CallerPrincipalCallback(callerCallback.getSubject(),
                                    callerCallback.getName());
                    }
                } else if (callback instanceof PasswordValidationCallback) {
                    if (this.passwordValidationCallback == null) {
                        PasswordValidationCallback passCallback = (PasswordValidationCallback) callback;
                        this.passwordValidationCallback = new PasswordValidationCallback(passCallback.getSubject(),
                                passCallback.getUsername(), passCallback.getPassword());
                    }
                } else if (callback instanceof GroupPrincipalCallback) {
                    if (this.groupPrincipalCallback == null) {
                        GroupPrincipalCallback groupCallback = (GroupPrincipalCallback) callback;
                        this.groupPrincipalCallback = new GroupPrincipalCallback(groupCallback.getSubject(),
View Full Code Here

    protected void registerWithCallbackHandler(Principal userPrincipal, String username,
                                               String password) {
        if (this.callbackHandler instanceof WebJASPICallbackHandler) {
            WebJASPICallbackHandler cbh = (WebJASPICallbackHandler) callbackHandler;

            PasswordValidationCallback passwordValidationCallback =
                    new PasswordValidationCallback(null, username, password.toCharArray());
            CallerPrincipalCallback callerCallback = new CallerPrincipalCallback(null, userPrincipal);
            try {
                cbh.handle(new Callback[] {passwordValidationCallback, callerCallback});
            } catch (Exception e) {
                throw new RuntimeException("Error handling callbacks: " + e.getLocalizedMessage(), e);
View Full Code Here

            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

        }

        // 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

                  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

                  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

                    GroupPrincipalCallback gpc = (GroupPrincipalCallback) callback;
                    s.getPrincipals().addAll(gpc.getSubject().getPrincipals());
                    s.getPublicCredentials().addAll(gpc.getSubject().getPublicCredentials());
                    s.getPrivateCredentials().addAll(gpc.getSubject().getPrivateCredentials());
                } else if (callback instanceof PasswordValidationCallback) {
                    PasswordValidationCallback pvc = (PasswordValidationCallback) callback;
                    s.getPrincipals().addAll(pvc.getSubject().getPrincipals());
                    s.getPublicCredentials().addAll(pvc.getSubject().getPublicCredentials());
                    s.getPrivateCredentials().addAll(pvc.getSubject().getPrivateCredentials());
                }
            }
            SecurityContext.setCurrent(new SecurityContext(s));
        }
    }
View Full Code Here

        
        /*
          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

TOP

Related Classes of javax.security.auth.message.callback.PasswordValidationCallback

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.