1 package org.cacert.gigi.email;
3 import java.io.DataInputStream;
4 import java.io.DataOutputStream;
5 import java.io.IOException;
6 import java.net.InetAddress;
7 import java.net.ServerSocket;
8 import java.net.Socket;
9 import java.util.Properties;
11 class TestEmailProvider extends EmailProvider {
17 protected TestEmailProvider(Properties props) {
19 servs = new ServerSocket(Integer.parseInt(props.getProperty("emailProvider.port")), 10,
20 InetAddress.getByName("127.0.0.1"));
21 } catch (IOException e) {
27 public synchronized void sendmail(String to, String subject, String message, String from, String replyto,
28 String toname, String fromname, String errorsto, boolean extra) throws IOException {
30 assureLocalConnection();
40 } catch (IOException e) {
46 private void assureLocalConnection() throws IOException {
50 } catch (IOException e) {
54 if (client == null || client.isClosed()) {
55 client = servs.accept();
56 out = new DataOutputStream(client.getOutputStream());
57 in = new DataInputStream(client.getInputStream());
62 public synchronized String checkEmailServer(int forUid, String address) throws IOException {
64 assureLocalConnection();
66 out.writeUTF("challengeAddrBox");
67 out.writeUTF(address);
69 } catch (IOException e) {
75 private void write(String to) throws IOException {
77 out.writeUTF("<null>");