Package javax.resource.spi.security

Examples of javax.resource.spi.security.PasswordCredential


     *                                     physical connection
     */
    public javax.resource.spi.ManagedConnection createManagedConnection(javax.security.auth.Subject subject,
                                                                        ConnectionRequestInfo cxRequestInfo) throws ResourceException {
        logFine("In createManagedConnection");
        PasswordCredential pc = SecurityUtils.getPasswordCredential(this, subject, cxRequestInfo);

        javax.sql.XADataSource dataSource = getDataSource();

        javax.sql.XAConnection xaConn = null;

        try {
            /* For the case where the user/passwd of the connection pool is
            * equal to the PasswordCredential for the connection request
            * get a connection from this pool directly.
            * for all other conditions go create a new connection
            */
            if (isEqual(pc, getUser(), getPassword())) {
                xaConn = dataSource.getXAConnection();
            } else {
                xaConn = dataSource.getXAConnection(pc.getUserName(),
                        new String(pc.getPassword()));
            }


        } catch (java.sql.SQLException sqle) {
            //_logger.log(Level.WARNING, "jdbc.exc_create_xa_conn",sqle);
View Full Code Here


     *                                     physical connection
     */
    public javax.resource.spi.ManagedConnection createManagedConnection(javax.security.auth.Subject subject,
                                                                        ConnectionRequestInfo cxRequestInfo) throws ResourceException {
        logFine("In createManagedConnection");
        PasswordCredential pc = SecurityUtils.getPasswordCredential(this, subject, cxRequestInfo);

        javax.sql.ConnectionPoolDataSource dataSource = getDataSource();

        javax.sql.PooledConnection cpConn = null;

        try {
            /* For the case where the user/passwd of the connection pool is
            * equal to the PasswordCredential for the connection request
            * get a connection from this pool directly.
            * for all other conditions go create a new connection
            */
            if (isEqual(pc, getUser(), getPassword())) {
                cpConn = dataSource.getPooledConnection();
            } else {
                cpConn = dataSource.getPooledConnection(pc.getUserName(),
                        new String(pc.getPassword()));
            }

        } catch (java.sql.SQLException sqle) {
            //_logger.log(Level.SEVERE, "jdbc.exc_create_ds_conn",sqle);
            _logger.log(Level.FINE, "jdbc.exc_create_ds_conn", sqle);
View Full Code Here

                                                                        ConnectionRequestInfo cxRequestInfo) throws ResourceException {
        logFine("In createManagedConnection");
        if (dsObjBuilder == null) {
            dsObjBuilder = new DataSourceObjectBuilder(spec);
        }
        PasswordCredential pc = SecurityUtils.getPasswordCredential(this, subject, cxRequestInfo);

        try {
            Class.forName(spec.getDetail(DataSourceSpec.CLASSNAME));
        } catch (ClassNotFoundException cnfe) {
            _logger.log(Level.SEVERE, "jdbc.exc_cnfe", cnfe);
            throw new ResourceException("The driver could not be loaded: " + spec.getDetail(DataSourceSpec.CLASSNAME));
        }

        java.sql.Connection dsConn = null;

        Properties driverProps = new Properties();
        //Will return a set of properties that would have setURL and <url> as objects
        //Get a set of normal case properties
        Hashtable properties = dsObjBuilder.parseDriverProperties(spec, false);
        Set<Map.Entry<String,Vector>> entries =
                (Set<Map.Entry<String, Vector>>) properties.entrySet();
        for(Map.Entry<String, Vector> entry : entries) {
            String value = null;
            String key = (String) entry.getKey();
            Vector values = (Vector) entry.getValue();
            if(!values.isEmpty() && values.size() == 1) {
                value = (String) values.firstElement();
            } else if(values.size() > 1) {
                logFine("More than one value for key : " + key);
            }
            String prop = getParsedKey(key);
            driverProps.put(prop, value);
            if(prop.equalsIgnoreCase("URL")) {
                if(spec.getDetail(DataSourceSpec.URL) == null) {
                    setConnectionURL(value);
                }
            }
        }
        try {
            if (cxRequestInfo != null) {
                driverProps.setProperty("user", pc.getUserName());
                driverProps.setProperty("password", new String(pc.getPassword()));
            } else {
                String user = spec.getDetail(DataSourceSpec.USERNAME);
                String password = spec.getDetail(DataSourceSpec.PASSWORD);
                if(user != null) {
                    driverProps.setProperty("user", user);
View Full Code Here

     *                                     physical connection
     */
    public javax.resource.spi.ManagedConnection createManagedConnection(javax.security.auth.Subject subject,
                                                                        ConnectionRequestInfo cxRequestInfo) throws ResourceException {
        logFine("In createManagedConnection");
        PasswordCredential pc = SecurityUtils.getPasswordCredential(this, subject, cxRequestInfo);

        javax.sql.DataSource dataSource = getDataSource();

        java.sql.Connection dsConn = null;

        try {
            /* For the case where the user/passwd of the connection pool is
            * equal to the PasswordCredential for the connection request
            * get a connection from this pool directly.
            * for all other conditions go create a new connection
            */

            if (isEqual(pc, getUser(), getPassword())) {
                dsConn = dataSource.getConnection();
            } else {
                dsConn = dataSource.getConnection(pc.getUserName(),
                        new String(pc.getPassword()));
            }
        } catch (java.sql.SQLException sqle) {
            //_logger.log(Level.WARNING, "jdbc.exc_create_conn", sqle.getMessage());
            if(_logger.isLoggable(Level.FINE)) {
                _logger.log(Level.FINE, "jdbc.exc_create_conn", sqle.getMessage());
View Full Code Here

     *                                     physical connection
     */
    public javax.resource.spi.ManagedConnection createManagedConnection(javax.security.auth.Subject subject,
                                                                        ConnectionRequestInfo cxRequestInfo) throws ResourceException {
        logFine("In createManagedConnection");
        PasswordCredential pc = SecurityUtils.getPasswordCredential(this, subject, cxRequestInfo);

        javax.sql.XADataSource dataSource = getDataSource();

        javax.sql.XAConnection xaConn = null;

        try {
            /* For the case where the user/passwd of the connection pool is
            * equal to the PasswordCredential for the connection request
            * get a connection from this pool directly.
            * for all other conditions go create a new connection
            */
            if (isEqual(pc, getUser(), getPassword())) {
                xaConn = dataSource.getXAConnection();
            } else {
                xaConn = dataSource.getXAConnection(pc.getUserName(),
                        new String(pc.getPassword()));
            }


        } catch (java.sql.SQLException sqle) {
            //_logger.log(Level.WARNING, "jdbc.exc_create_xa_conn",sqle);
View Full Code Here

        if (connectionSet == null) {
            return null;
        }


        PasswordCredential pc = SecurityUtils.getPasswordCredential(this, subject, cxRequestInfo);

        java.util.Iterator iter = connectionSet.iterator();
        com.sun.gjc.spi.ManagedConnection mc = null;

        while (iter.hasNext()) {
View Full Code Here

        if (info == null) {
            if (subject == null) {
                return null;
            } else {
                PasswordCredential pc = (PasswordCredential) AccessController.doPrivileged
                        (new PrivilegedAction() {
                            public Object run() {
                                Set passwdCredentialSet = subject.getPrivateCredentials(PasswordCredential.class);
                                Iterator iter = passwdCredentialSet.iterator();
                                while (iter.hasNext()) {
                                    PasswordCredential temp = (PasswordCredential) iter.next();
                                    if (temp.getManagedConnectionFactory().equals(mcf)) {
                                        return temp;
                                    }
                                }
                                return null;
                            }
                        });
                if (pc == null) {
                    String msg = sm.getString("su.no_passwd_cred");
                    throw new javax.resource.spi.SecurityException(msg);
                } else {
                    return pc;
                }
            }
        } else {
            com.sun.gjc.spi.ConnectionRequestInfo cxReqInfo = (com.sun.gjc.spi.ConnectionRequestInfo) info;
            PasswordCredential pc = new PasswordCredential(cxReqInfo.getUser(), cxReqInfo.getPassword().toCharArray());
            pc.setManagedConnectionFactory(mcf);
            return pc;
        }
    }
View Full Code Here

     *                                     physical connection
     */
    public javax.resource.spi.ManagedConnection createManagedConnection(javax.security.auth.Subject subject,
                                                                        ConnectionRequestInfo cxRequestInfo) throws ResourceException {
        logFine("In createManagedConnection");
        PasswordCredential pc = SecurityUtils.getPasswordCredential(this, subject, cxRequestInfo);

        javax.sql.ConnectionPoolDataSource dataSource = getDataSource();

        javax.sql.PooledConnection cpConn = null;

        try {
            /* For the case where the user/passwd of the connection pool is
            * equal to the PasswordCredential for the connection request
            * get a connection from this pool directly.
            * for all other conditions go create a new connection
            */
            if (isEqual(pc, getUser(), getPassword())) {
                cpConn = dataSource.getPooledConnection();
            } else {
                cpConn = dataSource.getPooledConnection(pc.getUserName(),
                        new String(pc.getPassword()));
            }

        } catch (java.sql.SQLException sqle) {
            //_logger.log(Level.SEVERE, "jdbc.exc_create_ds_conn",sqle);
            if(_logger.isLoggable(Level.FINE)) {
View Full Code Here

         jc.setUserName(((QpidRAConnectionRequestInfo)info).getUserName());
         jc.setPassword(((QpidRAConnectionRequestInfo)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

         {
            _log.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

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.