/** * * Reads the mailbox name via {@link #mailboxUTF7()} but also decode it via {@link CharsetUtil#decodeModifiedUTF7(String)} * * If you really want to get the modified UTF7 version you should use {@link #mailboxUTF7()} * * @return decodedMailbox * */ public String mailbox() throws DecodingException { return CharsetUtil.decodeModifiedUTF7(mailboxUTF7()); }
@Override public ImapResponseComposer mailbox(String mailboxName) throws IOException { quote(CharsetUtil.encodeModifiedUTF7(mailboxName)); return this; }
private ImapMessage unsupportedCharset(String tag, ImapCommand command) { final StatusResponseFactory factory = getStatusResponseFactory(); final ResponseCode badCharset = StatusResponse.ResponseCode.badCharset(CharsetUtil.getAvailableCharsetNames()); return factory.taggedNo(tag, command, HumanReadableText.BAD_CHARSET, badCharset); }
private ImapMessage unsupportedCharset(final String tag, final ImapCommand command) { final StatusResponseFactory factory = getStatusResponseFactory(); final ResponseCode badCharset = StatusResponse.ResponseCode.badCharset(CharsetUtil.getAvailableCharsetNames()); final StatusResponse result = factory.taggedNo(tag, command, HumanReadableText.BAD_CHARSET, badCharset); return result; }
/** * * Reads the mailbox name via {@link #mailboxUTF7()} but also decode it via {@link CharsetUtil#decodeModifiedUTF7(String)} * * If you really want to get the modified UTF7 version you should use {@link #mailboxUTF7()} * * @return decodedMailbox * */ public String mailbox() throws DecodingException { return CharsetUtil.decodeModifiedUTF7(mailboxUTF7()); }
@Test public void testBadCharset() throws Exception { ImapRequestLineReader reader = new ImapRequestStreamLineReader( new ByteArrayInputStream("CHARSET BOGUS ".getBytes("US-ASCII")), new ByteArrayOutputStream()); parser.decode(command, reader, TAG, false, session); verify(mockStatusResponseFactory, times(1)).taggedNo( eq(TAG), same(command), eq(HumanReadableText.BAD_CHARSET), eq(StatusResponse.ResponseCode.badCharset(CharsetUtil.getAvailableCharsetNames()))); verifyNoMoreInteractions(mockStatusResponseFactory); }
/** * @see org.apache.james.imap.encode.ImapResponseComposer#mailbox(java.lang.String) */ public ImapResponseComposer mailbox(final String mailboxName) throws IOException { quote(CharsetUtil.encodeModifiedUTF7(mailboxName)); return this; }
private void listSubscriptions(ImapSession session, Responder responder, String referenceName, String mailboxName) throws SubscriptionException, MailboxException { MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session); Collection<String> mailboxes = getSubscriptionManager().subscriptions(mailboxSession); String decodedMailName = CharsetUtil.decodeModifiedUTF7(referenceName); MailboxNameExpression expression = new PrefixedRegex( decodedMailName, CharsetUtil.decodeModifiedUTF7(mailboxName), mailboxSession.getPathDelimiter()); Collection<String> mailboxResponses = new ArrayList<>(); for (String mailbox : mailboxes) { respond(responder, expression, mailbox, true, mailboxes, mailboxResponses, mailboxSession.getPathDelimiter()); } }
@Test public void testBadCharset() throws Exception { ImapRequestLineReader reader = new ImapRequestStreamLineReader( new ByteArrayInputStream("CHARSET BOGUS ".getBytes("US-ASCII")), new ByteArrayOutputStream()); parser.decode(command, reader, TAG, false, session); verify(mockStatusResponseFactory, times(1)).taggedNo( eq(TAG), same(command), eq(HumanReadableText.BAD_CHARSET), eq(StatusResponse.ResponseCode.badCharset(CharsetUtil.getAvailableCharsetNames()))); verifyNoMoreInteractions(mockStatusResponseFactory); }
private void listSubscriptions(ImapSession session, Responder responder, final String referenceName, final String mailboxName) throws SubscriptionException, MailboxException { final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session); final Collection<String> mailboxes = getSubscriptionManager().subscriptions(mailboxSession); // If the mailboxName is fully qualified, ignore the reference name. String finalReferencename = referenceName; if (mailboxName.charAt(0) == MailboxConstants.NAMESPACE_PREFIX_CHAR) { finalReferencename = ""; } // Is the interpreted (combined) pattern relative? boolean isRelative = ((finalReferencename + mailboxName).charAt(0) != MailboxConstants.NAMESPACE_PREFIX_CHAR); MailboxPath basePath = null; if (isRelative) { basePath = new MailboxPath(MailboxConstants.USER_NAMESPACE, mailboxSession.getUser().getUserName(), CharsetUtil.decodeModifiedUTF7(finalReferencename)); } else { basePath = buildFullPath(session, CharsetUtil.decodeModifiedUTF7(finalReferencename)); } final MailboxQuery expression = new MailboxQuery(basePath, CharsetUtil.decodeModifiedUTF7(mailboxName), mailboxSession.getPathDelimiter()); final Collection<String> mailboxResponses = new ArrayList<String>(); for (final String mailbox : mailboxes) { respond(responder, expression, mailbox, true, mailboxes, mailboxResponses, mailboxSession.getPathDelimiter()); } }
referenceRoot = referenceName.substring(0, firstDelimiter); referenceRoot = CharsetUtil.decodeModifiedUTF7(referenceRoot); } else { finalReferencename = CharsetUtil.decodeModifiedUTF7(finalReferencename); results = getMailboxManager().search(new MailboxQuery(basePath, CharsetUtil.decodeModifiedUTF7(mailboxName), mailboxSession.getPathDelimiter()), mailboxSession);
referenceRoot = referenceName.substring(0, firstDelimiter); referenceRoot = CharsetUtil.decodeModifiedUTF7(referenceRoot); } else { finalReferencename = CharsetUtil.decodeModifiedUTF7(finalReferencename); .expression(new PrefixedRegex( basePath.getName(), CharsetUtil.decodeModifiedUTF7(mailboxName), mailboxSession.getPathDelimiter())) .build(), mailboxSession);