Skip to content

Commit

Permalink
Second constructor for Role
Browse files Browse the repository at this point in the history
Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
  • Loading branch information
dmatej committed Sep 18, 2022
1 parent 9909f9c commit dbec2b0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -817,9 +817,10 @@ public Set<Role> getAppRoles() {
return this.appRoles;
}


// used by reflection, see ApplicationNode
public void addAppRole(SecurityRoleDescriptor descriptor) {
Role role = new Role(descriptor.getName());
role.setDescription(descriptor.getDescription());
Role role = new Role(descriptor.getName(), descriptor.getDescription());
getAppRoles().add(role);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,7 @@ public void addRole(Role role) {
* @param descriptor SecurityRoleDescriptor that describes the username and description of the role
*/
public void addRole(SecurityRoleDescriptor descriptor) {
Role role = new Role(descriptor.getName());
role.setDescription(descriptor.getDescription());
Role role = new Role(descriptor.getName(), descriptor.getDescription());
this.addRole(role);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1454,8 +1454,7 @@ public Enumeration<SecurityRoleDescriptor> getSecurityRoles() {
*/
@Override
public void addSecurityRole(SecurityRole securityRole) {
Role r = new Role(securityRole.getName());
r.setDescription(securityRole.getDescription());
Role r = new Role(securityRole.getName(), securityRole.getDescription());
super.addRole(r);
}

Expand Down Expand Up @@ -1487,8 +1486,7 @@ public SecurityRoleReference getSecurityRoleReferenceByName(String compName, Str
}

@Override
protected void combineSecurityConstraints(Set<SecurityConstraint> firstScSet,
Set<SecurityConstraint> secondScSet) {
protected void combineSecurityConstraints(Set<SecurityConstraint> firstScSet, Set<SecurityConstraint> secondScSet) {
Set<String> allUrlPatterns = new HashSet<>();
for (SecurityConstraint sc : firstScSet) {
for (WebResourceCollection wrc : sc.getWebResourceCollections()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,26 @@
public class Role extends PrincipalImpl {

private String description;
/**
* Creates a new Role with a given name
*
* @param name cannot be null
*/
public Role(final String name) {
super(name);
this.description = null;
}

/** Creates a new Role with a given name */
public Role(String name) {

/**
* Creates a new Role with a given name
*
* @param name cannot be null
* @param description can be null
*/
public Role(final String name, final String description) {
super(name);
this.description = description;
}


Expand Down

0 comments on commit dbec2b0

Please sign in to comment.