001package fr.ifremer.adagio.synchro.service;
002
003/*
004 * #%L
005 * SIH-Adagio :: Synchronization
006 * $Id:$
007 * $HeadURL:$
008 * %%
009 * Copyright (C) 2012 - 2014 Ifremer
010 * %%
011 * This program is free software: you can redistribute it and/or modify
012 * it under the terms of the GNU Affero General Public License as published by
013 * the Free Software Foundation, either version 3 of the License, or
014 * (at your option) any later version.
015 * 
016 * This program is distributed in the hope that it will be useful,
017 * but WITHOUT ANY WARRANTY; without even the implied warranty of
018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
019 * GNU General Public License for more details.
020 * 
021 * You should have received a copy of the GNU Affero General Public License
022 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
023 * #L%
024 */
025
026/**
027 * <p>
028 * Use to store security data, used by the syncrhonization process, specially in {@link SynchroInterceptor} subclasses.
029 * </p>
030 * <p>
031 * See example at {@link RootTableAccessRestrictionInterceptor}
032 * </p>
033 * 
034 * @author Benoit Lavenier <benoit.lavenier@e-is.pro>
035 * @since 3.5.3
036 * 
037 */
038public class SynchroSecurityContext {
039
040    private Integer userId = -1;
041
042    private Integer sessionId = -1;
043
044    public SynchroSecurityContext(Integer userId) {
045        this.userId = userId;
046    }
047
048    public SynchroSecurityContext(Integer userId, Integer sessionId) {
049        this.userId = userId;
050        this.sessionId = sessionId;
051    }
052
053    public Integer getUserId() {
054        return userId;
055    }
056
057    public void setUserId(Integer userId) {
058        this.userId = userId;
059    }
060
061    public Integer getSessionId() {
062        return this.sessionId;
063    }
064
065    public void setSessionId(Integer sessionId) {
066        this.sessionId = sessionId;
067    }
068
069    public boolean isUserLogged() {
070        return sessionId != null && userId != null;
071    }
072}