Examples of GeoServerUserGroupService


Examples of org.geoserver.security.GeoServerUserGroupService

   
    @Test
    public void testUserGroupServiceEncoder() throws Exception {
       
        GeoServerUserGroupService service = getSecurityManager().
                loadUserGroupService(XMLUserGroupService.DEFAULT_NAME);
       
        //getPBEPasswordEncoder();

//        boolean fail = true;
//        try {
//            encoder.initializeFor(service);
//        } catch (IOException ex){
//            fail = false;
//        }
//        assertFalse(fail);
       
        String password = "testpassword";
        char [] passwordArray = password.toCharArray();
        KeyStoreProvider keyStoreProvider = getSecurityManager().getKeyStoreProvider();
        keyStoreProvider.setUserGroupKey(service.getName(), password.toCharArray());
       
        GeoServerMultiplexingPasswordEncoder encoder3 = new GeoServerMultiplexingPasswordEncoder(getSecurityManager(),service);
       
        for (GeoServerPBEPasswordEncoder encoder: getPBEEncoders()) {
            encoder.initializeFor(service);
                        
            assertEquals(PasswordEncodingType.ENCRYPT,encoder.getEncodingType());
            assertEquals(encoder.getKeyAliasInKeyStore(),
                keyStoreProvider.aliasForGroupService(service.getName()));

            GeoServerPBEPasswordEncoder encoder2 = (GeoServerPBEPasswordEncoder)
                getSecurityManager().loadPasswordEncoder(encoder.getName());
            encoder2.initializeFor(service);
       
View Full Code Here

Examples of org.geoserver.security.GeoServerUserGroupService

    }
   
    public GeoServerUserGroupService createUserGroupService(String name,String passwordEncoderName) throws Exception {
        MemoryUserGroupServiceConfigImpl config =  getUserGroupConfg(name, passwordEncoderName);        
        GeoServerUserGroupService service = new MemoryUserGroupService();
        service.setSecurityManager(GeoServerExtensions.bean(GeoServerSecurityManager.class));
        service.initializeFromConfig(config);
        getSecurityManager().saveUserGroupService(config/*,isNewUGService(name)*/);
        return service;

    }
View Full Code Here

Examples of org.geoserver.security.GeoServerUserGroupService

    }


    @Test
    public void testDecodingUserDetailsService() throws Exception {
        GeoServerUserGroupService service = createUserGroupService("test");       
        DecodingUserDetailsService decService = DecodingUserDetailsService.newInstance(service);
        GeoServerUserGroupStore store = createStore(service);
        insertValues(store);
        store.store();
       
        String plainpassword = "geoserver";
        UserDetails admin =  service.loadUserByUsername(GeoServerUser.ADMIN_USERNAME);       
        assertFalse(plainpassword.equals(admin.getPassword()));
        UserDetails admin2 =  decService.loadUserByUsername(GeoServerUser.ADMIN_USERNAME);
        assertTrue(plainpassword.equals(admin2.getPassword()));
    }
View Full Code Here

