当前位置: 首页>>代码示例>>Java>>正文


Java UserException类代码示例

本文整理汇总了Java中com.icegreen.greenmail.user.UserException的典型用法代码示例。如果您正苦于以下问题:Java UserException类的具体用法?Java UserException怎么用?Java UserException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UserException类属于com.icegreen.greenmail.user包,在下文中一共展示了UserException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import com.icegreen.greenmail.user.UserException; //导入依赖的package包/类
@Before
public void setUp() throws MessagingException, UserException, InterruptedException {
    ServerSetup sS = new ServerSetup(4008, "localhost", ServerSetup.PROTOCOL_IMAPS);
    greenMail = new GreenMail(sS);
    greenMail.start();
    user = greenMail.setUser("[email protected]", "okkopa", "soooosecret");
    Properties props = System.getProperties();
    props.setProperty("mail.store.protocol", "imaps");
    Session session = Session.getDefaultInstance(props, null);
    MimeMessage message = new MimeMessage(session);
    message.setSubject("subject2576Hf");
    message.setText("viesti");
    user.deliver(message);

    Security.setProperty("ssl.SocketFactory.provider", DummySSLSocketFactory.class.getName());

    server = new IMAPserver("localhost", "okkopa", "soooosecret", 4008);
    server.login();

    IMAPfolder = new IMAPfolder(server, "inbox");

    assertTrue(greenMail.waitForIncomingEmail(5000, 1));

}
 
开发者ID:ohtuprojekti,项目名称:OKKoPa,代码行数:25,代码来源:IMAPfolderTest.java

示例2: setUp

import com.icegreen.greenmail.user.UserException; //导入依赖的package包/类
@Before
public void setUp() throws MessagingException, UserException, InterruptedException {
    Security.setProperty("ssl.SocketFactory.provider", DummySSLSocketFactory.class.getName());

    ServerSetup sS = new ServerSetup(4008, "localhost", ServerSetup.PROTOCOL_IMAPS);
    greenMail = new GreenMail(sS);
    greenMail.start();
    user = greenMail.setUser("[email protected]", "okkopa", "soooosecret");
    Properties props = System.getProperties();
    props.setProperty("mail.store.protocol", "imaps");
    Session session = Session.getDefaultInstance(props, null);
    MimeMessage message = new MimeMessage(session);
    message.setSubject("subject2576Hf");
    message.setText("viesti");
    user.deliver(message);

    assertTrue(greenMail.waitForIncomingEmail(5000, 1));

    server = new IMAPserver("localhost", "okkopa", "soooosecret", 4008);
    server.login();

    IMAPfolder = new IMAPfolder(server, "inbox");
}
 
开发者ID:ohtuprojekti,项目名称:OKKoPa,代码行数:24,代码来源:IMAPmessageTest.java

示例3: execute

