use of org.apereo.cas.ticket.code.OAuth20CodeExpirationPolicy in project cas by apereo.
the class OAuth20AuthorizationCodeGrantTypeTokenRequestValidatorTests method registerTicket.
private OAuth20Code registerTicket(final OAuthRegisteredService service) throws Exception {
val builder = new OAuth20DefaultCasAuthenticationBuilder(PrincipalFactoryUtils.newPrincipalFactory(), new WebApplicationServiceFactory(), new DefaultOAuth20ProfileScopeToAttributesFilter(), new CasConfigurationProperties());
val oauthCasAuthenticationBuilderService = builder.buildService(service, null, false);
val expirationPolicy = new ExpirationPolicyBuilder() {
private static final long serialVersionUID = 3911344031977989503L;
@Override
public ExpirationPolicy buildTicketExpirationPolicy() {
return new OAuth20CodeExpirationPolicy(1, 60);
}
@Override
public Class getTicketType() {
return OAuth20Code.class;
}
};
val oauthCode = new OAuth20DefaultOAuthCodeFactory(expirationPolicy, mock(ServicesManager.class)).create(oauthCasAuthenticationBuilderService, RegisteredServiceTestUtils.getAuthentication(), new MockTicketGrantingTicket("casuser"), new HashSet<>(), null, null, "clientid12345", new HashMap<>(), OAuth20ResponseTypes.CODE, OAuth20GrantTypes.AUTHORIZATION_CODE);
this.ticketRegistry.addTicket(oauthCode);
return oauthCode;
}
Aggregations