Search in sources :

Example 1 with RequestValidationError

use of com.nexblocks.authguard.api.dto.entities.RequestValidationError in project AuthGuard by AuthGuard.

the class VerificationRoute method verifyEmail.

public void verifyEmail(final Context context) {
    final String token = context.queryParam("token");
    if (token == null) {
        context.status(400).json(new RequestValidationError(Collections.singletonList(new Violation("token", ViolationType.MISSING_REQUIRED_VALUE))));
    }
    verificationService.verifyEmail(token);
    context.status(200);
}
Also used : Violation(com.nexblocks.authguard.api.dto.validation.violations.Violation) RequestValidationError(com.nexblocks.authguard.api.dto.entities.RequestValidationError)

Example 2 with RequestValidationError

use of com.nexblocks.authguard.api.dto.entities.RequestValidationError in project AuthGuard by AuthGuard.

the class OAuthRoute method authorize.

void authorize(final Context context) {
    final String provider = context.queryParam("provider");
    final String state = context.queryParam("state");
    final String code = context.queryParam("code");
    if (provider == null) {
        context.status(400).json(new RequestValidationError(Collections.singletonList(new Violation("provider", ViolationType.MISSING_REQUIRED_VALUE))));
        return;
    }
    if (state == null) {
        context.status(400).json(new RequestValidationError(Collections.singletonList(new Violation("state", ViolationType.MISSING_REQUIRED_VALUE))));
        return;
    }
    if (code == null) {
        context.status(400).json(new RequestValidationError(Collections.singletonList(new Violation("code", ViolationType.MISSING_REQUIRED_VALUE))));
        return;
    }
    context.json(oAuthService.exchangeAuthorizationCode(provider, state, code));
}
Also used : Violation(com.nexblocks.authguard.api.dto.validation.violations.Violation) RequestValidationError(com.nexblocks.authguard.api.dto.entities.RequestValidationError)

Example 3 with RequestValidationError

use of com.nexblocks.authguard.api.dto.entities.RequestValidationError in project AuthGuard by AuthGuard.

the class ExceptionHandlers method requestValidationException.

public static void requestValidationException(final RequestValidationException e, final Context context) {
    final RequestValidationError error = new RequestValidationError(e.getViolations());
    context.status(400).json(error);
}
Also used : RequestValidationError(com.nexblocks.authguard.api.dto.entities.RequestValidationError)

Example 4 with RequestValidationError

use of com.nexblocks.authguard.api.dto.entities.RequestValidationError in project AuthGuard by AuthGuard.

the class OAuthRoute method getAuthUrl.

void getAuthUrl(final Context context) {
    final String provider = context.queryParam("provider");
    if (provider == null) {
        context.status(400).json(new RequestValidationError(Collections.singletonList(new Violation("provider", ViolationType.MISSING_REQUIRED_VALUE))));
    } else {
        final String url = oAuthService.getAuthorizationUrl(provider).join();
        context.redirect(url);
    }
}
Also used : Violation(com.nexblocks.authguard.api.dto.validation.violations.Violation) RequestValidationError(com.nexblocks.authguard.api.dto.entities.RequestValidationError)

Aggregations

RequestValidationError (com.nexblocks.authguard.api.dto.entities.RequestValidationError)4 Violation (com.nexblocks.authguard.api.dto.validation.violations.Violation)3