import com.icegreen.greenmail.user.UserException; //导入依赖的package包/类
public void execute(Pop3Connection conn, Pop3State state,
                    String cmd) {
    try {
        String[] args = cmd.split(" ");
        if (args.length < 2) {
            conn.println("-ERR Required syntax: USER <username>");

            return;
        }

        String username = args[1];
        state.setUser(state.getUser(username));
        conn.println("+OK");
    } catch (UserException nsue) {
        conn.println("-ERR " + nsue);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-greenmail,代码行数:18,代码来源:UserCommand.java

示例4: contextInitialized

import com.icegreen.greenmail.user.UserException; //导入依赖的package包/类
@Override
public void contextInitialized(final ServletContextEvent sce) {
    log.info("Initializing GreenMail");

    managers = new Managers();
    ServletContext ctx = sce.getServletContext();
    configuration = ConfigurationFactory.create(extractParameters(ctx));
    services = ServiceFactory.create(configuration, managers);

    for (Configuration.User user : configuration.getUsers()) {
        GreenMailUser greenMailUser = managers.getUserManager().getUser(user.email);
        if (null == greenMailUser) {
            try {
                greenMailUser = managers.getUserManager().createUser(
                        user.email, user.login, user.password);
                greenMailUser.setPassword(user.password);
            } catch (UserException e) {
                throw new IllegalStateException(e);
            }
        }
    }
    for (Service s : services) {
        log.info("Starting GreenMail service: {}", s);
        s.startService();
    }
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:27,代码来源:GreenMailListener.java

示例5: execute

import com.icegreen.greenmail.user.UserException; //导入依赖的package包/类
@Override
public void execute(Pop3Connection conn, Pop3State state,
                    String cmd) {
    try {
        String[] args = cmd.split(" ");
        if (args.length < 2) {
            conn.println("-ERR Required syntax: USER <username>");

            return;
        }

        String username = args[1];
        state.setUser(state.getUser(username));
        conn.println("+OK");
    } catch (UserException nsue) {
        conn.println("-ERR " + nsue);
    }
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:19,代码来源:UserCommand.java

示例6: addMailUser

import com.icegreen.greenmail.user.UserException; //导入依赖的package包/类
private void addMailUser(final String user) {
    // Parse ...
    int posColon = user.indexOf(':');
    int posAt = user.indexOf('@');
    String login = user.substring(0, posColon);
    String pwd = user.substring(posColon + 1, posAt);
    String domain = user.substring(posAt + 1);
    String email = login + '@' + domain;
    if (log.isDebugEnabled()) {
        // This is a test system, so we do not care about pwd in the log file.
        log.debug("Adding user " + login + ':' + pwd + '@' + domain);
    }


    GreenMailUser greenMailUser = managers.getUserManager().getUser(email);
    if (null == greenMailUser) {
        try {
            greenMailUser = managers.getUserManager().createUser(email, login, pwd);
            greenMailUser.setPassword(pwd);
        } catch (UserException e) {
            throw new RuntimeException(e);
        }
    }
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:25,代码来源:GreenMailService.java

示例7: createUser

import com.icegreen.greenmail.user.UserException; //导入依赖的package包/类
public GreenMailUser createUser(String email, String login, String password) throws UserException
{
    // TODO: User creation/addition code should be implemented here (in the AlfrescoImapUserManager).
    // Following code is not need and not used in the current implementation.
    GreenMailUser user = new AlfrescoImapUser(email, login, password);
    user.create();
    addUser(user);
    return user;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:10,代码来源:AlfrescoImapUserManager.java

示例8: getUser

import com.icegreen.greenmail.user.UserException; //导入依赖的package包/类
public GreenMailUser getUser(String username) throws UserException {
    GreenMailUser user = _manager.getUser(username);
    if (null == user) {
        throw new NoSuchUserException(username + " doesn't exist");
    }
    return user;
}
 
开发者ID:Alfresco,项目名称:alfresco-greenmail,代码行数:8,代码来源:Pop3State.java

示例9: authenticate

import com.icegreen.greenmail.user.UserException; //导入依赖的package包/类
public void authenticate(String pass)
        throws UserException, FolderException {
    if (_user == null)
        throw new UserException("No user selected");

    _user.authenticate(pass);
    _inbox = imapHostManager.getInbox(_user);
}
 
开发者ID:Alfresco,项目名称:alfresco-greenmail,代码行数:9,代码来源:Pop3State.java

示例10: setUser

import com.icegreen.greenmail.user.UserException; //导入依赖的package包/类
public GreenMailUser setUser(String email, String login, String password) {
    GreenMailUser user = managers.getUserManager().getUser(email);
    if (null == user) {
        try {
            user = managers.getUserManager().createUser(email, login, password);
        } catch (UserException e) {
            throw new RuntimeException(e);
        }
    } else {
        user.setPassword(password);
    }
    return user;
}
 
开发者ID:Alfresco,项目名称:alfresco-greenmail,代码行数:14,代码来源:GreenMail.java

示例11: sendMail

import com.icegreen.greenmail.user.UserException; //导入依赖的package包/类
/**
 * Sending email to the user account in the server with additional headers.
 *
 * @param subject Email subject
 * @throws MessagingException if the properties set to the message are not valid
 * @throws UserException when no such user or user is null
 */
public void sendMail(String subject, Map<String, String> headers)
        throws MessagingException, UserException {
    MimeMessage message = createBasicMessage(subject);
    for (Map.Entry<String, String> entry : headers.entrySet()) {
        message.addHeader(entry.getKey(), entry.getValue());
    }
    greenMailUser.deliver(message);
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:16,代码来源:GreenMailClient.java

示例12: sendMessage

import com.icegreen.greenmail.user.UserException; //导入依赖的package包/类
/**
 * send message to users inbox
 * @param mimeMessage
 * @throws RuntimeException
 */

public void sendMessage(MimeMessage mimeMessage) throws RuntimeException {
    try {
        greenMailUser.deliver(mimeMessage);
    } catch (UserException e) {
        log.error("Error occurred while delivering user mail via greenmail", e);
        throw new RuntimeException("Error occurred while delivering user mail via greenmail", e);
    }
}
 
开发者ID:wso2,项目名称:carbon-platform-integration,代码行数:15,代码来源:MailUser.java

示例13: setUser

import com.icegreen.greenmail.user.UserException; //导入依赖的package包/类
@Override
public GreenMailUser setUser(String email, String login, String password) {
    GreenMailUser user = managers.getUserManager().getUser(login);
    if (null == user) {
        try {
            user = managers.getUserManager().createUser(email, login, password);
        } catch (UserException e) {
            throw new RuntimeException(e);
        }
    } else {
        user.setPassword(password);
    }
    return user;
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:15,代码来源:GreenMail.java

示例14: testSendAndReceive

import com.icegreen.greenmail.user.UserException; //导入依赖的package包/类
@Test
public void testSendAndReceive() throws UnsupportedEncodingException, MessagingException, UserException {
    Session smtpSession = greenMail.getSmtp().createSession();

    Message msg = new MimeMessage(smtpSession);
    msg.setFrom(new InternetAddress("[email protected]"));
    msg.addRecipient(Message.RecipientType.TO,
            new InternetAddress("[email protected]"));
    msg.setSubject("Email sent to GreenMail via plain JavaMail");
    msg.setText("Fetch me via IMAP");
    Transport.send(msg);

    // Create user, as connect verifies pwd
    greenMail.setUser("[email protected]", "[email protected]", "secret-pwd");

    // Alternative 1: Create session and store or ...
    Session imapSession = greenMail.getImap().createSession();
    Store store = imapSession.getStore("imap");
    store.connect("[email protected]", "secret-pwd");
    Folder inbox = store.getFolder("INBOX");
    inbox.open(Folder.READ_ONLY);
    Message msgReceived = inbox.getMessage(1);
    assertEquals(msg.getSubject(), msgReceived.getSubject());

    // Alternative 2: ... let GreenMail create and configure a store:
    IMAPStore imapStore = greenMail.getImap().createStore();
    imapStore.connect("[email protected]", "secret-pwd");
    inbox = imapStore.getFolder("INBOX");
    inbox.open(Folder.READ_ONLY);
    msgReceived = inbox.getMessage(1);
    assertEquals(msg.getSubject(), msgReceived.getSubject());

    // Alternative 3: ... directly fetch sent message using GreenMail API
    assertEquals(1, greenMail.getReceivedMessagesForDomain("[email protected]").length);
    msgReceived = greenMail.getReceivedMessagesForDomain("[email protected]")[0];
    assertEquals(msg.getSubject(), msgReceived.getSubject());

    store.close();
    imapStore.close();
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:41,代码来源:ExampleJavaMailTest.java

示例15: testPop3Capabillities

import com.icegreen.greenmail.user.UserException; //导入依赖的package包/类
@Test
public void testPop3Capabillities() throws MessagingException, UserException {
    final POP3Store store = greenMail.getPop3().createStore();
    greenMail.getManagers().getUserManager().createUser("[email protected]",
            "[email protected]", "pwd");
    store.connect("[email protected]", "pwd");
    try {
        assertTrue(store.capabilities().containsKey("UIDL"));
    } finally {
        store.close();
    }
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:13,代码来源:Pop3ServerTest.java


注:本文中的com.icegreen.greenmail.user.UserException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。