Search in sources :

Example 1 with UiUserSignedInEvent

use of com.epam.reportportal.auth.event.UiUserSignedInEvent in project service-authorization by reportportal.

the class AuthSuccessHandler method handle.

@Override
protected void handle(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException {
    OAuth2AccessToken token = getToken(authentication);
    MultiValueMap<String, String> query = new LinkedMultiValueMap<>();
    query.add("token", token.getValue());
    query.add("token_type", token.getTokenType());
    URI rqUrl = UriComponentsBuilder.fromHttpRequest(new ServletServerHttpRequest(request)).replacePath("/ui/authSuccess").replaceQueryParams(query).build().toUri();
    eventPublisher.publishEvent(new UiUserSignedInEvent(authentication));
    getRedirectStrategy().sendRedirect(request, response, rqUrl.toString().replaceFirst("authSuccess", "#authSuccess"));
}
Also used : ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) UiUserSignedInEvent(com.epam.reportportal.auth.event.UiUserSignedInEvent) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) OAuth2AccessToken(org.springframework.security.oauth2.common.OAuth2AccessToken) URI(java.net.URI)

Example 2 with UiUserSignedInEvent

use of com.epam.reportportal.auth.event.UiUserSignedInEvent in project service-authorization by reportportal.

the class EnableableAuthProvider method authenticate.

@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
    if (isEnabled()) {
        Authentication auth = getDelegate().authenticate(authentication);
        eventPublisher.publishEvent(new UiUserSignedInEvent(auth));
        return auth;
    } else {
        return null;
    }
}
Also used : UiUserSignedInEvent(com.epam.reportportal.auth.event.UiUserSignedInEvent) Authentication(org.springframework.security.core.Authentication)

Example 3 with UiUserSignedInEvent

use of com.epam.reportportal.auth.event.UiUserSignedInEvent in project service-authorization by reportportal.

the class BasicPasswordAuthenticationProvider method authenticate.

@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
    boolean accountNonLocked = !failureEventHandler.isBlocked(request.get());
    if (!accountNonLocked) {
        BusinessRule.fail().withError(ErrorType.ADDRESS_LOCKED);
    }
    Authentication auth = super.authenticate(authentication);
    eventPublisher.publishEvent(new UiUserSignedInEvent(auth));
    return auth;
}
Also used : UiUserSignedInEvent(com.epam.reportportal.auth.event.UiUserSignedInEvent) Authentication(org.springframework.security.core.Authentication)

Example 4 with UiUserSignedInEvent

use of com.epam.reportportal.auth.event.UiUserSignedInEvent in project service-authorization by reportportal.

the class OAuthSuccessHandler method handle.

@Override
protected void handle(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
    OAuth2Authentication oauth = (OAuth2Authentication) authentication;
    OAuth2AccessToken accessToken = tokenServicesFacade.get().createToken(ReportPortalClient.ui, oauth.getName(), oauth.getUserAuthentication(), oauth.getOAuth2Request().getExtensions());
    MultiValueMap<String, String> query = new LinkedMultiValueMap<>();
    query.add("token", accessToken.getValue());
    query.add("token_type", accessToken.getTokenType());
    URI rqUrl = UriComponentsBuilder.fromHttpRequest(new ServletServerHttpRequest(request)).replacePath("/ui/authSuccess.html").replaceQueryParams(query).build().toUri();
    eventPublisher.publishEvent(new UiUserSignedInEvent(authentication));
    getRedirectStrategy().sendRedirect(request, response, rqUrl.toString());
}
Also used : ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) UiUserSignedInEvent(com.epam.reportportal.auth.event.UiUserSignedInEvent) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) OAuth2AccessToken(org.springframework.security.oauth2.common.OAuth2AccessToken) OAuth2Authentication(org.springframework.security.oauth2.provider.OAuth2Authentication) URI(java.net.URI)

Example 5 with UiUserSignedInEvent

use of com.epam.reportportal.auth.event.UiUserSignedInEvent in project service-authorization by reportportal.

the class BasicPasswordAuthenticationProvider method authenticate.

@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
    boolean accountNonLocked = !failureEventHandler.isBlocked(request.get());
    if (!accountNonLocked) {
        throw new ReportPortalException(ErrorType.ADDRESS_LOCKED);
    }
    Authentication auth = super.authenticate(authentication);
    eventPublisher.publishEvent(new UiUserSignedInEvent(auth));
    return auth;
}
Also used : UiUserSignedInEvent(com.epam.reportportal.auth.event.UiUserSignedInEvent) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Authentication(org.springframework.security.core.Authentication)

Aggregations

UiUserSignedInEvent (com.epam.reportportal.auth.event.UiUserSignedInEvent)5 Authentication (org.springframework.security.core.Authentication)3 URI (java.net.URI)2 ServletServerHttpRequest (org.springframework.http.server.ServletServerHttpRequest)2 OAuth2AccessToken (org.springframework.security.oauth2.common.OAuth2AccessToken)2 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)2 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1 OAuth2Authentication (org.springframework.security.oauth2.provider.OAuth2Authentication)1