Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Officialdocu
Technical Guide - i18n and L10n
1http://documentation.magnolia-cms.com/technical-guide/i18n.html
Technical Guide - i18n and L10n

Magnolia CMS uses Sun's Java SE Security (JAAS). JAAS creates two distinct processes for:

...

The commit() method includes the values from both authentication and authorization. The authentication module provides all user properties, while the authorization module adds the roles and groups and the respective ACLs to the user object.

Example

In this example you are creatin Creating a new user class implementing

Javadoc
info.magnolia.cms.security.User
info.magnolia.cms.security.User
.:

  • First The simplest way to accomplish this is to create a JAAS module extending:
    Javadoc
    info.magnolia.jaas.sp.jcr.JCRAuthorizationModule
    info.magnolia.jaas.sp.jcr.JCRAuthorizationModule
  • The next step is Next, extend the following two methods:
Code Block
public void validateUser() throws LoginException {

        this.user = authenticate(this.name, this.pswd);

	if (this.user == null) {
            throw new FailedLoginException("User not found or password incorrect");
        }
	if (this.user.getAllGroups() != null) {
		this.setGroupNames((Set)this.user.getAllGroups());
	}
	if (this.user.getAllRoles() != null) {
		this.setRoleNames((Set) this.user.getAllRoles());
	}
    }
    public void setEntity() {
        EntityImpl user = new EntityImpl();
        user.addProperty(Entity.LANGUAGE, this.user.getLanguage());
        user.addProperty(Entity.NAME, this.user.getName());
        user.addProperty(Entity.PASSWORD, new String(this.pswd));
        this.subject.getPrincipals().add(user);
    }

Note that it is still necessary to implement the authentication method in order to properly create a User objectobject.

Adding the JAAS module to the JAAS configuration

As Magnolia is to be the secondary user management method used, it is necessary to use the following modifier:

...