Package javax.resource.spi.security

Examples of javax.resource.spi.security.PasswordCredential


    }

    public void testGetConnectionWithSubject() throws ResourceException {
        String user = new String("user");
        char password[] = {'a', 'b', 'c'};
        PasswordCredential creds = new PasswordCredential(user, password);
        creds.setManagedConnectionFactory(factory);
        subj.getPrivateCredentials().add(creds);
        Object o = mci.getConnection(subj, cri);

        verifyProxyInterceptors(o);
    }
View Full Code Here


         jc.setUserName(((HornetQRAConnectionRequestInfo)info).getUserName());
         jc.setPassword(((HornetQRAConnectionRequestInfo)info).getPassword());
      }
      else if (subject != null)
      {
         PasswordCredential pwdc = GetCredentialAction.getCredential(subject, mcf);

         if (pwdc == null)
         {
            throw new SecurityException("No password credentials found");
         }

         jc.setUserName(pwdc.getUserName());
         jc.setPassword(new String(pwdc.getPassword()));
      }
      else
      {
         throw new SecurityException("No Subject or ConnectionRequestInfo set, could not get credentials");
      }
View Full Code Here

         {
            HornetQRALogger.LOGGER.trace("run()");
         }

         Set<PasswordCredential> creds = subject.getPrivateCredentials(PasswordCredential.class);
         PasswordCredential pwdc = null;

         for (PasswordCredential curCred : creds)
         {
            if (curCred.getManagedConnectionFactory().equals(mcf))
            {
View Full Code Here

      if (password == null)
         throw new IllegalStateException("Password is null");

      Subject subject = new Subject();
      PasswordCredential credential = new PasswordCredential(userName, password.toCharArray());
      subject.getPrivateCredentials().add(credential);
      return subject;
   }
View Full Code Here

            // Credentials specifyed on connection request
            jc.name = ((JmsConnectionRequestInfo) info).getUserName();
            jc.pwd = ((JmsConnectionRequestInfo) info).getPassword();
        } else if (subject != null) {
            // Credentials from appserver
            PasswordCredential pwdc = GetCredentialAction.getCredential(subject, mcf);
            if (pwdc == null) {
                // No hit - we do need creds
                throw new SecurityException("No Password credentials found");
            }
            jc.name = pwdc.getUserName();
            jc.pwd = new String(pwdc.getPassword());
        } else {
            throw new SecurityException("No Subject or ConnectionRequestInfo set, could not get credentials");
        }
        return jc;
    }
View Full Code Here

            this.mcf = mcf;
        }

        public Object run() {
            Set creds = subject.getPrivateCredentials(PasswordCredential.class);
            PasswordCredential pwdc = null;
            Iterator credentials = creds.iterator();
            while (credentials.hasNext()) {
                PasswordCredential curCred = (PasswordCredential) credentials.next();
                if (curCred.getManagedConnectionFactory().equals(mcf)) {
                    pwdc = curCred;
                    break;
                }
            }
            return pwdc;
View Full Code Here

            return pwdc;
        }

        static PasswordCredential getCredential(Subject subject, ManagedConnectionFactory mcf) {
            GetCredentialAction action = new GetCredentialAction(subject, mcf);
            PasswordCredential pc = (PasswordCredential) AccessController.doPrivileged(action);
            return pc;
        }
View Full Code Here

        final Subject tempSubject = new Subject();
        if (prin != null) {
            String password = prin.getPassword();
            if (password != null) {
                final PasswordCredential pc =
                        new PasswordCredential(prin.getName(),
                                password.toCharArray());
                pc.setManagedConnectionFactory(mcf);
                AccessController.doPrivileged(new PrivilegedAction() {
                    public Object run() {
                        tempSubject.getPrincipals().add(prin);
                        tempSubject.getPrivateCredentials().add(pc);
                        return null;
View Full Code Here

                    }
                    ManagedConnectionFactory[] mcfs =
                            crt.obtainManagedConnectionFactories(poolInfo);
                    _logger.log(Level.INFO, "JMS resource recovery has created CFs = " + mcfs.length);
                    for (int i = 0; i < mcfs.length; i++) {
                        PasswordCredential pc = new PasswordCredential(
                                dbUser, dbPassword.toCharArray());
                        pc.setManagedConnectionFactory(mcfs[i]);
                        Principal prin =
                                new ResourcePrincipal(dbUser, dbPassword);
                        subject.getPrincipals().add(prin);
                        subject.getPrivateCredentials().add(pc);
                        ManagedConnection mc = mcfs[i].
                                createManagedConnection(subject, null);
                        connList.add(mc);
                        try {
                            XAResource xares = mc.getXAResource();
                            if (xares != null) {
                                xaresList.add(xares);
                            }
                        } catch (ResourceException ex) {
                            // ignored. Not at XA_TRANSACTION level
                        }
                    }

                } else {
                    ManagedConnectionFactory mcf =
                            crt.obtainManagedConnectionFactory(poolInfo);
                    PasswordCredential pc = new PasswordCredential(
                            dbUser, dbPassword.toCharArray());
                    pc.setManagedConnectionFactory(mcf);
                    Principal prin = new ResourcePrincipal(dbUser, dbPassword);
                    subject.getPrincipals().add(prin);
                    subject.getPrivateCredentials().add(pc);
                    ManagedConnection mc = mcf.createManagedConnection(subject, null);
                    connList.add(mc);
View Full Code Here

         jc.setUserName(((HornetQRAConnectionRequestInfo)info).getUserName());
         jc.setPassword(((HornetQRAConnectionRequestInfo)info).getPassword());
      }
      else if (subject != null)
      {
         PasswordCredential pwdc = GetCredentialAction.getCredential(subject, mcf);

         if (pwdc == null)
         {
            throw new SecurityException("No password credentials found");
         }

         jc.setUserName(pwdc.getUserName());
         jc.setPassword(new String(pwdc.getPassword()));
      }
      else
      {
         throw new SecurityException("No Subject or ConnectionRequestInfo set, could not get credentials");
      }
View Full Code Here

TOP

Related Classes of javax.resource.spi.security.PasswordCredential

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.