Clover icon

sunshower-sdk

  1. Project Clover database Sat May 12 2018 05:15:40 UTC
  2. Package io.sunshower.sdk.v1.core.security

File DefaultActivationEndpoint.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
9
4
1
48
38
4
0.44
2.25
4
1

Classes

Class Line # Actions
DefaultActivationEndpoint 15 9 4
1.0100%
 

Contributing tests

This file is covered by 8 tests. .

Source view

1    package io.sunshower.sdk.v1.core.security;
2   
3    import io.sunshower.core.security.crypto.EncryptionService;
4    import io.sunshower.model.core.auth.User;
5    import io.sunshower.sdk.core.ActivationEndpoint;
6    import io.sunshower.sdk.core.model.ActivationElement;
7    import io.sunshower.sdk.core.model.Activations;
8    import io.sunshower.sdk.lang.BooleanElement;
9    import io.sunshower.sdk.v1.model.core.Users;
10    import io.sunshower.sdk.v1.model.core.security.PrincipalElement;
11    import io.sunshower.service.security.ActivationService;
12   
13    import javax.inject.Inject;
14   
 
15    public class DefaultActivationEndpoint implements ActivationEndpoint {
16   
17    @Inject private Users users;
18    @Inject private Activations activations;
19   
20    @Inject private EncryptionService encryptionService;
21   
22    @Inject private ActivationService activationService;
23   
 
24  1 toggle @Override
25    public void deactivate() {
26  1 activationService.deactivate();
27    }
28   
 
29  3 toggle @Override
30    public BooleanElement isActive() {
31  3 return BooleanElement.valueOf(activationService.isActive());
32    }
33   
 
34  7 toggle @Override
35    public ActivationElement activate(PrincipalElement element) {
36  7 User user = users.toModel(element);
37  7 String password = element.getPassword();
38  7 String encryptedPassword = encryptionService.encrypt(password);
39  7 user.setPassword(encryptedPassword);
40  7 user.setActive(true);
41  7 return activations.toElement(activationService.activate(user));
42    }
43   
 
44  3 toggle @Override
45    public void delete(ActivationElement e) {
46  3 activationService.delete(activations.toModel(e));
47    }
48    }