Skip to content

Commit

Permalink
EPMRPP-97288 code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
grabsefx committed Jan 14, 2025
1 parent afb1aae commit b5fff1a
Show file tree
Hide file tree
Showing 18 changed files with 254 additions and 239 deletions.
24 changes: 12 additions & 12 deletions src/main/java/com/epam/reportportal/auth/AuthConfigService.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,18 @@ public OAuth2ProtectedResourceDetails loadResourceDetails(String name) {
*/
private static final Function<OAuthRegistrationResource, OAuth2ProtectedResourceDetails>
RESOURCE_DETAILS_CONVERTER = d -> {
BaseOAuth2ProtectedResourceDetails details = getOauth2ProtectedResourceDetails(d);
details.setId(d.getId());
details.setAccessTokenUri(d.getTokenUri());
Arrays.stream(AuthenticationScheme.values())
.filter(scheme -> scheme.name().equalsIgnoreCase(d.getClientAuthMethod()))
.findFirst()
.ifPresent(details::setClientAuthenticationScheme);
details.setClientId(d.getClientId());
details.setClientSecret(d.getClientSecret());
details.setScope(new ArrayList<>(d.getScopes()));
return details;
};
BaseOAuth2ProtectedResourceDetails details = getOauth2ProtectedResourceDetails(d);
details.setId(d.getId());
details.setAccessTokenUri(d.getTokenUri());
Arrays.stream(AuthenticationScheme.values())
.filter(scheme -> scheme.name().equalsIgnoreCase(d.getClientAuthMethod()))
.findFirst()
.ifPresent(details::setClientAuthenticationScheme);
details.setClientId(d.getClientId());
details.setClientSecret(d.getClientSecret());
details.setScope(new ArrayList<>(d.getScopes()));
return details;
};

private static BaseOAuth2ProtectedResourceDetails getOauth2ProtectedResourceDetails(
OAuthRegistrationResource oAuthRegistrationResource) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import net.coobird.thumbnailator.Thumbnails;

