How I can create new user from Java class to GlassFish?

I'm creating a basic web application where user can register and then login. Obviously there is registration, login and login error page. I'm using GlassFish server for authentication.

I would like to know that is there any possible way to create a new user from Java class or Servlet so that when user is created, it will be saved to 'file' Realm of GlassFish? To be more specific here's what I want to do:

  • Create user by using entity class which is defined.
  • Save that user entity to database.
  • Create new user with username and password to GlassFish file Realm.
  • This far I have got my requirement working but its quiet neat because this must be done manually everytime when you want to create a new user. So is there anyway to automate this process?


    I found the solution for this. The solution is that you need to create JDBC Realm in GlassFish and config it by giving required information such as JNDI, user group table, user name column, password column, groups table and etc.

    Note: You can't do this with file Realm, since in file Realm it save user details to file and not read from there.

    链接地址: http://www.djcxy.com/p/49116.html

    上一篇: Glassfish 4中的密码加密算法

    下一篇: 我如何从Java类创建新用户到GlassFish?