@Before public void setUp() throws Exception { dbHelper.onSetUp(); configHelper = new GoConfigFileHelper(goConfigDao); configHelper.onSetUp(); configHelper.addPipeline( "bar", "stage", MaterialConfigsMother.defaultMaterialConfigs(), "build"); pipelineConfig = configHelper.addPipeline( "foo", "stage", MaterialConfigsMother.defaultMaterialConfigs(), "build"); configHelper.addMingleConfigToPipeline( "foo", new MingleConfig("https://some-tracking-tool:8443", "project-super-secret", "hello=world")); CruiseConfig cruiseConfig = configHelper.load(); PipelineConfigs group = cruiseConfig.findGroup("defaultGroup"); group.setAuthorization( new Authorization( new ViewConfig(new AdminUser(new CaseInsensitiveString("authorized_user"))))); configHelper.writeConfigFile(cruiseConfig); SecurityConfig securityConfig = new SecurityConfig( new LdapConfig(new GoCipher()), new PasswordFileConfig("/tmp/foo.passwd"), true); securityConfig.adminsConfig().add(new AdminUser(new CaseInsensitiveString("admin"))); configHelper.addSecurity(securityConfig); }
public AdminAndRoleSelections getAdminAndRoleSelections(List<String> users) { final SecurityConfig securityConfig = goConfigService.security(); Set<Role> roles = allRoles(securityConfig); final List<TriStateSelection> roleSelections = TriStateSelection.forRoles(roles, users); final TriStateSelection adminSelection = TriStateSelection.forSystemAdmin( securityConfig.adminsConfig(), roles, new SecurityService.UserRoleMatcherImpl(securityConfig), users); return new AdminAndRoleSelections(adminSelection, roleSelections); }
public boolean match(CaseInsensitiveString user, CaseInsensitiveString role) { return securityConfig.isUserMemberOfRole(user, role); }
private HashSet<Role> allRoles(SecurityConfig security) { return new HashSet<Role>(security.getRoles()); }