package de.hsadmin.core.model;

import de.hsadmin.mods.user.UnixUser;

public class AuthorisationException extends HSAdminException {
	
	private static final long serialVersionUID = -8125905071037488732L;

	private UnixUser user;
	private String method;
	private AbstractEntity entity;
	private String field;

	public UnixUser getUser() {
		return user;
	}

	public String getMethod() {
		return method;
	}

	public AbstractEntity getEntity() {
		return entity;
	}

	public String getField() {
		return field;
	}

	public AuthorisationException(UnixUser user, String method) {
		super("nicht authorisiert fuer " + method + "()");

		this.user = user;
		this.method = method;
	}

	public AuthorisationException(UnixUser user, String method, AbstractEntity entity) {
		super("nicht authorisiert fuer " + method + "("
				+ entity.createStringKey() + ")");

		this.user = user;
		this.method = method;
		this.entity = entity;
	}

	public AuthorisationException(UnixUser user, String method, AbstractEntity entity,
			String field) {
		super("nicht authorisiert fuer " + method + "("
				+ entity.createStringKey() + "." + field + ")");

		this.user = user;
		this.method = method;
		this.entity = entity;
		this.field = field;
	}
}
