Project

General

Profile

« Previous | Next » 

Revision f3b73faa

Added by Andreas Kohlbecker over 4 years ago

fixing bean binding problem in CdmUserHelper

View differences:

src/main/java/eu/etaxonomy/cdm/service/CdmUserHelper.java
29 29
import eu.etaxonomy.cdm.api.application.RunAsAuthenticator;
30 30
import eu.etaxonomy.cdm.database.PermissionDeniedException;
31 31
import eu.etaxonomy.cdm.model.common.CdmBase;
32
import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
32 33
import eu.etaxonomy.cdm.model.common.User;
33 34
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
34 35
import eu.etaxonomy.cdm.persistence.hibernate.permission.CdmAuthority;
......
56 57
    @Qualifier("cdmRepository")
57 58
    private CdmRepository repo;
58 59

  
60
    AuthenticationProvider runAsAuthenticationProvider;
61

  
59 62
    @Autowired
60 63
    @Qualifier("runAsAuthenticationProvider")
61
    AuthenticationProvider runAsAuthenticationProvider;
64
    public void setRunAsAuthenticationProvider(AuthenticationProvider runAsAuthenticationProvider){
65
        this.runAsAuthenticationProvider = runAsAuthenticationProvider;
66
        runAsAutheticator.setRunAsAuthenticationProvider(runAsAuthenticationProvider);
67
    }
62 68

  
63 69
    RunAsAuthenticator runAsAutheticator = new RunAsAuthenticator();
64 70

  
65 71
    public CdmUserHelper(){
66 72
        super();
67
        runAsAutheticator.setRunAsAuthenticationProvider(runAsAuthenticationProvider);
68

  
69 73
    }
70 74

  
71 75
    @Override
......
205 209
            User user = (User)userDetails;
206 210
            authority = new CdmAuthority(cdmEntity, property, crud);
207 211
            try {
208
                newAuthorityAdded = user.getGrantedAuthorities().add(authority.asNewGrantedAuthority());
212
                GrantedAuthorityImpl grantedAuthority = repo.getGrantedAuthorityService().findAuthorityString(authority.toString());
213
                if(grantedAuthority == null){
214
                    grantedAuthority = authority.asNewGrantedAuthority();
215
                }
216
                newAuthorityAdded = user.getGrantedAuthorities().add(grantedAuthority);
209 217
            } catch (CdmAuthorityParsingException e) {
210 218
                throw new RuntimeException(e);
211 219
            }

Also available in: Unified diff