diff --git a/modules/eeuser/src/main/java/org/jpos/ee/Consumer.java b/modules/eeuser/src/main/java/org/jpos/ee/Consumer.java index a7c8b10e5..2ec0baf2f 100644 --- a/modules/eeuser/src/main/java/org/jpos/ee/Consumer.java +++ b/modules/eeuser/src/main/java/org/jpos/ee/Consumer.java @@ -20,6 +20,8 @@ import java.util.*; import java.io.Serializable; + +import jakarta.persistence.Transient; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.EqualsBuilder; @@ -127,7 +129,8 @@ public void removeRole (Role role) { public void removeAllRoles () { roles.clear (); } - public String getRolesAsString () { + @Transient + public String rolesAsString() { StringBuilder sb = new StringBuilder(); for (Role r : roles) { if (!sb.isEmpty()) diff --git a/modules/eeuser/src/main/java/org/jpos/ee/Role.java b/modules/eeuser/src/main/java/org/jpos/ee/Role.java index a2b71cde7..f9b070dd5 100644 --- a/modules/eeuser/src/main/java/org/jpos/ee/Role.java +++ b/modules/eeuser/src/main/java/org/jpos/ee/Role.java @@ -99,7 +99,7 @@ public boolean hasPermission (String permName) { ignoreRealm = true; permName = permName.substring(1); } - return permName != null && (getActivePermissions(ignoreRealm).contains(Permission.valueOf(permName))); + return permName != null && (activePermissions(ignoreRealm).contains(Permission.valueOf(permName))); } public void addPermission (String permName) { @@ -146,33 +146,33 @@ public String toString() { * get Fully Qualified Role Name * @return [realm:]role.name */ - private String getFQRN() { + private String FQRN() { return getRealm () != null ? String.format("%s:role.%s", getRealm().getName(), getName()) : String.format("role.%s", getName()); } - public Set getActivePermissions () { - return getActivePermissions(false); + public Set activePermissions() { + return activePermissions(false); } - public Set getActivePermissions (boolean ignoreRealm) { + public Set activePermissions(boolean ignoreRealm) { Set perm = new LinkedHashSet<>(); - perm.add(Permission.valueOf(getFQRN())); + perm.add(Permission.valueOf(FQRN())); if (ignoreRealm) perm.addAll(permissions); else - perm.addAll(getActivePermissions(getRealm())); + perm.addAll(activePermissions(getRealm())); for (Role r = this; r.getParent() != null; ) { r = r.getParent(); if (ignoreRealm) perm.addAll(r.getPermissions()); else - perm.addAll(r.getActivePermissions(getRealm())); + perm.addAll(r.activePermissions(getRealm())); } return perm; } - private Set getActivePermissions (Realm r) { + private Set activePermissions(Realm r) { return r != null ? permissions.stream().map( p -> Permission.valueOf(r.getName() + ":" + p.getName()) diff --git a/modules/eeuser/src/main/java/org/jpos/ee/User.java b/modules/eeuser/src/main/java/org/jpos/ee/User.java index 9aa2cc44f..719f9ee6d 100644 --- a/modules/eeuser/src/main/java/org/jpos/ee/User.java +++ b/modules/eeuser/src/main/java/org/jpos/ee/User.java @@ -188,7 +188,7 @@ public void removeRole (Role role) { public void removeAllRoles () { roles.clear (); } - public String getRolesAsString () { + public String rolesAsString() { StringBuilder sb = new StringBuilder(); for (Role r : roles) { if (!sb.isEmpty()) @@ -197,7 +197,7 @@ public String getRolesAsString () { } return sb.toString(); } - public String getRealmsAsString () { + public String realmsAsString() { StringBuilder sb = new StringBuilder(); for (Role r : roles) { if (r.getRealm() != null) { @@ -261,7 +261,7 @@ public int hashCode() { /** * @return nick(id) */ - public String getNickAndId() { + public String nickAndId() { StringBuilder sb = new StringBuilder (getNick()); sb.append ('('); sb.append (getId()); diff --git a/modules/eeuser/src/main/java/org/jpos/q2/cli/ADDUSER.java b/modules/eeuser/src/main/java/org/jpos/q2/cli/ADDUSER.java index b98fbe86b..3cfaf6ca3 100644 --- a/modules/eeuser/src/main/java/org/jpos/q2/cli/ADDUSER.java +++ b/modules/eeuser/src/main/java/org/jpos/q2/cli/ADDUSER.java @@ -80,7 +80,7 @@ public void exec(CLIContext cli, String[] args) throws Exception { Collections.addAll(user.getRoles(), rr); user.setActive(true); db.commit(); - cli.println ("User '" + user.getNickAndId() + "' created"); + cli.println ("User '" + user.nickAndId() + "' created"); } catch (Exception e) { cli.println (e.getMessage()); } diff --git a/modules/eeuser/src/main/java/org/jpos/q2/cli/PASSWD.java b/modules/eeuser/src/main/java/org/jpos/q2/cli/PASSWD.java index 5f6a267d6..bfd5b8a94 100644 --- a/modules/eeuser/src/main/java/org/jpos/q2/cli/PASSWD.java +++ b/modules/eeuser/src/main/java/org/jpos/q2/cli/PASSWD.java @@ -57,7 +57,7 @@ public void exec(CLIContext cli, String[] args) throws Exception { mgr.setPassword(user, line.getOptionValue('p')); db.session().persist(user); db.commit(); - cli.println ("User '" + user.getNickAndId() + "': password changed."); + cli.println ("User '" + user.nickAndId() + "': password changed."); } catch (Exception e) { cli.println (e.getMessage()); } diff --git a/modules/eeuser/src/main/java/org/jpos/q2/cli/RMUSER.java b/modules/eeuser/src/main/java/org/jpos/q2/cli/RMUSER.java index ce45d0604..c852ab41f 100644 --- a/modules/eeuser/src/main/java/org/jpos/q2/cli/RMUSER.java +++ b/modules/eeuser/src/main/java/org/jpos/q2/cli/RMUSER.java @@ -39,7 +39,7 @@ public void exec(CLIContext cli, String[] args) throws Exception { u.setDeleted(true); } db.commit(); - cli.println(u != null ? "User " + u.getNickAndId() + " has been deleted" : "User does not exist"); + cli.println(u != null ? "User " + u.nickAndId() + " has been deleted" : "User does not exist"); } catch (Exception e) { cli.println(e.getMessage()); }