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;
}
Aggregations