48 changed files with 51 additions and 1422 deletions
@ -1,35 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.server.common.data.id.deprecated; |
|
||||
|
|
||||
import com.fasterxml.jackson.annotation.JsonCreator; |
|
||||
import com.fasterxml.jackson.annotation.JsonProperty; |
|
||||
import org.thingsboard.server.common.data.id.UUIDBased; |
|
||||
|
|
||||
import java.util.UUID; |
|
||||
|
|
||||
@Deprecated |
|
||||
public class OAuth2ClientRegistrationId extends UUIDBased { |
|
||||
|
|
||||
@JsonCreator |
|
||||
public OAuth2ClientRegistrationId(@JsonProperty("id") UUID id) { |
|
||||
super(id); |
|
||||
} |
|
||||
|
|
||||
public static OAuth2ClientRegistrationId fromString(String clientRegistrationId) { |
|
||||
return new OAuth2ClientRegistrationId(UUID.fromString(clientRegistrationId)); |
|
||||
} |
|
||||
} |
|
||||
@ -1,35 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.server.common.data.id.deprecated; |
|
||||
|
|
||||
import com.fasterxml.jackson.annotation.JsonCreator; |
|
||||
import com.fasterxml.jackson.annotation.JsonProperty; |
|
||||
import org.thingsboard.server.common.data.id.UUIDBased; |
|
||||
|
|
||||
import java.util.UUID; |
|
||||
|
|
||||
@Deprecated |
|
||||
public class OAuth2ClientRegistrationInfoId extends UUIDBased { |
|
||||
|
|
||||
@JsonCreator |
|
||||
public OAuth2ClientRegistrationInfoId(@JsonProperty("id") UUID id) { |
|
||||
super(id); |
|
||||
} |
|
||||
|
|
||||
public static OAuth2ClientRegistrationInfoId fromString(String clientRegistrationInfoId) { |
|
||||
return new OAuth2ClientRegistrationInfoId(UUID.fromString(clientRegistrationInfoId)); |
|
||||
} |
|
||||
} |
|
||||
@ -1,45 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.server.common.data.oauth2.deprecated; |
|
||||
|
|
||||
import com.fasterxml.jackson.databind.JsonNode; |
|
||||
import lombok.*; |
|
||||
import org.thingsboard.server.common.data.oauth2.OAuth2MapperConfig; |
|
||||
|
|
||||
import java.util.List; |
|
||||
|
|
||||
@Deprecated |
|
||||
@EqualsAndHashCode |
|
||||
@Data |
|
||||
@ToString(exclude = {"clientSecret"}) |
|
||||
@NoArgsConstructor |
|
||||
@AllArgsConstructor |
|
||||
@Builder |
|
||||
public class ClientRegistrationDto { |
|
||||
private OAuth2MapperConfig mapperConfig; |
|
||||
private String clientId; |
|
||||
private String clientSecret; |
|
||||
private String authorizationUri; |
|
||||
private String accessTokenUri; |
|
||||
private List<String> scope; |
|
||||
private String userInfoUri; |
|
||||
private String userNameAttributeName; |
|
||||
private String jwkSetUri; |
|
||||
private String clientAuthenticationMethod; |
|
||||
private String loginButtonLabel; |
|
||||
private String loginButtonIcon; |
|
||||
private JsonNode additionalInfo; |
|
||||
} |
|
||||
@ -1,31 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.server.common.data.oauth2.deprecated; |
|
||||
|
|
||||
import lombok.*; |
|
||||
import org.thingsboard.server.common.data.oauth2.SchemeType; |
|
||||
|
|
||||
@Deprecated |
|
||||
@EqualsAndHashCode |
|
||||
@Data |
|
||||
@ToString |
|
||||
@NoArgsConstructor |
|
||||
@AllArgsConstructor |
|
||||
@Builder |
|
||||
public class DomainInfo { |
|
||||
private SchemeType scheme; |
|
||||
private String name; |
|
||||
} |
|
||||
@ -1,42 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.server.common.data.oauth2.deprecated; |
|
||||
|
|
||||
import lombok.Data; |
|
||||
import lombok.EqualsAndHashCode; |
|
||||
import org.thingsboard.server.common.data.oauth2.SchemeType; |
|
||||
import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientRegistrationInfo; |
|
||||
|
|
||||
@Deprecated |
|
||||
@EqualsAndHashCode(callSuper = true) |
|
||||
@Data |
|
||||
public class ExtendedOAuth2ClientRegistrationInfo extends OAuth2ClientRegistrationInfo { |
|
||||
|
|
||||
private String domainName; |
|
||||
private SchemeType domainScheme; |
|
||||
|
|
||||
public ExtendedOAuth2ClientRegistrationInfo() { |
|
||||
super(); |
|
||||
} |
|
||||
|
|
||||
public ExtendedOAuth2ClientRegistrationInfo(OAuth2ClientRegistrationInfo oAuth2ClientRegistrationInfo, |
|
||||
SchemeType domainScheme, |
|
||||
String domainName) { |
|
||||
super(oAuth2ClientRegistrationInfo); |
|
||||
this.domainScheme = domainScheme; |
|
||||
this.domainName = domainName; |
|
||||
} |
|
||||
} |
|
||||
@ -1,44 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.server.common.data.oauth2.deprecated; |
|
||||
|
|
||||
import lombok.Data; |
|
||||
import lombok.EqualsAndHashCode; |
|
||||
import lombok.NoArgsConstructor; |
|
||||
import lombok.ToString; |
|
||||
import org.thingsboard.server.common.data.BaseData; |
|
||||
import org.thingsboard.server.common.data.id.deprecated.OAuth2ClientRegistrationId; |
|
||||
import org.thingsboard.server.common.data.id.deprecated.OAuth2ClientRegistrationInfoId; |
|
||||
import org.thingsboard.server.common.data.oauth2.SchemeType; |
|
||||
|
|
||||
@Deprecated |
|
||||
@EqualsAndHashCode(callSuper = true) |
|
||||
@Data |
|
||||
@ToString |
|
||||
@NoArgsConstructor |
|
||||
public class OAuth2ClientRegistration extends BaseData<OAuth2ClientRegistrationId> { |
|
||||
|
|
||||
private OAuth2ClientRegistrationInfoId clientRegistrationId; |
|
||||
private String domainName; |
|
||||
private SchemeType domainScheme; |
|
||||
|
|
||||
public OAuth2ClientRegistration(OAuth2ClientRegistration clientRegistration) { |
|
||||
super(clientRegistration); |
|
||||
this.clientRegistrationId = clientRegistration.clientRegistrationId; |
|
||||
this.domainName = clientRegistration.domainName; |
|
||||
this.domainScheme = clientRegistration.domainScheme; |
|
||||
} |
|
||||
} |
|
||||
@ -1,78 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.server.common.data.oauth2.deprecated; |
|
||||
|
|
||||
import com.fasterxml.jackson.annotation.JsonProperty; |
|
||||
import lombok.Data; |
|
||||
import lombok.EqualsAndHashCode; |
|
||||
import lombok.NoArgsConstructor; |
|
||||
import lombok.ToString; |
|
||||
import org.thingsboard.server.common.data.HasName; |
|
||||
import org.thingsboard.server.common.data.SearchTextBasedWithAdditionalInfo; |
|
||||
import org.thingsboard.server.common.data.id.deprecated.OAuth2ClientRegistrationInfoId; |
|
||||
import org.thingsboard.server.common.data.oauth2.OAuth2MapperConfig; |
|
||||
|
|
||||
import java.util.List; |
|
||||
|
|
||||
@Deprecated |
|
||||
@EqualsAndHashCode(callSuper = true) |
|
||||
@Data |
|
||||
@ToString(exclude = {"clientSecret"}) |
|
||||
@NoArgsConstructor |
|
||||
public class OAuth2ClientRegistrationInfo extends SearchTextBasedWithAdditionalInfo<OAuth2ClientRegistrationInfoId> implements HasName { |
|
||||
|
|
||||
private boolean enabled; |
|
||||
private OAuth2MapperConfig mapperConfig; |
|
||||
private String clientId; |
|
||||
private String clientSecret; |
|
||||
private String authorizationUri; |
|
||||
private String accessTokenUri; |
|
||||
private List<String> scope; |
|
||||
private String userInfoUri; |
|
||||
private String userNameAttributeName; |
|
||||
private String jwkSetUri; |
|
||||
private String clientAuthenticationMethod; |
|
||||
private String loginButtonLabel; |
|
||||
private String loginButtonIcon; |
|
||||
|
|
||||
public OAuth2ClientRegistrationInfo(OAuth2ClientRegistrationInfo clientRegistration) { |
|
||||
super(clientRegistration); |
|
||||
this.enabled = clientRegistration.enabled; |
|
||||
this.mapperConfig = clientRegistration.mapperConfig; |
|
||||
this.clientId = clientRegistration.clientId; |
|
||||
this.clientSecret = clientRegistration.clientSecret; |
|
||||
this.authorizationUri = clientRegistration.authorizationUri; |
|
||||
this.accessTokenUri = clientRegistration.accessTokenUri; |
|
||||
this.scope = clientRegistration.scope; |
|
||||
this.userInfoUri = clientRegistration.userInfoUri; |
|
||||
this.userNameAttributeName = clientRegistration.userNameAttributeName; |
|
||||
this.jwkSetUri = clientRegistration.jwkSetUri; |
|
||||
this.clientAuthenticationMethod = clientRegistration.clientAuthenticationMethod; |
|
||||
this.loginButtonLabel = clientRegistration.loginButtonLabel; |
|
||||
this.loginButtonIcon = clientRegistration.loginButtonIcon; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY) |
|
||||
public String getName() { |
|
||||
return loginButtonLabel; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public String getSearchText() { |
|
||||
return getName(); |
|
||||
} |
|
||||
} |
|
||||
@ -1,32 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.server.common.data.oauth2.deprecated; |
|
||||
|
|
||||
import lombok.*; |
|
||||
|
|
||||
import java.util.List; |
|
||||
|
|
||||
@Deprecated |
|
||||
@EqualsAndHashCode |
|
||||
@Data |
|
||||
@ToString |
|
||||
@Builder(toBuilder = true) |
|
||||
@NoArgsConstructor |
|
||||
@AllArgsConstructor |
|
||||
public class OAuth2ClientsDomainParams { |
|
||||
private List<DomainInfo> domainInfos; |
|
||||
private List<ClientRegistrationDto> clientRegistrations; |
|
||||
} |
|
||||
@ -1,32 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.server.common.data.oauth2.deprecated; |
|
||||
|
|
||||
import lombok.*; |
|
||||
|
|
||||
import java.util.List; |
|
||||
|
|
||||
@Deprecated |
|
||||
@EqualsAndHashCode |
|
||||
@Data |
|
||||
@ToString |
|
||||
@Builder(toBuilder = true) |
|
||||
@NoArgsConstructor |
|
||||
@AllArgsConstructor |
|
||||
public class OAuth2ClientsParams { |
|
||||
private boolean enabled; |
|
||||
private List<OAuth2ClientsDomainParams> domainsParams; |
|
||||
} |
|
||||
@ -1,234 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.server.dao.model.sql.deprecated; |
|
||||
|
|
||||
import com.fasterxml.jackson.databind.JsonNode; |
|
||||
import lombok.Data; |
|
||||
import lombok.EqualsAndHashCode; |
|
||||
import org.hibernate.annotations.Type; |
|
||||
import org.hibernate.annotations.TypeDef; |
|
||||
import org.thingsboard.server.common.data.id.deprecated.OAuth2ClientRegistrationInfoId; |
|
||||
import org.thingsboard.server.common.data.oauth2.*; |
|
||||
import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientRegistrationInfo; |
|
||||
import org.thingsboard.server.dao.model.BaseSqlEntity; |
|
||||
import org.thingsboard.server.dao.model.ModelConstants; |
|
||||
import org.thingsboard.server.dao.model.sql.deprecated.OAuth2ClientRegistrationInfoEntity; |
|
||||
import org.thingsboard.server.dao.util.mapping.JsonStringType; |
|
||||
|
|
||||
import javax.persistence.*; |
|
||||
import java.util.Arrays; |
|
||||
|
|
||||
@Deprecated |
|
||||
@Data |
|
||||
@EqualsAndHashCode(callSuper = true) |
|
||||
@TypeDef(name = "json", typeClass = JsonStringType.class) |
|
||||
@MappedSuperclass |
|
||||
public abstract class AbstractOAuth2ClientRegistrationInfoEntity<T extends OAuth2ClientRegistrationInfo> extends BaseSqlEntity<T> { |
|
||||
|
|
||||
@Column(name = ModelConstants.OAUTH2_ENABLED_PROPERTY) |
|
||||
private Boolean enabled; |
|
||||
@Column(name = ModelConstants.OAUTH2_CLIENT_ID_PROPERTY) |
|
||||
private String clientId; |
|
||||
@Column(name = ModelConstants.OAUTH2_CLIENT_SECRET_PROPERTY) |
|
||||
private String clientSecret; |
|
||||
@Column(name = ModelConstants.OAUTH2_AUTHORIZATION_URI_PROPERTY) |
|
||||
private String authorizationUri; |
|
||||
@Column(name = ModelConstants.OAUTH2_TOKEN_URI_PROPERTY) |
|
||||
private String tokenUri; |
|
||||
@Column(name = ModelConstants.OAUTH2_SCOPE_PROPERTY) |
|
||||
private String scope; |
|
||||
@Column(name = ModelConstants.OAUTH2_USER_INFO_URI_PROPERTY) |
|
||||
private String userInfoUri; |
|
||||
@Column(name = ModelConstants.OAUTH2_USER_NAME_ATTRIBUTE_NAME_PROPERTY) |
|
||||
private String userNameAttributeName; |
|
||||
@Column(name = ModelConstants.OAUTH2_JWK_SET_URI_PROPERTY) |
|
||||
private String jwkSetUri; |
|
||||
@Column(name = ModelConstants.OAUTH2_CLIENT_AUTHENTICATION_METHOD_PROPERTY) |
|
||||
private String clientAuthenticationMethod; |
|
||||
@Column(name = ModelConstants.OAUTH2_LOGIN_BUTTON_LABEL_PROPERTY) |
|
||||
private String loginButtonLabel; |
|
||||
@Column(name = ModelConstants.OAUTH2_LOGIN_BUTTON_ICON_PROPERTY) |
|
||||
private String loginButtonIcon; |
|
||||
@Column(name = ModelConstants.OAUTH2_ALLOW_USER_CREATION_PROPERTY) |
|
||||
private Boolean allowUserCreation; |
|
||||
@Column(name = ModelConstants.OAUTH2_ACTIVATE_USER_PROPERTY) |
|
||||
private Boolean activateUser; |
|
||||
@Enumerated(EnumType.STRING) |
|
||||
@Column(name = ModelConstants.OAUTH2_MAPPER_TYPE_PROPERTY) |
|
||||
private MapperType type; |
|
||||
@Column(name = ModelConstants.OAUTH2_EMAIL_ATTRIBUTE_KEY_PROPERTY) |
|
||||
private String emailAttributeKey; |
|
||||
@Column(name = ModelConstants.OAUTH2_FIRST_NAME_ATTRIBUTE_KEY_PROPERTY) |
|
||||
private String firstNameAttributeKey; |
|
||||
@Column(name = ModelConstants.OAUTH2_LAST_NAME_ATTRIBUTE_KEY_PROPERTY) |
|
||||
private String lastNameAttributeKey; |
|
||||
@Enumerated(EnumType.STRING) |
|
||||
@Column(name = ModelConstants.OAUTH2_TENANT_NAME_STRATEGY_PROPERTY) |
|
||||
private TenantNameStrategyType tenantNameStrategy; |
|
||||
@Column(name = ModelConstants.OAUTH2_TENANT_NAME_PATTERN_PROPERTY) |
|
||||
private String tenantNamePattern; |
|
||||
@Column(name = ModelConstants.OAUTH2_CUSTOMER_NAME_PATTERN_PROPERTY) |
|
||||
private String customerNamePattern; |
|
||||
@Column(name = ModelConstants.OAUTH2_DEFAULT_DASHBOARD_NAME_PROPERTY) |
|
||||
private String defaultDashboardName; |
|
||||
@Column(name = ModelConstants.OAUTH2_ALWAYS_FULL_SCREEN_PROPERTY) |
|
||||
private Boolean alwaysFullScreen; |
|
||||
@Column(name = ModelConstants.OAUTH2_MAPPER_URL_PROPERTY) |
|
||||
private String url; |
|
||||
@Column(name = ModelConstants.OAUTH2_MAPPER_USERNAME_PROPERTY) |
|
||||
private String username; |
|
||||
@Column(name = ModelConstants.OAUTH2_MAPPER_PASSWORD_PROPERTY) |
|
||||
private String password; |
|
||||
@Column(name = ModelConstants.OAUTH2_MAPPER_SEND_TOKEN_PROPERTY) |
|
||||
private Boolean sendToken; |
|
||||
|
|
||||
@Type(type = "json") |
|
||||
@Column(name = ModelConstants.OAUTH2_ADDITIONAL_INFO_PROPERTY) |
|
||||
private JsonNode additionalInfo; |
|
||||
|
|
||||
public AbstractOAuth2ClientRegistrationInfoEntity() { |
|
||||
super(); |
|
||||
} |
|
||||
|
|
||||
public AbstractOAuth2ClientRegistrationInfoEntity(OAuth2ClientRegistrationInfo clientRegistrationInfo) { |
|
||||
if (clientRegistrationInfo.getId() != null) { |
|
||||
this.setUuid(clientRegistrationInfo.getId().getId()); |
|
||||
} |
|
||||
this.createdTime = clientRegistrationInfo.getCreatedTime(); |
|
||||
this.enabled = clientRegistrationInfo.isEnabled(); |
|
||||
this.clientId = clientRegistrationInfo.getClientId(); |
|
||||
this.clientSecret = clientRegistrationInfo.getClientSecret(); |
|
||||
this.authorizationUri = clientRegistrationInfo.getAuthorizationUri(); |
|
||||
this.tokenUri = clientRegistrationInfo.getAccessTokenUri(); |
|
||||
this.scope = clientRegistrationInfo.getScope().stream().reduce((result, element) -> result + "," + element).orElse(""); |
|
||||
this.userInfoUri = clientRegistrationInfo.getUserInfoUri(); |
|
||||
this.userNameAttributeName = clientRegistrationInfo.getUserNameAttributeName(); |
|
||||
this.jwkSetUri = clientRegistrationInfo.getJwkSetUri(); |
|
||||
this.clientAuthenticationMethod = clientRegistrationInfo.getClientAuthenticationMethod(); |
|
||||
this.loginButtonLabel = clientRegistrationInfo.getLoginButtonLabel(); |
|
||||
this.loginButtonIcon = clientRegistrationInfo.getLoginButtonIcon(); |
|
||||
this.additionalInfo = clientRegistrationInfo.getAdditionalInfo(); |
|
||||
OAuth2MapperConfig mapperConfig = clientRegistrationInfo.getMapperConfig(); |
|
||||
if (mapperConfig != null) { |
|
||||
this.allowUserCreation = mapperConfig.isAllowUserCreation(); |
|
||||
this.activateUser = mapperConfig.isActivateUser(); |
|
||||
this.type = mapperConfig.getType(); |
|
||||
OAuth2BasicMapperConfig basicConfig = mapperConfig.getBasic(); |
|
||||
if (basicConfig != null) { |
|
||||
this.emailAttributeKey = basicConfig.getEmailAttributeKey(); |
|
||||
this.firstNameAttributeKey = basicConfig.getFirstNameAttributeKey(); |
|
||||
this.lastNameAttributeKey = basicConfig.getLastNameAttributeKey(); |
|
||||
this.tenantNameStrategy = basicConfig.getTenantNameStrategy(); |
|
||||
this.tenantNamePattern = basicConfig.getTenantNamePattern(); |
|
||||
this.customerNamePattern = basicConfig.getCustomerNamePattern(); |
|
||||
this.defaultDashboardName = basicConfig.getDefaultDashboardName(); |
|
||||
this.alwaysFullScreen = basicConfig.isAlwaysFullScreen(); |
|
||||
} |
|
||||
OAuth2CustomMapperConfig customConfig = mapperConfig.getCustom(); |
|
||||
if (customConfig != null) { |
|
||||
this.url = customConfig.getUrl(); |
|
||||
this.username = customConfig.getUsername(); |
|
||||
this.password = customConfig.getPassword(); |
|
||||
this.sendToken = customConfig.isSendToken(); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public AbstractOAuth2ClientRegistrationInfoEntity(OAuth2ClientRegistrationInfoEntity oAuth2ClientRegistrationInfoEntity) { |
|
||||
this.setId(oAuth2ClientRegistrationInfoEntity.getId()); |
|
||||
this.setCreatedTime(oAuth2ClientRegistrationInfoEntity.getCreatedTime()); |
|
||||
this.enabled = oAuth2ClientRegistrationInfoEntity.getEnabled(); |
|
||||
this.clientId = oAuth2ClientRegistrationInfoEntity.getClientId(); |
|
||||
this.clientSecret = oAuth2ClientRegistrationInfoEntity.getClientSecret(); |
|
||||
this.authorizationUri = oAuth2ClientRegistrationInfoEntity.getAuthorizationUri(); |
|
||||
this.tokenUri = oAuth2ClientRegistrationInfoEntity.getTokenUri(); |
|
||||
this.scope = oAuth2ClientRegistrationInfoEntity.getScope(); |
|
||||
this.userInfoUri = oAuth2ClientRegistrationInfoEntity.getUserInfoUri(); |
|
||||
this.userNameAttributeName = oAuth2ClientRegistrationInfoEntity.getUserNameAttributeName(); |
|
||||
this.jwkSetUri = oAuth2ClientRegistrationInfoEntity.getJwkSetUri(); |
|
||||
this.clientAuthenticationMethod = oAuth2ClientRegistrationInfoEntity.getClientAuthenticationMethod(); |
|
||||
this.loginButtonLabel = oAuth2ClientRegistrationInfoEntity.getLoginButtonLabel(); |
|
||||
this.loginButtonIcon = oAuth2ClientRegistrationInfoEntity.getLoginButtonIcon(); |
|
||||
this.additionalInfo = oAuth2ClientRegistrationInfoEntity.getAdditionalInfo(); |
|
||||
this.allowUserCreation = oAuth2ClientRegistrationInfoEntity.getAllowUserCreation(); |
|
||||
this.activateUser = oAuth2ClientRegistrationInfoEntity.getActivateUser(); |
|
||||
this.type = oAuth2ClientRegistrationInfoEntity.getType(); |
|
||||
this.emailAttributeKey = oAuth2ClientRegistrationInfoEntity.getEmailAttributeKey(); |
|
||||
this.firstNameAttributeKey = oAuth2ClientRegistrationInfoEntity.getFirstNameAttributeKey(); |
|
||||
this.lastNameAttributeKey = oAuth2ClientRegistrationInfoEntity.getLastNameAttributeKey(); |
|
||||
this.tenantNameStrategy = oAuth2ClientRegistrationInfoEntity.getTenantNameStrategy(); |
|
||||
this.tenantNamePattern = oAuth2ClientRegistrationInfoEntity.getTenantNamePattern(); |
|
||||
this.customerNamePattern = oAuth2ClientRegistrationInfoEntity.getCustomerNamePattern(); |
|
||||
this.defaultDashboardName = oAuth2ClientRegistrationInfoEntity.getDefaultDashboardName(); |
|
||||
this.alwaysFullScreen = oAuth2ClientRegistrationInfoEntity.getAlwaysFullScreen(); |
|
||||
this.url = oAuth2ClientRegistrationInfoEntity.getUrl(); |
|
||||
this.username = oAuth2ClientRegistrationInfoEntity.getUsername(); |
|
||||
this.password = oAuth2ClientRegistrationInfoEntity.getPassword(); |
|
||||
this.sendToken = oAuth2ClientRegistrationInfoEntity.getSendToken(); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
protected OAuth2ClientRegistrationInfo toOAuth2ClientRegistrationInfo() { |
|
||||
OAuth2ClientRegistrationInfo clientRegistrationInfo = new OAuth2ClientRegistrationInfo(); |
|
||||
clientRegistrationInfo.setId(new OAuth2ClientRegistrationInfoId(id)); |
|
||||
clientRegistrationInfo.setEnabled(enabled); |
|
||||
clientRegistrationInfo.setCreatedTime(createdTime); |
|
||||
clientRegistrationInfo.setAdditionalInfo(additionalInfo); |
|
||||
clientRegistrationInfo.setMapperConfig( |
|
||||
OAuth2MapperConfig.builder() |
|
||||
.allowUserCreation(allowUserCreation) |
|
||||
.activateUser(activateUser) |
|
||||
.type(type) |
|
||||
.basic( |
|
||||
(type == MapperType.BASIC || type == MapperType.GITHUB) ? |
|
||||
OAuth2BasicMapperConfig.builder() |
|
||||
.emailAttributeKey(emailAttributeKey) |
|
||||
.firstNameAttributeKey(firstNameAttributeKey) |
|
||||
.lastNameAttributeKey(lastNameAttributeKey) |
|
||||
.tenantNameStrategy(tenantNameStrategy) |
|
||||
.tenantNamePattern(tenantNamePattern) |
|
||||
.customerNamePattern(customerNamePattern) |
|
||||
.defaultDashboardName(defaultDashboardName) |
|
||||
.alwaysFullScreen(alwaysFullScreen) |
|
||||
.build() |
|
||||
: null |
|
||||
) |
|
||||
.custom( |
|
||||
type == MapperType.CUSTOM ? |
|
||||
OAuth2CustomMapperConfig.builder() |
|
||||
.url(url) |
|
||||
.username(username) |
|
||||
.password(password) |
|
||||
.sendToken(sendToken) |
|
||||
.build() |
|
||||
: null |
|
||||
) |
|
||||
.build() |
|
||||
); |
|
||||
clientRegistrationInfo.setClientId(clientId); |
|
||||
clientRegistrationInfo.setClientSecret(clientSecret); |
|
||||
clientRegistrationInfo.setAuthorizationUri(authorizationUri); |
|
||||
clientRegistrationInfo.setAccessTokenUri(tokenUri); |
|
||||
clientRegistrationInfo.setScope(Arrays.asList(scope.split(","))); |
|
||||
clientRegistrationInfo.setUserInfoUri(userInfoUri); |
|
||||
clientRegistrationInfo.setUserNameAttributeName(userNameAttributeName); |
|
||||
clientRegistrationInfo.setJwkSetUri(jwkSetUri); |
|
||||
clientRegistrationInfo.setClientAuthenticationMethod(clientAuthenticationMethod); |
|
||||
clientRegistrationInfo.setLoginButtonLabel(loginButtonLabel); |
|
||||
clientRegistrationInfo.setLoginButtonIcon(loginButtonIcon); |
|
||||
return clientRegistrationInfo; |
|
||||
} |
|
||||
} |
|
||||
@ -1,49 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.server.dao.model.sql.deprecated; |
|
||||
|
|
||||
import lombok.Data; |
|
||||
import lombok.EqualsAndHashCode; |
|
||||
import org.thingsboard.server.common.data.oauth2.deprecated.ExtendedOAuth2ClientRegistrationInfo; |
|
||||
import org.thingsboard.server.common.data.oauth2.SchemeType; |
|
||||
|
|
||||
@Deprecated |
|
||||
@Data |
|
||||
@EqualsAndHashCode(callSuper = true) |
|
||||
public class ExtendedOAuth2ClientRegistrationInfoEntity extends AbstractOAuth2ClientRegistrationInfoEntity<ExtendedOAuth2ClientRegistrationInfo> { |
|
||||
|
|
||||
private String domainName; |
|
||||
private SchemeType domainScheme; |
|
||||
|
|
||||
public ExtendedOAuth2ClientRegistrationInfoEntity() { |
|
||||
super(); |
|
||||
} |
|
||||
|
|
||||
public ExtendedOAuth2ClientRegistrationInfoEntity(OAuth2ClientRegistrationInfoEntity oAuth2ClientRegistrationInfoEntity, |
|
||||
String domainName, |
|
||||
SchemeType domainScheme) { |
|
||||
super(oAuth2ClientRegistrationInfoEntity); |
|
||||
this.domainName = domainName; |
|
||||
this.domainScheme = domainScheme; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public ExtendedOAuth2ClientRegistrationInfo toData() { |
|
||||
return new ExtendedOAuth2ClientRegistrationInfo(super.toOAuth2ClientRegistrationInfo(), |
|
||||
domainScheme, |
|
||||
domainName); |
|
||||
} |
|
||||
} |
|
||||
@ -1,76 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.server.dao.model.sql.deprecated; |
|
||||
|
|
||||
import lombok.Data; |
|
||||
import lombok.EqualsAndHashCode; |
|
||||
import org.hibernate.annotations.TypeDef; |
|
||||
import org.thingsboard.server.common.data.id.deprecated.OAuth2ClientRegistrationId; |
|
||||
import org.thingsboard.server.common.data.id.deprecated.OAuth2ClientRegistrationInfoId; |
|
||||
import org.thingsboard.server.common.data.oauth2.*; |
|
||||
import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientRegistration; |
|
||||
import org.thingsboard.server.dao.model.BaseSqlEntity; |
|
||||
import org.thingsboard.server.dao.model.ModelConstants; |
|
||||
import org.thingsboard.server.dao.util.mapping.JsonStringType; |
|
||||
|
|
||||
import javax.persistence.*; |
|
||||
import java.util.UUID; |
|
||||
|
|
||||
@Deprecated |
|
||||
@Data |
|
||||
@EqualsAndHashCode(callSuper = true) |
|
||||
@Entity |
|
||||
@TypeDef(name = "json", typeClass = JsonStringType.class) |
|
||||
@Table(name = ModelConstants.OAUTH2_CLIENT_REGISTRATION_COLUMN_FAMILY_NAME) |
|
||||
public class OAuth2ClientRegistrationEntity extends BaseSqlEntity<OAuth2ClientRegistration> { |
|
||||
|
|
||||
@Column(name = ModelConstants.OAUTH2_CLIENT_REGISTRATION_INFO_ID_PROPERTY, columnDefinition = "uuid") |
|
||||
private UUID clientRegistrationInfoId; |
|
||||
|
|
||||
@Column(name = ModelConstants.OAUTH2_DOMAIN_NAME_PROPERTY) |
|
||||
private String domainName; |
|
||||
|
|
||||
@Enumerated(EnumType.STRING) |
|
||||
@Column(name = ModelConstants.OAUTH2_DOMAIN_SCHEME_PROPERTY) |
|
||||
private SchemeType domainScheme; |
|
||||
|
|
||||
public OAuth2ClientRegistrationEntity() { |
|
||||
super(); |
|
||||
} |
|
||||
|
|
||||
public OAuth2ClientRegistrationEntity(OAuth2ClientRegistration clientRegistration) { |
|
||||
if (clientRegistration.getId() != null) { |
|
||||
this.setUuid(clientRegistration.getId().getId()); |
|
||||
} |
|
||||
if (clientRegistration.getClientRegistrationId() != null){ |
|
||||
this.clientRegistrationInfoId = clientRegistration.getClientRegistrationId().getId(); |
|
||||
} |
|
||||
this.createdTime = clientRegistration.getCreatedTime(); |
|
||||
this.domainName = clientRegistration.getDomainName(); |
|
||||
this.domainScheme = clientRegistration.getDomainScheme(); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public OAuth2ClientRegistration toData() { |
|
||||
OAuth2ClientRegistration clientRegistration = new OAuth2ClientRegistration(); |
|
||||
clientRegistration.setId(new OAuth2ClientRegistrationId(id)); |
|
||||
clientRegistration.setClientRegistrationId(new OAuth2ClientRegistrationInfoId(clientRegistrationInfoId)); |
|
||||
clientRegistration.setCreatedTime(createdTime); |
|
||||
clientRegistration.setDomainName(domainName); |
|
||||
clientRegistration.setDomainScheme(domainScheme); |
|
||||
return clientRegistration; |
|
||||
} |
|
||||
} |
|
||||
@ -1,52 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.server.dao.model.sql.deprecated; |
|
||||
|
|
||||
import lombok.Data; |
|
||||
import lombok.EqualsAndHashCode; |
|
||||
import org.hibernate.annotations.TypeDef; |
|
||||
import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientRegistrationInfo; |
|
||||
import org.thingsboard.server.dao.model.ModelConstants; |
|
||||
import org.thingsboard.server.dao.util.mapping.JsonStringType; |
|
||||
|
|
||||
import javax.persistence.Entity; |
|
||||
import javax.persistence.Table; |
|
||||
|
|
||||
@Deprecated |
|
||||
@Data |
|
||||
@EqualsAndHashCode(callSuper = true) |
|
||||
@Entity |
|
||||
@TypeDef(name = "json", typeClass = JsonStringType.class) |
|
||||
@Table(name = ModelConstants.OAUTH2_CLIENT_REGISTRATION_INFO_COLUMN_FAMILY_NAME) |
|
||||
public class OAuth2ClientRegistrationInfoEntity extends AbstractOAuth2ClientRegistrationInfoEntity<OAuth2ClientRegistrationInfo> { |
|
||||
|
|
||||
public OAuth2ClientRegistrationInfoEntity() { |
|
||||
super(); |
|
||||
} |
|
||||
|
|
||||
public OAuth2ClientRegistrationInfoEntity(OAuth2ClientRegistrationInfo clientRegistration) { |
|
||||
super(clientRegistration); |
|
||||
} |
|
||||
|
|
||||
public OAuth2ClientRegistrationInfoEntity(OAuth2ClientRegistrationInfoEntity oAuth2ClientRegistrationInfoEntity) { |
|
||||
super(oAuth2ClientRegistrationInfoEntity); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public OAuth2ClientRegistrationInfo toData() { |
|
||||
return super.toOAuth2ClientRegistrationInfo(); |
|
||||
} |
|
||||
} |
|
||||
@ -1,24 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.server.dao.oauth2.deprecated; |
|
||||
|
|
||||
import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientRegistration; |
|
||||
import org.thingsboard.server.dao.Dao; |
|
||||
|
|
||||
@Deprecated |
|
||||
public interface OAuth2ClientRegistrationDao extends Dao<OAuth2ClientRegistration> { |
|
||||
void deleteAll(); |
|
||||
} |
|
||||
@ -1,34 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.server.dao.oauth2.deprecated; |
|
||||
|
|
||||
import org.thingsboard.server.common.data.oauth2.deprecated.ExtendedOAuth2ClientRegistrationInfo; |
|
||||
import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientRegistrationInfo; |
|
||||
import org.thingsboard.server.common.data.oauth2.SchemeType; |
|
||||
import org.thingsboard.server.dao.Dao; |
|
||||
|
|
||||
import java.util.List; |
|
||||
|
|
||||
@Deprecated |
|
||||
public interface OAuth2ClientRegistrationInfoDao extends Dao<OAuth2ClientRegistrationInfo> { |
|
||||
List<OAuth2ClientRegistrationInfo> findAll(); |
|
||||
|
|
||||
List<ExtendedOAuth2ClientRegistrationInfo> findAllExtended(); |
|
||||
|
|
||||
List<OAuth2ClientRegistrationInfo> findByDomainSchemesAndDomainName(List<SchemeType> domainSchemes, String domainName); |
|
||||
|
|
||||
void deleteAll(); |
|
||||
} |
|
||||
@ -1,48 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.server.dao.sql.oauth2.deprecated; |
|
||||
|
|
||||
import lombok.RequiredArgsConstructor; |
|
||||
import org.springframework.data.repository.CrudRepository; |
|
||||
import org.springframework.stereotype.Component; |
|
||||
import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientRegistration; |
|
||||
import org.thingsboard.server.dao.model.sql.deprecated.OAuth2ClientRegistrationEntity; |
|
||||
import org.thingsboard.server.dao.oauth2.deprecated.OAuth2ClientRegistrationDao; |
|
||||
import org.thingsboard.server.dao.sql.JpaAbstractDao; |
|
||||
|
|
||||
import java.util.UUID; |
|
||||
|
|
||||
@Deprecated |
|
||||
@Component |
|
||||
@RequiredArgsConstructor |
|
||||
public class JpaOAuth2ClientRegistrationDao extends JpaAbstractDao<OAuth2ClientRegistrationEntity, OAuth2ClientRegistration> implements OAuth2ClientRegistrationDao { |
|
||||
private final OAuth2ClientRegistrationRepository repository; |
|
||||
|
|
||||
@Override |
|
||||
protected Class<OAuth2ClientRegistrationEntity> getEntityClass() { |
|
||||
return OAuth2ClientRegistrationEntity.class; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
protected CrudRepository<OAuth2ClientRegistrationEntity, UUID> getCrudRepository() { |
|
||||
return repository; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public void deleteAll() { |
|
||||
repository.deleteAll(); |
|
||||
} |
|
||||
} |
|
||||
@ -1,77 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.server.dao.sql.oauth2.deprecated; |
|
||||
|
|
||||
import lombok.RequiredArgsConstructor; |
|
||||
import org.springframework.data.repository.CrudRepository; |
|
||||
import org.springframework.stereotype.Component; |
|
||||
import org.thingsboard.server.common.data.oauth2.deprecated.ExtendedOAuth2ClientRegistrationInfo; |
|
||||
import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientRegistrationInfo; |
|
||||
import org.thingsboard.server.common.data.oauth2.SchemeType; |
|
||||
import org.thingsboard.server.dao.DaoUtil; |
|
||||
import org.thingsboard.server.dao.model.sql.deprecated.OAuth2ClientRegistrationInfoEntity; |
|
||||
import org.thingsboard.server.dao.oauth2.deprecated.OAuth2ClientRegistrationInfoDao; |
|
||||
import org.thingsboard.server.dao.sql.JpaAbstractDao; |
|
||||
|
|
||||
import java.util.ArrayList; |
|
||||
import java.util.List; |
|
||||
import java.util.UUID; |
|
||||
import java.util.stream.Collectors; |
|
||||
|
|
||||
@Deprecated |
|
||||
@Component |
|
||||
@RequiredArgsConstructor |
|
||||
public class JpaOAuth2ClientRegistrationInfoDao extends JpaAbstractDao<OAuth2ClientRegistrationInfoEntity, OAuth2ClientRegistrationInfo> implements OAuth2ClientRegistrationInfoDao { |
|
||||
private final OAuth2ClientRegistrationInfoRepository repository; |
|
||||
|
|
||||
@Override |
|
||||
protected Class<OAuth2ClientRegistrationInfoEntity> getEntityClass() { |
|
||||
return OAuth2ClientRegistrationInfoEntity.class; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
protected CrudRepository<OAuth2ClientRegistrationInfoEntity, UUID> getCrudRepository() { |
|
||||
return repository; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public List<OAuth2ClientRegistrationInfo> findAll() { |
|
||||
Iterable<OAuth2ClientRegistrationInfoEntity> entities = repository.findAll(); |
|
||||
List<OAuth2ClientRegistrationInfo> result = new ArrayList<>(); |
|
||||
entities.forEach(entity -> { |
|
||||
result.add(DaoUtil.getData(entity)); |
|
||||
}); |
|
||||
return result; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public List<ExtendedOAuth2ClientRegistrationInfo> findAllExtended() { |
|
||||
return repository.findAllExtended().stream() |
|
||||
.map(DaoUtil::getData) |
|
||||
.collect(Collectors.toList()); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public List<OAuth2ClientRegistrationInfo> findByDomainSchemesAndDomainName(List<SchemeType> domainSchemes, String domainName) { |
|
||||
List<OAuth2ClientRegistrationInfoEntity> entities = repository.findAllByDomainSchemesAndName(domainSchemes, domainName); |
|
||||
return entities.stream().map(DaoUtil::getData).collect(Collectors.toList()); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public void deleteAll() { |
|
||||
repository.deleteAll(); |
|
||||
} |
|
||||
} |
|
||||
@ -1,42 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.server.dao.sql.oauth2.deprecated; |
|
||||
|
|
||||
import org.springframework.data.jpa.repository.Query; |
|
||||
import org.springframework.data.repository.CrudRepository; |
|
||||
import org.springframework.data.repository.query.Param; |
|
||||
import org.thingsboard.server.common.data.oauth2.SchemeType; |
|
||||
import org.thingsboard.server.dao.model.sql.deprecated.ExtendedOAuth2ClientRegistrationInfoEntity; |
|
||||
import org.thingsboard.server.dao.model.sql.deprecated.OAuth2ClientRegistrationInfoEntity; |
|
||||
|
|
||||
import java.util.List; |
|
||||
import java.util.UUID; |
|
||||
|
|
||||
@Deprecated |
|
||||
public interface OAuth2ClientRegistrationInfoRepository extends CrudRepository<OAuth2ClientRegistrationInfoEntity, UUID> { |
|
||||
@Query("SELECT new OAuth2ClientRegistrationInfoEntity(cr_info) " + |
|
||||
"FROM OAuth2ClientRegistrationInfoEntity cr_info " + |
|
||||
"LEFT JOIN OAuth2ClientRegistrationEntity cr on cr_info.id = cr.clientRegistrationInfoId " + |
|
||||
"WHERE cr.domainName = :domainName " + |
|
||||
"AND cr.domainScheme IN (:domainSchemes)") |
|
||||
List<OAuth2ClientRegistrationInfoEntity> findAllByDomainSchemesAndName(@Param("domainSchemes") List<SchemeType> domainSchemes, |
|
||||
@Param("domainName") String domainName); |
|
||||
|
|
||||
@Query("SELECT new org.thingsboard.server.dao.model.sql.deprecated.ExtendedOAuth2ClientRegistrationInfoEntity(cr_info, cr.domainName, cr.domainScheme) " + |
|
||||
"FROM OAuth2ClientRegistrationInfoEntity cr_info " + |
|
||||
"LEFT JOIN OAuth2ClientRegistrationEntity cr on cr_info.id = cr.clientRegistrationInfoId ") |
|
||||
List<ExtendedOAuth2ClientRegistrationInfoEntity> findAllExtended(); |
|
||||
} |
|
||||
@ -1,25 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.server.dao.sql.oauth2.deprecated; |
|
||||
|
|
||||
import org.springframework.data.repository.CrudRepository; |
|
||||
import org.thingsboard.server.dao.model.sql.deprecated.OAuth2ClientRegistrationEntity; |
|
||||
|
|
||||
import java.util.UUID; |
|
||||
|
|
||||
@Deprecated |
|
||||
public interface OAuth2ClientRegistrationRepository extends CrudRepository<OAuth2ClientRegistrationEntity, UUID> { |
|
||||
} |
|
||||
Loading…
Reference in new issue