Clover icon

sunshower-core

  1. Project Clover database Fri Apr 6 2018 03:27:42 UTC
  2. Package io.sunshower.service.security

File Impersonation.java

 

Coverage histogram

../../../../img/srcFileCovDistChart3.png
53% of files have more coverage

Code metrics

0
13
14
1
82
66
14
1.08
0.93
14
1

Classes

Class Line # Actions
Impersonation 12 13 14
0.2222222222.2%
 

Contributing tests

This file is covered by 4 tests. .

Source view

1    package io.sunshower.service.security;
2   
3    import io.sunshower.model.core.auth.Tenant;
4    import io.sunshower.model.core.auth.User;
5    import java.util.Arrays;
6    import java.util.Collection;
7    import java.util.Collections;
8    import org.springframework.security.core.Authentication;
9    import org.springframework.security.core.GrantedAuthority;
10    import org.springframework.security.core.userdetails.UserDetails;
11   
 
12    public class Impersonation extends User implements Authentication, UserDetails {
13    final GrantedAuthority[] roles;
14    final Tenant tenant = new Tenant();
15   
 
16  4 toggle public Impersonation(GrantedAuthority... roles) {
17  4 this.roles = roles;
18    }
19   
 
20  8 toggle @Override
21    public Collection<? extends GrantedAuthority> getAuthorities() {
22  8 return Collections.unmodifiableList(Arrays.asList(roles));
23    }
24   
 
25  0 toggle @Override
26    public Tenant getTenant() {
27  0 return tenant;
28    }
29   
 
30  0 toggle @Override
31    public String getPassword() {
32  0 return "impersonation";
33    }
34   
 
35  0 toggle @Override
36    public String getUsername() {
37  0 return "impersonation";
38    }
39   
 
40  0 toggle @Override
41    public boolean isAccountNonExpired() {
42  0 return true;
43    }
44   
 
45  0 toggle @Override
46    public boolean isAccountNonLocked() {
47  0 return true;
48    }
49   
 
50  0 toggle @Override
51    public boolean isCredentialsNonExpired() {
52  0 return true;
53    }
54   
 
55  0 toggle @Override
56    public boolean isEnabled() {
57  0 return true;
58    }
59   
 
60  0 toggle @Override
61    public Object getCredentials() {
62  0 return new User();
63    }
64   
 
65  0 toggle @Override
66    public Object getPrincipal() {
67  0 return this;
68    }
69   
 
70  7 toggle @Override
71    public boolean isAuthenticated() {
72  7 return true;
73    }
74   
 
75  0 toggle @Override
76    public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException {}
77   
 
78  0 toggle @Override
79    public String getName() {
80  0 return "impersonation";
81    }
82    }