Example usage for javax.security.auth.login AccountException getClass

List of usage examples for javax.security.auth.login AccountException getClass

Introduction

In this page you can find the example usage for javax.security.auth.login AccountException getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:io.cos.cas.authentication.handler.support.OpenScienceFrameworkPrincipalFromRequestRemoteUserNonInteractiveCredentialsAction.java

@Override
protected Event doExecute(final RequestContext context) throws Exception {
    final Credential credential;
    try {/* www.  ja v a2 s .co m*/
        credential = constructCredentialsFromRequest(context);
    } catch (final AccountException e) {
        final Map<String, Class<? extends Exception>> failures = new LinkedHashMap<>();
        failures.put(e.getClass().getSimpleName(), e.getClass());
        return getEventFactorySupport().event(this, AUTHENTICATION_FAILURE,
                new LocalAttributeMap<Object>("error", new AuthenticationException(failures)));
    }

    if (credential == null) {
        return error();
    }

    final String ticketGrantingTicketId = WebUtils.getTicketGrantingTicketId(context);
    final Service service = WebUtils.getService(context);

    if (isRenewPresent(context) && ticketGrantingTicketId != null && service != null) {

        try {
            final ServiceTicket serviceTicketId = this.centralAuthenticationService
                    .grantServiceTicket(ticketGrantingTicketId, service, credential);
            WebUtils.putServiceTicketInRequestScope(context, serviceTicketId);
            return result("warn");
        } catch (final AuthenticationException e) {
            onError(context, credential);
            return error();
        } catch (final TicketException e) {
            this.centralAuthenticationService.destroyTicketGrantingTicket(ticketGrantingTicketId);
            logger.debug("Attempted to generate a ServiceTicket using renew=true with different credential", e);
        }
    }

    try {
        WebUtils.putTicketGrantingTicketInScopes(context,
                this.centralAuthenticationService.createTicketGrantingTicket(credential));
        onSuccess(context, credential);
        return success();
    } catch (final AuthenticationException e) {
        return getEventFactorySupport().event(this, AUTHENTICATION_FAILURE,
                new LocalAttributeMap<Object>("error", e));
    } catch (final Exception e) {
        onError(context, credential);
        return error();
    }
}