Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

Security on embedded space - Creating Roles & Users

Hi, I am new to GigaSpaces and I am trying to implement proof of concept model for using the gigaspaces security in one of our application. For this:

  1. I have created an embedded space

     UrlSpaceConfigurer configurer = new UrlSpaceConfigurer("/./mySpace").secured(true));
     IJSpace space = configurer.space();
     GigaSpace gigaSpace = new GigaSpaceConfigurer(space).gigaSpace();
    
  2. Now, I am creating Roles and permissions (not sure whether I am doing correctly here)

    // access security manager and create roles/users
    Properties securityProperties = new Properties();
    
    com.gigaspaces.security.SecurityManager securityManager = SecurityFactory
            .createSecurityManager(securityProperties);
    DirectoryManager directoryManager = securityManager.createDirectoryManager(new User("admin", "admin"));
    
    // create a role
    RoleManager roleManager = directoryManager.getRoleManager();
    roleManager.createRole(new Role("READ_ONLY_USER", new SpaceAuthority(SpacePrivilege.READ, new ClassFilter("*"))));
    roleManager.createRole(new Role("READ_WRITE_USER", new SpaceAuthority(SpacePrivilege.READ, new ClassFilter("*")),
            new SpaceAuthority(SpacePrivilege.WRITE, new ClassFilter("*"))));
    
    // create users and assign authorities
    UserManager userManager = directoryManager.getUserManager();
    userManager.createUser(new User("userA", "userA", new RoleAuthority("READ_ONLY_USER")));
    userManager.createUser(new User("userB", "userB", new RoleAuthority("READ_WRITE_USER")));
    
  3. Now testing my authencation by supplying incorrect password

    UrlSpaceConfigurer configurer = new UrlSpaceConfigurer("jini://localhost/*/SecuredSpace").securityConfig(new SecurityConfig("userA", "userA"));
    IJSpace space = configurer.space();
    GigaSpace gigaSpace = new GigaSpaceConfigurer(space).gigaSpace();
    

The above code is keep throwing AuthencationException. Can anyone help me on this? Thanks, P

asked 2013-10-18 04:36:35 -0500

P gravatar image

updated 2013-10-18 09:53:35 -0500

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

You need to close the DirectoryManager after you're done modifying it to flush the changes to the disk, otherwise they're discarded.

// access directory manager to manage users & roles:
DirectoryManager directoryManager = securityManager.createDirectoryManager(new User("admin", "admin"));
// Add users & roles
directoryManager.getRoleManager().createRole(...)
directoryManager.getUserManager().createUser(...)
// Close directory manager to flush changes
directoryManager.close();

BTW, you can also create roles and users via the GigaSpaces Management Center (a.k.a gs-ui)

answered 2013-10-20 03:00:14 -0500

niv gravatar image
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-10-18 04:36:35 -0500

Seen: 179 times

Last updated: Oct 20 '13