org.apache.james.mailbox.MailboxSession Maven / Gradle / Ivy
/****************************************************************
* 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.mailbox;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import org.apache.james.core.Username;
import org.apache.james.mailbox.model.MailboxConstants;
import com.google.common.base.MoreObjects;
/**
* Mailbox session.
*/
public class MailboxSession {
public static class SessionId {
public static SessionId of(long sessionId) {
return new SessionId(sessionId);
}
private final long sessionId;
private SessionId(long sessionId) {
this.sessionId = sessionId;
}
public long getValue() {
return sessionId;
}
@Override
public final boolean equals(Object o) {
if (o instanceof SessionId) {
SessionId that = (SessionId) o;
return Objects.equals(this.sessionId, that.sessionId);
}
return false;
}
@Override
public final int hashCode() {
return Objects.hash(sessionId);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("sessionId", sessionId)
.toString();
}
}
/**
* Id which will be used for a System session
*/
public static long SYSTEM_SESSION_ID = 0L;
public enum SessionType {
/**
* Session was created via the System
*/
System,
/**
* Session belongs to a specific user which was authenticated somehow
*/
User
}
private final Collection sharedSpaces;
private final String otherUsersSpace;
private final String personalSpace;
private final SessionId sessionId;
private final Username userName;
private boolean open = true;
private final List localePreferences;
private final Map