From eae6a04e2a5875bab29b238f8300ebd37efa2b2a Mon Sep 17 00:00:00 2001 From: Benoit Tellier Date: Thu, 17 Dec 2015 15:09:21 +0000 Subject: [PATCH] JAMES-1618 Remove non RFC-5804 compliant GETACTIVE command git-svn-id: https://svn.apache.org/repos/asf/james/project/trunk@1720593 13f79535-47bb-0310-9956-ffa450edef68 --- .../api/commands/CoreCommands.java | 2 +- .../managesieve/api/commands/GetActive.java | 38 ---------------- .../james/managesieve/core/CoreProcessor.java | 18 -------- .../transcode/ManageSieveProcessor.java | 2 - .../ManageSieveMailetTestCase.java | 44 ------------------- 5 files changed, 1 insertion(+), 103 deletions(-) delete mode 100644 protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/GetActive.java diff --git a/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/CoreCommands.java b/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/CoreCommands.java index 9fd905c05b4..092472a9552 100644 --- a/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/CoreCommands.java +++ b/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/CoreCommands.java @@ -28,7 +28,7 @@ * @see RFC 5804 Commands */ public interface CoreCommands extends Capability, CheckScript, DeleteScript, GetScript, HaveSpace, - ListScripts, PutScript, RenameScript, SetActive, GetActive, Noop, Unauthenticate, Logout, Authenticate, StartTLS, + ListScripts, PutScript, RenameScript, SetActive, Noop, Unauthenticate, Logout, Authenticate, StartTLS, CapabilityAdvertiser { } diff --git a/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/GetActive.java b/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/GetActive.java deleted file mode 100644 index a4083005e5b..00000000000 --- a/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/GetActive.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.james.managesieve.api.commands; - -import org.apache.james.managesieve.api.AuthenticationRequiredException; -import org.apache.james.managesieve.api.Session; -import org.apache.james.sieverepository.api.exception.ScriptNotFoundException; -import org.apache.james.sieverepository.api.exception.StorageException; - -/** - * GetActive is an extension to the commands defined by RFC 5804. It provides a means - * of retrieving a user's currently active script in a single call. The alternative using RFC 5804 - * mandated commands is to call ListScripts, parse the result to identify the active script and - * call GetScript to retrieve it. - */ -public interface GetActive { - - String getActive(Session session); - -} diff --git a/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java b/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java index 30453cb16a0..06dde5f34d1 100644 --- a/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java +++ b/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java @@ -269,24 +269,6 @@ public String setActive(Session session, String name) { return "OK"; } - @Override - public String getActive(Session session) { - try { - authenticationCheck(session); - return IOUtils.toString(sieveRepository.getActive(session.getUser())) + "\r\nOK"; - } catch (AuthenticationRequiredException ex) { - return "NO"; - } catch (ScriptNotFoundException ex) { - return "NO (NONEXISTENT) \"" + ex.getMessage() + "\""; - } catch (StorageException ex) { - return "NO \"" + ex.getMessage() + "\""; - } catch (UserNotFoundException e) { - return "NO : User not found"; - } catch (IOException e) { - return "NO \"" + e.getMessage() + "\""; - } - } - @Override public String noop(String tag) { if(Strings.isNullOrEmpty(tag)) { diff --git a/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/ManageSieveProcessor.java b/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/ManageSieveProcessor.java index 6ff3686790f..f922b0e8917 100644 --- a/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/ManageSieveProcessor.java +++ b/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/ManageSieveProcessor.java @@ -92,8 +92,6 @@ private String matchCommandWithImplementation(Session session, String arguments, return argumentParser.checkScript(session, arguments); } else if (command.equals(DELETESCRIPT)) { return argumentParser.deleteScript(session, arguments); - } else if (command.equals(GETACTIVE)) { - return argumentParser.getActive(session, arguments); } else if (command.equals(GETSCRIPT)) { return argumentParser.getScript(session, arguments); } else if (command.equals(HAVESPACE)) { diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailetTestCase.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailetTestCase.java index c3ef5b9d706..3d3c4f23f7b 100644 --- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailetTestCase.java +++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailetTestCase.java @@ -459,50 +459,6 @@ public final void testSetActiveNoScriptName() throws Exception { ensureResponse("Re: SETACTIVE", "NO \"Missing argument: script name\""); } - @Test - public final void testGetActiveUnauthorized() throws Exception { - MimeMessage message = prepareMimeMessage("GETACTIVE", USER, SIEVE_LOCALHOST); - Mail mail = new FakeMail(); - mail.setMessage(message); - mailet.service(mail); - ensureResponse("Re: GETACTIVE", message.getSender(), "NO"); - } - - @Test - public final void testGetActive() throws Exception { - when(sieveRepository.getActive(USER)).thenAnswer(new Answer() { - public String answer(InvocationOnMock invocationOnMock) throws Throwable { - return SCRIPT_CONTENT; - } - }); - MimeMessage message = prepareMimeMessage("GETACTIVE", USER, SIEVE_LOCALHOST); - Mail mail = new FakeMail(); - mail.setMessage(message); - mail.setAttribute(ManageSieveMailet.SMTP_AUTH_USER_ATTRIBUTE_NAME, USER); - mailet.service(mail); - ensureResponse("Re: GETACTIVE", message.getSender(), SCRIPT_CONTENT + "\r\n" + "OK"); - } - - @Test - public final void testGetActiveExtraArgs() throws Exception { - MimeMessage message = prepareMimeMessage("GETACTIVE extra", USER, SIEVE_LOCALHOST); - Mail mail = new FakeMail(); - mail.setMessage(message); - message.setSubject("GETACTIVE extra"); - message.saveChanges(); - mailet.service(mail); - ensureResponse("Re: GETACTIVE extra", message.getSender(), "NO \"Too many arguments: extra\""); - } - - @Test - public final void testGetActiveDesactivated() throws Exception { - MimeMessage message = prepareMimeMessage("GETACTIVE", USER, SIEVE_LOCALHOST); - Mail mail = new FakeMail(); - mail.setMessage(message); - mailet.service(mail); - ensureResponse("Re: GETACTIVE", message.getSender(), "NO"); - } - private void initializeMailet() throws MessagingException { mailet = new ManageSieveMailet(); mailet.setSieveParser(sieveParser);