Commit a6eefa903e9a386deb289a64a2b86d17cb17b99f

Authored by vzikratyi
1 parent 6e7d0c63

Added required methods to OAuth2Service

1 /** 1 /**
2 * Copyright © 2016-2020 The Thingsboard Authors 2 * Copyright © 2016-2020 The Thingsboard Authors
3 - * 3 + * <p>
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at 6 * You may obtain a copy of the License at
7 - *  
8 - * http://www.apache.org/licenses/LICENSE-2.0  
9 - * 7 + * <p>
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + * <p>
10 * Unless required by applicable law or agreed to in writing, software 10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, 11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,6 +15,9 @@ @@ -15,6 +15,9 @@
15 */ 15 */
16 package org.thingsboard.server.dao.oauth2; 16 package org.thingsboard.server.dao.oauth2;
17 17
  18 +import org.thingsboard.server.common.data.id.CustomerId;
  19 +import org.thingsboard.server.common.data.id.EntityId;
  20 +import org.thingsboard.server.common.data.id.TenantId;
18 import org.thingsboard.server.common.data.oauth2.OAuth2ClientInfo; 21 import org.thingsboard.server.common.data.oauth2.OAuth2ClientInfo;
19 import org.thingsboard.server.common.data.oauth2.OAuth2ClientRegistration; 22 import org.thingsboard.server.common.data.oauth2.OAuth2ClientRegistration;
20 23
@@ -24,4 +27,24 @@ public interface OAuth2Service { @@ -24,4 +27,24 @@ public interface OAuth2Service {
24 OAuth2ClientRegistration getClientRegistration(String registrationId); 27 OAuth2ClientRegistration getClientRegistration(String registrationId);
25 28
26 List<OAuth2ClientInfo> getOAuth2Clients(); 29 List<OAuth2ClientInfo> getOAuth2Clients();
  30 +
  31 + List<OAuth2ClientRegistration> getSystemOAuth2ClientRegistrations(TenantId tenantId);
  32 +
  33 + List<OAuth2ClientRegistration> getTenantOAuth2ClientRegistrations(TenantId tenantId);
  34 +
  35 + List<OAuth2ClientRegistration> getCustomerOAuth2ClientRegistrations(TenantId tenantId, CustomerId customerId);
  36 +
  37 + OAuth2ClientRegistration saveSystemOAuth2ClientRegistration(OAuth2ClientRegistration clientRegistration);
  38 +
  39 + OAuth2ClientRegistration saveTenantOAuth2ClientRegistration(TenantId tenantId, OAuth2ClientRegistration clientRegistration);
  40 +
  41 + OAuth2ClientRegistration saveCustomerOAuth2ClientRegistration(TenantId tenantId, CustomerId customerId, OAuth2ClientRegistration clientRegistration);
  42 +
  43 + void deleteDomainOAuth2ClientRegistrationByEntityId(TenantId tenantId, EntityId entityId);
  44 +
  45 + boolean isOAuth2ClientRegistrationAllowed(TenantId tenantId, EntityId entityId);
  46 +
  47 + boolean isCustomerOAuth2ClientRegistrationAllowed(TenantId tenantId);
  48 +
  49 +
27 } 50 }
@@ -18,6 +18,9 @@ package org.thingsboard.server.dao.oauth2; @@ -18,6 +18,9 @@ package org.thingsboard.server.dao.oauth2;
18 import lombok.extern.slf4j.Slf4j; 18 import lombok.extern.slf4j.Slf4j;
19 import org.springframework.beans.factory.annotation.Autowired; 19 import org.springframework.beans.factory.annotation.Autowired;
20 import org.springframework.stereotype.Service; 20 import org.springframework.stereotype.Service;
  21 +import org.thingsboard.server.common.data.id.CustomerId;
  22 +import org.thingsboard.server.common.data.id.EntityId;
  23 +import org.thingsboard.server.common.data.id.TenantId;
21 import org.thingsboard.server.common.data.oauth2.*; 24 import org.thingsboard.server.common.data.oauth2.*;
22 25
23 import java.util.Collections; 26 import java.util.Collections;
@@ -53,6 +56,51 @@ public class OAuth2ServiceImpl implements OAuth2Service { @@ -53,6 +56,51 @@ public class OAuth2ServiceImpl implements OAuth2Service {
53 } 56 }
54 57
55 @Override 58 @Override
  59 + public List<OAuth2ClientRegistration> getSystemOAuth2ClientRegistrations(TenantId tenantId) {
  60 + return null;
  61 + }
  62 +
  63 + @Override
  64 + public List<OAuth2ClientRegistration> getTenantOAuth2ClientRegistrations(TenantId tenantId) {
  65 + return null;
  66 + }
  67 +
  68 + @Override
  69 + public List<OAuth2ClientRegistration> getCustomerOAuth2ClientRegistrations(TenantId tenantId, CustomerId customerId) {
  70 + return null;
  71 + }
  72 +
  73 + @Override
  74 + public OAuth2ClientRegistration saveSystemOAuth2ClientRegistration(OAuth2ClientRegistration clientRegistration) {
  75 + return null;
  76 + }
  77 +
  78 + @Override
  79 + public OAuth2ClientRegistration saveTenantOAuth2ClientRegistration(TenantId tenantId, OAuth2ClientRegistration clientRegistration) {
  80 + return null;
  81 + }
  82 +
  83 + @Override
  84 + public OAuth2ClientRegistration saveCustomerOAuth2ClientRegistration(TenantId tenantId, CustomerId customerId, OAuth2ClientRegistration clientRegistration) {
  85 + return null;
  86 + }
  87 +
  88 + @Override
  89 + public void deleteDomainOAuth2ClientRegistrationByEntityId(TenantId tenantId, EntityId entityId) {
  90 +
  91 + }
  92 +
  93 + @Override
  94 + public boolean isOAuth2ClientRegistrationAllowed(TenantId tenantId, EntityId entityId) {
  95 + return false;
  96 + }
  97 +
  98 + @Override
  99 + public boolean isCustomerOAuth2ClientRegistrationAllowed(TenantId tenantId) {
  100 + return false;
  101 + }
  102 +
  103 + @Override
56 public OAuth2ClientRegistration getClientRegistration(String registrationId) { 104 public OAuth2ClientRegistration getClientRegistration(String registrationId) {
57 if (oauth2Configuration == null || !oauth2Configuration.isEnabled()) return null; 105 if (oauth2Configuration == null || !oauth2Configuration.isEnabled()) return null;
58 OAuth2Client oAuth2Client = oauth2Configuration.getClients() == null ? null : oauth2Configuration.getClients().get(registrationId); 106 OAuth2Client oAuth2Client = oauth2Configuration.getClients() == null ? null : oauth2Configuration.getClients().get(registrationId);