Package org.apache.mailet

Examples of org.apache.mailet.Mailet


                    MailetConfigImpl configImpl = new MailetConfigImpl();
                    configImpl.setMailetName(mailetName);
                    configImpl.setConfiguration(configuration);
                    configImpl.setMailetContext(context);

                    Mailet mailet = (Mailet) Class.forName(className).newInstance();
                    mailet.init(configImpl);
                    return mailet;
                } catch (ClassNotFoundException cnfe) {
                    //do this so we loop through all the packages
                }
            }
View Full Code Here


                    if (theClassLoader == null) {
                        theClassLoader = this.getClass().getClassLoader();
                    }

                    Mailet mailet = (Mailet) theClassLoader.loadClass(className).newInstance();
                    mailet.init(configImpl);
                    return mailet;
                } catch (ClassNotFoundException cnfe) {
                    //do this so we loop through all the packages
                }
            }
View Full Code Here

    public void testDKIMSign() throws MessagingException, IOException,
            FailException {
        String message = "Received: by 10.XX.XX.12 with SMTP id dfgskldjfhgkljsdfhgkljdhfg;\r\n\tTue, 06 Oct 2009 07:37:34 -0700 (PDT)\r\nReturn-Path: <bounce@example.com>\r\nReceived: from example.co.uk (example.co.uk [XX.XXX.125.19])\r\n\tby mx.example.com with ESMTP id dgdfgsdfgsd.97.2009.10.06.07.37.32;\r\n\tTue, 06 Oct 2009 07:37:32 -0700 (PDT)\r\nFrom: apache@bago.org\r\nTo: apache@bago.org\r\n\r\nbody\r\nprova\r\n";

        Mailet mailet = new DKIMSign();

        FakeMailetConfig mci = new FakeMailetConfig("Test",
                new FakeMailContext());
        mci
                .setProperty(
                        "signatureTemplate",
                        "v=1; s=selector; d=example.com; h=from:to:received:received; a=rsa-sha256; bh=; b=;");
        mci.setProperty("privateKey", TESTING_PEM);

        mailet.init(mci);

        Mail mail = new FakeMail();
        mail.setMessage(new MimeMessage(Session
                .getDefaultInstance(new Properties()),
                new ByteArrayInputStream(message.getBytes())));

        mailet.service(mail);

        Mailet m7bit = new ConvertTo7Bit();
        m7bit.init(mci);
        m7bit.service(mail);

        ByteArrayOutputStream rawMessage = new ByteArrayOutputStream();
        mail.getMessage().writeTo(rawMessage);

        MockPublicKeyRecordRetriever mockPublicKeyRecordRetriever = new MockPublicKeyRecordRetriever(
View Full Code Here

    public void testDKIMSignFuture() throws MessagingException, IOException,
            FailException {
        String message = "Received: by 10.XX.XX.12 with SMTP id dfgskldjfhgkljsdfhgkljdhfg;\r\n\tTue, 06 Oct 2009 07:37:34 -0700 (PDT)\r\nReturn-Path: <bounce@example.com>\r\nReceived: from example.co.uk (example.co.uk [XX.XXX.125.19])\r\n\tby mx.example.com with ESMTP id dgdfgsdfgsd.97.2009.10.06.07.37.32;\r\n\tTue, 06 Oct 2009 07:37:32 -0700 (PDT)\r\nFrom: apache@bago.org\r\nTo: apache@bago.org\r\n\r\nbody\r\nprova\r\n";

        Mailet mailet = new DKIMSign();

        FakeMailetConfig mci = new FakeMailetConfig("Test",
                new FakeMailContext());
        mci
                .setProperty(
                        "signatureTemplate",
                        "v=1; t="+((System.currentTimeMillis()/1000)+1000)+"; s=selector; d=example.com; h=from:to:received:received; a=rsa-sha256; bh=; b=;");
        mci.setProperty("privateKey", TESTING_PEM);

        mailet.init(mci);

        Mail mail = new FakeMail();
        mail.setMessage(new MimeMessage(Session
                .getDefaultInstance(new Properties()),
                new ByteArrayInputStream(message.getBytes())));

        mailet.service(mail);

        Mailet m7bit = new ConvertTo7Bit();
        m7bit.init(mci);
        m7bit.service(mail);

        ByteArrayOutputStream rawMessage = new ByteArrayOutputStream();
        mail.getMessage().writeTo(rawMessage);
       
        MockPublicKeyRecordRetriever mockPublicKeyRecordRetriever = new MockPublicKeyRecordRetriever(
View Full Code Here

    public void testDKIMSignTime() throws MessagingException, IOException,
            FailException {
        String message = "Received: by 10.XX.XX.12 with SMTP id dfgskldjfhgkljsdfhgkljdhfg;\r\n\tTue, 06 Oct 2009 07:37:34 -0700 (PDT)\r\nReturn-Path: <bounce@example.com>\r\nReceived: from example.co.uk (example.co.uk [XX.XXX.125.19])\r\n\tby mx.example.com with ESMTP id dgdfgsdfgsd.97.2009.10.06.07.37.32;\r\n\tTue, 06 Oct 2009 07:37:32 -0700 (PDT)\r\nFrom: apache@bago.org\r\nTo: apache@bago.org\r\n\r\nbody\r\nprova\r\n";

        Mailet mailet = new DKIMSign();

        FakeMailetConfig mci = new FakeMailetConfig("Test",
                new FakeMailContext());
        mci
                .setProperty(
                        "signatureTemplate",
                        "v=1; t=; s=selector; d=example.com; h=from:to:received:received; a=rsa-sha256; bh=; b=;");
        mci.setProperty("privateKey", TESTING_PEM);

        mailet.init(mci);

        Mail mail = new FakeMail();
        mail.setMessage(new MimeMessage(Session
                .getDefaultInstance(new Properties()),
                new ByteArrayInputStream(message.getBytes())));

        mailet.service(mail);

        Mailet m7bit = new ConvertTo7Bit();
        m7bit.init(mci);
        m7bit.service(mail);

        ByteArrayOutputStream rawMessage = new ByteArrayOutputStream();
        mail.getMessage().writeTo(rawMessage);

        MockPublicKeyRecordRetriever mockPublicKeyRecordRetriever = new MockPublicKeyRecordRetriever(
View Full Code Here

                .getDefaultInstance(new Properties()));
        mm.addFrom(new Address[] { new InternetAddress("io@bago.org") });
        mm.addRecipient(RecipientType.TO, new InternetAddress("io@bago.org"));
        mm.setText("An 8bit encoded body with \u20ACuro symbol.", "ISO-8859-15");

        Mailet mailet = new DKIMSign();

        FakeMailetConfig mci = new FakeMailetConfig("Test",
                new FakeMailContext());
        mci
                .setProperty(
                        "signatureTemplate",
                        "v=1; s=selector; d=example.com; h=from:to:received:received; a=rsa-sha256; bh=; b=;");
        mci
                .setProperty(
                        "privateKey",
                        TESTING_PEM);

        mailet.init(mci);

        Mail mail = new FakeMail();
        mail.setMessage(mm);

        Mailet m7bit = new ConvertTo7Bit();
        m7bit.init(mci);

        mailet.service(mail);

        m7bit.service(mail);

        ByteArrayOutputStream rawMessage = new ByteArrayOutputStream();
        mail.getMessage().writeTo(rawMessage);

        MockPublicKeyRecordRetriever mockPublicKeyRecordRetriever = new MockPublicKeyRecordRetriever(
View Full Code Here

                        TESTING_PEM);

        Mail mail = new FakeMail();
        mail.setMessage(mm);

        Mailet mailet = new DKIMSign();
        mailet.init(mci);

        Mailet m7bit = new ConvertTo7Bit();
        m7bit.init(mci);
        m7bit.service(mail);

        mailet.service(mail);

        m7bit.service(mail);

        ByteArrayOutputStream rawMessage = new ByteArrayOutputStream();
        mail.getMessage().writeTo(rawMessage);

        MockPublicKeyRecordRetriever mockPublicKeyRecordRetriever = new MockPublicKeyRecordRetriever(
View Full Code Here

                        TESTING_PEM);

        Mail mail = new FakeMail();
        mail.setMessage(mm);

        Mailet mailet = new DKIMSign();
        mailet.init(mci);

        Mailet m7bit = new ConvertTo7Bit();
        m7bit.init(mci);
        // m7bit.service(mail);

        mailet.service(mail);

        m7bit.service(mail);

        ByteArrayOutputStream rawMessage = new ByteArrayOutputStream();
        mail.getMessage().writeTo(rawMessage);

        MockPublicKeyRecordRetriever mockPublicKeyRecordRetriever = new MockPublicKeyRecordRetriever(
View Full Code Here

        assertNotNull(attr);
        assertTrue(attr.startsWith("neutral"));
    }

    private Mail process(String message) throws MessagingException {
        Mailet mailet = new DKIMVerify() {

            @Override
            public void init() throws MessagingException {
                verifier = new DKIMVerifier(new MockPublicKeyRecordRetriever(
                        "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDYDaYKXzwVYwqWbLhmuJ66aTAN8wmDR+rfHE8HfnkSOax0oIoTM5zquZrTLo30870YMfYzxwfB6j/Nz3QdwrUD/t0YMYJiUKyWJnCKfZXHJBJ+yfRHr7oW+UW3cVo9CG2bBfIxsInwYe175g9UjyntJpWueqdEIo1c2bhv9Mp66QIDAQAB;",
                        "selector", "example.com"));
            }
           
        };

        FakeMailetConfig mci = new FakeMailetConfig("Test",
                new FakeMailContext());

        mailet.init(mci);

        Mail mail = new FakeMail();
        mail.setMessage(new MimeMessage(Session
                .getDefaultInstance(new Properties()),
                new ByteArrayInputStream(message.getBytes())));

        mailet.service(mail);
        return mail;
    }
View Full Code Here

    public void testNoAttachment() {

    }

    public void testSimpleAttachment() throws MessagingException, IOException {
        Mailet mailet = initMailet();

        MimeMessage message = new MimeMessage(Session
                .getDefaultInstance(new Properties()));

        MimeMultipart mm = new MimeMultipart();
        MimeBodyPart mp = new MimeBodyPart();
        mp.setText("simple text");
        mm.addBodyPart(mp);
        String body = "\u0023\u00A4\u00E3\u00E0\u00E9";
        MimeBodyPart mp2 = new MimeBodyPart(new ByteArrayInputStream(
                ("Content-Transfer-Encoding: 8bit\r\nContent-Type: application/octet-stream; charset=utf-8\r\n\r\n" + body).getBytes("UTF-8")));
        mp2.setDisposition("attachment");
        mp2.setFileName("10.tmp");
        mm.addBodyPart(mp2);
        String body2 = "\u0014\u00A3\u00E1\u00E2\u00E4";
        MimeBodyPart mp3 = new MimeBodyPart(new ByteArrayInputStream(
                ("Content-Transfer-Encoding: 8bit\r\nContent-Type: application/octet-stream; charset=utf-8\r\n\r\n" + body2).getBytes("UTF-8")));
        mp3.setDisposition("attachment");
        mp3.setFileName("temp.zip");
        mm.addBodyPart(mp3);
        message.setSubject("test");
        message.setContent(mm);
        message.saveChanges();

        Mail mail = new FakeMail();
        mail.setMessage(message);

        mailet.service(mail);

        ByteArrayOutputStream rawMessage = new ByteArrayOutputStream();
        mail.getMessage().writeTo(rawMessage,
                new String[] { "Bcc", "Content-Length", "Message-ID" });
View Full Code Here

TOP

Related Classes of org.apache.mailet.Mailet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.