本文整理汇总了Java中org.jasig.cas.client.validation.Cas30ServiceTicketValidator类的典型用法代码示例。如果您正苦于以下问题:Java Cas30ServiceTicketValidator类的具体用法?Java Cas30ServiceTicketValidator怎么用?Java Cas30ServiceTicketValidator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Cas30ServiceTicketValidator类属于org.jasig.cas.client.validation包,在下文中一共展示了Cas30ServiceTicketValidator类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateRequestAndBuildCasAssertion
import org.jasig.cas.client.validation.Cas30ServiceTicketValidator; //导入依赖的package包/类
private Assertion validateRequestAndBuildCasAssertion(final HttpServletResponse response,
final HttpServletRequest request,
final Pair<AuthnRequest, MessageContext> pair) throws Exception {
final AuthnRequest authnRequest = pair.getKey();
final String ticket = CommonUtils.safeGetParameter(request, CasProtocolConstants.PARAMETER_TICKET);
final Cas30ServiceTicketValidator validator = new Cas30ServiceTicketValidator(this.serverPrefix);
final HttpsURLConnectionFactory factory = new HttpsURLConnectionFactory();
factory.setHostnameVerifier(this.hostnameVerifier);
validator.setURLConnectionFactory(factory);
validator.setRenew(authnRequest.isForceAuthn());
final String serviceUrl = constructServiceUrl(request, response, pair);
LOGGER.debug("Created service url for validation: [{}]", serviceUrl);
final Assertion assertion = validator.validate(ticket, serviceUrl);
logCasValidationAssertion(assertion);
return assertion;
}
示例2: validateRequestAndBuildCasAssertion
import org.jasig.cas.client.validation.Cas30ServiceTicketValidator; //导入依赖的package包/类
private Assertion validateRequestAndBuildCasAssertion(final HttpServletResponse response,
final HttpServletRequest request,
final WSFederationRequest fedRequest) throws Exception {
final String ticket = CommonUtils.safeGetParameter(request, CasProtocolConstants.PARAMETER_TICKET);
final Cas30ServiceTicketValidator validator = new Cas30ServiceTicketValidator(casProperties.getServer().getPrefix());
final String serviceUrl = constructServiceUrl(request, response, fedRequest);
LOGGER.debug("Created service url for validation: [{}]", serviceUrl);
final Assertion assertion = validator.validate(ticket, serviceUrl);
LOGGER.debug("Located CAS assertion [{}]", assertion);
return assertion;
}
示例3: generateToken
import org.jasig.cas.client.validation.Cas30ServiceTicketValidator; //导入依赖的package包/类
/**
* Generate token string.
*
* @param service the service
* @param parameters the parameters
* @return the jwt
*/
protected String generateToken(final Service service, final Map<String, String> parameters) {
try {
final String ticketId = parameters.get(CasProtocolConstants.PARAMETER_TICKET);
final Cas30ServiceTicketValidator validator = new Cas30ServiceTicketValidator(casProperties.getServer().getPrefix());
final Assertion assertion = validator.validate(ticketId, service.getId());
final JWTClaimsSet.Builder claims =
new JWTClaimsSet.Builder()
.audience(service.getId())
.issuer(casProperties.getServer().getPrefix())
.jwtID(ticketId)
.issueTime(assertion.getAuthenticationDate())
.subject(assertion.getPrincipal().getName());
assertion.getAttributes().forEach(claims::claim);
assertion.getPrincipal().getAttributes().forEach(claims::claim);
if (assertion.getValidUntilDate() != null) {
claims.expirationTime(assertion.getValidUntilDate());
} else {
final ZonedDateTime dt = ZonedDateTime.now().plusSeconds(ticketGrantingTicketExpirationPolicy.getTimeToLive());
claims.expirationTime(DateTimeUtils.dateOf(dt));
}
final JWTClaimsSet claimsSet = claims.build();
final JSONObject object = claimsSet.toJSONObject();
return tokenCipherExecutor.encode(object.toJSONString());
} catch (final Exception e) {
throw Throwables.propagate(e);
}
}
示例4: build
import org.jasig.cas.client.validation.Cas30ServiceTicketValidator; //导入依赖的package包/类
@Override
public TicketValidator build() {
Cas30ServiceTicketValidator ticketValidator = new Cas30ServiceTicketValidator(casServerUrlPrefix);
if (proxyChainsValidation != null) {
logger.warn(OMISSION_MESSAGE_TEMPLATE, "proxyChainsValidation");
}
if (proxyChains != null) {
logger.warn(OMISSION_MESSAGE_TEMPLATE, "proxyChains");
}
if (allowEmptyProxyChain != null) {
logger.warn(OMISSION_MESSAGE_TEMPLATE, "allowEmptyProxyChain");
}
super.configure(ticketValidator);
return ticketValidator;
}
示例5: internalInit
import org.jasig.cas.client.validation.Cas30ServiceTicketValidator; //导入依赖的package包/类
@Override
protected void internalInit(final WebContext context) {
CommonHelper.assertNotBlank("casServerPrefixUrl", this.casServerPrefixUrl);
if (CommonHelper.isBlank(casRestUrl)) {
casRestUrl = casServerPrefixUrl;
if (!casRestUrl.endsWith("/")) {
casRestUrl += "/";
}
casRestUrl += "v1/tickets";
}
if (this.ticketValidator == null) {
this.ticketValidator = new Cas30ServiceTicketValidator(this.casServerPrefixUrl);
}
}
示例6: testDoGetPassiveAndForced
import org.jasig.cas.client.validation.Cas30ServiceTicketValidator; //导入依赖的package包/类
@Test
public void testDoGetPassiveAndForced() throws Exception {
//Mock some objects.
HttpServletRequest request = createDoGetHttpServletRequest(CONVERSATION_TICKET_GATEWAY_ATTEMPTED, TICKET, "true");
HttpServletResponse response = createMockHttpServletResponse();
Assertion assertion = createMockAssertion();
Cas20ServiceTicketValidator ticketValidator = PowerMockito.mock(Cas30ServiceTicketValidator.class);
PowerMockito.when(ticketValidator.validate(TICKET, URL_WITH_CONVERSATION_GATEWAY_ATTEMPTED)).thenReturn(assertion);
PowerMockito.mockStatic(ExternalAuthentication.class);
BDDMockito.given(ExternalAuthentication.startExternalAuthentication(request)).willReturn(E1S1);
//Prep our object
ShibcasAuthServlet shibcasAuthServlet = createShibcasAuthServlet();
//Override the internal Cas30TicketValidator because we don't want it to call a real server
MemberModifier.field(ShibcasAuthServlet.class, "ticketValidator").set(shibcasAuthServlet, ticketValidator);
//Passive and forced request/response
BDDMockito.given(request.getAttribute(ExternalAuthentication.FORCE_AUTHN_PARAM)).willReturn("true");
BDDMockito.given(request.getAttribute(ExternalAuthentication.PASSIVE_AUTHN_PARAM)).willReturn("true");
shibcasAuthServlet.doGet(request, response);
//Verify
verify(request).setAttribute(ExternalAuthentication.PRINCIPAL_NAME_KEY, JDOE);
}
示例7: ticketValidator
import org.jasig.cas.client.validation.Cas30ServiceTicketValidator; //导入依赖的package包/类
@Bean
public Cas30ServiceTicketValidator ticketValidator() {
Cas30ServiceTicketValidator validator = new Cas30ServiceTicketValidator(loginProperties.getCasUrl());
validator.setEncoding("UTF-8");
return validator;
}