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


Java ProtocolException类代码示例

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


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

示例1: setFlag

import com.icegreen.greenmail.imap.ProtocolException; //导入依赖的package包/类
public void setFlag(String flagString, Flags flags) throws ProtocolException {
    if (flagString.equalsIgnoreCase(MessageFlags.ANSWERED)) {
        flags.add(Flags.Flag.ANSWERED);
    } else if (flagString.equalsIgnoreCase(MessageFlags.DELETED)) {
        flags.add(Flags.Flag.DELETED);
    } else if (flagString.equalsIgnoreCase(MessageFlags.DRAFT)) {
        flags.add(Flags.Flag.DRAFT);
    } else if (flagString.equalsIgnoreCase(MessageFlags.FLAGGED)) {
        flags.add(Flags.Flag.FLAGGED);
    } else if (flagString.equalsIgnoreCase(MessageFlags.SEEN)) {
        flags.add(Flags.Flag.SEEN);
    } else if (flagString.equalsIgnoreCase(MessageFlags.RECENT)) {
        flags.add(Flags.Flag.RECENT);
    } else {
        // User flag
        flags.add(flagString);
    }
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:19,代码来源:CommandParser.java

示例2: statusDataItems

import com.icegreen.greenmail.imap.ProtocolException; //导入依赖的package包/类
StatusDataItems statusDataItems(ImapRequestLineReader request)
        throws ProtocolException {
    StatusDataItems items = new StatusDataItems();

    request.nextWordChar();
    consumeChar(request, '(');
    CharacterValidator validator = new NoopCharValidator();
    String nextWord = consumeWord(request, validator);
    while (!nextWord.endsWith(")")) {
        addItem(nextWord, items);
        nextWord = consumeWord(request, validator);
    }
    // Got the closing ")", may be attached to a word.
    if (nextWord.length() > 1) {
        addItem(nextWord.substring(0, nextWord.length() - 1), items);
    }

    return items;
}
 
开发者ID:Alfresco,项目名称:alfresco-greenmail,代码行数:20,代码来源:StatusCommand.java

示例3: addItem

import com.icegreen.greenmail.imap.ProtocolException; //导入依赖的package包/类
private void addItem(String nextWord, StatusDataItems items)
        throws ProtocolException {
    if (nextWord.equals(MESSAGES)) {
        items.messages = true;
    } else if (nextWord.equals(RECENT)) {
        items.recent = true;
    } else if (nextWord.equals(UIDNEXT)) {
        items.uidNext = true;
    } else if (nextWord.equals(UIDVALIDITY)) {
        items.uidValidity = true;
    } else if (nextWord.equals(UNSEEN)) {
        items.unseen = true;
    } else {
        throw new ProtocolException("Unknown status item: '" + nextWord + "'");
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-greenmail,代码行数:17,代码来源:StatusCommand.java

示例4: doProcess

import com.icegreen.greenmail.imap.ProtocolException; //导入依赖的package包/类
/**
 * @see CommandTemplate#doProcess
 */
protected void doProcess(ImapRequestLineReader request,
                         ImapResponse response,
                         ImapSession session)
        throws ProtocolException {
    String userid = parser.astring(request);
    String password = parser.astring(request);
    parser.endLine(request);

    if (session.getUserManager().test(userid, password)) {
        GreenMailUser user = session.getUserManager().getUser(userid);
        session.setAuthenticated(user);
        response.commandComplete(this);

    } else {
        response.commandFailed(this, "Invalid login/password");
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-greenmail,代码行数:21,代码来源:LoginCommand.java

示例5: nstring

import com.icegreen.greenmail.imap.ProtocolException; //导入依赖的package包/类
/**
 * Reads an argument of type "nstring" from the request.
 */
public String nstring(ImapRequestLineReader request) throws ProtocolException {
    char next = request.nextWordChar();
    switch (next) {
        case '"':
            return consumeQuoted(request);
        case '{':
            return consumeLiteral(request);
        default:
            String value = atom(request);
            if ("NIL".equals(value)) {
                return null;
            } else {
                throw new ProtocolException("Invalid nstring value: valid values are '\"...\"', '{12} CRLF *CHAR8', and 'NIL'.");
            }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-greenmail,代码行数:20,代码来源:CommandParser.java

示例6: date

import com.icegreen.greenmail.imap.ProtocolException; //导入依赖的package包/类
/**
 * Reads a "date" argument from the request.
 * TODO handle timezones properly
 */
public Date date(ImapRequestLineReader request) throws ProtocolException {
    char next = request.nextWordChar();
    String dateString;
    if (next == '"') {
        dateString = consumeQuoted(request);
    } else {
        dateString = atom(request);
    }

    DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
    try {
        return dateFormat.parse(dateString);
    } catch (ParseException e) {
        throw new ProtocolException("Invalid date format.");
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-greenmail,代码行数:21,代码来源:CommandParser.java

示例7: consumeWord

import com.icegreen.greenmail.imap.ProtocolException; //导入依赖的package包/类
/**
 * Reads the next "word from the request, comprising all characters up to the next SPACE.
 * Characters are tested by the supplied CharacterValidator, and an exception is thrown
 * if invalid characters are encountered.
 */
protected String consumeWord(ImapRequestLineReader request,
                             CharacterValidator validator)
        throws ProtocolException {
    StringBuffer atom = new StringBuffer();

    char next = request.nextWordChar();
    while (!isWhitespace(next)) {
        if (validator.isValid(next)) {
            atom.append(next);
            request.consume();
        } else {
            throw new ProtocolException("Invalid character: '" + next + "'");
        }
        next = request.nextChar();
    }
    return atom.toString();
}
 
开发者ID:Alfresco,项目名称:alfresco-greenmail,代码行数:23,代码来源:CommandParser.java

示例8: consumeQuoted

import com.icegreen.greenmail.imap.ProtocolException; //导入依赖的package包/类
/**
 * Reads a quoted string value from the request.
 */
protected String consumeQuoted(ImapRequestLineReader request)
        throws ProtocolException {
    // The 1st character must be '"'
    consumeChar(request, '"');

    StringBuffer quoted = new StringBuffer();
    char next = request.nextChar();
    while (next != '"') {
        if (next == '\\') {
            request.consume();
            next = request.nextChar();
            if (!isQuotedSpecial(next)) {
                throw new ProtocolException("Invalid escaped character in quote: '" +
                        next + "'");
            }
        }
        quoted.append(next);
        request.consume();
        next = request.nextChar();
    }

    consumeChar(request, '"');

    return quoted.toString();
}
 
开发者ID:Alfresco,项目名称:alfresco-greenmail,代码行数:29,代码来源:CommandParser.java

示例9: doProcess

import com.icegreen.greenmail.imap.ProtocolException; //导入依赖的package包/类
/**
     * @see CommandTemplate#doProcess
     */
    protected void doProcess(ImapRequestLineReader request,
                             ImapResponse response,
                             ImapSession session)
            throws ProtocolException, FolderException {
        parser.endLine(request);

        if (!session.getSelected().isReadonly()) {
            MailFolder folder = session.getSelected();
            folder.expunge();
        }
        session.deselect();
        
//      Don't send unsolicited responses on close.
        session.unsolicitedResponses(response);
        response.commandComplete(this);
    }
 
开发者ID:Alfresco,项目名称:alfresco-greenmail,代码行数:20,代码来源:CloseCommand.java

示例10: setFlag

import com.icegreen.greenmail.imap.ProtocolException; //导入依赖的package包/类
public void setFlag(String flagString, Flags flags) throws ProtocolException {
    if (flagString.equalsIgnoreCase(MessageFlags.ANSWERED)) {
        flags.add(Flags.Flag.ANSWERED);
    } else if (flagString.equalsIgnoreCase(MessageFlags.DELETED)) {
        flags.add(Flags.Flag.DELETED);
    } else if (flagString.equalsIgnoreCase(MessageFlags.DRAFT)) {
        flags.add(Flags.Flag.DRAFT);
    } else if (flagString.equalsIgnoreCase(MessageFlags.FLAGGED)) {
        flags.add(Flags.Flag.FLAGGED);
    } else if (flagString.equalsIgnoreCase(MessageFlags.SEEN)) {
        flags.add(Flags.Flag.SEEN);
    } else {
        throw new ProtocolException("Invalid flag string.");
    }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:16,代码来源:CommandParser.java

示例11: addItem

import com.icegreen.greenmail.imap.ProtocolException; //导入依赖的package包/类
private void addItem(String nextWord, StatusDataItems items)
        throws ProtocolException {
    if (nextWord.equals(MESSAGES)) {
        items.messages = true;
    } else if (nextWord.equals(RECENT)) {
        items.recent = true;
    } else if (nextWord.equals(UIDNEXT)) {
        items.uidNext = true;
    } else if (nextWord.equals(UIDVALIDITY)) {
        items.uidValidity = true;
    } else if (nextWord.equals(UNSEEN)) {
        items.unseen = true;
    } else {
        throw new ProtocolException("Unknown status item: '" + nextWord + '\'');
    }
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:17,代码来源:StatusCommand.java

示例12: doProcess

import com.icegreen.greenmail.imap.ProtocolException; //导入依赖的package包/类
/**
 * @see CommandTemplate#doProcess
 */
@Override
protected void doProcess(ImapRequestLineReader request,
                         ImapResponse response,
                         ImapSession session)
        throws ProtocolException, FolderException {
    parser.endLine(request);

    if( session.getHost().getStore().isQuotaSupported()) {
        response.untaggedResponse(CAPABILITY_RESPONSE + SP + "QUOTA");
    }
    else {
        response.untaggedResponse(CAPABILITY_RESPONSE);
    }
    session.unsolicitedResponses(response);
    response.commandComplete(this);
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:20,代码来源:CapabilityCommand.java

示例13: doProcess

import com.icegreen.greenmail.imap.ProtocolException; //导入依赖的package包/类
@Override
protected void doProcess(final ImapRequestLineReader request, final ImapResponse response,
                         final ImapSession session) throws ProtocolException, FolderException, AuthorizationException {
    if(!session.getHost().getStore().isQuotaSupported()) {
        response.commandFailed(this,"Quota is not supported. Activate quota capability first");
    }

    String root = parser.mailbox(request);
    // NAME root (name usage limit)

    Quota[] quota = session.getHost().getStore().getQuota(
            root, session.getUser().getQualifiedMailboxName());
    for(Quota q: quota) {
        StringBuilder buf = new StringBuilder();
        appendQuota(q, buf);
        response.untaggedResponse(buf.toString());
    }

    response.commandComplete(this);
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:21,代码来源:QuotaCommand.java

示例14: doProcess

import com.icegreen.greenmail.imap.ProtocolException; //导入依赖的package包/类
/**
 * @see CommandTemplate#doProcess
 */
@Override
protected void doProcess(ImapRequestLineReader request,
                         ImapResponse response,
                         ImapSession session)
        throws ProtocolException {
    String userid = parser.astring(request);
    String password = parser.astring(request);
    parser.endLine(request);

    if (session.getUserManager().test(userid, password)) {
        GreenMailUser user = session.getUserManager().getUser(userid);
        session.setAuthenticated(user);
        response.commandComplete(this);

    } else {
        response.commandFailed(this, "Invalid login/password for user id "+userid);
    }
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:22,代码来源:LoginCommand.java

示例15: dateTime

import com.icegreen.greenmail.imap.ProtocolException; //导入依赖的package包/类
/**
 * Reads a "date-time" argument from the request.
 */
public Date dateTime(ImapRequestLineReader request) throws ProtocolException {
    char next = request.nextWordChar();
    String dateString;
    // From https://tools.ietf.org/html/rfc3501 :
    // date-time       = DQUOTE date-day-fixed "-" date-month "-" date-year
    //                   SP time SP zone DQUOTE
    // zone            = ("+" / "-") 4DIGIT
    if (next == '"') {
        dateString = consumeQuoted(request);
    } else {
        throw new ProtocolException("DateTime values must be quoted.");
    }

    try {
        // You can use Z or zzzz
        return new SimpleDateFormat("dd-MMM-yyyy hh:mm:ss Z", Locale.US).parse(dateString);
    } catch (ParseException e) {
        throw new ProtocolException("Invalid date format <" + dateString + ">, should comply to dd-MMM-yyyy hh:mm:ss Z");
    }
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:24,代码来源:CommandParser.java


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