Examples of PasswordValidationCallback


Examples of com.sun.xml.wss.impl.callback.PasswordValidationCallback

    public String authenticateUser(Map context, String username )
            throws XWSSecurityException {

        PasswordValidationCallback.DerivedKeyPasswordRequest request =
                new PasswordValidationCallback.DerivedKeyPasswordRequest(username);
        PasswordValidationCallback passwordValidationCallback =
                new PasswordValidationCallback(request);
        ProcessingContext.copy(passwordValidationCallback.getRuntimeProperties(), context);
        Callback[] callbacks = new Callback[]{passwordValidationCallback};
        boolean result = false;
        try {
            callbackHandler.handle(callbacks);
            RealmAuthenticationAdapter adapter = passwordValidationCallback.getRealmAuthenticationAdapter();
            if (passwordValidationCallback.getValidator() != null) {
                result = passwordValidationCallback.getResult();

                if (result == true) {
                updateUsernameInSubject(getSubject(context), username, null);
                }
            }
View Full Code Here

Examples of com.sun.xml.wss.impl.callback.PasswordValidationCallback

            throws XWSSecurityException {

        PasswordValidationCallback.DigestPasswordRequest request =
                new PasswordValidationCallback.DigestPasswordRequest(
                username, passwordDigest, nonce, created);
        PasswordValidationCallback passwordValidationCallback =
                new PasswordValidationCallback(request);
        ProcessingContext.copy(passwordValidationCallback.getRuntimeProperties(), context);
        Callback[] callbacks = new Callback[]{passwordValidationCallback};

        boolean result = false;
        try {
            callbackHandler.handle(callbacks);
            RealmAuthenticationAdapter adapter = passwordValidationCallback.getRealmAuthenticationAdapter();
            if (passwordValidationCallback.getValidator() != null) {
                result = passwordValidationCallback.getResult();
                if (result == true) {
                    updateUsernameInSubject(getSubject(context), username, null);
                }
            } else if (adapter != null) {
                result = adapter.authenticate(getSubject(context), username, passwordDigest, nonce, created, context);
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

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

     
      //The Authentication process has been a success. We need to register
      //the principal, username, password with the container
      if(result)
      {
         PasswordValidationCallback pvc = cbh.getPasswordValidationCallback();
         CallerPrincipalCallback cpcb = cbh.getCallerPrincipalCallback();
         this.register(request, response, cpcb.getPrincipal(), authMethod,
               pvc.getUsername(), new String(pvc.getPassword()));
      }
     
      return result;
   }
View Full Code Here

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

   {
      if(this.callbackHandler instanceof TomcatJASPICallbackHandler)
      {
         TomcatJASPICallbackHandler cbh = (TomcatJASPICallbackHandler) callbackHandler;
        
         PasswordValidationCallback passwordValidationCallback =
            new PasswordValidationCallback(null,username,password.toCharArray());  
         cbh.setPasswordValidationCallback(passwordValidationCallback);
        
         cbh.setCallerPrincipalCallback(new CallerPrincipalCallback(null,userPrincipal));
      }
      else
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) {
                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

      if (callback instanceof CallerPrincipalCallback) {
        callerPrincipal = ((CallerPrincipalCallback) callback).getPrincipal();
      } else if (callback instanceof GroupPrincipalCallback) {
        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();

        SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
        try {
          Object loginObj = securityService.login(securityRealmName, userName, password == null ? "" : new String(password));
          securityService.associate(loginObj);
          callerPrincipal = securityService.getCallerPrincipal();
          passwordValidationCallback.setResult(true);
        } catch (LoginException e) {
          passwordValidationCallback.setResult(false);
        }
      }
      // server to jaspi communication
      // TODO implement these
      else if (callback instanceof CertStoreCallback) {
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.