List of usage examples for org.springframework.security.core.userdetails UserDetails getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:de.kaiserpfalzEdv.office.ui.web.security.KPOfficeAuthenticationProvider.java
@Override protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException { if (KPOfficeUserDetail.class.isAssignableFrom(userDetails.getClass())) { try {//from ww w .j a va 2 s . c om service.check(((KPOfficeUserDetail) userDetails).getTicket()); LOG.info("Checked: {}", userDetails); } catch (NoSuchTicketException | InvalidTicketException e) { throw new BadCredentialsException("Wrong credentials for '" + userDetails.getUsername() + "'."); } } }
From source file:org.callistasoftware.netcare.mvk.authentication.service.impl.MvkPreAuthenticationServiceImpl.java
@Override public UserDetails loadUserDetails(PreAuthenticatedAuthenticationToken authToken) throws UsernameNotFoundException { getLog().info("Retrieve information about user. The user is pre-authenticated..."); final AuthenticationResult preAuthenticated; if (authToken.getPrincipal() instanceof AuthenticationResult) { getLog().debug("Not yet authenticated. We have an authentication result from MVK."); preAuthenticated = (AuthenticationResult) authToken.getPrincipal(); } else {// w w w.j av a2 s. c om /* * We already have an authenticated principal. * Let callback determine whether this is a care giver or patient */ final UserDetails principal = this.callback.verifyPrincipal(authToken.getPrincipal()); if (principal != null) { getLog().debug("Already authenticated. The type of authentication is: {}", principal.getClass().getSimpleName()); return principal; } else { throw new RuntimeException("Unknown authentication."); } } /* * We have an authentication result. Let's deal with it */ try { return this.callback.lookupPrincipal(preAuthenticated); } catch (final Exception e) { // This is ok... just create the missing user } if (this.createMissingUsers != null && Boolean.valueOf(this.createMissingUsers)) { return this.callback.createMissingUser(preAuthenticated); } else { throw new RuntimeException( "Please configure whether to create missing users or not. This is done via the mvk.create-missing-users property."); } }