예제 #1
0
  private void loadComponentVars(String input) {
    if (input == null || input.equals("")) {
      return;
    }
    String[] keyValues = input.split(",");

    for (String kvs : keyValues) {
      String[] split = kvs.split(":");
      String keyEncoded = split[0];
      String valueEncoded = split[1];

      String key = StringUtils.toAsciiString(Base64Coder.decode(keyEncoded));
      String value = StringUtils.toAsciiString(Base64Coder.decode(valueEncoded));

      this.componentVars.put(key, value);
    }
  }
예제 #2
0
  private void loadSavedMessages(String input) {
    String[] messages = input.split(",");

    for (String encodedMessage : messages) {
      String message = StringUtils.toAsciiString(Base64Coder.decode(encodedMessage));
      this.savedMessages.add(message);
    }
  }
  private static String readRSAKey(Connection connection, String pkPath) throws SQLException {
    String res = null;
    byte[] fileBuf = new byte[2048];

    BufferedInputStream fileIn = null;

    try {
      File f = new File(pkPath);
      String canonicalPath = f.getCanonicalPath();
      fileIn = new BufferedInputStream(new FileInputStream(canonicalPath));

      int bytesRead = 0;

      StringBuffer sb = new StringBuffer();
      while ((bytesRead = fileIn.read(fileBuf)) != -1) {
        sb.append(StringUtils.toAsciiString(fileBuf, 0, bytesRead));
      }
      res = sb.toString();

    } catch (IOException ioEx) {

      if (connection.getParanoid()) {
        throw SQLError.createSQLException(
            Messages.getString("Sha256PasswordPlugin.0", new Object[] {""}),
            SQLError.SQL_STATE_ILLEGAL_ARGUMENT,
            connection.getExceptionInterceptor());
      }
      throw SQLError.createSQLException(
          Messages.getString("Sha256PasswordPlugin.0", new Object[] {"'" + pkPath + "'"}),
          SQLError.SQL_STATE_ILLEGAL_ARGUMENT,
          ioEx,
          connection.getExceptionInterceptor());

    } finally {
      if (fileIn != null) {
        try {
          fileIn.close();
        } catch (Exception ex) {
          SQLException sqlEx =
              SQLError.createSQLException(
                  Messages.getString("Sha256PasswordPlugin.1"),
                  SQLError.SQL_STATE_GENERAL_ERROR,
                  ex,
                  connection.getExceptionInterceptor());

          throw sqlEx;
        }
      }
    }

    return res;
  }