Examples of PGSQLSimpleException


Examples of com.impossibl.postgres.jdbc.PGSQLSimpleException

   * {@inheritDoc}
   */
  @Override
  public void commit() throws SQLException {
    if (owner.getState() != PGXAConnection.STATE_IDLE) {
      SQLException se = new PGSQLSimpleException("commit not allowed", "55000");
      owner.fireConnectionError(se);
      throw se;
    }
    super.commit();
  }
View Full Code Here

Examples of com.impossibl.postgres.jdbc.PGSQLSimpleException

   * {@inheritDoc}
   */
  @Override
  public void rollback() throws SQLException {
    if (owner.getState() != PGXAConnection.STATE_IDLE) {
      SQLException se = new PGSQLSimpleException("rollback not allowed", "55000");
      owner.fireConnectionError(se);
      throw se;
    }
    super.rollback();
  }
View Full Code Here

Examples of com.impossibl.postgres.jdbc.PGSQLSimpleException

   * {@inheritDoc}
   */
  @Override
  public void rollback(Savepoint savepoint) throws SQLException {
    if (owner.getState() != PGXAConnection.STATE_IDLE) {
      SQLException se = new PGSQLSimpleException("rollback(Savepoint) not allowed", "55000");
      owner.fireConnectionError(se);
      throw se;
    }
    super.rollback(savepoint);
  }
View Full Code Here

Examples of com.impossibl.postgres.jdbc.PGSQLSimpleException

   * {@inheritDoc}
   */
  @Override
  public void setAutoCommit(boolean autoCommit) throws SQLException {
    if (owner.getState() != PGXAConnection.STATE_IDLE && autoCommit) {
      SQLException se = new PGSQLSimpleException("setAutoCommit(true) not allowed", "55000");
      owner.fireConnectionError(se);
      throw se;
    }
    super.setAutoCommit(autoCommit);
  }
View Full Code Here

Examples of com.impossibl.postgres.jdbc.PGSQLSimpleException

      CertificateFactory cf;
      try {
        cf = CertificateFactory.getInstance("X.509");
      }
      catch (CertificateException ex) {
        error = new PGSQLSimpleException("Could not find a java cryptographic algorithm: X.509 CertificateFactory not available");
        return null;
      }

      Collection<? extends Certificate> certs;
      try {
        certs = cf.generateCertificates(new FileInputStream(certfile));
      }
      catch (FileNotFoundException ioex) {
        if (!defaultfile) {
          // It is not an error if there is no file at the default location
          error = new PGSQLSimpleException("Could not open SSL certificate file " + certfile, ioex);
        }
        return null;
      }
      catch (CertificateException gsex) {
        error = new PGSQLSimpleException("Loading the SSL certificate " + certfile + " into a KeyManager failed", gsex);
        return null;
      }

      certificates = certs.toArray(new X509Certificate[certs.size()]);
    }
View Full Code Here

Examples of com.impossibl.postgres.jdbc.PGSQLSimpleException

          PasswordCallback pwdcb = new PasswordCallback("Enter SSL password:", false);
          try {
            cbh.handle(new Callback[] {pwdcb});
          }
          catch (UnsupportedCallbackException ucex) {
            error = new PGSQLSimpleException("Could not read password for SSL key file, console is not available", ucex);
            return null;
          }

          try {

            PBEKeySpec pbeKeySpec = new PBEKeySpec(pwdcb.getPassword());

            // Now create the Key from the PBEKeySpec
            SecretKeyFactory skFac = SecretKeyFactory.getInstance(ePKInfo.getAlgName());
            Key pbeKey = skFac.generateSecret(pbeKeySpec);

            // Extract the iteration count and the salt
            AlgorithmParameters algParams = ePKInfo.getAlgParameters();
            cipher.init(Cipher.DECRYPT_MODE, pbeKey, algParams);

            // Decrypt the encryped private key into a PKCS8EncodedKeySpec
            KeySpec pkcs8KeySpec = ePKInfo.getKeySpec(cipher);
            key = keyFactory.generatePrivate(pkcs8KeySpec);
          }
          catch (GeneralSecurityException ikex) {
            error = new PGSQLSimpleException("Could not decrypt SSL key file " + keyfileName, ikex);
            return null;
          }
        }
      }
    }
    catch (IOException ioex) {
      error = new PGSQLSimpleException("Could not read SSL key file " + keyfileName, ioex);
    }
    catch (NoSuchAlgorithmException ex) {
      error = new PGSQLSimpleException("Could not find a java cryptographic algorithm: " + ex.getMessage(), ex);
      return null;
    }

    return key;
  }
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.