1
|
/**
|
2
|
* Copyright (C) 2017 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.vaadin.permission;
|
10
|
|
11
|
import java.io.Serializable;
|
12
|
|
13
|
import org.apache.log4j.Logger;
|
14
|
|
15
|
import com.vaadin.navigator.View;
|
16
|
import com.vaadin.spring.access.ViewInstanceAccessControl;
|
17
|
import com.vaadin.ui.UI;
|
18
|
|
19
|
/**
|
20
|
* Denies, allows access to view by evaluating the {@link AccessRestrictedView#isAccessDenied()} flag.
|
21
|
*
|
22
|
* @author a.kohlbecker
|
23
|
*/
|
24
|
public class AccessRestrictedViewControlBean implements ViewInstanceAccessControl, Serializable {
|
25
|
|
26
|
private static final long serialVersionUID = -5192116600545639108L;
|
27
|
|
28
|
private final static Logger logger = Logger.getLogger(AccessRestrictedViewControlBean.class);
|
29
|
|
30
|
/**
|
31
|
* {@inheritDoc}
|
32
|
*/
|
33
|
@Override
|
34
|
public boolean isAccessGranted(UI ui, String beanName, View view) {
|
35
|
|
36
|
if(AccessRestrictedView.class.isAssignableFrom(view.getClass())){
|
37
|
AccessRestrictedView restricedView = (AccessRestrictedView)view;
|
38
|
if(logger.isDebugEnabled()){
|
39
|
logger.debug("Access to view " + view.getClass().getSimpleName() + (restricedView.isAccessDenied() ? " denied": " allowed"));
|
40
|
}
|
41
|
return restricedView.isAccessDenied();
|
42
|
}
|
43
|
logger.debug("allowing view by fall through, no check performed");
|
44
|
return true;
|
45
|
}
|
46
|
}
|