Пример #1
0
 public static Calendar getUpdateDate(Calendar serverDate, Calendar localDate) {
   String lDate = Util.getGeneralizedTime();
   Calendar newLocalDate = Util.getCalendar(lDate);
   long timeMil = 0;
   if (serverDate.compareTo(localDate) == 1)
     timeMil = serverDate.getTimeInMillis() - localDate.getTimeInMillis();
   if (DEBUG) System.out.println("Time def btw server and client: " + timeMil);
   return Util.incCalendar(newLocalDate, (int) timeMil);
 }
Пример #2
0
        @SuppressWarnings("unchecked")
	public JPanel makeChoicePanel(JPanel p, int []_y) {
		int y=_y[0];
		GridBagConstraints c = new GridBagConstraints();
		c.fill = GridBagConstraints.NONE;
		
		c.anchor = GridBagConstraints.EAST;
		c.gridx = 0; c.gridy = y++;		
		TranslatedLabel label_choice = new TranslatedLabel("Vote");
		p.add(label_choice, c);
		c.gridx = 1;
		c.anchor = GridBagConstraints.WEST;
		choices = getChoices();
		p.add(vote_choice_field = new JComboBox(choices),c);
		vote_choice_field.addItemListener(this);
		
		vote_nojust_field = new JRadioButton(_("No Justification"));
		vote_oldjust_field = new JRadioButton(_("Old Justification"));
		vote_newjust_field = new JRadioButton(_("New Justification"));
		vote_nojust_field.setMnemonic(KeyEvent.VK_N);
		vote_oldjust_field.setMnemonic(KeyEvent.VK_O);
		vote_newjust_field.setMnemonic(KeyEvent.VK_W);
		vote_nojust_field.setActionCommand("j_none");
		vote_oldjust_field.setActionCommand("j_old");
		vote_newjust_field.setActionCommand("j_new");
		vote_nojust_field.setSelected(true);
		vote_oldjust_field.setSelected(false);
		vote_newjust_field.setSelected(false);
		ButtonGroup vote_j_group = new ButtonGroup();
		vote_j_group.add(vote_nojust_field);
		vote_j_group.add(vote_oldjust_field);
		vote_j_group.add(vote_newjust_field);		
		JPanel vj_panel=new JPanel();
		vj_panel.setLayout(new BoxLayout(vj_panel, BoxLayout.Y_AXIS));
		vj_panel.add(vote_nojust_field);
		vj_panel.add(vote_oldjust_field);
		vj_panel.add(vote_newjust_field);		
		vote_nojust_field.addActionListener(this);
		vote_oldjust_field.addActionListener(this);
		vote_newjust_field.addActionListener(this);
		
		c.anchor = GridBagConstraints.EAST;
		c.gridx = 0; c.gridy = y++;
		TranslatedLabel label_type = new TranslatedLabel("Type");
		p.add(label_type, c);
		c.gridx = 1;
		c.anchor = GridBagConstraints.WEST;
		p.add(vj_panel,c);
		
		c.anchor = GridBagConstraints.EAST;
		c.gridx = 0; c.gridy = y++;		
		TranslatedLabel label_old_just = new TranslatedLabel("Old Justification");
		p.add(label_old_just, c);
		c.gridx = 1;
		c.anchor = GridBagConstraints.WEST;
		p.add(just_old_just_field = new JComboBox(combo_answerTo),c);
		//p.add(just_answer_field = new JTextField(TITLE_LEN),c);
		//just_answer_field.getDocument().addDocumentListener(this);
		just_old_just_field.setEnabled(false);
		just_old_just_field.addItemListener(this);

		String creation_date = Util.getGeneralizedTime();
		vote_date_field = new JTextField(creation_date);
		vote_date_field.setColumns(creation_date.length());
		
		c.gridx = 0; c.gridy = y++;		
		c.anchor = GridBagConstraints.EAST;
		TranslatedLabel label_date = new TranslatedLabel("Creation Date");
		p.add(label_date, c);
		c.gridx = 1;
		c.anchor = GridBagConstraints.WEST;
		//hash_org.creation_date = creation_date;
		p.add(vote_date_field,c);
		vote_date_field.setForeground(Color.GREEN);
		//name_field.addActionListener(this); //name_field.addFocusListener(this);
		vote_date_field.getDocument().addDocumentListener(this);
		
		c.gridx = 0; c.gridy = y++;		
		c.gridx = 1;
		c.anchor = GridBagConstraints.WEST;
		p.add(vote_dategen_field = new JButton(_("Set Current Date")),c);
		vote_dategen_field.addActionListener(this);

		if (SUBMIT) {
			c.anchor = GridBagConstraints.EAST;
			c.gridx = 0; c.gridy = y++;		
			c.gridx = 1;
			c.anchor = GridBagConstraints.WEST;
			p.add(just_submit_field = new JButton(_("Submit Vote")),c);
			just_submit_field.addActionListener(this);
		}
		_y[0] = y;
		return p;
	}	
