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


Java TicketGrantingTicket.grantServiceTicket方法代码示例

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


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

示例1: testUpdateOfRegistry

import org.jasig.cas.ticket.TicketGrantingTicket; //导入方法依赖的package包/类
@Test
public void testUpdateOfRegistry() {
    final TicketGrantingTicket t = new TicketGrantingTicketImpl("test", TestUtils.getAuthentication(),
            new NeverExpiresExpirationPolicy());
    this.ticketRegistry.addTicket(t);
    final TicketGrantingTicket returned = (TicketGrantingTicket) this.ticketRegistry.getTicket("test");

    final ServiceTicket s = returned.grantServiceTicket("test2", TestUtils.getService(),
            new NeverExpiresExpirationPolicy(), true);

    this.ticketRegistry.addTicket(s);
    final ServiceTicket s2 = (ServiceTicket) this.ticketRegistry.getTicket("test2");
    assertNotNull(s2.grantTicketGrantingTicket("ff", TestUtils.getAuthentication(),
            new NeverExpiresExpirationPolicy()));

    assertTrue(s2.isValidFor(TestUtils.getService()));
    assertTrue(this.wasTicketUpdated);

    returned.markTicketExpired();
    assertTrue(t.isExpired());
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:22,代码来源:DistributedTicketRegistryTests.java

示例2: verifyGetTicketsFromRegistryEqualToTicketsAdded

import org.jasig.cas.ticket.TicketGrantingTicket; //导入方法依赖的package包/类
@Test
public void verifyGetTicketsFromRegistryEqualToTicketsAdded() {
    final Collection<Ticket> tickets = new ArrayList<>();

    for (int i = 0; i < TICKETS_IN_REGISTRY; i++) {
        final TicketGrantingTicket ticketGrantingTicket = new TicketGrantingTicketImpl("TEST" + i,
                TestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
        final ServiceTicket st = ticketGrantingTicket.grantServiceTicket("tests" + i,
                org.jasig.cas.services.TestUtils.getService(),
                new NeverExpiresExpirationPolicy(), false, true);
        tickets.add(ticketGrantingTicket);
        tickets.add(st);
        this.ticketRegistry.addTicket(ticketGrantingTicket);
        this.ticketRegistry.addTicket(st);
    }

    try {
        final Collection<Ticket> ticketRegistryTickets = this.ticketRegistry.getTickets();
        assertEquals("The size of the registry is not the same as the collection.", ticketRegistryTickets.size(),
                tickets.size());

        for (final Ticket ticket : tickets) {
            if (!ticketRegistryTickets.contains(ticket)) {
                fail("Ticket was added to registry but was not found in retrieval of collection of all tickets.");
            }
        }
    } catch (final Exception e) {
        logger.error(e.getMessage(), e);
        fail("Caught an exception. But no exception should have been thrown.");
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:32,代码来源:EhCacheTicketRegistryTests.java

示例3: newST

import org.jasig.cas.ticket.TicketGrantingTicket; //导入方法依赖的package包/类
static ServiceTicket newST(final TicketGrantingTicket parent) {
   return parent.grantServiceTicket(
           ID_GENERATOR.getNewTicketId("ST"),
           new MockService("https://service.example.com"),
           EXP_POLICY_ST,
           false);
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:8,代码来源:JpaTicketRegistryTests.java

示例4: verifyDeleteTicketWithPGT

import org.jasig.cas.ticket.TicketGrantingTicket; //导入方法依赖的package包/类
@Test
public void verifyDeleteTicketWithPGT() {
    final Authentication a = TestUtils.getAuthentication();
    this.ticketRegistry.addTicket(new TicketGrantingTicketImpl(
            "TGT", a, new NeverExpiresExpirationPolicy()));
    final TicketGrantingTicket tgt = this.ticketRegistry.getTicket(
            "TGT", TicketGrantingTicket.class);

    final Service service = org.jasig.cas.services.TestUtils.getService("TGT_DELETE_TEST");

    final ServiceTicket st1 = tgt.grantServiceTicket(
            "ST1", service, new NeverExpiresExpirationPolicy(), true, false);

    this.ticketRegistry.addTicket(st1);

    assertNotNull(this.ticketRegistry.getTicket("TGT", TicketGrantingTicket.class));
    assertNotNull(this.ticketRegistry.getTicket("ST1", ServiceTicket.class));

    final TicketGrantingTicket pgt = st1.grantProxyGrantingTicket("PGT-1", a, new NeverExpiresExpirationPolicy());
    assertEquals(a, pgt.getAuthentication());

    this.ticketRegistry.addTicket(pgt);
    assertTrue("TGT and children were deleted", this.ticketRegistry.deleteTicket(tgt.getId()) == 3);

    assertNull(this.ticketRegistry.getTicket("TGT", TicketGrantingTicket.class));
    assertNull(this.ticketRegistry.getTicket("ST1", ServiceTicket.class));
    assertNull(this.ticketRegistry.getTicket("PGT-1", ServiceTicket.class));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:29,代码来源:EhCacheTicketRegistryTests.java

示例5: verifyProxiedInstancesEqual

import org.jasig.cas.ticket.TicketGrantingTicket; //导入方法依赖的package包/类
@Test
public void verifyProxiedInstancesEqual() {
    final TicketGrantingTicket t = new TicketGrantingTicketImpl("test",
            org.jasig.cas.authentication.TestUtils.getAuthentication(),
            new NeverExpiresExpirationPolicy());
    this.ticketRegistry.addTicket(t);

    final TicketGrantingTicket returned = (TicketGrantingTicket) this.ticketRegistry.getTicket("test");
    assertEquals(t, returned);
    assertEquals(returned, t);

    assertEquals(t.getCreationTime(), returned.getCreationTime());
    assertEquals(t.getAuthentication(), returned.getAuthentication());
    assertEquals(t.getCountOfUses(), returned.getCountOfUses());
    assertEquals(t.getGrantingTicket(), returned.getGrantingTicket());
    assertEquals(t.getId(), returned.getId());
    assertEquals(t.getChainedAuthentications(), returned.getChainedAuthentications());
    assertEquals(t.isExpired(), returned.isExpired());
    assertEquals(t.isRoot(), returned.isRoot());

    final ServiceTicket s = t.grantServiceTicket("stest", org.jasig.cas.services.TestUtils.getService(),
            new NeverExpiresExpirationPolicy(), false, true);
    this.ticketRegistry.addTicket(s);

    final ServiceTicket sreturned = (ServiceTicket) this.ticketRegistry.getTicket("stest");
    assertEquals(s, sreturned);
    assertEquals(sreturned, s);

    assertEquals(s.getCreationTime(), sreturned.getCreationTime());
    assertEquals(s.getCountOfUses(), sreturned.getCountOfUses());
    assertEquals(s.getGrantingTicket(), sreturned.getGrantingTicket());
    assertEquals(s.getId(), sreturned.getId());
    assertEquals(s.isExpired(), sreturned.isExpired());
    assertEquals(s.getService(), sreturned.getService());
    assertEquals(s.isFromNewLogin(), sreturned.isFromNewLogin());
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:37,代码来源:DistributedTicketRegistryTests.java

示例6: verifyDeleteTicketWithChildren

import org.jasig.cas.ticket.TicketGrantingTicket; //导入方法依赖的package包/类
@Test
public void verifyDeleteTicketWithChildren() {
    this.ticketRegistry.addTicket(new TicketGrantingTicketImpl(
            "TGT", TestUtils.getAuthentication(), new NeverExpiresExpirationPolicy()));
    final TicketGrantingTicket tgt = this.ticketRegistry.getTicket(
            "TGT", TicketGrantingTicket.class);

    final Service service = org.jasig.cas.services.TestUtils.getService("TGT_DELETE_TEST");

    final ServiceTicket st1 = tgt.grantServiceTicket(
            "ST1", service, new NeverExpiresExpirationPolicy(), true, false);
    final ServiceTicket st2 = tgt.grantServiceTicket(
            "ST2", service, new NeverExpiresExpirationPolicy(), true, false);
    final ServiceTicket st3 = tgt.grantServiceTicket(
            "ST3", service, new NeverExpiresExpirationPolicy(), true, false);

    this.ticketRegistry.addTicket(st1);
    this.ticketRegistry.addTicket(st2);
    this.ticketRegistry.addTicket(st3);

    assertNotNull(this.ticketRegistry.getTicket("TGT", TicketGrantingTicket.class));
    assertNotNull(this.ticketRegistry.getTicket("ST1", ServiceTicket.class));
    assertNotNull(this.ticketRegistry.getTicket("ST2", ServiceTicket.class));
    assertNotNull(this.ticketRegistry.getTicket("ST3", ServiceTicket.class));

    this.ticketRegistry.deleteTicket(tgt.getId());

    assertNull(this.ticketRegistry.getTicket("TGT", TicketGrantingTicket.class));
    assertNull(this.ticketRegistry.getTicket("ST1", ServiceTicket.class));
    assertNull(this.ticketRegistry.getTicket("ST2", ServiceTicket.class));
    assertNull(this.ticketRegistry.getTicket("ST3", ServiceTicket.class));
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:33,代码来源:EhCacheTicketRegistryTests.java

示例7: verifyProxiedInstancesEqual

import org.jasig.cas.ticket.TicketGrantingTicket; //导入方法依赖的package包/类
@Test
public void verifyProxiedInstancesEqual() {
    final TicketGrantingTicket t = new TicketGrantingTicketImpl("test", TestUtils.getAuthentication(),
            new NeverExpiresExpirationPolicy());
    this.ticketRegistry.addTicket(t);

    final TicketGrantingTicket returned = (TicketGrantingTicket) this.ticketRegistry.getTicket("test");
    assertEquals(t, returned);
    assertEquals(returned, t);

    assertEquals(t.getCreationTime(), returned.getCreationTime());
    assertEquals(t.getAuthentication(), returned.getAuthentication());
    assertEquals(t.getCountOfUses(), returned.getCountOfUses());
    assertEquals(t.getGrantingTicket(), returned.getGrantingTicket());
    assertEquals(t.getId(), returned.getId());
    assertEquals(t.getChainedAuthentications(), returned.getChainedAuthentications());
    assertEquals(t.isExpired(), returned.isExpired());
    assertEquals(t.isRoot(), returned.isRoot());

    final ServiceTicket s = t.grantServiceTicket("stest", TestUtils.getService(),
            new NeverExpiresExpirationPolicy(), false);
    this.ticketRegistry.addTicket(s);

    final ServiceTicket sreturned = (ServiceTicket) this.ticketRegistry.getTicket("stest");
    assertEquals(s, sreturned);
    assertEquals(sreturned, s);

    assertEquals(s.getCreationTime(), sreturned.getCreationTime());
    assertEquals(s.getCountOfUses(), sreturned.getCountOfUses());
    assertEquals(s.getGrantingTicket(), sreturned.getGrantingTicket());
    assertEquals(s.getId(), sreturned.getId());
    assertEquals(s.isExpired(), sreturned.isExpired());
    assertEquals(s.getService(), sreturned.getService());
    assertEquals(s.isFromNewLogin(), sreturned.isFromNewLogin());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:36,代码来源:DistributedTicketRegistryTests.java

示例8: newST

import org.jasig.cas.ticket.TicketGrantingTicket; //导入方法依赖的package包/类
static ServiceTicket newST(final TicketGrantingTicket parent) {
   return parent.grantServiceTicket(
           ID_GENERATOR.getNewTicketId(ServiceTicket.PREFIX),
           new MockService("https://service.example.com"),
           EXP_POLICY_ST,
           false,
           true);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:9,代码来源:JpaTicketRegistryTests.java

示例9: verifyEncodeDecodeTGTWithSingleton

import org.jasig.cas.ticket.TicketGrantingTicket; //导入方法依赖的package包/类
@Test
public void verifyEncodeDecodeTGTWithSingleton() throws Exception {
    final Map<String, Object> newAttributes = new HashMap<>();
    newAttributes.put(NICKNAME_KEY, Collections.singleton(NICKNAME_VALUE));
    final Credential userPassCredential = new UsernamePasswordCredential(USERNAME, PASSWORD);
    final TicketGrantingTicket expectedTGT = new MockTicketGrantingTicket(TGT_ID, userPassCredential, newAttributes);
    expectedTGT.grantServiceTicket(ST_ID, null, null, false, true);
    assertEquals(expectedTGT, transcoder.decode(transcoder.encode(expectedTGT)));
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:10,代码来源:KryoTranscoderTests.java

示例10: verifyEncodeDecodeTGTWithUnmodifiableSet

import org.jasig.cas.ticket.TicketGrantingTicket; //导入方法依赖的package包/类
@Test
public void verifyEncodeDecodeTGTWithUnmodifiableSet() throws Exception {
    final Map<String, Object> newAttributes = new HashMap<>();
    final Set<String> values = new HashSet<>();
    values.add(NICKNAME_VALUE);
    newAttributes.put(NICKNAME_KEY, Collections.unmodifiableSet(values));
    final Credential userPassCredential = new UsernamePasswordCredential(USERNAME, PASSWORD);
    final TicketGrantingTicket expectedTGT = new MockTicketGrantingTicket(TGT_ID, userPassCredential, newAttributes);
    expectedTGT.grantServiceTicket(ST_ID, null, null, false, true);
    assertEquals(expectedTGT, transcoder.decode(transcoder.encode(expectedTGT)));
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:12,代码来源:KryoTranscoderTests.java

示例11: verifyEncodeDecodeTGTWithLinkedHashMap

import org.jasig.cas.ticket.TicketGrantingTicket; //导入方法依赖的package包/类
@Test
public void verifyEncodeDecodeTGTWithLinkedHashMap() throws Exception {
    final Credential userPassCredential = new UsernamePasswordCredential(USERNAME, PASSWORD);
    final TicketGrantingTicket expectedTGT =
            new MockTicketGrantingTicket(TGT_ID, userPassCredential, new LinkedHashMap<String, Object>(this.principalAttributes));
    expectedTGT.grantServiceTicket(ST_ID, null, null, false);
    assertEquals(expectedTGT, transcoder.decode(transcoder.encode(expectedTGT)));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:9,代码来源:KryoTranscoderTests.java

示例12: verifyDeleteTicketWithChildren

import org.jasig.cas.ticket.TicketGrantingTicket; //导入方法依赖的package包/类
@Test
public void verifyDeleteTicketWithChildren() throws Exception {
    this.hzTicketRegistry1.addTicket(new TicketGrantingTicketImpl(
            "TGT", org.jasig.cas.authentication.TestUtils.getAuthentication(), new NeverExpiresExpirationPolicy()));
    final TicketGrantingTicket tgt = this.hzTicketRegistry1.getTicket(
            "TGT", TicketGrantingTicket.class);

    final Service service = TestUtils.getService("TGT_DELETE_TEST");

    final ServiceTicket st1 = tgt.grantServiceTicket(
            "ST1", service, new NeverExpiresExpirationPolicy(), true, false);
    final ServiceTicket st2 = tgt.grantServiceTicket(
            "ST2", service, new NeverExpiresExpirationPolicy(), true, false);
    final ServiceTicket st3 = tgt.grantServiceTicket(
            "ST3", service, new NeverExpiresExpirationPolicy(), true, false);

    this.hzTicketRegistry1.addTicket(st1);
    this.hzTicketRegistry1.addTicket(st2);
    this.hzTicketRegistry1.addTicket(st3);

    assertNotNull(this.hzTicketRegistry1.getTicket(tgt.getId(), TicketGrantingTicket.class));
    assertNotNull(this.hzTicketRegistry1.getTicket("ST1", ServiceTicket.class));
    assertNotNull(this.hzTicketRegistry1.getTicket("ST2", ServiceTicket.class));
    assertNotNull(this.hzTicketRegistry1.getTicket("ST3", ServiceTicket.class));

    assertTrue("TGT and children were deleted", this.hzTicketRegistry1.deleteTicket(tgt.getId()) > 0);

    assertNull(this.hzTicketRegistry1.getTicket(tgt.getId(), TicketGrantingTicket.class));
    assertNull(this.hzTicketRegistry1.getTicket("ST1", ServiceTicket.class));
    assertNull(this.hzTicketRegistry1.getTicket("ST2", ServiceTicket.class));
    assertNull(this.hzTicketRegistry1.getTicket("ST3", ServiceTicket.class));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:33,代码来源:HazelcastTicketRegistryTests.java

示例13: verifyDeleteTicketWithPGT

import org.jasig.cas.ticket.TicketGrantingTicket; //导入方法依赖的package包/类
@Test
public void verifyDeleteTicketWithPGT() {
    final Authentication a = org.jasig.cas.authentication.TestUtils.getAuthentication();
    this.hzTicketRegistry1.addTicket(new TicketGrantingTicketImpl(
            "TGT", a, new NeverExpiresExpirationPolicy()));
    final TicketGrantingTicket tgt = this.hzTicketRegistry1.getTicket(
            "TGT", TicketGrantingTicket.class);

    final Service service = org.jasig.cas.services.TestUtils.getService("TGT_DELETE_TEST");

    final ServiceTicket st1 = tgt.grantServiceTicket(
            "ST1", service, new NeverExpiresExpirationPolicy(), true, false);

    this.hzTicketRegistry1.addTicket(st1);

    assertNotNull(this.hzTicketRegistry1.getTicket("TGT", TicketGrantingTicket.class));
    assertNotNull(this.hzTicketRegistry1.getTicket("ST1", ServiceTicket.class));

    final TicketGrantingTicket pgt = st1.grantProxyGrantingTicket("PGT-1", a, new NeverExpiresExpirationPolicy());
    assertEquals(a, pgt.getAuthentication());

    assertTrue("TGT and children were deleted", this.hzTicketRegistry1.deleteTicket(tgt.getId()) > 0);

    assertNull(this.hzTicketRegistry1.getTicket("TGT", TicketGrantingTicket.class));
    assertNull(this.hzTicketRegistry1.getTicket("ST1", ServiceTicket.class));
    assertNull(this.hzTicketRegistry1.getTicket("PGT-1", ServiceTicket.class));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:28,代码来源:HazelcastTicketRegistryTests.java

示例14: verifyEncodeDecodeTGTImpl

import org.jasig.cas.ticket.TicketGrantingTicket; //导入方法依赖的package包/类
@Test
public void verifyEncodeDecodeTGTImpl() throws Exception {
    final Credential userPassCredential = new UsernamePasswordCredential(USERNAME, PASSWORD);
    final AuthenticationBuilder bldr = new DefaultAuthenticationBuilder(
            new DefaultPrincipalFactory()
                    .createPrincipal("user", Collections.unmodifiableMap(this.principalAttributes)));
    bldr.setAttributes(Collections.unmodifiableMap(this.principalAttributes));
    bldr.setAuthenticationDate(new DateTime());
    bldr.addCredential(new BasicCredentialMetaData(userPassCredential));
    bldr.addFailure("error", AccountNotFoundException.class);
    bldr.addSuccess("authn", new DefaultHandlerResult(
            new AcceptUsersAuthenticationHandler(),
            new BasicCredentialMetaData(userPassCredential)));

    final TicketGrantingTicket expectedTGT =
            new TicketGrantingTicketImpl(TGT_ID,
                    org.jasig.cas.services.TestUtils.getService(),
                    null, bldr.build(),
                    new NeverExpiresExpirationPolicy());

    final ServiceTicket ticket = expectedTGT.grantServiceTicket(ST_ID,
            org.jasig.cas.services.TestUtils.getService(),
            new NeverExpiresExpirationPolicy(), false, true);
    CachedData result = transcoder.encode(expectedTGT);
    final TicketGrantingTicket resultTicket = (TicketGrantingTicket) transcoder.decode(result);

    assertEquals(expectedTGT, resultTicket);
    result = transcoder.encode(ticket);
    final ServiceTicket resultStTicket = (ServiceTicket) transcoder.decode(result);
    assertEquals(ticket, resultStTicket);

}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:33,代码来源:KryoTranscoderTests.java

示例15: verifyDeleteTicketWithPGT

import org.jasig.cas.ticket.TicketGrantingTicket; //导入方法依赖的package包/类
@Test
public void verifyDeleteTicketWithPGT() {
    final Authentication a = TestUtils.getAuthentication();
    this.registry.addTicket(new TicketGrantingTicketImpl(
            "TGT", a, new NeverExpiresExpirationPolicy()));
    final TicketGrantingTicket tgt = this.registry.getTicket(
            "TGT", TicketGrantingTicket.class);

    final Service service = TestUtils.getService("TGT_DELETE_TEST");

    final ServiceTicket st1 = tgt.grantServiceTicket(
            "ST1", service, new NeverExpiresExpirationPolicy(), true, false);

    this.registry.addTicket(st1);

    assertNotNull(this.registry.getTicket("TGT", TicketGrantingTicket.class));
    assertNotNull(this.registry.getTicket("ST1", ServiceTicket.class));

    final TicketGrantingTicket pgt = st1.grantProxyGrantingTicket("PGT-1", a, new NeverExpiresExpirationPolicy());
    assertEquals(a, pgt.getAuthentication());
    
    assertTrue("TGT and children were deleted", this.registry.deleteTicket(tgt.getId()) == 3);
    
    assertNull(this.registry.getTicket("TGT", TicketGrantingTicket.class));
    assertNull(this.registry.getTicket("ST1", ServiceTicket.class));
    assertNull(this.registry.getTicket("PGT-1", ServiceTicket.class));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:28,代码来源:MemCacheTicketRegistryTests.java


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