/**
* Copyright (C) 2013 DaiKit.com - daikit-commons module (admin@daikit.com)
*
* Project home : http://code.daikit.com/commons
*
* Licensed 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 com.daikit.commons.shared.exception.authentication;
import com.daikit.commons.shared.exception.DkException;
import com.daikit.commons.shared.exception.context.DkExceptionContext;
/**
* It should be thrown when the logged user on server side is not the same than the one on client side (the one on
* client side is retrieved from the cookie sent with the request).
*
* @author tcaselli
* @version $Revision$ Last modifier: $Author$ Last commit: $Date$
*/
public class DkUserLoggedChangedException extends DkException
{
/**
*
*/
private static final long serialVersionUID = -8748230545225247186L;
private static final String NEW_LOGGED_USER_ID_KEY = "new_logged_user_id_key";
/**
* Instantiates a new UserLoggedChangedException.
*/
public DkUserLoggedChangedException()
{
super();
}
/**
* Instantiates a new UserLoggedChangedException.
*
* @param newLoggedUserId
* the new logged user id
*/
public DkUserLoggedChangedException(final String newLoggedUserId)
{
super();
setNewLoggedUserId(newLoggedUserId);
}
/**
* Instantiates a new UserLoggedChangedException.
*
* @param message
* the message
* @param newLoggedUserId
* the new logged user id
*/
public DkUserLoggedChangedException(final String message, final String newLoggedUserId)
{
super(message);
setNewLoggedUserId(newLoggedUserId);
}
/**
* Instantiates a new UserLoggedChangedException.
*
* @param message
* the message
* @param newLoggedUserId
* the new logged user id
* @param cause
* the cause
*/
public DkUserLoggedChangedException(final String message, final String newLoggedUserId, final Throwable cause)
{
super(new DkExceptionContext(message), cause);
setNewLoggedUserId(newLoggedUserId);
}
/**
* Instantiates a new UserLoggedChangedException.
*
* @param context
* the context
* @param newLoggedUserId
* the new logged user id
*/
public DkUserLoggedChangedException(final DkExceptionContext context, final String newLoggedUserId)
{
super(context);
setNewLoggedUserId(newLoggedUserId);
}
/**
* Instantiates a new UserLoggedChangedException.
*
* @param context
* the context
* @param newLoggedUserId
* the new logged user id
* @param cause
* the cause
*/
public DkUserLoggedChangedException(final DkExceptionContext context, final String newLoggedUserId, final Throwable cause)
{
super(context, cause);
setNewLoggedUserId(newLoggedUserId);
}
/**
* @return the newLoggedUserId
*/
public String getNewLoggedUserId()
{
return getContext().get(NEW_LOGGED_USER_ID_KEY);
}
/**
* @param newLoggedUserId
* the newLoggedUserId to set
*/
public void setNewLoggedUserId(final String newLoggedUserId)
{
getContext().put(NEW_LOGGED_USER_ID_KEY, newLoggedUserId);
}
}