use of com.epam.ta.reportportal.exception.ReportPortalException in project service-authorization by reportportal.
the class GetSamlIntegrationsStrategy method getIntegration.
@Override
public AbstractAuthResource getIntegration() {
IntegrationType samlIntegrationType = integrationTypeRepository.findByName(AuthIntegrationType.SAML.getName()).orElseThrow(() -> new ReportPortalException(ErrorType.AUTH_INTEGRATION_NOT_FOUND, AuthIntegrationType.SAML.getName()));
List<Integration> providers = integrationRepository.findAllGlobalByType(samlIntegrationType);
SamlProvidersResource resource = TO_PROVIDERS_RESOURCE.apply(providers);
resource.setType(samlIntegrationType.getName());
return resource;
}
use of com.epam.ta.reportportal.exception.ReportPortalException in project service-authorization by reportportal.
the class GetLdapStrategy method getIntegration.
@Override
public AbstractLdapResource getIntegration() {
IntegrationType ldapIntegrationType = integrationTypeRepository.findByName(AuthIntegrationType.LDAP.getName()).orElseThrow(() -> new ReportPortalException(ErrorType.AUTH_INTEGRATION_NOT_FOUND, AuthIntegrationType.LDAP.getName()));
// or else empty integration with default 'enabled = false' flag
LdapResource ldapResource = LdapConverter.TO_RESOURCE.apply(integrationRepository.findByNameAndTypeIdAndProjectIdIsNull(AuthIntegrationType.LDAP.getName(), ldapIntegrationType.getId()).orElseGet(Integration::new));
ldapResource.setType(ldapIntegrationType.getName());
return ldapResource;
}
use of com.epam.ta.reportportal.exception.ReportPortalException in project service-authorization by reportportal.
the class OAuthSuccessHandler method getToken.
@Override
protected OAuth2AccessToken getToken(Authentication authentication) {
OAuth2Authentication oAuth2Authentication = ofNullable((OAuth2Authentication) authentication).orElseThrow(() -> new ReportPortalException(ErrorType.ACCESS_DENIED));
String login = String.valueOf(oAuth2Authentication.getPrincipal());
return tokenServicesFacade.get().createToken(ReportPortalClient.ui, normalizeId(login), authentication, ofNullable(oAuth2Authentication.getOAuth2Request()).map(OAuth2Request::getExtensions).orElseGet(Collections::emptyMap));
}
Aggregations