/** * Retrieve all tickets from the registry. * * @return collection of tickets currently stored in the registry. Tickets * might or might not be valid i.e. expired. */ Collection<Ticket> getTickets();
/** * Remove a specific ticket from the registry. * If ticket to delete is TGT then related service tickets are removed as well. * * @param ticketId The id of the ticket to delete. * @return the number of tickets deleted including children. */ int deleteTicket(String ticketId);
if (StringUtils.isBlank(this.sql) || StringUtils.isBlank(this.algorithmName) || getJdbcTemplate() == null) { throw new GeneralSecurityException("Authentication handler is not configured correctly"); }
final String username = transformedCredential.getUsername(); try { // Get password and salt final Map<String, Object> rows = getJdbcTemplate().queryForMap(this.sql, username); final String encodedPassword = rows.get("password").toString(); final String dbSalt = rows.get("salt").toString(); SaltPasswordEncoder passwordEncoder = new SaltPasswordEncoder(); passwordEncoder.setSalt(dbSalt); if (!passwordEncoder.matches(transformedCredential.getPassword(), encodedPassword)) { throw new FailedLoginException("Password does not match value on record."); } // 登录成功,踢掉前一个相同登录的人 forceLogout(username); return createHandlerResult(transformedCredential, this.principalFactory.createPrincipal(username), null);
} catch (final IncorrectResultSizeDataAccessException e) { if (e.getActualSize() == 0) { throw new AccountNotFoundException(username + " not found with SQL query"); } else { throw new FailedLoginException("Multiple records found for " + username); } } catch (final DataAccessException e) { throw new PreventedException("SQL exception while executing query for " + username, e); }
javax.persistence.TransactionRequiredException: No EntityManager with actual transaction available for current thread - cannot reliably process 'remove' call at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:282) ~[spring-orm-4.3.4.RELEASE.jar:4.3.4.RELEASE] at com.sun.proxy.$Proxy175.remove(Unknown Source) ~[?:?] at org.apereo.cas.ticket.registry.JpaTicketRegistry.removeTicket(JpaTicketRegistry.java:72) ~[cas-server-support-jpa-ticket-registry-5.0.4.jar:5.0.4] at org.apereo.cas.ticket.registry.JpaTicketRegistry.deleteTicketsFromResultList(JpaTicketRegistry.java:214) ~[cas-server-support-jpa-ticket-registry-5.0.4.jar:5.0.4] at org.apereo.cas.ticket.registry.JpaTicketRegistry.deleteTicketGrantingTickets(JpaTicketRegistry.java:244) ~[cas-server-support-jpa-ticket-registry-5.0.4.jar:5.0.4] at org.apereo.cas.ticket.registry.JpaTicketRegistry.deleteSingleTicket(JpaTicketRegistry.java:158) ~[cas-server-support-jpa-ticket-registry-5.0.4.jar:5.0.4] at org.apereo.cas.ticket.registry.AbstractTicketRegistry.deleteTicket(AbstractTicketRegistry.java:125) ~[cas-server-core-tickets-5.0.4.jar:5.0.4] at org.apereo.cas.ticket.registry.AbstractTicketRegistry$$FastClassBySpringCGLIB$$d3c67a11.invoke(<generated>) ~[cas-server-core-tickets-5.0.4.jar:5.0.4] at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-4.3.4.RELEASE.jar:4.3.4.RELEASE] at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:651) ~[spring-aop-4.3.4.RELEASE.jar:4.3.4.RELEASE] at org.apereo.cas.ticket.registry.JpaTicketRegistry$$EnhancerBySpringCGLIB$$b6d104b8.deleteTicket(<generated>) ~[cas-server-support-jpa-ticket-registry-5.0.4.jar:5.0.4] at org.apereo.cas.ticket.registry.AbstractTicketRegistry$$FastClassBySpringCGLIB$$d3c67a11.invoke(<generated>) ~[cas-server-core-tickets-5.0.4.jar:5.0.4] at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-4.3.4.RELEASE.jar:4.3.4.RELEASE] at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:651) ~[spring-aop-4.3.4.RELEASE.jar:4.3.4.RELEASE] at org.apereo.cas.ticket.registry.JpaTicketRegistry$$EnhancerBySpringCGLIB$$ef44b76a.deleteTicket(<generated>) ~[cas-server-support-jpa-ticket-registry-5.0.4.jar:5.0.4] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_31] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_31] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_31] at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_31]
javax.persistence.TransactionRequiredException: no transaction is in progress at org.hibernate.internal.SessionImpl.checkTransactionNeeded(SessionImpl.java:3428) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final] at org.hibernate.internal.SessionImpl.find(SessionImpl.java:3362) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final] at org.hibernate.internal.SessionImpl.find(SessionImpl.java:3342) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_31] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_31] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_31] at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_31] at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:347) ~[spring-orm-4.3.4.RELEASE.jar:4.3.4.RELEASE] at com.sun.proxy.$Proxy175.find(Unknown Source) ~[?:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_31] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_31] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_31] at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_31] at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:298) ~[spring-orm-4.3.4.RELEASE.jar:4.3.4.RELEASE] at com.sun.proxy.$Proxy175.find(Unknown Source) ~[?:?]
/** * JPA implementation of a CAS {@link TicketRegistry}. This implementation of * ticket registry is suitable for HA environments. * * @author Scott Battaglia * @author Marvin S. Addison * @since 3.2.1 */ @EnableTransactionManagement(proxyTargetClass = true) @Transactional(transactionManager = "ticketTransactionManager", readOnly = false) public class JpaTicketRegistry extends AbstractTicketRegistry { .....................其余的省略.............................. }
if (StringUtils.isBlank(this.sql) || StringUtils.isBlank(this.algorithmName) || getJdbcTemplate() == null) { throw new GeneralSecurityException("Authentication handler is not configured correctly"); }
final String username = transformedCredential.getUsername(); try { // Get password and salt final Map<String, Object> rows = getJdbcTemplate().queryForMap(this.sql, username); final String encodedPassword = rows.get("password").toString(); final String dbSalt = rows.get("salt").toString(); SaltPasswordEncoder passwordEncoder = new SaltPasswordEncoder(); passwordEncoder.setSalt(dbSalt); if (!passwordEncoder.matches(transformedCredential.getPassword(), encodedPassword)) { throw new FailedLoginException("Password does not match value on record."); } // 登录成功,踢掉前一个相同登录的人 getForceLogoutManager().doLogout(username); return createHandlerResult(transformedCredential, this.principalFactory.createPrincipal(username), null);
} catch (final IncorrectResultSizeDataAccessException e) { if (e.getActualSize() == 0) { throw new AccountNotFoundException(username + " not found with SQL query"); } else { throw new FailedLoginException("Multiple records found for " + username); } } catch (final DataAccessException e) { throw new PreventedException("SQL exception while executing query for " + username, e); }