home *** CD-ROM | disk | FTP | other *** search
- package sun.net.www.protocol.mailto;
-
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.OutputStream;
- import java.net.InetAddress;
- import java.net.SocketPermission;
- import java.net.URL;
- import java.net.UnknownHostException;
- import java.security.Permission;
- import sun.net.smtp.SmtpClient;
- import sun.net.www.MessageHeader;
- import sun.net.www.ParseUtil;
- import sun.net.www.URLConnection;
-
- public class MailToURLConnection extends URLConnection {
- // $FF: renamed from: is java.io.InputStream
- InputStream field_0 = null;
- // $FF: renamed from: os java.io.OutputStream
- OutputStream field_1 = null;
- SmtpClient client;
- Permission permission;
-
- MailToURLConnection(URL var1) {
- super(var1);
- MessageHeader var2 = new MessageHeader();
- var2.add("content-type", "text/html");
- ((URLConnection)this).setProperties(var2);
- }
-
- String getFromAddress() {
- String var1 = System.getProperty("user.fromaddr");
- if (var1 == null) {
- var1 = System.getProperty("user.name");
- if (var1 != null) {
- String var2 = System.getProperty("mail.host");
- if (var2 == null) {
- try {
- var2 = InetAddress.getLocalHost().getHostName();
- } catch (UnknownHostException var4) {
- }
- }
-
- var1 = var1 + "@" + var2;
- } else {
- var1 = "";
- }
- }
-
- return var1;
- }
-
- public void connect() throws IOException {
- this.client = new SmtpClient();
- }
-
- public synchronized OutputStream getOutputStream() throws IOException {
- if (this.field_1 != null) {
- return this.field_1;
- } else if (this.field_0 != null) {
- throw new IOException("Cannot write output after reading input.");
- } else {
- this.connect();
- String var1 = ParseUtil.decode(super.url.getPath());
- this.client.from(this.getFromAddress());
- this.client.to(var1);
- this.field_1 = this.client.startMessage();
- return this.field_1;
- }
- }
-
- public Permission getPermission() throws IOException {
- if (this.permission == null) {
- this.connect();
- String var1 = this.client.getMailHost() + ":" + 25;
- this.permission = new SocketPermission(var1, "connect");
- }
-
- return this.permission;
- }
- }
-