Esempio n. 1
0
 public void addparam(String id, byte[] body) {
   CSCPPARAM param = new CSCPPARAM();
   param.setId(id);
   param.setBody(body);
   param.build();
   add(param);
 }
Esempio n. 2
0
 public CSCPPARAM getparam(String id) {
   for (int i = 0; i < this.params.size(); i++) {
     CSCPPARAM param = this.params.get(i);
     if (param.getId().equals(id)) return param;
   }
   return null;
 }
Esempio n. 3
0
  public HashMap<String, String> rcheck(String msgid) throws IOException {
    if (this.userid == null || this.password == null) {
      System.out.println("setuser required");
      return null;
    }

    HashMap<String, String> map = new HashMap<String, String>();

    map.put("VERSION", VERSION_STR);
    map.put("COMMAND", "CHECK-RESULT");
    if (this.crypt.equals("MD5")) map.put("CRYPT-METHOD", "MD5");
    map.put("AUTH-ID", this.userid);
    map.put("AUTH-PASS", this.password);
    map.put("LANGUAGE", "JAVA");
    map.put("MESSAGE-ID", msgid);

    CSCP cscp = new CSCP();
    cscp.addparam(CSCPPARAM.ID_MESSAGE, TBSP.build(map));
    cscp.build();
    String packet = cscp.getPacketString();
    fos.write(packet.getBytes(), 0, packet.getBytes().length);
    fos.flush();

    CSCP cscp2 = new CSCP();
    cscp2.read(bis);
    CSCPPARAM ack = cscp2.getparam(CSCPPARAM.ID_MESSAGE);
    return TBSP.parse(ack.getBody());
  }
Esempio n. 4
0
  /** send all of messages */
  public void send() throws IOException {
    if (this.userid == null || this.password == null) {
      System.out.println("setuser required");
      return;
    }

    for (int i = 0; i < pduList.size(); i++) {
      byte[] packet = assembleFields(pduList.get(i));
      fos.write(packet, 0, packet.length);
      fos.flush();

      CSCP cscp = new CSCP();
      cscp.read(bis);
      CSCPPARAM ack = cscp.getparam(CSCPPARAM.ID_MESSAGE);
      if (ack == null) {
        System.out.println("no ack returned");
        break;
      }
      String tbspstr = ack.getBody();

      HashMap<String, String> map = TBSP.parse(tbspstr);

      result.add(map);
    }
  }
Esempio n. 5
0
  public HashMap<String, String> cancelGroup(String groupId) throws IOException {
    if (this.userid == null || this.password == null) {
      System.out.println("setuser required");
      return null;
    }

    byte[] packet = encodeGroupCancel(groupId);
    fos.write(packet, 0, packet.length);
    fos.flush();

    CSCP cscp = new CSCP();
    cscp.read(bis);
    CSCPPARAM ack = cscp.getparam(CSCPPARAM.ID_MESSAGE);
    if (ack == null) {
      System.out.println("no ack returned");
      return null;
    }
    String tbspstr = ack.getBody();
    return TBSP.parse(tbspstr);
  }
Esempio n. 6
0
  public String read(BufferedInputStream bis) throws IOException {
    byte[] version = new byte[CSCP_VERSION_SIZE];
    byte[] bodylen = new byte[CSCP_BODYLEN_SIZE];
    byte[] body = new byte[0];

    bis.read(version, 0, CSCP_VERSION_SIZE);
    bis.read(bodylen, 0, CSCP_BODYLEN_SIZE);
    int ibodylen = Integer.valueOf((new String(bodylen)).trim());
    if (ibodylen > 0) {
      int restlen = ibodylen;
      do {
        CSCPPARAM param = new CSCPPARAM();
        param.read(bis);
        restlen -= param.size();
        add(param);
      } while (restlen > 0);
      body = new byte[ibodylen];
      // bis.read(body, 0, ibodylen);
    }
    return new String(body);
  }
Esempio n. 7
0
 public void add(CSCPPARAM param) {
   this.params.add(param);
   this.bodylen += param.size();
 }