Package com.impossibl.postgres.system

Examples of com.impossibl.postgres.system.Context


      }

      @Override
      public void authenticateClear(ProtocolImpl protocol) throws IOException {

        Context context = protocol.getContext();

        String password = context.getSetting(CREDENTIALS_PASSWORD).toString();

        ByteBuf msg = protocol.channel.alloc().buffer();

        protocol.writePassword(msg, password);

        protocol.send(msg);
      }

      @Override
      public void authenticateCrypt(ProtocolImpl protocol) throws IOException {
      }

      @Override
      public void authenticateMD5(ProtocolImpl protocol, byte[] salt) throws IOException {

        Context context = protocol.getContext();

        String username = context.getSetting(CREDENTIALS_USERNAME).toString();
        String password = context.getSetting(CREDENTIALS_PASSWORD).toString();

        String response = MD5Authentication.encode(password, username, salt);

        ByteBuf msg = protocol.channel.alloc().buffer();
View Full Code Here


  }

  public void writeStartup(ByteBuf msg, Map<String, Object> params) throws IOException {

    Context context = getContext();

    if (logger.isLoggable(FINEST))
      logger.finest("STARTUP: " + params);

    beginMessage(msg, (byte) 0);

    // Version
    msg.writeShort(3);
    msg.writeShort(0);

    // Name=Value pairs
    for (Map.Entry<String, Object> paramEntry : params.entrySet()) {
      writeCString(msg, paramEntry.getKey(), context.getCharset());
      writeCString(msg, paramEntry.getValue().toString(), context.getCharset());
    }

    msg.writeByte(0);

    endMessage(msg);
View Full Code Here

    endMessage(msg);
  }

  public void writePassword(ByteBuf msg, String password) throws IOException {

    Context context = getContext();

    if (logger.isLoggable(FINEST))
      logger.finest("PASSWORD: " + password);

    beginMessage(msg, PASSWORD_MSG_ID);

    writeCString(msg, password, context.getCharset());

    endMessage(msg);
  }
View Full Code Here

    endMessage(msg);
  }

  public void writeQuery(ByteBuf msg, String query) throws IOException {

    Context context = getContext();

    if (logger.isLoggable(FINEST))
      logger.finest("QUERY: " + query);

    beginMessage(msg, QUERY_MSG_ID);

    writeCString(msg, query, context.getCharset());

    endMessage(msg);
  }
View Full Code Here

    endMessage(msg);
  }

  public void writeParse(ByteBuf msg, String stmtName, String query, List<Type> paramTypes) throws IOException {

    Context context = getContext();

    if (logger.isLoggable(FINEST))
      logger.finest("PARSE (" + stmtName + "): " + query);

    beginMessage(msg, PARSE_MSG_ID);

    writeCString(msg, stmtName != null ? stmtName : "", context.getCharset());
    writeCString(msg, query, context.getCharset());

    msg.writeShort(paramTypes.size());
    for (Type paramType : paramTypes) {
      int paramTypeOid = paramType != null ? paramType.getId() : 0;
      msg.writeInt(paramTypeOid);
View Full Code Here

    endMessage(msg);
  }

  public void writeBind(ByteBuf msg, String portalName, String stmtName, List<Type> parameterTypes, List<Object> parameterValues, List<Format> resultFieldFormats, boolean computeLength) throws IOException {

    Context context = getContext();

    if (logger.isLoggable(FINEST))
      logger.finest("BIND (" + portalName + "): " + parameterValues.size());

    byte[] portalNameBytes = nullToEmpty(portalName).getBytes(context.getCharset());
    byte[] stmtNameBytes = nullToEmpty(stmtName).getBytes(context.getCharset());

    if (computeLength) {

      // Compute length of message
      int length = 4;
View Full Code Here

  }

  public void writeDescribe(ByteBuf msg, ServerObjectType target, String targetName) throws IOException {

    Context context = getContext();

    if (logger.isLoggable(FINEST))
      logger.finest("DESCRIBE " + target + " (" + targetName + ")");

    beginMessage(msg, DESCRIBE_MSG_ID);

    msg.writeByte(target.getId());
    writeCString(msg, targetName != null ? targetName : "", context.getCharset());

    endMessage(msg);
  }
View Full Code Here

    endMessage(msg);
  }

  public void writeExecute(ByteBuf msg, String portalName, int maxRows) throws IOException {

    Context context = getContext();

    if (logger.isLoggable(FINEST))
      logger.finest("EXECUTE (" + portalName + "): " + maxRows);

    beginMessage(msg, EXECUTE_MSG_ID);

    writeCString(msg, portalName != null ? portalName : "", context.getCharset());
    msg.writeInt(maxRows);

    endMessage(msg);
  }
View Full Code Here

    endMessage(msg);
  }

  public void writeFunctionCall(ByteBuf msg, int functionId, List<Type> paramTypes, List<Object> paramValues) throws IOException {

    Context context = getContext();

    beginMessage(msg, FUNCTION_CALL_MSG_ID);

    msg.writeInt(functionId);
View Full Code Here

    endMessage(msg);
  }

  public void writeClose(ByteBuf msg, ServerObjectType target, String targetName) throws IOException {

    Context context = getContext();

    if (logger.isLoggable(FINEST))
      logger.finest("CLOSE " + target + ": " + targetName);

    beginMessage(msg, CLOSE_MSG_ID);

    msg.writeByte(target.getId());
    writeCString(msg, targetName != null ? targetName : "", context.getCharset());

    endMessage(msg);
  }
View Full Code Here

TOP

Related Classes of com.impossibl.postgres.system.Context

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.