本文整理汇总了Java中org.jasig.cas.ticket.TicketGrantingTicket类的典型用法代码示例。如果您正苦于以下问题:Java TicketGrantingTicket类的具体用法?Java TicketGrantingTicket怎么用?Java TicketGrantingTicket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TicketGrantingTicket类属于org.jasig.cas.ticket包,在下文中一共展示了TicketGrantingTicket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifySsoSessionCookieOnRenewAsParameter
import org.jasig.cas.ticket.TicketGrantingTicket; //导入依赖的package包/类
@Test
public void verifySsoSessionCookieOnRenewAsParameter() throws Exception {
final MockHttpServletResponse response = new MockHttpServletResponse();
final MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(CasProtocolConstants.PARAMETER_RENEW, "true");
final TicketGrantingTicket tgt = mock(TicketGrantingTicket.class);
when(tgt.getId()).thenReturn("test");
request.setCookies(new Cookie("TGT", "test5"));
WebUtils.putTicketGrantingTicketInScopes(this.context, tgt);
this.context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
this.action.setCreateSsoSessionCookieOnRenewAuthentications(false);
assertEquals("success", this.action.execute(this.context).getId());
assertEquals(0, response.getCookies().length);
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:SendTicketGrantingTicketActionTests.java
示例2: generateSuccessView
import org.jasig.cas.ticket.TicketGrantingTicket; //导入依赖的package包/类
/**
* Generate the success view. The result will contain the assertion and the proxy iou.
*
* @param assertion the assertion
* @param proxyIou the proxy iou
* @param service the validated service
* @param proxyGrantingTicket the proxy granting ticket
* @return the model and view, pointed to the view name set by
*/
private ModelAndView generateSuccessView(final Assertion assertion, final String proxyIou,
final WebApplicationService service,
final TicketGrantingTicket proxyGrantingTicket) {
final ModelAndView modelAndView = getModelAndView(true, service);
modelAndView.addObject(CasViewConstants.MODEL_ATTRIBUTE_NAME_ASSERTION, assertion);
modelAndView.addObject(CasViewConstants.MODEL_ATTRIBUTE_NAME_SERVICE, service);
modelAndView.addObject(CasViewConstants.MODEL_ATTRIBUTE_NAME_PROXY_GRANTING_TICKET_IOU, proxyIou);
if (proxyGrantingTicket != null) {
modelAndView.addObject(CasViewConstants.MODEL_ATTRIBUTE_NAME_PROXY_GRANTING_TICKET, proxyGrantingTicket.getId());
}
final Map<String, ?> augmentedModelObjects = augmentSuccessViewModelObjects(assertion);
if (augmentedModelObjects != null) {
modelAndView.addAllObjects(augmentedModelObjects);
}
return modelAndView;
}
示例3: testSuccessfulServiceTicket
import org.jasig.cas.ticket.TicketGrantingTicket; //导入依赖的package包/类
@Test
public void testSuccessfulServiceTicket() throws Exception {
final MockRequestContext context = new MockRequestContext();
final MockHttpServletRequest request = new MockHttpServletRequest();
final Authentication authentication = TestUtils.getAuthentication("scootman28");
final TicketGrantingTicket t = new TicketGrantingTicketImpl("TGT-11", authentication,
new NeverExpiresExpirationPolicy());
this.ticketRegistry.addTicket(t);
request.setParameter("openid.identity", "http://openid.aol.com/scootman28");
request.setParameter("openid.return_to", "http://www.cnn.com");
final OpenIdService service = OpenIdService.createServiceFrom(request);
context.getFlowScope().put("service", service);
context.getFlowScope().put("ticketGrantingTicketId", t.getId());
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request,
new MockHttpServletResponse()));
assertEquals("success", this.action.execute(context).getId());
}
示例4: verifyValidServiceTicketAndFormatAsJson
import org.jasig.cas.ticket.TicketGrantingTicket; //导入依赖的package包/类
@Test
public void verifyValidServiceTicketAndFormatAsJson() throws Exception {
final Service svc = org.jasig.cas.authentication.TestUtils.getService("proxyService");
final AuthenticationContext ctx = org.jasig.cas.authentication.TestUtils
.getAuthenticationContext(getAuthenticationSystemSupport(), svc);
final TicketGrantingTicket tId = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final ServiceTicket sId = getCentralAuthenticationService().grantServiceTicket(tId.getId(), svc, ctx);
final MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter("service", svc.getId());
request.addParameter("ticket", sId.getId());
request.addParameter("format", ValidationResponseType.JSON.name());
final ModelAndView modelAndView = this.serviceValidateController.handleRequestInternal(request, new MockHttpServletResponse());
assertEquals(modelAndView.getViewName(), AbstractServiceValidateController.DEFAULT_SERVICE_VIEW_NAME_JSON);
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:18,代码来源:AbstractServiceValidateControllerTests.java
示例5: resolveFromInternal
import org.jasig.cas.ticket.TicketGrantingTicket; //导入依赖的package包/类
protected String resolveFromInternal(final JoinPoint joinPoint) {
final Object arg1 = joinPoint.getArgs()[0];
if (arg1 instanceof Credential) {
return arg1.toString();
} else if (arg1 instanceof String) {
final Ticket ticket = this.ticketRegistry.getTicket((String) arg1);
if (ticket instanceof ServiceTicket) {
final ServiceTicket serviceTicket = (ServiceTicket) ticket;
return serviceTicket.getGrantingTicket().getAuthentication().getPrincipal().getId();
} else if (ticket instanceof TicketGrantingTicket) {
final TicketGrantingTicket tgt = (TicketGrantingTicket) ticket;
return tgt.getAuthentication().getPrincipal().getId();
}
} else {
final SecurityContext securityContext = SecurityContextHolder.getContext();
if (securityContext != null) {
final Authentication authentication = securityContext.getAuthentication();
if (authentication != null) {
return ((UserDetails) authentication.getPrincipal()).getUsername();
}
}
}
return UNKNOWN_USER;
}
示例6: createMockTicketGrantingTicket
import org.jasig.cas.ticket.TicketGrantingTicket; //导入依赖的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
示例7: verifyValidServiceTicketWithDifferentEncodingAndIgnoringCase
import org.jasig.cas.ticket.TicketGrantingTicket; //导入依赖的package包/类
@Test
public void verifyValidServiceTicketWithDifferentEncodingAndIgnoringCase() throws Exception {
final String origSvc = "http://www.jasig.org?param=hello+world";
final Service svc = org.jasig.cas.authentication.TestUtils.getService(origSvc);
final AuthenticationContext ctx = org.jasig.cas.authentication.TestUtils
.getAuthenticationContext(getAuthenticationSystemSupport(), svc);
this.serviceValidateController.setProxyHandler(new Cas10ProxyHandler());
final TicketGrantingTicket tId = getCentralAuthenticationService()
.createTicketGrantingTicket(ctx);
final ServiceTicket sId = getCentralAuthenticationService()
.grantServiceTicket(tId.getId(), svc, ctx);
final String reqSvc = "http://WWW.JASIG.ORG?PARAM=hello%20world";
final MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter("service", org.jasig.cas.authentication.TestUtils.getService(reqSvc).getId());
request.addParameter("ticket", sId.getId());
assertEquals(AbstractServiceValidateController.DEFAULT_SERVICE_SUCCESS_VIEW_NAME,
this.serviceValidateController.handleRequestInternal(request,
new MockHttpServletResponse()).getViewName());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:26,代码来源:AbstractServiceValidateControllerTests.java
示例8: createTicketGrantingTicket
import org.jasig.cas.ticket.TicketGrantingTicket; //导入依赖的package包/类
/**
* @throws IllegalArgumentException if the credentials are null.
*/
@Audit(
action="TICKET_GRANTING_TICKET",
actionResolverName="CREATE_TICKET_GRANTING_TICKET_RESOLVER",
resourceResolverName="CREATE_TICKET_GRANTING_TICKET_RESOURCE_RESOLVER")
@Profiled(tag = "CREATE_TICKET_GRANTING_TICKET", logFailuresSeparately = false)
@Transactional(readOnly = false)
public String createTicketGrantingTicket(final Credential... credentials)
throws AuthenticationException, TicketException {
Assert.notNull(credentials, "credentials cannot be null");
final Authentication authentication = this.authenticationManager.authenticate(credentials);
final TicketGrantingTicket ticketGrantingTicket = new TicketGrantingTicketImpl(
this.ticketGrantingTicketUniqueTicketIdGenerator
.getNewTicketId(TicketGrantingTicket.PREFIX),
authentication, this.ticketGrantingTicketExpirationPolicy);
this.ticketRegistry.addTicket(ticketGrantingTicket);
return ticketGrantingTicket.getId();
}
示例9: verifyExpiredTicketGrantingTicketImpl
import org.jasig.cas.ticket.TicketGrantingTicket; //导入依赖的package包/类
@Test
public void verifyExpiredTicketGrantingTicketImpl() throws Exception {
final MockHttpServletRequest mockRequest = new MockHttpServletRequest("GET", CONTEXT
+ OAuthConstants.PROFILE_URL);
mockRequest.setParameter(OAuthConstants.ACCESS_TOKEN, TGT_ID);
final MockHttpServletResponse mockResponse = new MockHttpServletResponse();
final OAuth20WrapperController oauth20WrapperController = new OAuth20WrapperController();
final TicketRegistry ticketRegistry = mock(TicketRegistry.class);
final TicketGrantingTicket ticketGrantingTicket = mock(TicketGrantingTicket.class);
when(ticketGrantingTicket.isExpired()).thenReturn(true);
when(ticketRegistry.getTicket(TGT_ID)).thenReturn(ticketGrantingTicket);
oauth20WrapperController.setTicketRegistry(ticketRegistry);
oauth20WrapperController.afterPropertiesSet();
oauth20WrapperController.handleRequest(mockRequest, mockResponse);
assertEquals(200, mockResponse.getStatus());
assertEquals(CONTENT_TYPE, mockResponse.getContentType());
assertEquals("{\"error\":\"" + OAuthConstants.EXPIRED_ACCESS_TOKEN + "\"}", mockResponse.getContentAsString());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:19,代码来源:OAuth20ProfileControllerTests.java
示例10: verifyResolverServiceTicket
import org.jasig.cas.ticket.TicketGrantingTicket; //导入依赖的package包/类
@Test
public void verifyResolverServiceTicket() throws Exception {
final Credential c = TestUtils.getCredentialsWithSameUsernameAndPassword();
final AuthenticationContext ctx = TestUtils.getAuthenticationContext(getAuthenticationSystemSupport(), c);
final TicketGrantingTicket ticketId = getCentralAuthenticationService()
.createTicketGrantingTicket(ctx);
final ServiceTicket st = getCentralAuthenticationService().grantServiceTicket(ticketId.getId(),
TestUtils.getService(), ctx);
final TicketOrCredentialPrincipalResolver res = new TicketOrCredentialPrincipalResolver(getCentralAuthenticationService());
final JoinPoint jp = mock(JoinPoint.class);
when(jp.getArgs()).thenReturn(new Object[] {st.getId()});
final String result = res.resolveFrom(jp, null);
assertNotNull(result);
assertEquals(result, c.getId());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:20,代码来源:TicketOrCredentialPrincipalResolverTests.java
示例11: verifyUpdateOfRegistry
import org.jasig.cas.ticket.TicketGrantingTicket; //导入依赖的package包/类
@Test
public void verifyUpdateOfRegistry() {
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");
final ServiceTicket s = returned.grantServiceTicket("test2", org.jasig.cas.services.TestUtils.getService(),
new NeverExpiresExpirationPolicy(), true, true);
this.ticketRegistry.addTicket(s);
final ServiceTicket s2 = (ServiceTicket) this.ticketRegistry.getTicket("test2");
assertNotNull(s2.grantProxyGrantingTicket("ff", org.jasig.cas.authentication.TestUtils.getAuthentication(),
new NeverExpiresExpirationPolicy()));
assertTrue(s2.isValidFor(org.jasig.cas.services.TestUtils.getService()));
assertTrue(this.wasTicketUpdated);
returned.markTicketExpired();
assertTrue(t.isExpired());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:23,代码来源:DistributedTicketRegistryTests.java
示例12: verifyAllowsAccessToHighSecurityServiceWithPasswordAndOTPViaRenew
import org.jasig.cas.ticket.TicketGrantingTicket; //导入依赖的package包/类
@Test
public void verifyAllowsAccessToHighSecurityServiceWithPasswordAndOTPViaRenew() throws Exception {
// Note the original credential used to start SSO session does not satisfy security policy
final AuthenticationContext ctx = processAuthenticationAttempt(HIGH_SERVICE, newUserPassCredentials("alice", "alice"));
final TicketGrantingTicket tgt = cas.createTicketGrantingTicket(ctx);
assertNotNull(tgt);
final AuthenticationContext ctx2 = processAuthenticationAttempt(HIGH_SERVICE, newUserPassCredentials("alice", "alice"),
new OneTimePasswordCredential("alice", "31415"));
final ServiceTicket st = cas.grantServiceTicket(
tgt.getId(),
HIGH_SERVICE,
ctx2);
assertNotNull(st);
// Confirm the authentication in the assertion is the one that satisfies security policy
final Assertion assertion = cas.validateServiceTicket(st.getId(), HIGH_SERVICE);
assertEquals(2, assertion.getPrimaryAuthentication().getSuccesses().size());
assertTrue(assertion.getPrimaryAuthentication().getSuccesses().containsKey("passwordHandler"));
assertTrue(assertion.getPrimaryAuthentication().getSuccesses().containsKey("oneTimePasswordHandler"));
assertTrue(assertion.getPrimaryAuthentication().getAttributes().containsKey(
SuccessfulHandlerMetaDataPopulator.SUCCESSFUL_AUTHENTICATION_HANDLERS));
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:25,代码来源:MultifactorAuthenticationTests.java
示例13: verifySuccessfulServiceTicket
import org.jasig.cas.ticket.TicketGrantingTicket; //导入依赖的package包/类
@Test
public void verifySuccessfulServiceTicket() throws Exception {
final MockRequestContext context = new MockRequestContext();
final MockHttpServletRequest request = new MockHttpServletRequest();
final Authentication authentication = org.jasig.cas.authentication.TestUtils.getAuthentication("scootman28");
final TicketGrantingTicket t = new TicketGrantingTicketImpl("TGT-11", authentication,
new NeverExpiresExpirationPolicy());
this.ticketRegistry.addTicket(t);
request.setParameter(OpenIdProtocolConstants.OPENID_IDENTITY, "http://openid.aol.com/scootman28");
request.setParameter(OpenIdProtocolConstants.OPENID_RETURNTO, "http://www.cnn.com");
final OpenIdService service = new OpenIdServiceFactory().createService(request);
context.getFlowScope().put("service", service);
context.getFlowScope().put("ticketGrantingTicketId", t.getId());
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request,
new MockHttpServletResponse()));
assertEquals("success", this.action.execute(context).getId());
}
示例14: verifyValidServiceTicketWithValidPgtNoProxyHandling
import org.jasig.cas.ticket.TicketGrantingTicket; //导入依赖的package包/类
@Test
public void verifyValidServiceTicketWithValidPgtNoProxyHandling() throws Exception {
this.serviceValidateController.setProxyHandler(new Cas10ProxyHandler());
final TicketGrantingTicket tId = getCentralAuthenticationService()
.createTicketGrantingTicket(TestUtils.getCredentialsWithSameUsernameAndPassword());
final ServiceTicket sId = getCentralAuthenticationService()
.grantServiceTicket(tId.getId(), TestUtils.getService());
final MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter("service", TestUtils.getService().getId());
request.addParameter("ticket", sId.getId());
request.addParameter("pgtUrl", "https://www.github.com");
assertEquals(ServiceValidateController.DEFAULT_SERVICE_SUCCESS_VIEW_NAME,
this.serviceValidateController.handleRequestInternal(request,
new MockHttpServletResponse()).getViewName());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:18,代码来源:AbstractServiceValidateControllerTests.java
示例15: authenticate
import org.jasig.cas.ticket.TicketGrantingTicket; //导入依赖的package包/类
@Override
public HandlerResult authenticate(final Credential credential) throws GeneralSecurityException {
final OpenIdCredential c = (OpenIdCredential) credential;
final TicketGrantingTicket t = this.ticketRegistry.getTicket(c.getTicketGrantingTicketId(),
TicketGrantingTicket.class);
if (t == null || t.isExpired()) {
throw new FailedLoginException("TGT is null or expired.");
}
final Principal principal = t.getAuthentication().getPrincipal();
if (!principal.getId().equals(c.getUsername())) {
throw new FailedLoginException("Principal ID mismatch");
}
return new HandlerResult(this, new BasicCredentialMetaData(c), principal);
}