📄 networkconfigdialog.java
字号:
addButton(ACTION_OK, this); addCloseButton("Cancel"); } public void actionPerformed(ActionEvent ev) { String filen = filename.getText(); if (filen == null || filen.equals("")) { TahitiDialog.alert(getMainWindow(), "Specify filename") .popupAtCenterOfParent(); return; } String owner = getOwnerName(); String workDir = FileUtils.getWorkDirectoryForUser(owner); String secretFilename = workDir + File.separator + filen; SharedSecret secret = null; try { secret = SharedSecret.load(secretFilename); } catch (FileNotFoundException excpt) { TahitiDialog.alert(getMainWindow(), "File not found: " + secretFilename) .popupAtCenterOfParent(); return; } catch (IOException excpt) { TahitiDialog.alert(getMainWindow(), "Cannot read file: " + secretFilename) .popupAtCenterOfParent(); return; } if (secret == null) { TahitiDialog.alert(getMainWindow(), "No shared secret: " + secretFilename) .popupAtCenterOfParent(); return; } String domainName = secret.getDomainName(); SharedSecrets secrets = SharedSecrets.getSharedSecrets(); SharedSecret sec = secrets.getSharedSecret(domainName); if (sec != null) { TahitiDialog.alert(getMainWindow(), "The shared secret for domain '" + domainName + "' already exists").popupAtCenterOfParent(); return; } secrets.addSharedSecret(secret); secrets.save(); TahitiDialog.message(getMainWindow(), "Imported", "The shared secret for domain '" + domainName + "' is imported").popupAtCenterOfParent(); dispose(); } } ; TahitiDialog d = new ImportSharedSecret(getMainWindow()); d.popupAtCenterOfParent(); } private void inform() { Resource aglets_res = Resource.getResourceFor("aglets"); if (Tahiti.enableBox) { // Tahiti.POLLING.setFrequency( aglets_res.getInteger("aglets.box.update.sec", 0)); } } public void itemStateChanged(ItemEvent ev) { updateGUIState(); } /* * Layouts all components */ void makePanel() { GridBagPanel p = new GridBagPanel(); add("Center", p); GridBagConstraints cns = new GridBagConstraints(); cns.anchor = GridBagConstraints.WEST; cns.fill = GridBagConstraints.BOTH; cns.weightx = 1.0; cns.weighty = 1.0; cns.insets = new Insets(5, 5, 5, 5); p.setConstraints(cns); BorderPanel panel = new BorderPanel("Http Tunneling"); p.add(panel, GridBagConstraints.REMAINDER); setupHttpTunnelingPanel(panel); // panel = new BorderPanel("Subscription"); // p.add(panel, GridBagConstraints.REMAINDER); // setupSubscriptionPanel(panel); panel = new BorderPanel("Authentication"); p.add(panel, GridBagConstraints.REMAINDER); setupAuthenticationPanel(panel); panel = new BorderPanel("Others"); p.add(panel, GridBagConstraints.REMAINDER); setupOthersPanel(panel); _updateChoice.addItem("None"); _updateChoice.addItem("At most every 15sec"); _updateChoice.addItem("At most every 30sec"); _updateChoice.addItem("At most every 1 min"); _updateChoice.addItem("At most every 5 min"); _updateChoice.addItem("At most every 15min"); _updateChoice.addItem("At most once an hour"); updateValues(); } protected Panel makeSubscribeButtonPanel() { Panel p = new Panel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT)); p.add(_subscribe); p.add(_unsubscribe); _subscribe.setActionCommand(ACTION_SUBSCRIBE); _subscribe.addActionListener(this); _unsubscribe.setActionCommand(ACTION_UNSUBSCRIBE); _unsubscribe.addActionListener(this); return p; } private void removeSharedSecret() { // ?????NEED TO BE IMPLEMENTED (HT) class RemoveSharedSecret extends TahitiDialog implements ActionListener { List list; TextField password; SharedSecrets secrets; RemoveSharedSecret(Frame f, SharedSecrets secs) { super(f, REMOVE_SHARED_SECRET, true); secrets = secs; add("North", new Label(REMOVE_SHARED_SECRET, Label.CENTER)); GridBagPanel p = new GridBagPanel(); add(p); list = new List(5, false); password = new TextField(20); password.setEchoChar('*'); GridBagConstraints cns = new GridBagConstraints(); cns.fill = GridBagPanel.HORIZONTAL; cns.anchor = GridBagConstraints.WEST; cns.gridwidth = GridBagConstraints.REMAINDER; p.setConstraints(cns); p.addLabeled("Domain name list", list); p.addLabeled("Password", password); list.addActionListener(this); Enumeration domains = secrets.getDomainNames(); if (domains != null) { while (domains.hasMoreElements()) { String domain = (String)domains.nextElement(); list.add(domain); } } password.addActionListener(this); addButton(ACTION_OK, this); addCloseButton("Cancel"); } public void actionPerformed(ActionEvent ev) { String domainName = list.getSelectedItem(); if (domainName == null || domainName.equals("")) { TahitiDialog .alert(getMainWindow(), "Select a domain name in list") .popupAtCenterOfParent(); return; } SharedSecret secret = secrets.getSharedSecret(domainName); if (secret == null) { TahitiDialog .alert(getMainWindow(), "Shared secret does not exist") .popupAtCenterOfParent(); return; } AgletRuntime rt = AgletRuntime.getAgletRuntime(); // Certificate ownerCert = rt.getOwnerCertificate(); String ownerName = rt.getOwnerName(); if (rt.authenticateOwner(ownerName, password.getText()) == null) { TahitiDialog .alert(getMainWindow(), "Authentication failed") .popupAtCenterOfParent(); password.setText(""); return; } /* * ------------ * String ownerName = secret.getOwnerName(); * UserAuthenticator auth = UserAuthenticator.getUserAuthenticator(); * User owner = auth.getUser(ownerName); * if(owner==null) { * TahitiDialog.alert(getMainWindow(), * "The owner does not exist").popupAtCenterOfParent(); * return; * } * if(!owner.isNoLogin() && !owner.verify(password.getText())) { * TahitiDialog.alert(getMainWindow(), * "Password is incorrect").popupAtCenterOfParent(); * password.setText(""); * return; * } * ---------------- */ secrets.removeSharedSecret(domainName); secrets.save(); TahitiDialog.message(getMainWindow(), "Removed", "The domain '" + domainName + "' is removed").popupAtCenterOfParent(); dispose(); } } ; SharedSecrets secrets = SharedSecrets.getSharedSecrets(); if (secrets == null) { TahitiDialog.alert(getMainWindow(), "No shared secrets").popupAtCenterOfParent(); return; } TahitiDialog d = new RemoveSharedSecret(getMainWindow(), secrets); d.popupAtCenterOfParent(); } void restoreDefaults() { _updateChoice.select(0); _httpTunneling.setState(false); _httpMessaging.setState(false); } /* * private boolean check () { * int min = -1; * PopupMessageWindow mw = null; * * try { * min = Integer.parseInt(_boxUpdate.getText().trim()); * } catch(Exception e) { * min = -1; * } * * if (min<0) { * (mw=new PopupMessageWindow(_parent,"ERROR!!","invalid update setting")).popup(_parent); * return false; * } * return true; * } */ private boolean save() { boolean changed = false; String value; Resource system_res = Resource.getResourceFor("system"); Resource atp_res = Resource.getResourceFor("atp"); boolean use = _useProxy.getState(); if (use != atp_res.getBoolean("atp.useHttpProxy", false)) { changed = true; } atp_res.setResource("atp.useHttpProxy", String.valueOf(use)); value = _proxyHost.getText().trim(); if (value.equals(atp_res.getString("atp.http.proxyHost")) == false) { changed = true; } atp_res.setResource("atp.http.proxyHost", value); system_res.setResource("proxyHost", use ? value : ""); system_res.setResource("http.proxyHost", use ? value : ""); value = _proxyPort.getText().trim(); if (value.equals(atp_res.getString("atp.http.proxyPort")) == false) { changed = true; } atp_res.setResource("atp.http.proxyPort", value); system_res.setResource("proxyPort", use ? value : ""); system_res.setResource("http.proxyPort", use ? value : ""); value = _noProxy.getText().trim(); if (value.equals(atp_res.getString("atp.noProxy")) == false) { changed = true; } atp_res.setResource("atp.noProxy", value); system_res.setResource("http.nonProxyHosts", value); /* * allow/disallow http tunneling/messaging */ atp_res.setResource("atp.http.tunneling", String.valueOf(_httpTunneling.getState())); atp_res.setResource("atp.http.messaging", String.valueOf(_httpMessaging.getState())); // com.ibm.atp.daemon.Daemon.update(); /* * authentication */ final boolean auth = _authenticationMode.getState(); if (auth != atp_res.getBoolean("atp.authentication", false)) { changed = true; } atp_res.setResource("atp.authentication", String.valueOf(auth)); if (auth) { System.out.println("AUTHENTICATION MODE ON."); // SharedSecrets.getSharedSecrets(); } else { System.out.println("AUTHENTICATION MODE OFF."); } final boolean secureseed = _secureRandomSeed.getState(); atp_res.setResource("atp.secureseed", String.valueOf(secureseed)); if (secureseed) { System.out.println("USE SECURE RANDOM SEED."); } else { System.out.println("USE UNSECURE PSEUDO RANDOM SEED."); } // Randoms.setUseSecureRandomSeed(secureseed); if (auth) { System.out .print("[Generating random seed ... wait for a while ... "); if (auth) { // Randoms.getRandomGenerator(Challenge.LENGTH); } System.out.println("done.]"); } Resource aglets_res = Resource.getResourceFor("aglets"); if (Tahiti.enableBox) { aglets_res .setResource("aglets.box.update.sec", String .valueOf(updateValue(_updateChoice .getSelectedIndex()))); aglets_res .setResource("aglets.box.update", String .valueOf(_updateChoice.getSelectedIndex())); aglets_res.setResource("aglets.box.host", _boxHost.getText().trim()); aglets_res.setResource("aglets.box.passwd", _boxPasswd.getText().trim()); aglets_res.setResource("aglets.box.userid", _boxUserid.getText().trim()); aglets_res.setResource("aglets.box.subscribe", setSubscribeStatus(_boxSubscribe));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -