Search in sources :

Example 1 with OAuth20CodeExpirationPolicy

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;
}
Also used : lombok.val(lombok.val) MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) OAuth20Code(org.apereo.cas.ticket.code.OAuth20Code) WebApplicationServiceFactory(org.apereo.cas.authentication.principal.WebApplicationServiceFactory) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) OAuth20DefaultCasAuthenticationBuilder(org.apereo.cas.support.oauth.authenticator.OAuth20DefaultCasAuthenticationBuilder) OAuth20DefaultOAuthCodeFactory(org.apereo.cas.ticket.code.OAuth20DefaultOAuthCodeFactory) ExpirationPolicyBuilder(org.apereo.cas.ticket.ExpirationPolicyBuilder) OAuth20CodeExpirationPolicy(org.apereo.cas.ticket.code.OAuth20CodeExpirationPolicy) DefaultOAuth20ProfileScopeToAttributesFilter(org.apereo.cas.support.oauth.profile.DefaultOAuth20ProfileScopeToAttributesFilter)

Aggregations

lombok.val (lombok.val)1 WebApplicationServiceFactory (org.apereo.cas.authentication.principal.WebApplicationServiceFactory)1 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)1 MockTicketGrantingTicket (org.apereo.cas.mock.MockTicketGrantingTicket)1 OAuth20DefaultCasAuthenticationBuilder (org.apereo.cas.support.oauth.authenticator.OAuth20DefaultCasAuthenticationBuilder)1 DefaultOAuth20ProfileScopeToAttributesFilter (org.apereo.cas.support.oauth.profile.DefaultOAuth20ProfileScopeToAttributesFilter)1 ExpirationPolicyBuilder (org.apereo.cas.ticket.ExpirationPolicyBuilder)1 OAuth20Code (org.apereo.cas.ticket.code.OAuth20Code)1 OAuth20CodeExpirationPolicy (org.apereo.cas.ticket.code.OAuth20CodeExpirationPolicy)1 OAuth20DefaultOAuthCodeFactory (org.apereo.cas.ticket.code.OAuth20DefaultOAuthCodeFactory)1