本文整理汇总了Java中org.jasig.cas.ticket.TicketState类的典型用法代码示例。如果您正苦于以下问题:Java TicketState类的具体用法?Java TicketState怎么用?Java TicketState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TicketState类属于org.jasig.cas.ticket包,在下文中一共展示了TicketState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isExpired
import org.jasig.cas.ticket.TicketState; //导入依赖的package包/类
@Override
public boolean isExpired(final TicketState ticketState) {
final long currentSystemTimeInMillis = System.currentTimeMillis();
// Ticket has been used, check maxTimeToLive (hard window)
if (currentSystemTimeInMillis - ticketState.getCreationTime() >= maxTimeToLiveInMilliSeconds) {
LOGGER.debug("Ticket is expired because the time since creation is greater than maxTimeToLiveInMilliSeconds");
return true;
}
// Ticket is within hard window, check timeToKill (sliding window)
if (currentSystemTimeInMillis - ticketState.getLastTimeUsed() >= timeToKillInMilliSeconds) {
LOGGER.debug("Ticket is expired because the time since last use is greater than timeToKillInMilliseconds");
return true;
}
return false;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:19,代码来源:TicketGrantingTicketExpirationPolicy.java
示例2: isExpired
import org.jasig.cas.ticket.TicketState; //导入依赖的package包/类
@Override
public boolean isExpired(final TicketState ticketState) {
final long currentTimeInMillis = System.currentTimeMillis();
final long lastTimeTicketWasUsed = ticketState.getLastTimeUsed();
if (ticketState.getCountOfUses() == 0
&& (currentTimeInMillis - lastTimeTicketWasUsed < this.timeToKillInMilliSeconds)) {
LOGGER.debug("Ticket is not expired due to a count of zero and the time being less "
+ "than the timeToKillInMilliseconds");
return false;
}
if ((currentTimeInMillis - lastTimeTicketWasUsed >= this.timeToKillInMilliSeconds)) {
LOGGER.debug("Ticket is expired due to the time being greater than the timeToKillInMilliseconds");
return true;
}
if ((currentTimeInMillis - lastTimeTicketWasUsed <= this.timeInBetweenUsesInMilliSeconds)) {
LOGGER.warn("Ticket is expired due to the time being less than the waiting period.");
return true;
}
return false;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:25,代码来源:ThrottledUseAndTimeoutExpirationPolicy.java
示例3: isExpired
import org.jasig.cas.ticket.TicketState; //导入依赖的package包/类
@Override
public boolean isExpired(final TicketState ticketState) {
if (ticketState == null) {
LOGGER.debug("Ticket state is null for {}", this.getClass().getSimpleName());
return true;
}
final long countUses = ticketState.getCountOfUses();
if (countUses >= this.numberOfUses) {
LOGGER.debug("Ticket usage count {} is greater than or equal to {}", countUses, this.numberOfUses);
return true;
}
final long systemTime = System.currentTimeMillis();
final long lastTimeUsed = ticketState.getLastTimeUsed();
final long difference = systemTime - lastTimeUsed;
if (difference >= this.timeToKillInMilliSeconds) {
LOGGER.debug("Ticket has expired because the difference between current time [{}] "
+ "and ticket time [{}] is greater than or equal to [{}]", systemTime, lastTimeUsed,
this.timeToKillInMilliSeconds);
return true;
}
return false;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:25,代码来源:MultiTimeUseOrTimeoutExpirationPolicy.java
示例4: isExpired
import org.jasig.cas.ticket.TicketState; //导入依赖的package包/类
@Override
public boolean isExpired(final TicketState ticketState) {
if (this.rememberMeExpirationPolicy != null && this.sessionExpirationPolicy != null) {
final Boolean b = (Boolean) ticketState.getAuthentication().getAttributes().
get(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME);
if (b == null || b.equals(Boolean.FALSE)) {
LOGGER.debug("Ticket is not associated with a remember-me authentication. Invoking {}", sessionExpirationPolicy);
return this.sessionExpirationPolicy.isExpired(ticketState);
}
LOGGER.debug("Ticket is associated with a remember-me authentication. Invoking {}", rememberMeExpirationPolicy);
return this.rememberMeExpirationPolicy.isExpired(ticketState);
}
LOGGER.warn("No expiration policy settings are defined");
return false;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:19,代码来源:RememberMeDelegatingExpirationPolicy.java
示例5: isExpired
import org.jasig.cas.ticket.TicketState; //导入依赖的package包/类
@Override
public boolean isExpired(final TicketState ticketState) {
final long currentSystemTimeInMillis = System.currentTimeMillis();
// Ticket has been used, check maxTimeToLive (hard window)
if ((currentSystemTimeInMillis - ticketState.getCreationTime() >= maxTimeToLiveInMilliSeconds)) {
logger.debug("Ticket is expired because the time since creation is greater than maxTimeToLiveInMilliSeconds");
return true;
}
// Ticket is within hard window, check timeToKill (sliding window)
if ((currentSystemTimeInMillis - ticketState.getLastTimeUsed() >= timeToKillInMilliSeconds)) {
logger.debug("Ticket is expired because the time since last use is greater than timeToKillInMilliseconds");
return true;
}
return false;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:19,代码来源:TicketGrantingTicketExpirationPolicy.java
示例6: isExpired
import org.jasig.cas.ticket.TicketState; //导入依赖的package包/类
@Override
public boolean isExpired(final TicketState ticketState) {
final long currentTimeInMillis = System.currentTimeMillis();
final long lastTimeTicketWasUsed = ticketState.getLastTimeUsed();
if (ticketState.getCountOfUses() == 0
&& (currentTimeInMillis - lastTimeTicketWasUsed < this.timeToKillInMilliSeconds)) {
logger.debug("Ticket is not expired due to a count of zero and the time being less "
+ "than the timeToKillInMilliseconds");
return false;
}
if ((currentTimeInMillis - lastTimeTicketWasUsed >= this.timeToKillInMilliSeconds)) {
logger.debug("Ticket is expired due to the time being greater than the timeToKillInMilliseconds");
return true;
}
if ((currentTimeInMillis - lastTimeTicketWasUsed <= this.timeInBetweenUsesInMilliSeconds)) {
logger.warn("Ticket is expired due to the time being less than the waiting period.");
return true;
}
return false;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:25,代码来源:ThrottledUseAndTimeoutExpirationPolicy.java
示例7: verifyGrantServiceTicketWithExpiredTicketGrantingTicket
import org.jasig.cas.ticket.TicketState; //导入依赖的package包/类
@Test(expected=TicketException.class)
public void verifyGrantServiceTicketWithExpiredTicketGrantingTicket() throws Exception {
((CentralAuthenticationServiceImpl) getCentralAuthenticationService()).setTicketGrantingTicketExpirationPolicy(
new ExpirationPolicy() {
private static final long serialVersionUID = 1L;
public boolean isExpired(final TicketState ticket) {
return true;
}});
final TicketGrantingTicket ticketId = getCentralAuthenticationService()
.createTicketGrantingTicket(
TestUtils.getCredentialsWithSameUsernameAndPassword());
try {
getCentralAuthenticationService().grantServiceTicket(ticketId.getId(),
TestUtils.getService());
} finally {
((CentralAuthenticationServiceImpl) getCentralAuthenticationService()).setTicketGrantingTicketExpirationPolicy(
new NeverExpiresExpirationPolicy());
}
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:22,代码来源:CentralAuthenticationServiceImplTests.java
示例8: isExpired
import org.jasig.cas.ticket.TicketState; //导入依赖的package包/类
public boolean isExpired(final TicketState ticketState) {
if (ticketState.getCountOfUses() == 0
&& (System.currentTimeMillis() - ticketState.getLastTimeUsed() < this.timeToKillInMilliSeconds)) {
LOGGER.debug("Ticket is not expired due to a count of zero and the time being less "
+ "than the timeToKillInMilliseconds");
return false;
}
if ((System.currentTimeMillis() - ticketState.getLastTimeUsed() >= this.timeToKillInMilliSeconds)) {
LOGGER.debug("Ticket is expired due to the time being greater than the timeToKillInMilliseconds");
return true;
}
if ((System.currentTimeMillis() - ticketState.getLastTimeUsed() <= this.timeInBetweenUsesInMilliSeconds)) {
LOGGER.warn("Ticket is expired due to the time being less than the waiting period.");
return true;
}
return false;
}
示例9: testGrantServiceTicketWithExpiredTicketGrantingTicket
import org.jasig.cas.ticket.TicketState; //导入依赖的package包/类
@Test(expected=TicketException.class)
public void testGrantServiceTicketWithExpiredTicketGrantingTicket() throws Exception {
((CentralAuthenticationServiceImpl) getCentralAuthenticationService()).setTicketGrantingTicketExpirationPolicy(
new ExpirationPolicy() {
private static final long serialVersionUID = 1L;
public boolean isExpired(final TicketState ticket) {
return true;
}});
final String ticketId = getCentralAuthenticationService()
.createTicketGrantingTicket(
TestUtils.getCredentialsWithSameUsernameAndPassword());
try {
getCentralAuthenticationService().grantServiceTicket(ticketId,
TestUtils.getService());
} finally {
((CentralAuthenticationServiceImpl) getCentralAuthenticationService()).setTicketGrantingTicketExpirationPolicy(
new NeverExpiresExpirationPolicy());
}
}
示例10: isExpired
import org.jasig.cas.ticket.TicketState; //导入依赖的package包/类
@Override
public boolean isExpired(final TicketState ticketState) {
final long currentSystemTimeInMillis = System.currentTimeMillis();
// Ticket has been used, check maxTimeToLive (hard window)
if ((currentSystemTimeInMillis - ticketState.getCreationTime() >= maxTimeToLiveInMilliSeconds)) {
LOGGER.debug("Ticket is expired because the time since creation is greater than maxTimeToLiveInMilliSeconds");
return true;
}
// Ticket is within hard window, check timeToKill (sliding window)
if ((currentSystemTimeInMillis - ticketState.getLastTimeUsed() >= timeToKillInMilliSeconds)) {
LOGGER.debug("Ticket is expired because the time since last use is greater than timeToKillInMilliseconds");
return true;
}
return false;
}
示例11: verifyExpiredServiceTicket
import org.jasig.cas.ticket.TicketState; //导入依赖的package包/类
@Test
public void verifyExpiredServiceTicket() throws Exception {
clearAllServices();
final MockHttpServletRequest mockRequest = new MockHttpServletRequest("GET", CONTEXT
+ OAuthConstants.ACCESS_TOKEN_URL);
mockRequest.setParameter(OAuthConstants.CLIENT_ID, CLIENT_ID);
mockRequest.setParameter(OAuthConstants.REDIRECT_URI, REDIRECT_URI);
mockRequest.setParameter(OAuthConstants.CLIENT_SECRET, CLIENT_SECRET);
mockRequest.setParameter(OAuthConstants.CODE, CODE);
final MockHttpServletResponse mockResponse = new MockHttpServletResponse();
((OAuth20WrapperController) oauth20WrapperController)
.getServicesManager().save(getRegisteredService(REDIRECT_URI, CLIENT_SECRET));
final Map<String, Object> map = new HashMap<>();
map.put(NAME, VALUE);
final List<String> list = Arrays.asList(VALUE, VALUE);
map.put(NAME2, list);
final Principal p = org.jasig.cas.authentication.TestUtils.getPrincipal(ID, map);
final TicketGrantingTicketImpl impl = new TicketGrantingTicketImpl(TGT_ID,
org.jasig.cas.authentication.TestUtils.getAuthentication(p), new NeverExpiresExpirationPolicy());
((OAuth20WrapperController) oauth20WrapperController)
.getTicketRegistry().addTicket(new ServiceTicketImpl("ST1", impl,
org.jasig.cas.authentication.TestUtils.getService(), false,
new ExpirationPolicy() {
private static final long serialVersionUID = -7321055962209199811L;
@Override
public boolean isExpired(final TicketState ticketState) {
return true;
}
}));
oauth20WrapperController.handleRequest(mockRequest, mockResponse);
assertEquals(400, mockResponse.getStatus());
assertEquals("error=" + OAuthConstants.INVALID_GRANT, mockResponse.getContentAsString());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:40,代码来源:OAuth20AccessTokenControllerTests.java
示例12: isExpired
import org.jasig.cas.ticket.TicketState; //导入依赖的package包/类
@Override
public boolean isExpired(final TicketState ticketState) {
final Boolean b = (Boolean) ticketState.getAuthentication().getAttributes().
get(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME);
if (b == null || b.equals(Boolean.FALSE)) {
return this.sessionExpirationPolicy.isExpired(ticketState);
}
return this.rememberMeExpirationPolicy.isExpired(ticketState);
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:12,代码来源:RememberMeDelegatingExpirationPolicy.java
示例13: isExpired
import org.jasig.cas.ticket.TicketState; //导入依赖的package包/类
public boolean isExpired(final TicketState ticketState) {
// Ticket has been used, check maxTimeToLive (hard window)
if ((System.currentTimeMillis() - ticketState.getCreationTime() >= maxTimeToLiveInMilliSeconds)) {
LOGGER.debug("Ticket is expired because the time since creation is greater than maxTimeToLiveInMilliSeconds");
return true;
}
// Ticket is within hard window, check timeToKill (sliding window)
if ((System.currentTimeMillis() - ticketState.getLastTimeUsed() >= timeToKillInMilliSeconds)) {
LOGGER.debug("Ticket is expired because the time since last use is greater than timeToKillInMilliseconds");
return true;
}
return false;
}
示例14: isExpired
import org.jasig.cas.ticket.TicketState; //导入依赖的package包/类
public boolean isExpired(final TicketState ticketState) {
final Boolean b = (Boolean) ticketState.getAuthentication().getAttributes().
get(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME);
if (b == null || b.equals(Boolean.FALSE)) {
return this.sessionExpirationPolicy.isExpired(ticketState);
}
return this.rememberMeExpirationPolicy.isExpired(ticketState);
}
示例15: verifyOK
import org.jasig.cas.ticket.TicketState; //导入依赖的package包/类
@Test
public void verifyOK() throws Exception {
final MockHttpServletRequest mockRequest = new MockHttpServletRequest("GET", CONTEXT
+ OAuthConstants.ACCESS_TOKEN_URL);
mockRequest.setParameter(OAuthConstants.CLIENT_ID, CLIENT_ID);
mockRequest.setParameter(OAuthConstants.REDIRECT_URI, REDIRECT_URI);
mockRequest.setParameter(OAuthConstants.CLIENT_SECRET, CLIENT_SECRET);
mockRequest.setParameter(OAuthConstants.CODE, CODE);
final MockHttpServletResponse mockResponse = new MockHttpServletResponse();
((OAuth20WrapperController) oauth20WrapperController)
.getServicesManager().save(getRegisteredService(REDIRECT_URI, CLIENT_SECRET));
final Map<String, Object> map = new HashMap<>();
map.put(NAME, VALUE);
final List<String> list = Arrays.asList(VALUE, VALUE);
map.put(NAME2, list);
final Principal p = org.jasig.cas.authentication.TestUtils.getPrincipal(ID, map);
final TicketGrantingTicketImpl impl = new TicketGrantingTicketImpl(TGT_ID,
org.jasig.cas.authentication.TestUtils.getAuthentication(p), new NeverExpiresExpirationPolicy());
((OAuth20WrapperController) oauth20WrapperController)
.getTicketRegistry().addTicket(new ServiceTicketImpl(CODE, impl,
org.jasig.cas.authentication.TestUtils.getService(), false,
new ExpirationPolicy() {
private static final long serialVersionUID = -7321055962209199811L;
@Override
public boolean isExpired(final TicketState ticketState) {
return false;
}
}));
oauth20WrapperController.handleRequest(mockRequest, mockResponse);
((OAuth20WrapperController) oauth20WrapperController)
.getTicketRegistry().deleteTicket(CODE);
assertEquals("text/plain", mockResponse.getContentType());
assertEquals(200, mockResponse.getStatus());
final String body = mockResponse.getContentAsString();
assertTrue(body.contains(OAuthConstants.ACCESS_TOKEN + '='));
assertTrue(body.contains(OAuthConstants.EXPIRES_IN + '='));
// delta = 2 seconds
final int delta = 2;
final int timeLeft = Integer.parseInt(StringUtils.substringAfter(body, '&' + OAuthConstants.EXPIRES_IN + '='));
assertTrue(timeLeft >= TIMEOUT - 10 - delta);
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:53,代码来源:OAuth20AccessTokenControllerTests.java