Project

General

Profile

Revision b4d87f3f

IDb4d87f3f377474f268e6fca33514182f084232ab
Parent 9493160a
Child b10dc109

Added by Andreas Kohlbecker almost 3 years ago

fix #6855 disabling add Team, Person buttons when privileges insufficient
- also extending UserHelper class

View differences:

src/main/java/eu/etaxonomy/cdm/service/CdmUserHelper.java
109 109
    public boolean userHasPermission(Class<? extends CdmBase> cdmType, Integer entitiyId, Object ... args){
110 110
        EnumSet<CRUD> crudSet = crudSetFromArgs(args);
111 111
        try {
112
        return permissionEvaluator.hasPermission(getAuthentication(), cdmType, entitiyId.toString(), crudSet);
112
            return permissionEvaluator.hasPermission(getAuthentication(), cdmType, entitiyId.toString(), crudSet);
113
        } catch (PermissionDeniedException e){
114
            //IGNORE
115
        }
116
        return false;
117
    }
118

  
119
    @Override
120
    public boolean userHasPermission(Class<? extends CdmBase> cdmType, Object ... args){
121
        EnumSet<CRUD> crudSet = crudSetFromArgs(args);
122
        try {
123
            return permissionEvaluator.hasPermission(getAuthentication(), cdmType, crudSet);
113 124
        } catch (PermissionDeniedException e){
114 125
            //IGNORE
115 126
        }
src/main/java/eu/etaxonomy/cdm/vaadin/component/common/TeamOrPersonField.java
76 76
        addSizedComponent(personsListEditor);
77 77

  
78 78
        setConverter(new CdmBaseDeproxyConverter<TeamOrPersonBase<?>>());
79

  
80
        updateToolBarButtonStates();
79 81
    }
80 82

  
81 83
    /**
......
122 124

  
123 125
    private void updateToolBarButtonStates(){
124 126
        TeamOrPersonBase<?> val = getInternalValue();
127
        boolean userCanCreate = UserHelper.fromSession().userHasPermission(Person.class, "CREATE");
125 128
        removeButton.setEnabled(val != null);
126
        personButton.setEnabled(val == null);
127
        teamButton.setEnabled(val == null);
129
        personButton.setEnabled(userCanCreate && val == null);
130
        teamButton.setEnabled(userCanCreate && val == null);
128 131
    }
129 132

  
130 133
    /**
src/main/java/eu/etaxonomy/cdm/vaadin/security/UserHelper.java
36 36

  
37 37
    boolean userHasPermission(Class<? extends CdmBase> cdmType, Integer entitiyId, Object ... args);
38 38

  
39
    boolean userHasPermission(Class<? extends CdmBase> cdmType, Object ... args);
40

  
39 41
    boolean userHasPermission(CdmBase entity, Object ... args);
40 42

  
41 43
    boolean userIsRegistrationCurator();
......
48 50

  
49 51
    boolean userIsAutheticated();
50 52

  
53

  
51 54
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)