PROTOCOLS-117 Bonus: Remove unused MPT class (for subscription)
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/e4b2b377 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/e4b2b377 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/e4b2b377 Branch: refs/heads/master Commit: e4b2b377056df62a6f7bc54a6333b6c2d0ff013e Parents: c2669b8 Author: benwa <[email protected]> Authored: Thu Nov 2 14:34:14 2017 +0700 Committer: benwa <[email protected]> Committed: Fri Nov 3 15:48:40 2017 +0700 ---------------------------------------------------------------------- .../mpt/user/InMemoryMailboxUserManager.java | 101 ------------------- .../org/apache/james/mpt/user/MailboxUser.java | 77 -------------- 2 files changed, 178 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/e4b2b377/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/user/InMemoryMailboxUserManager.java ---------------------------------------------------------------------- diff --git a/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/user/InMemoryMailboxUserManager.java b/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/user/InMemoryMailboxUserManager.java deleted file mode 100644 index 6fda45e..0000000 --- a/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/user/InMemoryMailboxUserManager.java +++ /dev/null @@ -1,101 +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.mpt.user; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import org.apache.james.mailbox.MailboxSession; -import org.apache.james.mailbox.SubscriptionManager; -import org.apache.james.mailbox.exception.SubscriptionException; - -/** - * Stores users in memory. - */ -public class InMemoryMailboxUserManager implements SubscriptionManager { - - private final Map<String, MailboxUser> users; - - public InMemoryMailboxUserManager() { - this.users = new HashMap<>(); - } - - public boolean isAuthentic(String userid, CharSequence password) { - MailboxUser user = (MailboxUser) users.get(userid); - final boolean result; - if (user == null) { - result = false; - } else { - result = user.isPassword(password); - } - return result; - } - - public void subscribe(MailboxSession session, String mailbox) - throws SubscriptionException { - MailboxSession.User u = session.getUser(); - MailboxUser user = (MailboxUser) users.get(u.getUserName()); - if (user == null) { - user = new MailboxUser(u.getUserName()); - users.put(u.getUserName(), user); - } - user.addSubscription(mailbox); - } - - public Collection<String> subscriptions(org.apache.james.mailbox.MailboxSession session) throws SubscriptionException { - MailboxSession.User u = session.getUser(); - MailboxUser user = (MailboxUser) users.get(u.getUserName()); - if (user == null) { - user = new MailboxUser(u.getUserName()); - users.put(u.getUserName(), user); - } - return user.getSubscriptions(); - } - - public void unsubscribe(org.apache.james.mailbox.MailboxSession session, String mailbox) - throws SubscriptionException { - MailboxSession.User u = session.getUser(); - MailboxUser user = (MailboxUser) users.get(u.getUserName()); - if (user == null) { - user = new MailboxUser(u.getUserName()); - users.put(u.getUserName(), user); - } - user.removeSubscription(mailbox); - } - - public void addUser(String userid, CharSequence password) { - MailboxUser user = (MailboxUser) users.get(userid); - if (user == null) { - user = new MailboxUser(userid); - users.put(userid, user); - } - user.setPassword(password); - } - - public void endProcessingRequest(MailboxSession session) { - - } - - public void startProcessingRequest(MailboxSession session) { - - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/e4b2b377/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/user/MailboxUser.java ---------------------------------------------------------------------- diff --git a/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/user/MailboxUser.java b/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/user/MailboxUser.java deleted file mode 100644 index 05f9c89..0000000 --- a/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/user/MailboxUser.java +++ /dev/null @@ -1,77 +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.mpt.user; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -class MailboxUser { - private final String userName; - - private CharSequence password; - - private final Set<String> subscriptions; - - public MailboxUser(String userName) { - this.userName = userName; - this.subscriptions = new HashSet<>(); - } - - public String getUserName() { - return userName; - } - - public void setPassword(CharSequence password) { - this.password = password; - } - - public Collection<String> getSubscriptions() { - return Collections.unmodifiableSet(subscriptions); - } - - public void addSubscription(String subscription) { - this.subscriptions.add(subscription); - } - - public void removeSubscription(String mailbox) { - this.subscriptions.remove(mailbox); - } - - public boolean isPassword(CharSequence password) { - final boolean result; - if (password == null) { - result = this.password == null; - } else if (this.password == null) { - result = false; - } else if (this.password.length() == password.length()) { - for (int i=0;i<password.length();i++) { - if (password.charAt(i) != this.password.charAt(i)) { - return false; - } - } - result = true; - } else { - result = false; - } - return result; - } -} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
