Package javax.resource.spi.security

Examples of javax.resource.spi.security.PasswordCredential


      LoginContext lc = new LoginContext("testJaasSecurityDomainIdentityLoginModule");
      lc.login();
      Subject subject = lc.getSubject();
      assertTrue("Principals contains sa", subject.getPrincipals().contains(new SimplePrincipal("sa")));
      Set creds = subject.getPrivateCredentials(PasswordCredential.class);
      PasswordCredential pc = (PasswordCredential) creds.iterator().next();
      String username = pc.getUserName();
      String password = new String(pc.getPassword());
      assertTrue("PasswordCredential.username = sa", username.equals("sa"));
      assertTrue("PasswordCredential.password = ", password.equals(""));
      lc.logout();
      server.unregisterMBean(name);
      MBeanServerFactory.releaseMBeanServer(server);
View Full Code Here


        throws ResourceException
    {

        checkIfDestroyed();

        PasswordCredential pc = RaHelper.getPasswordCredential(mcf, subject, connectionRequestInfo);

        if (!passCred.equals(pc))
        {
            // TODO change the message, we are not dealing with an endpoint here
            throw new javax.resource.spi.SecurityException(
View Full Code Here

                    // null");
                    return null;
                }

                char[] password = muleInfo.getPassword().toCharArray();
                PasswordCredential pc = new PasswordCredential(muleInfo.getUserName(), password);
                pc.setManagedConnectionFactory(mcf);
                return pc;
            }
        }
        else
        {
            PasswordCredential pc = (PasswordCredential)AccessController.doPrivileged(new PrivilegedAction()
            {
                public Object run()
                {
                    Set creds = subject.getPrivateCredentials(PasswordCredential.class);
                    Iterator iter = creds.iterator();
                    while (iter.hasNext())
                    {
                        PasswordCredential candidate = (PasswordCredential)iter.next();
                        if (candidate != null)
                        {
                            ManagedConnectionFactory candidatemcf = candidate.getManagedConnectionFactory();
                            if (candidatemcf != null && candidatemcf.equals(mcf))
                            {
                                return candidate;
                            }
                        }
View Full Code Here

    public ManagedConnection matchManagedConnections(Set connectionSet,
                                                     Subject subject,
                                                     ConnectionRequestInfo cxRequestInfo)
        throws ResourceException
    {
        PasswordCredential pc = RaHelper.getPasswordCredential(this, subject, cxRequestInfo);

        Iterator it = connectionSet.iterator();
        while (it.hasNext())
        {
            Object obj = it.next();
            if (obj instanceof MuleManagedConnection)
            {
                MuleManagedConnection mc = (MuleManagedConnection)obj;
                PasswordCredential mcpc = mc.getPasswordCredential();
                if (mcpc != null && pc != null && mcpc.equals(pc))
                {
                    return mc;
                }
            }
        }
View Full Code Here

     */
    public Object getConnection(Subject subject, ConnectionRequestInfo cri)
    throws ResourceException
    {
        PersistenceManagerImpl.LOGGER.debug("Obtaining Connection for this ManagedConnection "+this);
        PasswordCredential pc = getManagedConnectionFactory().getPasswordCredential(subject);
        if (credential != pc && credential != null && pc != null && !credential.equals(pc))
        {
            throw new ResourceException("Wrong subject: "+subject+" MCF credentials: "+pc+" MC credentials: "+credential);
        }

View Full Code Here

     */
    public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo cri)
    throws ResourceException
    {
        freezeConfiguration();
        PasswordCredential pc = getPasswordCredential(subject);
        ManagedConnectionImpl mc = new ManagedConnectionImpl(this,pc);
        return mc;
    }
View Full Code Here

     *
     */
    public ManagedConnection matchManagedConnections(Set mcs, Subject subject, ConnectionRequestInfo cri)
    throws ResourceException
    {
        PasswordCredential pc = getPasswordCredential(subject);
        for (Iterator i = mcs.iterator(); i.hasNext();)
        {
            Object o = i.next();
            if (!(o instanceof ManagedConnectionImpl))
            {
                continue;
            }

            ManagedConnectionImpl mc = (ManagedConnectionImpl)o;
            if (!(mc.getManagedConnectionFactory().equals(this)))
            {
                continue;
            }
            if (pc == null && mc.getPasswordCredential() == null)
            {
                return mc;
            }
            if( pc != null && mc.getPasswordCredential() != null && pc.equals(mc.getPasswordCredential()))
            {
                return mc;
            }
        }
        return null;
View Full Code Here

            if (!properties.containsKey("javax.jdo.option.ConnectionUserName") ||
              !properties.containsKey("javax.jdo.option.ConnectionPassword"))
            {
                return null;
            }
            PasswordCredential pc=new PasswordCredential(properties.getProperty("javax.jdo.option.ConnectionUserName"), properties.getProperty("javax.jdo.option.ConnectionPassword").toCharArray());
            pc.setManagedConnectionFactory(this);
            return pc;
        }

        for (Iterator i=subject.getPrivateCredentials().iterator();i.hasNext();)
        {
            Object o = i.next();
            if (o instanceof PasswordCredential)
            {
                PasswordCredential pc = (PasswordCredential)o;
                if (this.equals(pc.getManagedConnectionFactory()))
                {
                    return pc;
                }
            }
        }
View Full Code Here

    public boolean commit() throws LoginException {
        if (resourcePrincipalName == null || userName == null || password == null) {
            return false;
        }
        subject.getPrincipals().add(new ResourcePrincipal(resourcePrincipalName));
        PasswordCredential passwordCredential = new PasswordCredential(userName, password);
        passwordCredential.setManagedConnectionFactory(managedConnectionFactory);
        subject.getPrivateCredentials().add(passwordCredential);
        return false;
    }
View Full Code Here

    public boolean commit() throws LoginException {
        if (resourcePrincipalName == null || userName == null || password == null) {
            return false;
        }
        subject.getPrincipals().add(new ResourcePrincipal(resourcePrincipalName));
        PasswordCredential passwordCredential = new PasswordCredential(userName, password);
        passwordCredential.setManagedConnectionFactory(managedConnectionFactory);
        subject.getPrivateCredentials().add(passwordCredential);
        return false;
    }
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.