Skip to content
This repository has been archived by the owner on Apr 27, 2021. It is now read-only.

Commit

Permalink
#21 x509 LifecycleManager
Browse files Browse the repository at this point in the history
  • Loading branch information
rwinch committed Jun 10, 2013
1 parent c83f922 commit d2b4216
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
* @author Rob Winch
* @since 3.2
*/
public final class X509Configurator extends SecurityConfiguratorAdapter<DefaultSecurityFilterChain, HttpConfiguration> {
public final class X509Configurator extends BaseHttpConfigurator {
private X509AuthenticationFilter x509AuthenticationFilter;
private AuthenticationUserDetailsService<PreAuthenticatedAuthenticationToken> authenticationUserDetailsService;
private String subjectPrincipalRegex;
Expand Down Expand Up @@ -170,7 +170,7 @@ private X509AuthenticationFilter getFilter(
if(authenticationDetailsSource != null) {
x509AuthenticationFilter.setAuthenticationDetailsSource(authenticationDetailsSource);
}
x509AuthenticationFilter.afterPropertiesSet();
x509AuthenticationFilter = registerLifecycle(x509AuthenticationFilter);
}

return x509AuthenticationFilter;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.security.config.annotation.web

import org.springframework.security.config.annotation.BaseSpringSpec
import org.springframework.security.config.annotation.authentication.AuthenticationManagerBuilder
import org.springframework.security.web.authentication.preauth.x509.X509AuthenticationFilter;
import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter
import org.springframework.security.web.session.ConcurrentSessionFilter;
import org.springframework.security.web.session.SessionManagementFilter;

/**
*
* @author Rob Winch
*/
class X509ConfiguratorTests extends BaseSpringSpec {

def "x509 LifecycleManager"() {
setup:
LifecycleManager lifecycleManager = Mock()
HttpConfiguration http = new HttpConfiguration(lifecycleManager, authenticationBldr)
when:
http
.x509()
.and()
.build()

then: "X509AuthenticationFilter is registered with LifecycleManager"
1 * lifecycleManager.registerLifecycle(_ as X509AuthenticationFilter) >> {X509AuthenticationFilter o -> o}
}
}

0 comments on commit d2b4216

Please sign in to comment.