8 changed files with 113 additions and 205 deletions
@ -1,34 +1,18 @@ |
|||||
package org.thingsboard.server.common.data.oauth2; |
package org.thingsboard.server.common.data.oauth2; |
||||
|
|
||||
import lombok.*; |
import lombok.Builder; |
||||
import org.thingsboard.server.common.data.BaseData; |
import lombok.Data; |
||||
import org.thingsboard.server.common.data.id.OAuth2IntegrationId; |
import lombok.EqualsAndHashCode; |
||||
|
import lombok.ToString; |
||||
|
|
||||
@EqualsAndHashCode(callSuper = true) |
@Builder(toBuilder = true) |
||||
|
@EqualsAndHashCode |
||||
@Data |
@Data |
||||
@ToString |
@ToString |
||||
public class OAuth2MapperConfig extends BaseData<OAuth2IntegrationId> { |
public class OAuth2MapperConfig { |
||||
private boolean allowUserCreation; |
private boolean allowUserCreation; |
||||
private boolean activateUser; |
private boolean activateUser; |
||||
private MapperType type; |
private MapperType type; |
||||
private OAuth2BasicMapperConfig basicConfig; |
private OAuth2BasicMapperConfig basicConfig; |
||||
private OAuth2CustomMapperConfig customConfig; |
private OAuth2CustomMapperConfig customConfig; |
||||
|
|
||||
public OAuth2MapperConfig() { |
|
||||
super(); |
|
||||
} |
|
||||
|
|
||||
public OAuth2MapperConfig(OAuth2IntegrationId id) { |
|
||||
super(id); |
|
||||
} |
|
||||
|
|
||||
@Builder(toBuilder = true) |
|
||||
public OAuth2MapperConfig(OAuth2IntegrationId id, boolean allowUserCreation, boolean activateUser, MapperType type, OAuth2BasicMapperConfig basicConfig, OAuth2CustomMapperConfig customConfig) { |
|
||||
super(id); |
|
||||
this.allowUserCreation = allowUserCreation; |
|
||||
this.activateUser = activateUser; |
|
||||
this.type = type; |
|
||||
this.basicConfig = basicConfig; |
|
||||
this.customConfig = customConfig; |
|
||||
} |
|
||||
} |
} |
||||
|
|||||
@ -1,101 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2020 The Thingsboard Authors |
|
||||
* <p> |
|
||||
* 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 |
|
||||
* <p> |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* <p> |
|
||||
* 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; |
|
||||
|
|
||||
import lombok.Data; |
|
||||
import lombok.EqualsAndHashCode; |
|
||||
import org.hibernate.annotations.TypeDef; |
|
||||
import org.thingsboard.server.common.data.id.OAuth2IntegrationId; |
|
||||
import org.thingsboard.server.common.data.oauth2.MapperType; |
|
||||
import org.thingsboard.server.common.data.oauth2.OAuth2BasicMapperConfig; |
|
||||
import org.thingsboard.server.common.data.oauth2.OAuth2CustomMapperConfig; |
|
||||
import org.thingsboard.server.common.data.oauth2.OAuth2MapperConfig; |
|
||||
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.*; |
|
||||
|
|
||||
@Data |
|
||||
@EqualsAndHashCode(callSuper = true) |
|
||||
@Entity |
|
||||
@TypeDef(name = "json", typeClass = JsonStringType.class) |
|
||||
@Table(name = ModelConstants.OAUTH2_MAPPER_CONFIG_COLUMN_FAMILY_NAME) |
|
||||
public class OAuth2MapperConfigEntity extends BaseSqlEntity<OAuth2MapperConfig> { |
|
||||
|
|
||||
@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; |
|
||||
@Column(name = ModelConstants.OAUTH2_TENANT_NAME_STRATEGY_PROPERTY) |
|
||||
private String 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; |
|
||||
|
|
||||
public OAuth2MapperConfigEntity() { |
|
||||
super(); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public OAuth2MapperConfig toData() { |
|
||||
return OAuth2MapperConfig.builder() |
|
||||
.id(new OAuth2IntegrationId(toUUID(id))) |
|
||||
.allowUserCreation(allowUserCreation) |
|
||||
.activateUser(activateUser) |
|
||||
.type(type) |
|
||||
.basicConfig( |
|
||||
OAuth2BasicMapperConfig.builder() |
|
||||
.emailAttributeKey(emailAttributeKey) |
|
||||
.firstNameAttributeKey(firstNameAttributeKey) |
|
||||
.lastNameAttributeKey(lastNameAttributeKey) |
|
||||
.tenantNameStrategy(tenantNameStrategy) |
|
||||
.tenantNamePattern(tenantNamePattern) |
|
||||
.customerNamePattern(customerNamePattern) |
|
||||
.defaultDashboardName(defaultDashboardName) |
|
||||
.alwaysFullScreen(alwaysFullScreen) |
|
||||
.build() |
|
||||
) |
|
||||
.customConfig( |
|
||||
OAuth2CustomMapperConfig.builder() |
|
||||
.url(url) |
|
||||
.username(username) |
|
||||
.password(password) |
|
||||
.build() |
|
||||
) |
|
||||
.build(); |
|
||||
} |
|
||||
} |
|
||||
Loading…
Reference in new issue