Пример #3
0
  public static updates.VersionInfo getWSVersionInfo(
      URL url, String GID, SK myPeerSK, Hashtable<Object, Object> context) {
    if (DEBUG_) System.out.println("call getWSVersionInfo on URL " + url);
    int i = url.toString().indexOf("&");
    if (i == -1) {
      if (DEBUG_) System.out.println("URL " + url + " has no PK hash");
      return null;
    }
    String PK_hex = url.toString().substring(i + 1);
    try {
      url = new URL(url.toString().substring(0, i));
    } catch (MalformedURLException ex) {
      System.out.println("error in url: " + url);
      return null;
    }
    if (DEBUG_) System.out.println("pk= " + PK_hex + "  url= " + url);
    DdWS service = new DdWS(url);
    if (DEBUG_) if (service == null) System.out.println("service=null");

    // service.getHandlerResolver().getHandlerChain(service.getDdWSPort()).add(new Handler());
    DdWSPortType DDver = service.getDdWSPort();
    // System.out.println("part: "+ service);

    BindingProvider bindingProvider = ((BindingProvider) DDver);

    List<javax.xml.ws.handler.Handler> handlerChain =
        bindingProvider.getBinding().getHandlerChain();
    Handler handler = new Handler();
    handler.setPK_Hex(PK_hex);
    handlerChain.add(handler);
    bindingProvider.getBinding().setHandlerChain(handlerChain);

    if (DEBUG_) if (DDver == null) System.out.println("DDver=null");
    // build history object
    Map<String, Object> c = bindingProvider.getRequestContext();
    Object URLloc = c.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
    /* To change the location address
    *context.put(
      BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
      newAddress);
    */
    // System.out.println("loc: "+URLloc.toString());
    DateInfo d;
    if ((d = (DateInfo) context.get(url.toString())) == null) {
      if (ClientUpdates.DEBUG || DEBUG) System.out.println(" Context = null");
      d = new DateInfo();
    } else {
      if (ClientUpdates.DEBUG || DEBUG) System.out.println("localtime: " + d.LocalDate.getTime());
      if (ClientUpdates.DEBUG || DEBUG)
        System.out.println("Caltime: " + d.CalculatedDate.getTime());
      if (ClientUpdates.DEBUG || DEBUG)
        if (d.ServerDate != null) System.out.println("Servertime: " + d.ServerDate.getTime());
    }
    if (d.ServerDate != null) // server date set only with error
    d.CalculatedDate = getUpdateDate(d.ServerDate, d.LocalDate);
    d.ServerDate = null;
    String lDate = Util.getGeneralizedTime();
    d.LocalDate = Util.getCalendar(lDate);
    if (d.CalculatedDate == null) d.CalculatedDate = d.LocalDate;
    Request rq = new Request(GID, URLloc.toString(), d.CalculatedDate);
    String signature = Util.stringSignatureFromByte(rq.sign(myPeerSK));
    History h = new History();
    h.setGID(rq.peerGID);
    h.setUrl(rq.url);
    h.setDate(Encoder.getGeneralizedTime(rq.date)); // date as generalized for server side
    h.setSignature(signature);
    VersionInfo response = null;
    context.put(url.toString(), d);
    try {
      response = DDver.getVersionInfo(h);
    } catch (SOAPFaultException e) {
      if (DEBUG)
        System.err.println(
            "WSUpdate:HandleService:Code: "
                + e.getFault().getFaultCode()
                + ", Actor: "
                + e.getFault().getFaultActor()
                + ", String: "
                + e.getFault().getFaultString());
      if (e.getFault().getFaultActor().trim().equals("date")) {
        statusCode = INVALID_DATE;
        errorString = e.getFault().getFaultString();
        d = (DateInfo) context.get(url.toString());
        d.ServerDate = Util.getCalendar(errorString + ".000Z"); // Calendar.getInstance();
        context.remove(url.toString());
        context.put(url.toString(), d);
        // d.ServerDate.setTime(new Date(Long.parseLong(errorString)));
        if (DEBUG)
          System.out.println(
              "WSUpdate:HandleService:Server: "
                  + d.ServerDate.getTime()
                  + "  Client: "
                  + d.LocalDate.getTime());
      } else if (e.getFault().getFaultActor().trim().equals("url")) {
        statusCode = INVALID_URL;
        errorString = e.getFault().getFaultString();
      }
      return null;
    }
    statusCode = handler.isValidSignature();
    if (statusCode == INVALID_SIGNATURE) {
      return null;
    }
    updates.VersionInfo v = new updates.VersionInfo();
    v.version = response.getVersion();
    v.script = response.getScript();
    v.date = Util.getCalendar(response.getDate());
    // v.signature = Util.byteSignatureFromString(response.getSignature());
    v.data = new updates.Downloadable[response.getData().size()];
    Downloadable downloadable = null;
    for (i = 0; i < v.data.length; i++) {
      v.data[i] = new updates.Downloadable();
      downloadable = (Downloadable) response.getData().get(i);
      v.data[i].filename = downloadable.getFileName();
      v.data[i].url = downloadable.getUrl();
      v.data[i].digest = Util.byteSignatureFromString(downloadable.getDigest());
    }
    v.releaseQD = new data.D_ReleaseQuality[response.getQOTD().size()];
    TestDef testDef = null;
    for (i = 0; i < v.releaseQD.length; i++) {
      testDef = (TestDef) response.getQOTD().get(i);
      //	int index = testDef.getRef().intValue() - 1;
      int index = testDef.getRef().intValue();
      v.releaseQD[index] = new data.D_ReleaseQuality();

      v.releaseQD[index]._quality = new String[testDef.getQualityStructure().size()];
      for (int j = 0; j < v.releaseQD[index]._quality.length; j++) {
        v.releaseQD[index]._quality[j] = testDef.getQualityStructure().get(j);
      }
      v.releaseQD[index].description = testDef.getDesc();
    }

    v.testers_data = new data.D_SoftwareUpdatesReleaseInfoByTester[response.getTesters().size()];
    TesterInfo testerInfo = null;
    for (i = 0; i < v.testers_data.length; i++) {
      testerInfo = (TesterInfo) response.getTesters().get(i);
      v.testers_data[i] = new data.D_SoftwareUpdatesReleaseInfoByTester();
      v.testers_data[i].name = testerInfo.getName();
      v.testers_data[i].public_key_hash = testerInfo.getDigestPK();
      v.testers_data[i].tester_QoT =
          new float[response.getQOTD().size()]; // not all array elements are used
      v.testers_data[i].tester_RoT =
          new float[response.getQOTD().size()]; // not all array elements are used
      for (int j = 0; j < testerInfo.getTests().size(); j++) {
        // int index = ((Test)testerInfo.getTests().get(j)).getQualityRef().intValue() - 1;
        int index = ((Test) testerInfo.getTests().get(j)).getQualityRef().intValue();
        v.testers_data[i].tester_QoT[index] =
            ((Test) testerInfo.getTests().get(j)).getQoT().floatValue();
        v.testers_data[i].tester_RoT[index] =
            ((Test) testerInfo.getTests().get(j)).getRoT().floatValue();
      }
      v.testers_data[i].signature = Util.byteSignatureFromString(testerInfo.getSignature());
    }

    return v;
  }