当前位置: 首页>>代码示例>>Java>>正文


Java ExpirationPolicy类代码示例

本文整理汇总了Java中org.jasig.cas.ticket.ExpirationPolicy的典型用法代码示例。如果您正苦于以下问题:Java ExpirationPolicy类的具体用法?Java ExpirationPolicy怎么用?Java ExpirationPolicy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ExpirationPolicy类属于org.jasig.cas.ticket包,在下文中一共展示了ExpirationPolicy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createMockTicketGrantingTicket

import org.jasig.cas.ticket.ExpirationPolicy; //导入依赖的package包/类
private TicketGrantingTicket createMockTicketGrantingTicket(final String id,
        final ServiceTicket svcTicket, final boolean isExpired, 
        final TicketGrantingTicket root, final List<Authentication> chainedAuthnList) {
    final TicketGrantingTicket tgtMock = mock(TicketGrantingTicket.class);
    when(tgtMock.isExpired()).thenReturn(isExpired);
    when(tgtMock.getId()).thenReturn(id);

    final String svcId = svcTicket.getService().getId();
    when(tgtMock.grantServiceTicket(anyString(), argThat(new VerifyServiceByIdMatcher(svcId)),
            any(ExpirationPolicy.class), anyBoolean(), anyBoolean())).thenReturn(svcTicket);
    when(tgtMock.getRoot()).thenReturn(root);
    when(tgtMock.getChainedAuthentications()).thenReturn(chainedAuthnList);
    when(tgtMock.getAuthentication()).thenReturn(this.authentication);
    when(svcTicket.getGrantingTicket()).thenReturn(tgtMock);   
    
    return tgtMock;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:18,代码来源:CentralAuthenticationServiceImplWithMockitoTests.java

示例2: CentralAuthenticationServiceImpl

import org.jasig.cas.ticket.ExpirationPolicy; //导入依赖的package包/类
/**
 * Build the central authentication service implementation.
 *
 * @param ticketRegistry the tickets registry.
 * @param serviceTicketRegistry the service tickets registry.
 * @param authenticationManager the authentication manager.
 * @param ticketGrantingTicketUniqueTicketIdGenerator the TGT id generator.
 * @param uniqueTicketIdGeneratorsForService the map with service and ticket id generators.
 * @param ticketGrantingTicketExpirationPolicy the TGT expiration policy.
 * @param serviceTicketExpirationPolicy the service ticket expiration policy.
 * @param servicesManager the services manager.
 * @param logoutManager the logout manager.
 */
public CentralAuthenticationServiceImpl(final TicketRegistry ticketRegistry,
                                        final TicketRegistry serviceTicketRegistry,
                                        final AuthenticationManager authenticationManager,
                                        final UniqueTicketIdGenerator ticketGrantingTicketUniqueTicketIdGenerator,
                                        final Map<String, UniqueTicketIdGenerator> uniqueTicketIdGeneratorsForService,
                                        final ExpirationPolicy ticketGrantingTicketExpirationPolicy,
                                        final ExpirationPolicy serviceTicketExpirationPolicy,
                                        final ServicesManager servicesManager,
                                        final LogoutManager logoutManager) {
    this.ticketRegistry = ticketRegistry;
    if (serviceTicketRegistry == null) {
        this.serviceTicketRegistry = ticketRegistry;
    } else {
        this.serviceTicketRegistry = serviceTicketRegistry;
    }
    this.authenticationManager = authenticationManager;
    this.ticketGrantingTicketUniqueTicketIdGenerator = ticketGrantingTicketUniqueTicketIdGenerator;
    this.uniqueTicketIdGeneratorsForService = uniqueTicketIdGeneratorsForService;
    this.ticketGrantingTicketExpirationPolicy = ticketGrantingTicketExpirationPolicy;
    this.serviceTicketExpirationPolicy = serviceTicketExpirationPolicy;
    this.servicesManager = servicesManager;
    this.logoutManager = logoutManager;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:37,代码来源:CentralAuthenticationServiceImpl.java

示例3: createMockTicketGrantingTicket

import org.jasig.cas.ticket.ExpirationPolicy; //导入依赖的package包/类
private TicketGrantingTicket createMockTicketGrantingTicket(final String id,
        final ServiceTicket svcTicket, final boolean isExpired, 
        final TicketGrantingTicket root, final List<Authentication> chainedAuthnList) {
    final TicketGrantingTicket tgtMock = mock(TicketGrantingTicket.class);
    when(tgtMock.isExpired()).thenReturn(isExpired);
    when(tgtMock.getId()).thenReturn(id);

    final String svcId = svcTicket.getService().getId();
    when(tgtMock.grantServiceTicket(anyString(), argThat(new VerifyServiceByIdMatcher(svcId)),
            any(ExpirationPolicy.class), anyBoolean())).thenReturn(svcTicket);
    when(tgtMock.getRoot()).thenReturn(root);
    when(tgtMock.getChainedAuthentications()).thenReturn(chainedAuthnList);
    when(svcTicket.getGrantingTicket()).thenReturn(tgtMock);   
    
    return tgtMock;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:CentralAuthenticationServiceImplWithMockitoTests.java

示例4: verifyGrantServiceTicketWithExpiredTicketGrantingTicket

import org.jasig.cas.ticket.ExpirationPolicy; //导入依赖的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

示例5: testGrantServiceTicketWithExpiredTicketGrantingTicket

import org.jasig.cas.ticket.ExpirationPolicy; //导入依赖的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());
    }
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:21,代码来源:CentralAuthenticationServiceImplTests.java

示例6: CentralAuthenticationServiceImpl

import org.jasig.cas.ticket.ExpirationPolicy; //导入依赖的package包/类
/**
 * Build the central authentication service implementation.
 *
 * @param ticketRegistry the tickets registry.
 * @param authenticationManager the authentication manager.
 * @param ticketGrantingTicketUniqueTicketIdGenerator the TGT id generator.
 * @param uniqueTicketIdGeneratorsForService the map with service and ticket id generators.
 * @param ticketGrantingTicketExpirationPolicy the TGT expiration policy.
 * @param serviceTicketExpirationPolicy the service ticket expiration policy.
 * @param servicesManager the services manager.
 * @param logoutManager the logout manager.
 */
public CentralAuthenticationServiceImpl(final TicketRegistry ticketRegistry,
                                        final AuthenticationManager authenticationManager,
                                        final UniqueTicketIdGenerator ticketGrantingTicketUniqueTicketIdGenerator,
                                        final Map<String, UniqueTicketIdGenerator> uniqueTicketIdGeneratorsForService,
                                        final ExpirationPolicy ticketGrantingTicketExpirationPolicy,
                                        final ExpirationPolicy serviceTicketExpirationPolicy,
                                        final ServicesManager servicesManager,
                                        final LogoutManager logoutManager) {
    this.ticketRegistry = ticketRegistry;
    this.authenticationManager = authenticationManager;
    this.ticketGrantingTicketUniqueTicketIdGenerator = ticketGrantingTicketUniqueTicketIdGenerator;
    this.uniqueTicketIdGeneratorsForService = uniqueTicketIdGeneratorsForService;
    this.ticketGrantingTicketExpirationPolicy = ticketGrantingTicketExpirationPolicy;
    this.serviceTicketExpirationPolicy = serviceTicketExpirationPolicy;
    this.servicesManager = servicesManager;
    this.logoutManager = logoutManager;
}
 
开发者ID:xuchengdong,项目名称:cas4.1.9,代码行数:30,代码来源:CentralAuthenticationServiceImpl.java

示例7: verifyDestroyRemoteRegistry

import org.jasig.cas.ticket.ExpirationPolicy; //导入依赖的package包/类
/**
 * This test checks that the TGT destruction happens properly for a remote registry.
 * It previously failed when the deletion happens before the ticket was marked expired because an update was necessary for that.
 *
 * @throws AuthenticationException
 * @throws AbstractTicketException
 */
@Test
public void verifyDestroyRemoteRegistry() throws AbstractTicketException, AuthenticationException {
    final MockOnlyOneTicketRegistry registry = new MockOnlyOneTicketRegistry();
    final TicketGrantingTicketImpl tgt = new TicketGrantingTicketImpl("TGT-1", mock(Authentication.class),
        mock(ExpirationPolicy.class));
    final MockExpireUpdateTicketLogoutManager logoutManager = new MockExpireUpdateTicketLogoutManager(registry);
    registry.addTicket(tgt);
    final CentralAuthenticationServiceImpl cas = new CentralAuthenticationServiceImpl(registry, null, null, logoutManager);
    cas.setApplicationEventPublisher(mock(ApplicationEventPublisher.class));
    cas.destroyTicketGrantingTicket(tgt.getId());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:19,代码来源:CentralAuthenticationServiceImplTests.java

示例8: verifyExpiredServiceTicket

import org.jasig.cas.ticket.ExpirationPolicy; //导入依赖的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

示例9: grantProxyGrantingTicket

import org.jasig.cas.ticket.ExpirationPolicy; //导入依赖的package包/类
@Transactional(readOnly=false, transactionManager = "ticketTransactionManager")
@Override
public ProxyGrantingTicket grantProxyGrantingTicket(final String id,
                                                    final Authentication authentication,
                                                    final ExpirationPolicy expirationPolicy) {
    final ProxyGrantingTicket t = this.getTicket().grantProxyGrantingTicket(id,
            authentication, expirationPolicy);
    updateTicket();
    return t;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:11,代码来源:ServiceTicketDelegator.java

示例10: grantServiceTicket

import org.jasig.cas.ticket.ExpirationPolicy; //导入依赖的package包/类
@Transactional(readOnly=false, transactionManager = "ticketTransactionManager")
@Override
public ServiceTicket grantServiceTicket(final String id, final Service service,
                                        final ExpirationPolicy expirationPolicy, final boolean credentialsProvided,
                                        final boolean onlyTrackMostRecentSession) {
    final ServiceTicket t = this.getTicket().grantServiceTicket(id, service,
            expirationPolicy, credentialsProvided, onlyTrackMostRecentSession);
    updateTicket();
    return t;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:11,代码来源:TicketGrantingTicketDelegator.java

示例11: grantProxyTicket

import org.jasig.cas.ticket.ExpirationPolicy; //导入依赖的package包/类
@Transactional(readOnly=false, transactionManager = "ticketTransactionManager")
@Override
public ProxyTicket grantProxyTicket(final String id, final Service service, final ExpirationPolicy expirationPolicy,
                                    final boolean onlyTrackMostRecentSession) {
    final ProxyTicket t = this.getTicket().grantProxyTicket(id, service, expirationPolicy,
            onlyTrackMostRecentSession);
    updateTicket();
    return t;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:10,代码来源:ProxyGrantingTicketDelegator.java

示例12: grantServiceTicket

import org.jasig.cas.ticket.ExpirationPolicy; //导入依赖的package包/类
@Override
public ServiceTicket grantServiceTicket(
        final String id,
        final Service service,
        final ExpirationPolicy expirationPolicy,
        final boolean credentialsProvided,
        final boolean onlyTrackMostRecentSession) {
    usageCount++;
    return new MockServiceTicket(id, service, this);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:11,代码来源:MockTicketGrantingTicket.java

示例13: grantProxyGrantingTicket

import org.jasig.cas.ticket.ExpirationPolicy; //导入依赖的package包/类
@Override
public ProxyGrantingTicket grantProxyGrantingTicket(
        final String id,
        final Authentication authentication,
        final ExpirationPolicy expirationPolicy) {
    return null;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:8,代码来源:MockServiceTicket.java

示例14: verifyFinishAuthentication

import org.jasig.cas.ticket.ExpirationPolicy; //导入依赖的package包/类
@Test
public void verifyFinishAuthentication() throws Exception {
    final MockHttpServletRequest mockRequest = new MockHttpServletRequest();
    mockRequest.setParameter(Clients.DEFAULT_CLIENT_NAME_PARAMETER, "FacebookClient");

    final MockHttpSession mockSession = new MockHttpSession();
    mockSession.setAttribute(ClientAction.THEME, MY_THEME);
    mockSession.setAttribute(ClientAction.LOCALE, MY_LOCALE);
    mockSession.setAttribute(ClientAction.METHOD, MY_METHOD);
    final Service service = new SimpleWebApplicationServiceImpl(MY_SERVICE);
    mockSession.setAttribute(ClientAction.SERVICE, service);
    mockRequest.setSession(mockSession);

    final ServletExternalContext servletExternalContext = mock(ServletExternalContext.class);
    when(servletExternalContext.getNativeRequest()).thenReturn(mockRequest);

    final MockRequestContext mockRequestContext = new MockRequestContext();
    mockRequestContext.setExternalContext(servletExternalContext);

    final FacebookClient facebookClient = new MockFacebookClient();
    final Clients clients = new Clients(MY_LOGIN_URL, facebookClient);

    final TicketGrantingTicket tgt = new TicketGrantingTicketImpl(TGT_ID, mock(Authentication.class), mock(ExpirationPolicy.class));
    final CentralAuthenticationService casImpl = mock(CentralAuthenticationService.class);
    when(casImpl.createTicketGrantingTicket(any(Credential.class))).thenReturn(tgt);
    final ClientAction action = new ClientAction(casImpl, clients);
    final Event event = action.execute(mockRequestContext);
    assertEquals("success", event.getId());
    assertEquals(MY_THEME, mockRequest.getAttribute(ClientAction.THEME));
    assertEquals(MY_LOCALE, mockRequest.getAttribute(ClientAction.LOCALE));
    assertEquals(MY_METHOD, mockRequest.getAttribute(ClientAction.METHOD));
    assertEquals(MY_SERVICE, mockRequest.getAttribute(ClientAction.SERVICE));
    final MutableAttributeMap flowScope = mockRequestContext.getFlowScope();
    final MutableAttributeMap requestScope = mockRequestContext.getRequestScope();
    assertEquals(service, flowScope.get(ClientAction.SERVICE));
    assertEquals(TGT_ID, flowScope.get(TGT_NAME));
    assertEquals(TGT_ID, requestScope.get(TGT_NAME));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:39,代码来源:ClientActionTests.java

示例15: grantTicketGrantingTicket

import org.jasig.cas.ticket.ExpirationPolicy; //导入依赖的package包/类
@Override
public TicketGrantingTicket grantTicketGrantingTicket(final String id,
        final Authentication authentication, final ExpirationPolicy expirationPolicy) {
    final TicketGrantingTicket t = this.getTicket().grantTicketGrantingTicket(id,
            authentication, expirationPolicy);
    updateTicket();
    return t;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:9,代码来源:AbstractDistributedTicketRegistry.java


注:本文中的org.jasig.cas.ticket.ExpirationPolicy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。