Examples of org.geoserver.security.GeoServerUserGroupService

    @Test
    public void testCopyFrom() {
        try {
   
            // from crypt tp crytp
            GeoServerUserGroupService service1 = createUserGroupService("copyFrom");
            GeoServerUserGroupService service2 = createUserGroupService("copyTo");           
            copyFrom(service1,service2);
           
            // from plain to plain
            service1 = createUserGroupService("copyFrom1",getPlainTextPasswordEncoder().getName());
            service2 = createUserGroupService("copyTo1",getPlainTextPasswordEncoder().getName());           
View Full Code Here

Examples of org.geoserver.security.GeoServerUserGroupService

    protected UserGroupStoreValidationWrapper createStore(String name) throws IOException {
        MemoryUserGroupServiceConfigImpl config = new MemoryUserGroupServiceConfigImpl();        
        config.setName(name);       
        config.setPasswordEncoderName(getPBEPasswordEncoder().getName());
        config.setPasswordPolicyName(PasswordValidator.DEFAULT_NAME);
        GeoServerUserGroupService service = new MemoryUserGroupService();
        service.setSecurityManager(getSecurityManager());
        service.initializeFromConfig(config);       
        return new UserGroupStoreValidationWrapper(service.createStore());
    }
View Full Code Here

Examples of org.geoserver.security.GeoServerUserGroupService

            new UsernamePasswordAuthenticationToken(username,password,l));
    }

    protected void addUser(String username, String password, List<String> groups, List<String> roles) throws Exception {
        GeoServerSecurityManager secMgr = getSecurityManager();
        GeoServerUserGroupService ugService = secMgr.loadUserGroupService("default");

        GeoServerUserGroupStore ugStore = ugService.createStore();
        GeoServerUser user = ugStore.createUserObject(username, password, true);
        ugStore.addUser(user);

        if (groups != null && !groups.isEmpty()) {
            for (String groupName : groups) {
View Full Code Here

Examples of org.geoserver.security.GeoServerUserGroupService

            // check for default admin password
            visibility= manager.checkForDefaultAdminPassword();
            Page changeItPage = null;
            String passwordEncoderName=null;
            try {
                GeoServerUserGroupService ugService = manager.loadUserGroupService(XMLUserGroupService.DEFAULT_NAME);               
                if (ugService != null) {
                    passwordEncoderName = ugService.getPasswordEncoderName();
                    GeoServerUser user = ugService.getUserByUsername(ADMIN_USERNAME);
                    if (user != null) {
                        changeItPage = new EditUserPage(ugService.getName(), user);
                    }
                }
            } catch (IOException e) {
                LOGGER.log(Level.WARNING, "Error looking up admin user", e);
            }
View Full Code Here

Examples of org.geoserver.security.GeoServerUserGroupService

   
    protected static GeoServerUserGroupService createH2UserGroupService(String serviceName,
        GeoServerSecurityManager securityManager) throws Exception {       

        if (securityManager.listUserGroupServices().contains(serviceName)) {
            GeoServerUserGroupService service = securityManager.loadUserGroupService(serviceName);
            if (service.canCreateStore()) {
                GeoServerUserGroupStore store = service.createStore();
                store.clear();
                store.store();
            }
            SecurityUserGroupServiceConfig old =
                    securityManager.loadUserGroupServiceConfig(serviceName);
View Full Code Here

Examples of org.geoserver.security.GeoServerUserGroupService

        MemoryUserGroupServiceConfigImpl ugconfig = new MemoryUserGroupServiceConfigImpl();        
        ugconfig.setName("testAdminRole");       
        ugconfig.setClassName(MemoryUserGroupService.class.getName());
        ugconfig.setPasswordEncoderName(getPBEPasswordEncoder().getName());
        ugconfig.setPasswordPolicyName(PasswordValidator.DEFAULT_NAME);
        GeoServerUserGroupService ugService = new MemoryUserGroupService();
        ugService.setSecurityManager(GeoServerExtensions.bean(GeoServerSecurityManager.class));
        ugService.initializeFromConfig(ugconfig);       

       
        RoleCalculator calc = new RoleCalculator(ugService, service);
        SortedSet<GeoServerRole> roles;
       
        roles = calc.calculateRoles(ugService.createUserObject("user1", "abc", true));
        assertTrue(roles.size()==4);
        assertTrue(roles.contains(adminRole));
        assertTrue(roles.contains(GeoServerRole.ADMIN_ROLE));
        assertTrue(roles.contains(groupAdminRole));
        assertTrue(roles.contains(GeoServerRole.GROUP_ADMIN_ROLE));

       
        roles = calc.calculateRoles(ugService.createUserObject("user2", "abc", true));
        assertTrue(roles.size()==2);
        assertTrue(roles.contains(adminRole));
        assertTrue(roles.contains(GeoServerRole.ADMIN_ROLE));

        roles = calc.calculateRoles(ugService.createUserObject("user3", "abc", true));
        assertTrue(roles.size()==1);
        assertTrue(roles.contains(role1));       

    }
View Full Code Here

Examples of org.geoserver.security.GeoServerUserGroupService

//        ugConfig.setPasswordEncoderName(GeoserverUserPBEPasswordEncoder.PrototypeName);
        ugConfig.setPasswordEncoderName(getDigestPasswordEncoder().getName());
        ugConfig.setPasswordPolicyName(PasswordValidator.DEFAULT_NAME);
        getSecurityManager().saveUserGroupService(ugConfig);

        GeoServerUserGroupService service = getSecurityManager().loadUserGroupService(serviceName);
        service.initializeFromConfig(ugConfig);
        return service;               
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.