Search in sources :

Example 1 with OAuth2RegistrationId

use of org.thingsboard.server.common.data.id.OAuth2RegistrationId in project thingsboard by thingsboard.

the class OAuth2RegistrationEntity method toData.

@Override
public OAuth2Registration toData() {
    OAuth2Registration registration = new OAuth2Registration();
    registration.setId(new OAuth2RegistrationId(id));
    registration.setCreatedTime(createdTime);
    registration.setOauth2ParamsId(new OAuth2ParamsId(oauth2ParamsId));
    registration.setAdditionalInfo(additionalInfo);
    registration.setMapperConfig(OAuth2MapperConfig.builder().allowUserCreation(allowUserCreation).activateUser(activateUser).type(type).basic((type == MapperType.BASIC || type == MapperType.GITHUB || type == MapperType.APPLE) ? 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());
    registration.setClientId(clientId);
    registration.setClientSecret(clientSecret);
    registration.setAuthorizationUri(authorizationUri);
    registration.setAccessTokenUri(tokenUri);
    registration.setScope(Arrays.asList(scope.split(",")));
    registration.setPlatforms(StringUtils.isNotEmpty(platforms) ? Arrays.stream(platforms.split(",")).map(str -> PlatformType.valueOf(str)).collect(Collectors.toList()) : Collections.emptyList());
    registration.setUserInfoUri(userInfoUri);
    registration.setUserNameAttributeName(userNameAttributeName);
    registration.setJwkSetUri(jwkSetUri);
    registration.setClientAuthenticationMethod(clientAuthenticationMethod);
    registration.setLoginButtonLabel(loginButtonLabel);
    registration.setLoginButtonIcon(loginButtonIcon);
    return registration;
}
Also used : JsonStringType(org.thingsboard.server.dao.util.mapping.JsonStringType) Arrays(java.util.Arrays) BaseSqlEntity(org.thingsboard.server.dao.model.BaseSqlEntity) OAuth2RegistrationId(org.thingsboard.server.common.data.id.OAuth2RegistrationId) OAuth2BasicMapperConfig(org.thingsboard.server.common.data.oauth2.OAuth2BasicMapperConfig) EnumType(javax.persistence.EnumType) Table(javax.persistence.Table) Enumerated(javax.persistence.Enumerated) JsonNode(com.fasterxml.jackson.databind.JsonNode) PlatformType(org.thingsboard.server.common.data.oauth2.PlatformType) StringUtils(io.micrometer.core.instrument.util.StringUtils) TenantNameStrategyType(org.thingsboard.server.common.data.oauth2.TenantNameStrategyType) Entity(javax.persistence.Entity) OAuth2CustomMapperConfig(org.thingsboard.server.common.data.oauth2.OAuth2CustomMapperConfig) MapperType(org.thingsboard.server.common.data.oauth2.MapperType) UUID(java.util.UUID) EqualsAndHashCode(lombok.EqualsAndHashCode) Type(org.hibernate.annotations.Type) Collectors(java.util.stream.Collectors) OAuth2ParamsId(org.thingsboard.server.common.data.id.OAuth2ParamsId) Column(javax.persistence.Column) OAuth2MapperConfig(org.thingsboard.server.common.data.oauth2.OAuth2MapperConfig) Data(lombok.Data) TypeDef(org.hibernate.annotations.TypeDef) OAuth2Registration(org.thingsboard.server.common.data.oauth2.OAuth2Registration) Collections(java.util.Collections) ModelConstants(org.thingsboard.server.dao.model.ModelConstants) OAuth2ParamsId(org.thingsboard.server.common.data.id.OAuth2ParamsId) OAuth2RegistrationId(org.thingsboard.server.common.data.id.OAuth2RegistrationId) OAuth2Registration(org.thingsboard.server.common.data.oauth2.OAuth2Registration)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 StringUtils (io.micrometer.core.instrument.util.StringUtils)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 UUID (java.util.UUID)1 Collectors (java.util.stream.Collectors)1 Column (javax.persistence.Column)1 Entity (javax.persistence.Entity)1 EnumType (javax.persistence.EnumType)1 Enumerated (javax.persistence.Enumerated)1 Table (javax.persistence.Table)1 Data (lombok.Data)1 EqualsAndHashCode (lombok.EqualsAndHashCode)1 Type (org.hibernate.annotations.Type)1 TypeDef (org.hibernate.annotations.TypeDef)1 OAuth2ParamsId (org.thingsboard.server.common.data.id.OAuth2ParamsId)1 OAuth2RegistrationId (org.thingsboard.server.common.data.id.OAuth2RegistrationId)1 MapperType (org.thingsboard.server.common.data.oauth2.MapperType)1 OAuth2BasicMapperConfig (org.thingsboard.server.common.data.oauth2.OAuth2BasicMapperConfig)1 OAuth2CustomMapperConfig (org.thingsboard.server.common.data.oauth2.OAuth2CustomMapperConfig)1