Revision b32150b1
Added by Andreas Kohlbecker over 5 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/permission/AccessRestrictedView.java | ||
---|---|---|
36 | 36 |
*/ |
37 | 37 |
public Collection<Collection<GrantedAuthority>> allowedGrantedAuthorities(); |
38 | 38 |
|
39 |
public String getAccessDeniedMessage(); |
|
40 |
|
|
41 |
/** |
|
42 |
* The <code>accessDeniedMessage</code> can be set my the presenter, e.g. in response |
|
43 |
* to an Exception or during the processing of the bean to be loaded into the view. |
|
44 |
* <p> |
|
45 |
* In case an <code>accessDeniedMessage</code> is present access to the view is considered |
|
46 |
* to be denied. |
|
47 |
* |
|
48 |
* @param accessDeniedMessage |
|
49 |
*/ |
|
50 |
public void setAccessDeniedMessage(String accessDeniedMessage); |
|
51 |
|
|
52 |
/** |
|
53 |
* Evaluated by the {@link AccessRestrictedViewControlBean} |
|
54 |
* |
|
55 |
* @return true if the {@link #getAccessDeniedMessage()} is not <code>null</code>. |
|
56 |
*/ |
|
57 |
default public boolean isAccessDenied(){ |
|
58 |
return getAccessDeniedMessage() != null; |
|
59 |
} |
|
60 |
|
|
39 | 61 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/permission/AccessRestrictedViewControlBean.java | ||
---|---|---|
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 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/permission/AnnotationBasedAccessControlBean.java | ||
---|---|---|
25 | 25 |
* @since Apr 24, 2017 |
26 | 26 |
* |
27 | 27 |
* |
28 |
* FIMXE 1. consider renaming this class and its interface, since it is no longer annotation based!!!!
|
|
28 |
* (FIMXE 1. consider renaming this class and its interface, since it is no longer annotation based!!!!)
|
|
29 | 29 |
* |
30 |
* FIMXE 2. this class should implement ViewAccessControl. The view class can be accessed via the application
|
|
31 |
* context before the view bean has been created. see #7967 |
|
30 |
* FIMXE 2. this class should implement ViewAccessControl. The view class and annotations can be accessed
|
|
31 |
* via the application context before the view bean has been created. see #7967
|
|
32 | 32 |
*/ |
33 | 33 |
public class AnnotationBasedAccessControlBean implements ViewInstanceAccessControl, Serializable { |
34 | 34 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/permission/AnnotationBasedAccessControlConfiguration.java | ||
---|---|---|
27 | 27 |
return new AnnotationBasedAccessControlBean(); |
28 | 28 |
} |
29 | 29 |
|
30 |
@Bean |
|
31 |
@UIScope // TODO move into own @Configuration class? |
|
32 |
public AccessRestrictedViewControlBean accessRestrictedViewControlBean() { |
|
33 |
return new AccessRestrictedViewControlBean(); |
|
34 |
} |
|
35 |
|
|
30 | 36 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/RedirectToLoginView.java | ||
---|---|---|
22 | 22 |
import com.vaadin.ui.VerticalLayout; |
23 | 23 |
import com.vaadin.ui.themes.ValoTheme; |
24 | 24 |
|
25 |
import eu.etaxonomy.cdm.service.UserHelperAccess; |
|
25 | 26 |
import eu.etaxonomy.vaadin.ui.navigation.NavigationEvent; |
26 | 27 |
import eu.etaxonomy.vaadin.ui.navigation.NavigationManager; |
27 | 28 |
|
... | ... | |
54 | 55 |
public RedirectToLoginView() { |
55 | 56 |
|
56 | 57 |
this.setWidth("100%"); |
57 |
Label header = new Label("Access denied");
|
|
58 |
header.setStyleName(ValoTheme.BUTTON_LARGE);
|
|
58 |
Label header = new Label("Access to this content is restricted");
|
|
59 |
header.setStyleName(ValoTheme.LABEL_FAILURE);
|
|
59 | 60 |
header.setWidthUndefined(); |
60 | 61 |
|
61 | 62 |
addComponent(header); |
... | ... | |
68 | 69 |
@Override |
69 | 70 |
public void enter(ViewChangeEvent event) { |
70 | 71 |
|
71 |
String currentState = ((Navigator)navigationManager).getState(); |
|
72 |
// redirect to the login view and pass over the current state |
|
73 |
uiEventBus.publish(this, new NavigationEvent(LoginViewBean.NAME, currentState)); |
|
72 |
if(!UserHelperAccess.userHelper().userIsAutheticated()){ |
|
73 |
String currentState = ((Navigator)navigationManager).getState(); |
|
74 |
// redirect to the login view and pass over the current state |
|
75 |
uiEventBus.publish(this, new NavigationEvent(LoginViewBean.NAME, currentState)); |
|
76 |
} |
|
74 | 77 |
} |
75 | 78 |
|
76 | 79 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/common/InstitutionPopupEditor.java | ||
---|---|---|
9 | 9 |
package eu.etaxonomy.cdm.vaadin.view.common; |
10 | 10 |
|
11 | 11 |
import org.springframework.context.annotation.Scope; |
12 |
import org.springframework.security.core.GrantedAuthority; |
|
13 | 12 |
|
14 | 13 |
import com.vaadin.spring.annotation.SpringComponent; |
15 | 14 |
import com.vaadin.ui.GridLayout; |
... | ... | |
19 | 18 |
import eu.etaxonomy.cdm.vaadin.event.InstitutionEditorAction; |
20 | 19 |
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityButtonUpdater; |
21 | 20 |
import eu.etaxonomy.cdm.vaadin.model.common.InstitutionDTO; |
22 |
import eu.etaxonomy.cdm.vaadin.permission.AccessRestrictedView; |
|
23 | 21 |
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator; |
24 | 22 |
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityCombobox; |
25 | 23 |
import eu.etaxonomy.vaadin.event.EditorActionType; |
... | ... | |
32 | 30 |
*/ |
33 | 31 |
@SpringComponent |
34 | 32 |
@Scope("prototype") |
35 |
public class InstitutionPopupEditor extends AbstractCdmDTOPopupEditor<InstitutionDTO, Institution, InstitutionEditorPresenter> implements InstitutionPopupEditorView, AccessRestrictedView {
|
|
33 |
public class InstitutionPopupEditor extends AbstractCdmDTOPopupEditor<InstitutionDTO, Institution, InstitutionEditorPresenter> implements InstitutionPopupEditorView { |
|
36 | 34 |
|
37 | 35 |
private static final long serialVersionUID = 2019724189877425882L; |
38 | 36 |
|
... | ... | |
78 | 76 |
codeField.focus(); |
79 | 77 |
} |
80 | 78 |
|
81 |
/** |
|
82 |
* {@inheritDoc} |
|
83 |
*/ |
|
84 |
@Override |
|
85 |
public boolean allowAnonymousAccess() { |
|
86 |
return false; |
|
87 |
} |
|
88 |
|
|
89 |
/** |
|
90 |
* {@inheritDoc} |
|
91 |
*/ |
|
92 |
@Override |
|
93 |
public java.util.Collection<java.util.Collection<GrantedAuthority>> allowedGrantedAuthorities() { |
|
94 |
return null; |
|
95 |
} |
|
96 |
|
|
97 | 79 |
/** |
98 | 80 |
* {@inheritDoc} |
99 | 81 |
*/ |
src/main/java/eu/etaxonomy/cdm/vaadin/view/distributionStatus/DistributionTableViewBean.java | ||
---|---|---|
68 | 68 |
*/ |
69 | 69 |
@ViewScope |
70 | 70 |
@SpringView(name=DistributionTableViewBean.NAME) |
71 |
public class DistributionTableViewBean |
|
72 |
extends AbstractPageView<DistributionTablePresenter> |
|
71 |
public class DistributionTableViewBean extends AbstractPageView<DistributionTablePresenter> |
|
73 | 72 |
implements IDistributionTableView, AccessRestrictedView { |
74 | 73 |
|
75 | 74 |
private static final long serialVersionUID = 1L; |
... | ... | |
87 | 86 |
private AreaAndTaxonSettingsConfigWindow areaAndTaxonConfigWindow;; |
88 | 87 |
private DistributionStatusSettingsConfigWindow distributionStatusConfigWindow; |
89 | 88 |
private HelpWindow helpWindow; |
89 |
private String accessDeniedMessage; |
|
90 | 90 |
|
91 | 91 |
/** |
92 | 92 |
* Creates a new distribution status editor view. |
... | ... | |
422 | 422 |
return null; |
423 | 423 |
} |
424 | 424 |
|
425 |
@Override |
|
426 |
public String getAccessDeniedMessage() { |
|
427 |
return accessDeniedMessage; |
|
428 |
} |
|
429 |
|
|
430 |
@Override |
|
431 |
public void setAccessDeniedMessage(String accessDeniedMessage) { |
|
432 |
this.accessDeniedMessage = accessDeniedMessage; |
|
433 |
|
|
434 |
} |
|
435 |
|
|
425 | 436 |
/** |
426 | 437 |
* {@inheritDoc} |
427 | 438 |
*/ |
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetPopupEditor.java | ||
---|---|---|
48 | 48 |
* @author a.kohlbecker |
49 | 49 |
* @since May 15, 2017 |
50 | 50 |
* |
51 |
* TODO as subclass of AbstractCdmPopupEditor? |
|
52 |
* |
|
51 | 53 |
*/ |
52 | 54 |
@SpringComponent |
53 | 55 |
@Scope("prototype") |
... | ... | |
88 | 90 |
|
89 | 91 |
private Panel typeDesignationsScrollPanel; |
90 | 92 |
|
93 |
private String accessDeniedMessage; |
|
94 |
|
|
91 | 95 |
/** |
92 | 96 |
* @return the countrySelectField |
93 | 97 |
*/ |
... | ... | |
267 | 271 |
return "tiny"; |
268 | 272 |
} |
269 | 273 |
|
270 |
/** |
|
271 |
* {@inheritDoc} |
|
272 |
*/ |
|
273 | 274 |
@Override |
274 | 275 |
public boolean allowAnonymousAccess() { |
275 | 276 |
return false; |
276 | 277 |
} |
277 | 278 |
|
278 |
/** |
|
279 |
* {@inheritDoc} |
|
280 |
*/ |
|
281 | 279 |
@Override |
282 | 280 |
public Collection<Collection<GrantedAuthority>> allowedGrantedAuthorities() { |
283 | 281 |
return null; |
284 | 282 |
} |
285 | 283 |
|
284 |
@Override |
|
285 |
public String getAccessDeniedMessage() { |
|
286 |
return accessDeniedMessage; |
|
287 |
} |
|
288 |
|
|
289 |
@Override |
|
290 |
public void setAccessDeniedMessage(String accessDeniedMessage) { |
|
291 |
this.accessDeniedMessage = accessDeniedMessage; |
|
292 |
} |
|
293 |
|
|
286 | 294 |
/** |
287 | 295 |
* {@inheritDoc} |
288 | 296 |
*/ |
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNamePopupEditor.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.vaadin.view.name; |
10 | 10 |
|
11 |
import java.util.Collection; |
|
12 | 11 |
import java.util.EnumSet; |
13 | 12 |
import java.util.HashMap; |
14 | 13 |
import java.util.List; |
... | ... | |
17 | 16 |
|
18 | 17 |
import org.apache.commons.lang3.BooleanUtils; |
19 | 18 |
import org.springframework.context.annotation.Scope; |
20 |
import org.springframework.security.core.GrantedAuthority; |
|
21 | 19 |
|
22 | 20 |
import com.vaadin.data.Property; |
23 | 21 |
import com.vaadin.data.Property.ValueChangeListener; |
... | ... | |
45 | 43 |
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorActionStrRep; |
46 | 44 |
import eu.etaxonomy.cdm.vaadin.model.name.NameRelationshipDTO; |
47 | 45 |
import eu.etaxonomy.cdm.vaadin.model.name.TaxonNameDTO; |
48 |
import eu.etaxonomy.cdm.vaadin.permission.AccessRestrictedView; |
|
49 | 46 |
import eu.etaxonomy.cdm.vaadin.permission.CdmEditDeletePermissionTester; |
50 | 47 |
import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults; |
51 | 48 |
import eu.etaxonomy.cdm.vaadin.util.TeamOrPersonBaseCaptionGenerator; |
... | ... | |
67 | 64 |
@SpringComponent |
68 | 65 |
@Scope("prototype") |
69 | 66 |
public class TaxonNamePopupEditor extends AbstractCdmDTOPopupEditor<TaxonNameDTO, TaxonName, TaxonNameEditorPresenter> |
70 |
implements TaxonNamePopupEditorView, AccessRestrictedView{
|
|
67 |
implements TaxonNamePopupEditorView{ |
|
71 | 68 |
|
72 | 69 |
private static final long serialVersionUID = -7037436241474466359L; |
73 | 70 |
|
... | ... | |
862 | 859 |
super.cancel(); |
863 | 860 |
} |
864 | 861 |
|
865 |
/** |
|
866 |
* {@inheritDoc} |
|
867 |
*/ |
|
868 |
@Override |
|
869 |
public boolean allowAnonymousAccess() { |
|
870 |
return false; |
|
871 |
} |
|
872 |
|
|
873 |
/** |
|
874 |
* {@inheritDoc} |
|
875 |
*/ |
|
876 |
@Override |
|
877 |
public Collection<Collection<GrantedAuthority>> allowedGrantedAuthorities() { |
|
878 |
return null; |
|
879 |
} |
|
880 | 862 |
|
881 | 863 |
/** |
882 | 864 |
* {@inheritDoc} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/occurrence/CollectionPopupEditor.java | ||
---|---|---|
9 | 9 |
package eu.etaxonomy.cdm.vaadin.view.occurrence; |
10 | 10 |
|
11 | 11 |
import org.springframework.context.annotation.Scope; |
12 |
import org.springframework.security.core.GrantedAuthority; |
|
13 | 12 |
|
14 | 13 |
import com.vaadin.spring.annotation.SpringComponent; |
15 | 14 |
import com.vaadin.ui.GridLayout; |
... | ... | |
23 | 22 |
import eu.etaxonomy.cdm.vaadin.event.CollectionEditorAction; |
24 | 23 |
import eu.etaxonomy.cdm.vaadin.event.InstitutionEditorAction; |
25 | 24 |
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityButtonUpdater; |
26 |
import eu.etaxonomy.cdm.vaadin.permission.AccessRestrictedView; |
|
27 | 25 |
import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults; |
28 | 26 |
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator; |
29 | 27 |
import eu.etaxonomy.cdm.vaadin.util.CollectionCaptionGenerator; |
... | ... | |
38 | 36 |
*/ |
39 | 37 |
@SpringComponent |
40 | 38 |
@Scope("prototype") |
41 |
public class CollectionPopupEditor extends AbstractCdmPopupEditor<Collection, CollectionEditorPresenter> implements CollectionPopupEditorView, AccessRestrictedView {
|
|
39 |
public class CollectionPopupEditor extends AbstractCdmPopupEditor<Collection, CollectionEditorPresenter> implements CollectionPopupEditorView { |
|
42 | 40 |
|
43 | 41 |
private static final long serialVersionUID = 2019724189877425882L; |
44 | 42 |
|
... | ... | |
87 | 85 |
codeField.focus(); |
88 | 86 |
} |
89 | 87 |
|
90 |
/** |
|
91 |
* {@inheritDoc} |
|
92 |
*/ |
|
93 |
@Override |
|
94 |
public boolean allowAnonymousAccess() { |
|
95 |
return false; |
|
96 |
} |
|
97 |
|
|
98 |
/** |
|
99 |
* {@inheritDoc} |
|
100 |
*/ |
|
101 |
@Override |
|
102 |
public java.util.Collection<java.util.Collection<GrantedAuthority>> allowedGrantedAuthorities() { |
|
103 |
return null; |
|
104 |
} |
|
105 |
|
|
106 | 88 |
/** |
107 | 89 |
* {@inheritDoc} |
108 | 90 |
*/ |
src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferencePopupEditor.java | ||
---|---|---|
9 | 9 |
package eu.etaxonomy.cdm.vaadin.view.reference; |
10 | 10 |
|
11 | 11 |
import java.util.Arrays; |
12 |
import java.util.Collection; |
|
13 | 12 |
import java.util.EnumSet; |
14 | 13 |
import java.util.HashMap; |
15 | 14 |
import java.util.LinkedHashMap; |
... | ... | |
18 | 17 |
|
19 | 18 |
import org.apache.log4j.Logger; |
20 | 19 |
import org.springframework.context.annotation.Scope; |
21 |
import org.springframework.security.core.GrantedAuthority; |
|
22 | 20 |
|
23 | 21 |
import com.vaadin.spring.annotation.SpringComponent; |
24 | 22 |
import com.vaadin.ui.AbstractField; |
... | ... | |
44 | 42 |
import eu.etaxonomy.cdm.vaadin.data.validator.InReferenceTypeValidator; |
45 | 43 |
import eu.etaxonomy.cdm.vaadin.event.InstitutionEditorAction; |
46 | 44 |
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction; |
47 |
import eu.etaxonomy.cdm.vaadin.permission.AccessRestrictedView; |
|
48 | 45 |
import eu.etaxonomy.cdm.vaadin.permission.RolesAndPermissions; |
49 | 46 |
import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults; |
50 | 47 |
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator; |
... | ... | |
64 | 61 |
*/ |
65 | 62 |
@SpringComponent |
66 | 63 |
@Scope("prototype") |
67 |
public class ReferencePopupEditor extends AbstractCdmPopupEditor<Reference, ReferenceEditorPresenter> implements ReferencePopupEditorView, AccessRestrictedView {
|
|
64 |
public class ReferencePopupEditor extends AbstractCdmPopupEditor<Reference, ReferenceEditorPresenter> implements ReferencePopupEditorView { |
|
68 | 65 |
|
69 | 66 |
private static final long serialVersionUID = -4347633563800758815L; |
70 | 67 |
|
... | ... | |
451 | 448 |
return false; |
452 | 449 |
} |
453 | 450 |
|
454 |
/** |
|
455 |
* {@inheritDoc} |
|
456 |
*/ |
|
457 |
@Override |
|
458 |
public boolean allowAnonymousAccess() { |
|
459 |
return false; |
|
460 |
} |
|
461 |
|
|
462 |
/** |
|
463 |
* {@inheritDoc} |
|
464 |
*/ |
|
465 |
@Override |
|
466 |
public Collection<Collection<GrantedAuthority>> allowedGrantedAuthorities() { |
|
467 |
return null; |
|
468 |
} |
|
469 |
|
|
470 | 451 |
@Override |
471 | 452 |
public ListSelect getTypeSelect() { |
472 | 453 |
return typeSelect; |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListViewBean.java | ||
---|---|---|
87 | 87 |
|
88 | 88 |
private AbstractSelect statusTypeFilter; |
89 | 89 |
|
90 |
private String accessDeniedMessage; |
|
91 |
|
|
90 | 92 |
public ListViewBean() { |
91 | 93 |
super(); |
92 | 94 |
} |
... | ... | |
256 | 258 |
return null; |
257 | 259 |
} |
258 | 260 |
|
261 |
@Override |
|
262 |
public String getAccessDeniedMessage() { |
|
263 |
return accessDeniedMessage; |
|
264 |
} |
|
265 |
|
|
266 |
@Override |
|
267 |
public void setAccessDeniedMessage(String accessDeniedMessage) { |
|
268 |
this.accessDeniedMessage = accessDeniedMessage; |
|
269 |
|
|
270 |
} |
|
271 |
|
|
259 | 272 |
/** |
260 | 273 |
* @return the identifierFilter |
261 | 274 |
*/ |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationMessagesPopup.java | ||
---|---|---|
52 | 52 |
|
53 | 53 |
private DelegatingErrorHandler errrorHandler = new DelegatingErrorHandler(); |
54 | 54 |
|
55 |
private String accessDeniedMessage; |
|
56 |
|
|
55 | 57 |
public RegistrationMessagesPopup() { |
56 | 58 |
|
57 | 59 |
mainLayout = new VerticalLayout(); |
... | ... | |
155 | 157 |
return null; |
156 | 158 |
} |
157 | 159 |
|
160 |
@Override |
|
161 |
public String getAccessDeniedMessage() { |
|
162 |
return accessDeniedMessage; |
|
163 |
} |
|
164 |
|
|
165 |
@Override |
|
166 |
public void setAccessDeniedMessage(String accessDeniedMessage) { |
|
167 |
this.accessDeniedMessage = accessDeniedMessage; |
|
168 |
|
|
169 |
} |
|
170 |
|
|
158 | 171 |
/** |
159 | 172 |
* {@inheritDoc} |
160 | 173 |
*/ |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationPopupEditor.java | ||
---|---|---|
9 | 9 |
package eu.etaxonomy.cdm.vaadin.view.registration; |
10 | 10 |
|
11 | 11 |
import java.util.Arrays; |
12 |
import java.util.Collection; |
|
13 | 12 |
|
14 | 13 |
import org.springframework.context.annotation.Scope; |
15 |
import org.springframework.security.core.GrantedAuthority; |
|
16 | 14 |
|
17 | 15 |
import com.vaadin.spring.annotation.SpringComponent; |
18 | 16 |
import com.vaadin.ui.DateField; |
... | ... | |
23 | 21 |
import eu.etaxonomy.cdm.model.name.Registration; |
24 | 22 |
import eu.etaxonomy.cdm.model.name.RegistrationStatus; |
25 | 23 |
import eu.etaxonomy.cdm.vaadin.component.TextFieldNFix; |
26 |
import eu.etaxonomy.cdm.vaadin.permission.AccessRestrictedView; |
|
27 | 24 |
import eu.etaxonomy.cdm.vaadin.util.converter.JodaDateTimeConverter; |
28 | 25 |
import eu.etaxonomy.vaadin.mvp.AbstractCdmPopupEditor; |
29 | 26 |
|
... | ... | |
35 | 32 |
@SpringComponent |
36 | 33 |
@Scope("prototype") |
37 | 34 |
public class RegistrationPopupEditor extends AbstractCdmPopupEditor<Registration, RegistrationEditorPresenter> |
38 |
implements RegistrationPopEditorView, AccessRestrictedView {
|
|
35 |
implements RegistrationPopEditorView { |
|
39 | 36 |
|
40 | 37 |
private static final long serialVersionUID = 5418275817834009509L; |
41 | 38 |
|
... | ... | |
118 | 115 |
return "tiny"; |
119 | 116 |
} |
120 | 117 |
|
121 |
/** |
|
122 |
* {@inheritDoc} |
|
123 |
*/ |
|
124 |
@Override |
|
125 |
public boolean allowAnonymousAccess() { |
|
126 |
return false; |
|
127 |
} |
|
128 |
|
|
129 |
/** |
|
130 |
* {@inheritDoc} |
|
131 |
*/ |
|
132 |
@Override |
|
133 |
public Collection<Collection<GrantedAuthority>> allowedGrantedAuthorities() { |
|
134 |
return null; |
|
135 |
} |
|
136 |
|
|
137 | 118 |
/** |
138 | 119 |
* @return the submitterField |
139 | 120 |
*/ |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java | ||
---|---|---|
48 | 48 |
import eu.etaxonomy.cdm.api.utility.RoleProber; |
49 | 49 |
import eu.etaxonomy.cdm.api.utility.UserHelper; |
50 | 50 |
import eu.etaxonomy.cdm.cache.CdmTransientEntityAndUuidCacher; |
51 |
import eu.etaxonomy.cdm.database.PermissionDeniedException; |
|
51 | 52 |
import eu.etaxonomy.cdm.ext.common.ExternalServiceException; |
52 | 53 |
import eu.etaxonomy.cdm.ext.registration.messages.IRegistrationMessageService; |
53 | 54 |
import eu.etaxonomy.cdm.model.ICdmEntityUuidCacher; |
... | ... | |
83 | 84 |
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction; |
84 | 85 |
import eu.etaxonomy.cdm.vaadin.event.TypeDesignationWorkingsetEditorAction; |
85 | 86 |
import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkingsetAction; |
87 |
import eu.etaxonomy.cdm.vaadin.permission.AccessRestrictedView; |
|
86 | 88 |
import eu.etaxonomy.cdm.vaadin.permission.RolesAndPermissions; |
87 | 89 |
import eu.etaxonomy.cdm.vaadin.theme.EditValoTheme; |
88 | 90 |
import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults; |
... | ... | |
329 | 331 |
workingset = getWorkingSetService().loadWorkingSetByReferenceUuid(referenceUuid, true); |
330 | 332 |
} catch (RegistrationValidationException error) { |
331 | 333 |
logger.error(error); |
332 |
Window errorDialog = new Window("Validation Error"); |
|
333 |
errorDialog.setModal(true); |
|
334 |
VerticalLayout subContent = new VerticalLayout(); |
|
335 |
subContent.setMargin(true); |
|
336 |
errorDialog.setContent(subContent); |
|
337 |
subContent.addComponent(new Label(error.getMessage())); |
|
338 |
UI.getCurrent().addWindow(errorDialog); |
|
334 |
showErrorDialog("Validation Error", error.getMessage()); |
|
335 |
} catch(PermissionDeniedException e){ |
|
336 |
logger.info(e); |
|
337 |
((AccessRestrictedView)getView()).setAccessDeniedMessage(e.getMessage()); |
|
339 | 338 |
} |
340 | 339 |
if(workingset == null || workingset.getCitationUuid() == null){ |
341 | 340 |
Reference citation = getRepo().getReferenceService().find(referenceUuid); |
... | ... | |
347 | 346 |
} |
348 | 347 |
} |
349 | 348 |
|
349 |
/** |
|
350 |
* @param errorDialogCaption |
|
351 |
* @param errorMessage |
|
352 |
*/ |
|
353 |
public void showErrorDialog(String errorDialogCaption, String errorMessage) { |
|
354 |
Window errorDialog = new Window(errorDialogCaption); |
|
355 |
errorDialog.setModal(true); |
|
356 |
VerticalLayout subContent = new VerticalLayout(); |
|
357 |
subContent.setMargin(true); |
|
358 |
errorDialog.setContent(subContent); |
|
359 |
subContent.addComponent(new Label(errorMessage)); |
|
360 |
UI.getCurrent().addWindow(errorDialog); |
|
361 |
} |
|
362 |
|
|
350 | 363 |
private void saveRegistrationStatusChange(UUID uuid, Object value) { |
351 | 364 |
Registration reg = getRepo().getRegistrationService().load(uuid); |
352 | 365 |
if(reg == null){ |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorksetViewBean.java | ||
---|---|---|
138 | 138 |
|
139 | 139 |
private RegistrationStatusFieldInstantiator statusFieldInstantiator; |
140 | 140 |
|
141 |
private String accessDeniedMessage; |
|
142 |
|
|
141 | 143 |
public RegistrationWorksetViewBean() { |
142 | 144 |
super(); |
143 | 145 |
} |
... | ... | |
592 | 594 |
new Notification(caption, sb.toString(), Notification.Type.HUMANIZED_MESSAGE, true).show(Page.getCurrent()); |
593 | 595 |
} |
594 | 596 |
|
595 |
/** |
|
596 |
* {@inheritDoc} |
|
597 |
*/ |
|
598 | 597 |
@Override |
599 | 598 |
public boolean allowAnonymousAccess() { |
600 | 599 |
return false; |
601 | 600 |
} |
602 | 601 |
|
603 |
/** |
|
604 |
* {@inheritDoc} |
|
605 |
*/ |
|
606 | 602 |
@Override |
607 | 603 |
public Collection<Collection<GrantedAuthority>> allowedGrantedAuthorities() { |
608 | 604 |
return null; |
609 | 605 |
} |
610 | 606 |
|
607 |
@Override |
|
608 |
public String getAccessDeniedMessage() { |
|
609 |
return accessDeniedMessage; |
|
610 |
} |
|
611 |
|
|
612 |
@Override |
|
613 |
public void setAccessDeniedMessage(String accessDeniedMessage) { |
|
614 |
this.accessDeniedMessage = accessDeniedMessage; |
|
615 |
} |
|
616 |
|
|
611 | 617 |
/** |
612 | 618 |
* @return the addNewNameRegistrationButton |
613 | 619 |
*/ |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/StartRegistrationViewBean.java | ||
---|---|---|
66 | 66 |
|
67 | 67 |
private Button continueButton; |
68 | 68 |
|
69 |
private String accessDeniedMessage; |
|
70 |
|
|
69 | 71 |
private static final String ELEMENT_WIDTH = "330px"; |
70 | 72 |
|
71 | 73 |
|
... | ... | |
198 | 200 |
return null; |
199 | 201 |
} |
200 | 202 |
|
203 |
@Override |
|
204 |
public String getAccessDeniedMessage() { |
|
205 |
return accessDeniedMessage; |
|
206 |
} |
|
207 |
|
|
208 |
@Override |
|
209 |
public void setAccessDeniedMessage(String accessDeniedMessage) { |
|
210 |
this.accessDeniedMessage = accessDeniedMessage; |
|
211 |
} |
|
212 |
|
|
213 |
|
|
201 | 214 |
/** |
202 | 215 |
* {@inheritDoc} |
203 | 216 |
*/ |
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractCdmDTOPopupEditor.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.vaadin.mvp; |
10 | 10 |
|
11 |
import java.util.Collection; |
|
11 | 12 |
import java.util.EnumSet; |
12 | 13 |
|
14 |
import org.springframework.security.core.GrantedAuthority; |
|
15 |
|
|
13 | 16 |
import com.vaadin.ui.Layout; |
14 | 17 |
|
15 | 18 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
16 | 19 |
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD; |
17 | 20 |
import eu.etaxonomy.cdm.vaadin.model.CdmEntityAdapterDTO; |
21 |
import eu.etaxonomy.cdm.vaadin.permission.AccessRestrictedView; |
|
18 | 22 |
import eu.etaxonomy.cdm.vaadin.view.PerEntityAuthorityGrantingEditor; |
19 | 23 |
|
20 | 24 |
/** |
... | ... | |
23 | 27 |
* |
24 | 28 |
*/ |
25 | 29 |
public abstract class AbstractCdmDTOPopupEditor<DTO extends CdmEntityAdapterDTO<CDM>, CDM extends CdmBase, P extends CdmEditorPresenterBase<DTO, CDM, ? extends ApplicationView>> |
26 |
extends AbstractPopupEditor<DTO, P> implements PerEntityAuthorityGrantingEditor { |
|
30 |
extends AbstractPopupEditor<DTO, P> implements PerEntityAuthorityGrantingEditor, AccessRestrictedView { |
|
31 |
|
|
32 |
private String accessDeniedMessage; |
|
27 | 33 |
|
28 | 34 |
/** |
29 | 35 |
* @param layout |
... | ... | |
44 | 50 |
((AbstractCdmDTOEditorPresenter)getPresenter()).setCdmEntityInstantiator(cdmEntityInstantiator); |
45 | 51 |
} |
46 | 52 |
|
53 |
@Override |
|
54 |
public boolean allowAnonymousAccess() { |
|
55 |
return false; |
|
56 |
} |
|
57 |
|
|
58 |
@Override |
|
59 |
public Collection<Collection<GrantedAuthority>> allowedGrantedAuthorities() { |
|
60 |
return null; |
|
61 |
} |
|
62 |
|
|
63 |
@Override |
|
64 |
public String getAccessDeniedMessage() { |
|
65 |
return accessDeniedMessage; |
|
66 |
} |
|
67 |
|
|
68 |
@Override |
|
69 |
public void setAccessDeniedMessage(String accessDeniedMessage) { |
|
70 |
this.accessDeniedMessage = accessDeniedMessage; |
|
71 |
|
|
72 |
} |
|
47 | 73 |
|
48 | 74 |
|
49 | 75 |
} |
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractCdmPopupEditor.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.vaadin.mvp; |
10 | 10 |
|
11 |
import java.util.Collection; |
|
11 | 12 |
import java.util.EnumSet; |
12 | 13 |
|
14 |
import org.springframework.security.core.GrantedAuthority; |
|
15 |
|
|
13 | 16 |
import com.vaadin.ui.Layout; |
14 | 17 |
|
15 | 18 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
16 | 19 |
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD; |
20 |
import eu.etaxonomy.cdm.vaadin.permission.AccessRestrictedView; |
|
17 | 21 |
import eu.etaxonomy.cdm.vaadin.view.PerEntityAuthorityGrantingEditor; |
18 | 22 |
|
19 | 23 |
/** |
... | ... | |
22 | 26 |
* |
23 | 27 |
*/ |
24 | 28 |
public abstract class AbstractCdmPopupEditor<CDM extends CdmBase, P extends CdmEditorPresenterBase<CDM, CDM, ? extends ApplicationView>> |
25 |
extends AbstractPopupEditor<CDM, P> implements PerEntityAuthorityGrantingEditor { |
|
29 |
extends AbstractPopupEditor<CDM, P> implements PerEntityAuthorityGrantingEditor, AccessRestrictedView { |
|
30 |
|
|
31 |
private String accessDeniedMessage; |
|
26 | 32 |
|
27 | 33 |
/** |
28 | 34 |
* @param layout |
... | ... | |
39 | 45 |
getPresenter().setGrantsForCurrentUser(crud); |
40 | 46 |
} |
41 | 47 |
|
48 |
@Override |
|
49 |
public boolean allowAnonymousAccess() { |
|
50 |
return false; |
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
public Collection<Collection<GrantedAuthority>> allowedGrantedAuthorities() { |
|
55 |
return null; |
|
56 |
} |
|
57 |
|
|
58 |
@Override |
|
59 |
public String getAccessDeniedMessage() { |
|
60 |
return accessDeniedMessage; |
|
61 |
} |
|
62 |
|
|
63 |
@Override |
|
64 |
public void setAccessDeniedMessage(String accessDeniedMessage) { |
|
65 |
this.accessDeniedMessage = accessDeniedMessage; |
|
66 |
|
|
67 |
} |
|
68 |
|
|
42 | 69 |
} |
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractView.java | ||
---|---|---|
18 | 18 |
* AbstractView is the base class of all MVP views. It takes care of finding |
19 | 19 |
* appropriate presenter component for the view. |
20 | 20 |
* |
21 |
* @param |
|
22 |
* <P> |
|
23 |
* type of the presenter this view uses. |
|
24 |
* |
|
25 |
* @author Peter / Vaadin |
|
21 |
* @param <P> type of the presenter this view uses. |
|
26 | 22 |
* @param <V> |
23 |
* @author Peter / Vaadin |
|
27 | 24 |
*/ |
28 | 25 |
@SuppressWarnings("serial") |
29 | 26 |
public abstract class AbstractView<P extends AbstractPresenter> extends CustomComponent |
... | ... | |
111 | 108 |
} |
112 | 109 |
} |
113 | 110 |
|
114 |
|
|
115 | 111 |
} |
Also available in: Unified diff
ref #7833 restricting access to RegistrationWorkingsetView: