Commit 6e7d0c633f6fee6203f18408fea4f0eafd01aa37

Authored by vzikratyi
1 parent 7fcf8a98

Small refactoring

@@ -39,7 +39,7 @@ public class OAuth2Controller extends BaseController { @@ -39,7 +39,7 @@ public class OAuth2Controller extends BaseController {
39 @ResponseBody 39 @ResponseBody
40 public OAuth2ClientRegistration getClientRegistrationById(@PathVariable(REGISTRATION_ID) String registrationId) throws ThingsboardException { 40 public OAuth2ClientRegistration getClientRegistrationById(@PathVariable(REGISTRATION_ID) String registrationId) throws ThingsboardException {
41 try { 41 try {
42 - return oauth2Service.getClientRegistrationByRegistrationId(registrationId); 42 + return oauth2Service.getClientRegistration(registrationId);
43 } catch (Exception e) { 43 } catch (Exception e) {
44 throw handleException(e); 44 throw handleException(e);
45 } 45 }
@@ -64,7 +64,7 @@ public class Oauth2AuthenticationSuccessHandler extends SimpleUrlAuthenticationS @@ -64,7 +64,7 @@ public class Oauth2AuthenticationSuccessHandler extends SimpleUrlAuthenticationS
64 try { 64 try {
65 OAuth2AuthenticationToken token = (OAuth2AuthenticationToken) authentication; 65 OAuth2AuthenticationToken token = (OAuth2AuthenticationToken) authentication;
66 66
67 - OAuth2ClientRegistration clientRegistration = oAuth2Service.getClientRegistrationByRegistrationId(token.getAuthorizedClientRegistrationId()); 67 + OAuth2ClientRegistration clientRegistration = oAuth2Service.getClientRegistration(token.getAuthorizedClientRegistrationId());
68 OAuth2ClientMapper mapper = oauth2ClientMapperProvider.getOAuth2ClientMapperByType(clientRegistration.getMapperConfig().getType()); 68 OAuth2ClientMapper mapper = oauth2ClientMapperProvider.getOAuth2ClientMapperByType(clientRegistration.getMapperConfig().getType());
69 SecurityUser securityUser = mapper.getOrCreateUserByClientPrincipal(token, clientRegistration.getMapperConfig()); 69 SecurityUser securityUser = mapper.getOrCreateUserByClientPrincipal(token, clientRegistration.getMapperConfig());
70 70
@@ -21,7 +21,7 @@ import org.thingsboard.server.common.data.oauth2.OAuth2ClientRegistration; @@ -21,7 +21,7 @@ import org.thingsboard.server.common.data.oauth2.OAuth2ClientRegistration;
21 import java.util.List; 21 import java.util.List;
22 22
23 public interface OAuth2Service { 23 public interface OAuth2Service {
24 - OAuth2ClientRegistration getClientRegistrationByRegistrationId(String registrationId); 24 + OAuth2ClientRegistration getClientRegistration(String registrationId);
25 25
26 List<OAuth2ClientInfo> getOAuth2Clients(); 26 List<OAuth2ClientInfo> getOAuth2Clients();
27 } 27 }
@@ -18,7 +18,7 @@ public class HybridClientRegistrationRepository implements ClientRegistrationRep @@ -18,7 +18,7 @@ public class HybridClientRegistrationRepository implements ClientRegistrationRep
18 18
19 @Override 19 @Override
20 public ClientRegistration findByRegistrationId(String registrationId) { 20 public ClientRegistration findByRegistrationId(String registrationId) {
21 - OAuth2ClientRegistration localClientRegistration = oAuth2Service.getClientRegistrationByRegistrationId(registrationId); 21 + OAuth2ClientRegistration localClientRegistration = oAuth2Service.getClientRegistration(registrationId);
22 return localClientRegistration == null ? 22 return localClientRegistration == null ?
23 null : toSpringClientRegistration(localClientRegistration); 23 null : toSpringClientRegistration(localClientRegistration);
24 } 24 }
@@ -53,7 +53,7 @@ public class OAuth2ServiceImpl implements OAuth2Service { @@ -53,7 +53,7 @@ public class OAuth2ServiceImpl implements OAuth2Service {
53 } 53 }
54 54
55 @Override 55 @Override
56 - public OAuth2ClientRegistration getClientRegistrationByRegistrationId(String registrationId) { 56 + public OAuth2ClientRegistration getClientRegistration(String registrationId) {
57 if (oauth2Configuration == null || !oauth2Configuration.isEnabled()) return null; 57 if (oauth2Configuration == null || !oauth2Configuration.isEnabled()) return null;
58 OAuth2Client oAuth2Client = oauth2Configuration.getClients() == null ? null : oauth2Configuration.getClients().get(registrationId); 58 OAuth2Client oAuth2Client = oauth2Configuration.getClients() == null ? null : oauth2Configuration.getClients().get(registrationId);
59 if (oAuth2Client != null){ 59 if (oAuth2Client != null){