/**
* Thumbnailator implementation using <a href="http://code.google.com/p/thumbnailator/">Thumbnailator</a>
* API
* Thumbnailator implementation. Using <a
* href="http://code.google.com/p/thumbnailator/">Thumbnailator</a> API.
*
* @author Andrei Varabyeu
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,19 +239,19 @@ protected final void configure(HttpSecurity http) throws Exception {
authCompositeFilter.setFilters(additionalFilters);

http
.antMatcher("/**")
.authorizeRequests()
.antMatchers(SSO_LOGIN_PATH
+ "/**", "/epam/**", "/info", "/health", "/api-docs/**", "/saml/**", "/templates/**")
.permitAll()
.anyRequest()
.authenticated()
.and()
.csrf().disable()
.formLogin().disable()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.antMatcher("/**")
.authorizeRequests()
.antMatchers(SSO_LOGIN_PATH
+ "/**", "/epam/**", "/info", "/health", "/api-docs/**", "/saml/**", "/templates/**")
.permitAll()
.anyRequest()
.authenticated()
.and()
.csrf().disable()
.formLogin().disable()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.addFilterAfter(authCompositeFilter, BasicAuthenticationFilter.class);
}

Expand Down Expand Up @@ -281,7 +281,6 @@ public AuthenticationEventPublisher authenticationEventPublisher(
}



@Bean
public AuthenticationProvider activeDirectoryAuthProvider() {
return new ActiveDirectoryAuthProvider(authConfigRepository, eventPublisher,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,6 @@ public OpenApiCustomiser sortTagsAlphabetically() {
}

private String getPathValue() {
return StringUtils.isEmpty(pathValue) || pathValue.equals("/") ? "/uat" : pathValue;
return StringUtils.isEmpty(pathValue) || pathValue.equals("/") ? "/uat" : pathValue;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
@NoRepositoryBean
public interface ReportPortalRepository<T, ID extends Serializable> extends JpaRepository<T, ID> {

void refresh(T t);

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ public AuthConfigurationEndpoint(CreateAuthIntegrationHandler createAuthIntegrat
/**
* Creates or updates auth integration settings.
*
* @param request Update request
* @param request Update request
* @param authType Type of Auth
* @param user User
* @return Successful message or an error
* @param user User
* @return Successful message or an error
*/
@Transactional
@PostMapping(value = "/{authType}")
Expand All @@ -87,9 +87,9 @@ public AbstractAuthResource createAuthIntegration(@RequestBody @Valid UpdateAuth
/**
* Creates or updates auth integration settings
*
* @param request Update request
* @param authType Type of Auth
* @param user User
* @param request Update request
* @param authType Type of Auth
* @param user User
* @param integrationId Integration ID
* @return Successful message or an error
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public OAuthConfigurationEndpoint(CreateAuthIntegrationHandler createAuthIntegra
* Updates oauth integration settings
*
* @param clientRegistrationResource OAuth configuration
* @param oauthProviderId Oauth settings Profile Id
* @param oauthProviderId Oauth settings Profile Id
* @return All defined OAuth integration settings
*/
@Transactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,53 +24,54 @@
import org.springframework.web.multipart.MultipartFile;

/**
* Binary data representation. Contains only input stream and data type.
* Introduced to simplify store/retrieve operations
* Binary data representation. Contains only input stream and data type. Introduced to simplify
* store/retrieve operations
*
* @author Andrei Varabyeu
*/
@Getter
public class BinaryData {

private String fileName;
private String fileName;

/**
* MIME Type of Binary Data
*/
private final String contentType;
/**
* MIME Type of Binary Data
*/
private final String contentType;

/**
* Data Stream
*/
private final InputStream inputStream;
/**
* Data Stream
*/
private final InputStream inputStream;

/**
* Content length
*/
private final Long length;
/**
* Content length
*/
private final Long length;

public BinaryData(String contentType, Long length, InputStream inputStream) {
this.contentType = contentType;
this.inputStream = inputStream;
this.length = length;
}
public BinaryData(String contentType, Long length, InputStream inputStream) {
this.contentType = contentType;
this.inputStream = inputStream;
this.length = length;
}

public BinaryData(String fileName, String contentType, Long length, InputStream inputStream) {
this.fileName = fileName;
this.contentType = contentType;
this.length = length;
this.inputStream = inputStream;
}
public BinaryData(String fileName, String contentType, Long length, InputStream inputStream) {
this.fileName = fileName;
this.contentType = contentType;
this.length = length;
this.inputStream = inputStream;
}

public BinaryData(MultipartFile multipartFile) {
this.contentType = multipartFile.getContentType();
this.length = multipartFile.getSize();
public BinaryData(MultipartFile multipartFile) {
this.contentType = multipartFile.getContentType();
this.length = multipartFile.getSize();

try {
this.inputStream = multipartFile.getInputStream();
} catch (IOException e) {
throw new ReportPortalException(ErrorType.INCORRECT_REQUEST, "Unable to create binary data from multipart file");
}
}
try {
this.inputStream = multipartFile.getInputStream();
} catch (IOException e) {
throw new ReportPortalException(ErrorType.INCORRECT_REQUEST,
"Unable to create binary data from multipart file");
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public enum ProjectAttributeEnum {
AUTO_PATTERN_ANALYZER_ENABLED(Prefix.ANALYZER + "isAutoPatternAnalyzerEnabled",
String.valueOf(false)),
AUTO_ANALYZER_ENABLED(Prefix.ANALYZER + "isAutoAnalyzerEnabled", String.valueOf(true)),
AUTO_ANALYZER_MODE(Prefix.ANALYZER + "autoAnalyzerMode", AnalyzeMode.CURRENT_AND_THE_SAME_NAME.getValue()),
AUTO_ANALYZER_MODE(Prefix.ANALYZER + "autoAnalyzerMode",
AnalyzeMode.CURRENT_AND_THE_SAME_NAME.getValue()),
ALL_MESSAGES_SHOULD_MATCH(Prefix.ANALYZER + "allMessagesShouldMatch", String.valueOf(false)),
SEARCH_LOGS_MIN_SHOULD_MATCH(Prefix.ANALYZER + "searchLogsMinShouldMatch",
String.valueOf(ProjectAnalyzerConfig.MIN_SHOULD_MATCH)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public UiAuthenticationSuccessEventHandler(UserRepository userRepository,
}

/**
* Handles the UI user signed-in event. Updates the last login date for the user
* and generates a personal project if the user has no projects.
* Also, if the user is inactive, it will be activated for SAML authentication.
* Handles the UI user signed-in event. Updates the last login date for the user and generates a
* personal project if the user has no projects. Also, if the user is inactive, it will be
* activated for SAML authentication.
*
* @param event the UI user signed-in event
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,22 @@ public class SamlConverter {
resource.setIdentityProviderName(integration.getName());
resource.setEnabled(integration.isEnabled());

EMAIL_ATTRIBUTE.getParameter(integration).ifPresent(resource::setEmailAttribute);
FIRST_NAME_ATTRIBUTE.getParameter(integration).ifPresent(resource::setFirstNameAttribute);
LAST_NAME_ATTRIBUTE.getParameter(integration).ifPresent(resource::setLastNameAttribute);
FULL_NAME_ATTRIBUTE.getParameter(integration).ifPresent(resource::setFullNameAttribute);
IDP_ALIAS.getParameter(integration).ifPresent(resource::setIdentityProviderAlias);
IDP_METADATA_URL.getParameter(integration).ifPresent(resource::setIdentityProviderMetadataUrl);
IDP_URL.getParameter(integration).ifPresent(resource::setIdentityProviderUrl);
IDP_NAME_ID.getParameter(integration).ifPresent(resource::setIdentityProviderNameId);
ROLES_ATTRIBUTE.getParameter(integration).ifPresent(resource::setRolesAttribute);
final IntegrationType integrationType = integration.getType();
ofNullable(integrationType.getDetails()).flatMap(typeDetails -> Optional.ofNullable(typeDetails.getDetails()))
.flatMap(BASE_PATH::getParameter)
.ifPresent(resource::setCallbackUrl);
return resource;
};
EMAIL_ATTRIBUTE.getParameter(integration).ifPresent(resource::setEmailAttribute);
FIRST_NAME_ATTRIBUTE.getParameter(integration).ifPresent(resource::setFirstNameAttribute);
LAST_NAME_ATTRIBUTE.getParameter(integration).ifPresent(resource::setLastNameAttribute);
FULL_NAME_ATTRIBUTE.getParameter(integration).ifPresent(resource::setFullNameAttribute);
IDP_ALIAS.getParameter(integration).ifPresent(resource::setIdentityProviderAlias);
IDP_METADATA_URL.getParameter(integration).ifPresent(resource::setIdentityProviderMetadataUrl);
IDP_URL.getParameter(integration).ifPresent(resource::setIdentityProviderUrl);
IDP_NAME_ID.getParameter(integration).ifPresent(resource::setIdentityProviderNameId);
ROLES_ATTRIBUTE.getParameter(integration).ifPresent(resource::setRolesAttribute);
final IntegrationType integrationType = integration.getType();
ofNullable(integrationType.getDetails()).flatMap(
typeDetails -> Optional.ofNullable(typeDetails.getDetails()))
.flatMap(BASE_PATH::getParameter)
.ifPresent(resource::setCallbackUrl);
return resource;
};

public static final Function<List<Integration>, List<ExternalIdentityProviderConfiguration>> TO_EXTERNAL_PROVIDER_CONFIG = integrations -> {
List<ExternalIdentityProviderConfiguration> externalProviders = integrations.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ public List<EmailResource> getUserEmails() {

public List<OrganizationResource> getUserOrganizations(String user) {
return getForObject(GITHUB_BASE_URL + "/user/orgs",
new ParameterizedTypeReference<>() {},
new ParameterizedTypeReference<>() {
},
user);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ public ResponseEntity<OAuthRegistrationResource> getOauthIntegrationById(String
.orElseGet(() -> {
ExtendedOAuthRegistrationResource body = new ExtendedOAuthRegistrationResource();
body.setErrorCode(ErrorType.AUTH_INTEGRATION_NOT_FOUND.getCode());
body.setMessage(Suppliers.formattedSupplier("Oauth settings with id = {} have not been found.",
oauthProviderId).get()
body.setMessage(
Suppliers.formattedSupplier("Oauth settings with id = {} have not been found.",
oauthProviderId).get()
);
return new ResponseEntity<>(body, HttpStatus.NOT_FOUND);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ public static void setLdapParameters(UpdateAuthRQ request, Integration integrati
Arrays.stream(LdapParameter.values()).forEach(it -> it.setParameter(request, integration));
}

public static void setSamlParameters(UpdateAuthRQ request, Integration integration) {
IDP_NAME.setParameter(request, integration);
IDP_METADATA_URL.setParameter(request, integration);
EMAIL_ATTRIBUTE.setParameter(request, integration);
IDP_NAME_ID.setParameter(request, integration);
IDP_ALIAS.setParameter(request, integration);
IDP_URL.setParameter(request, integration);
ROLES_ATTRIBUTE.setParameter(request, integration);
public static void setSamlParameters(UpdateAuthRQ request, Integration integration) {
IDP_NAME.setParameter(request, integration);
IDP_METADATA_URL.setParameter(request, integration);
EMAIL_ATTRIBUTE.setParameter(request, integration);
IDP_NAME_ID.setParameter(request, integration);
IDP_ALIAS.setParameter(request, integration);
IDP_URL.setParameter(request, integration);
ROLES_ATTRIBUTE.setParameter(request, integration);

FULL_NAME_ATTRIBUTE.getParameter(request).ifPresentOrElse(fullName -> {
FIRST_NAME_ATTRIBUTE.removeParameter(integration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@
*/
public enum SamlParameter {

BASE_PATH("callbackUrl", false),
IDP_NAME("identityProviderName", true),
IDP_METADATA_URL("identityProviderMetadataUrl", true),
EMAIL_ATTRIBUTE("emailAttribute", true),
IDP_NAME_ID("identityProviderNameId", false),
IDP_ALIAS("identityProviderAlias", false),
IDP_URL("identityProviderUrl", false),
FULL_NAME_ATTRIBUTE("fullNameAttribute", false),
FIRST_NAME_ATTRIBUTE("firstNameAttribute", false),
LAST_NAME_ATTRIBUTE("lastNameAttribute", false),
ROLES_ATTRIBUTE("rolesAttribute", false);
BASE_PATH("callbackUrl", false),
IDP_NAME("identityProviderName", true),
IDP_METADATA_URL("identityProviderMetadataUrl", true),
EMAIL_ATTRIBUTE("emailAttribute", true),
IDP_NAME_ID("identityProviderNameId", false),
IDP_ALIAS("identityProviderAlias", false),
IDP_URL("identityProviderUrl", false),
FULL_NAME_ATTRIBUTE("fullNameAttribute", false),
FIRST_NAME_ATTRIBUTE("firstNameAttribute", false),
LAST_NAME_ATTRIBUTE("lastNameAttribute", false),
ROLES_ATTRIBUTE("rolesAttribute", false);

private String parameterName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
@Getter
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SamlProvidersResource extends AbstractAuthResource {
@Valid
private List<SamlResource> providers;

@Valid
private List<SamlResource> providers;
}
Loading

0 comments on commit b5fff1a

Please sign in to comment.