use of hudson.util.spring.BeanBuilder in project hudson-2.x by hudson.
the class LegacySecurityRealm method createFilter.
/**
* Filter to run for the LegacySecurityRealm is the
* ChainServletFilter legacy from /WEB-INF/security/SecurityFilters.groovy.
*/
@Override
public Filter createFilter(FilterConfig filterConfig) {
Binding binding = new Binding();
SecurityComponents sc = this.createSecurityComponents();
binding.setVariable("securityComponents", sc);
binding.setVariable("securityRealm", this);
BeanBuilder builder = new BeanBuilder();
builder.parse(filterConfig.getServletContext().getResourceAsStream("/WEB-INF/security/SecurityFilters.groovy"), binding);
WebApplicationContext context = builder.createApplicationContext();
return (Filter) context.getBean("legacy");
}
use of hudson.util.spring.BeanBuilder in project hudson-2.x by hudson.
the class PAMSecurityRealm method createSecurityComponents.
public SecurityComponents createSecurityComponents() {
Binding binding = new Binding();
binding.setVariable("instance", this);
BeanBuilder builder = new BeanBuilder();
builder.parse(Hudson.getInstance().servletContext.getResourceAsStream("/WEB-INF/security/PAMSecurityRealm.groovy"), binding);
WebApplicationContext context = builder.createApplicationContext();
return new SecurityComponents(findBean(AuthenticationManager.class, context), new UserDetailsService() {
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
if (!UnixUser.exists(username))
throw new UsernameNotFoundException("No such Unix user: " + username);
// return some dummy instance
return new User(username, "", true, true, true, true, new GrantedAuthority[] { AUTHENTICATED_AUTHORITY });
}
});
}
use of hudson.util.spring.BeanBuilder in project hudson-2.x by hudson.
the class AbstractPasswordBasedSecurityRealm method createSecurityComponents.
@Override
public SecurityComponents createSecurityComponents() {
Binding binding = new Binding();
binding.setVariable("authenticator", new Authenticator());
BeanBuilder builder = new BeanBuilder();
builder.parse(Hudson.getInstance().servletContext.getResourceAsStream("/WEB-INF/security/AbstractPasswordBasedSecurityRealm.groovy"), binding);
WebApplicationContext context = builder.createApplicationContext();
return new SecurityComponents(findBean(AuthenticationManager.class, context), this);
}
use of hudson.util.spring.BeanBuilder in project hudson-2.x by hudson.
the class SecurityRealm method createFilter.
/**
* Creates {@link Filter} that all the incoming HTTP requests will go through
* for authentication.
* <p/>
* <p/>
* The default implementation uses {@link #getSecurityComponents()} and builds
* a standard filter chain from /WEB-INF/security/SecurityFilters.groovy.
* But subclasses can override this to completely change the filter sequence.
* <p/>
* <p/>
* For other plugins that want to contribute {@link Filter}, see
* {@link PluginServletFilter}.
*
* @since 1.271
*/
public Filter createFilter(FilterConfig filterConfig) {
LOGGER.entering(SecurityRealm.class.getName(), "createFilter");
Binding binding = new Binding();
SecurityComponents sc = getSecurityComponents();
binding.setVariable("securityComponents", sc);
binding.setVariable("securityRealm", this);
BeanBuilder builder = new BeanBuilder();
builder.parse(filterConfig.getServletContext().getResourceAsStream("/WEB-INF/security/SecurityFilters.groovy"), binding);
WebApplicationContext context = builder.createApplicationContext();
return (Filter) context.getBean("filter");
}
use of hudson.util.spring.BeanBuilder in project hudson-2.x by hudson.
the class LDAPSecurityRealm method createSecurityComponents.
public SecurityComponents createSecurityComponents() {
Binding binding = new Binding();
binding.setVariable("instance", this);
BeanBuilder builder = new BeanBuilder();
builder.parse(Hudson.getInstance().servletContext.getResourceAsStream("/WEB-INF/security/LDAPBindSecurityRealm.groovy"), binding);
WebApplicationContext appContext = builder.createApplicationContext();
ldapTemplate = new LdapTemplate(findBean(InitialDirContextFactory.class, appContext));
return new SecurityComponents(findBean(AuthenticationManager.class, appContext), new LDAPUserDetailsService(appContext));
}
Aggregations