/** * Gets a set of namespace codes which the current user is authorized for the given permissions. * * @param permissions List of permissions to query * * @return Set of namespace codes */ public Set<String> getAuthorizedNamespaces(NamespacePermissionEnum... permissions) { Set<String> namespaces = new HashSet<>(); if (SecurityContextHolder.getContext().getAuthentication() != null) { ApplicationUser applicationUser = getApplicationUser(); if (applicationUser != null) { for (NamespaceAuthorization namespaceAuthorization : applicationUser.getNamespaceAuthorizations()) { if (namespaceAuthorization.getNamespacePermissions().containsAll(Arrays.asList(permissions))) { namespaces.add(namespaceAuthorization.getNamespace()); } } } } return namespaces; }
/** * Gets a set of namespace codes which the current user is authorized for the given permissions. * * @param permissions List of permissions to query * * @return Set of namespace codes */ public Set<String> getAuthorizedNamespaces(NamespacePermissionEnum... permissions) { Set<String> namespaces = new HashSet<>(); if (SecurityContextHolder.getContext().getAuthentication() != null) { ApplicationUser applicationUser = getApplicationUser(); if (applicationUser != null) { for (NamespaceAuthorization namespaceAuthorization : applicationUser.getNamespaceAuthorizations()) { if (namespaceAuthorization.getNamespacePermissions().containsAll(Arrays.asList(permissions))) { namespaces.add(namespaceAuthorization.getNamespace()); } } } } return namespaces; }
/** * Returns true if the application user is authorized to the given namespace and has the given permissions. * * @param applicationUser the application user * @param namespace the namespace * @param permissions the permissions * * @return true if authorized, false otherwise */ private boolean isAuthorized(ApplicationUser applicationUser, String namespace, NamespacePermissionEnum... permissions) { if (applicationUser != null && applicationUser.getNamespaceAuthorizations() != null) { for (NamespaceAuthorization currentUserAuthorization : applicationUser.getNamespaceAuthorizations()) { List<NamespacePermissionEnum> currentUserNamespacePermissions = currentUserAuthorization.getNamespacePermissions(); if (currentUserNamespacePermissions == null) { currentUserNamespacePermissions = Collections.emptyList(); } if (StringUtils.equalsIgnoreCase(currentUserAuthorization.getNamespace(), namespace) && currentUserNamespacePermissions.stream().anyMatch(Arrays.asList(permissions)::contains)) { return true; } } } return false; }
/** * Returns true if the application user is authorized to the given namespace and has the given permissions. * * @param applicationUser the application user * @param namespace the namespace * @param permissions the permissions * * @return true if authorized, false otherwise */ private boolean isAuthorized(ApplicationUser applicationUser, String namespace, NamespacePermissionEnum... permissions) { if (applicationUser != null && applicationUser.getNamespaceAuthorizations() != null) { for (NamespaceAuthorization currentUserAuthorization : applicationUser.getNamespaceAuthorizations()) { List<NamespacePermissionEnum> currentUserNamespacePermissions = currentUserAuthorization.getNamespacePermissions(); if (currentUserNamespacePermissions == null) { currentUserNamespacePermissions = Collections.emptyList(); } if (StringUtils.equalsIgnoreCase(currentUserAuthorization.getNamespace(), namespace) && currentUserNamespacePermissions.stream().anyMatch(Arrays.asList(permissions)::contains)) { return true; } } } return false; }
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { { String theNamespace; theNamespace = this.getNamespace(); strategy.appendField(locator, this, "namespace", buffer, theNamespace, (this.namespace!= null)); } { List<NamespacePermissionEnum> theNamespacePermissions; theNamespacePermissions = ((this.namespacePermissions!= null)?this.getNamespacePermissions():null); strategy.appendField(locator, this, "namespacePermissions", buffer, theNamespacePermissions, (this.namespacePermissions!= null)); } return buffer; }
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { { String theNamespace; theNamespace = this.getNamespace(); strategy.appendField(locator, this, "namespace", buffer, theNamespace, (this.namespace!= null)); } { List<NamespacePermissionEnum> theNamespacePermissions; theNamespacePermissions = ((this.namespacePermissions!= null)?this.getNamespacePermissions():null); strategy.appendField(locator, this, "namespacePermissions", buffer, theNamespacePermissions, (this.namespacePermissions!= null)); } return buffer; }
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { { String theNamespace; theNamespace = this.getNamespace(); strategy.appendField(locator, this, "namespace", buffer, theNamespace, (this.namespace!= null)); } { List<NamespacePermissionEnum> theNamespacePermissions; theNamespacePermissions = ((this.namespacePermissions!= null)?this.getNamespacePermissions():null); strategy.appendField(locator, this, "namespacePermissions", buffer, theNamespacePermissions, (this.namespacePermissions!= null)); } return buffer; }
public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator, Object object, EqualsStrategy2 strategy) { if ((object == null)||(this.getClass()!= object.getClass())) { return false; } if (this == object) { return true; } final NamespaceAuthorization that = ((NamespaceAuthorization) object); { String lhsNamespace; lhsNamespace = this.getNamespace(); String rhsNamespace; rhsNamespace = that.getNamespace(); if (!strategy.equals(LocatorUtils.property(thisLocator, "namespace", lhsNamespace), LocatorUtils.property(thatLocator, "namespace", rhsNamespace), lhsNamespace, rhsNamespace, (this.namespace!= null), (that.namespace!= null))) { return false; } } { List<NamespacePermissionEnum> lhsNamespacePermissions; lhsNamespacePermissions = ((this.namespacePermissions!= null)?this.getNamespacePermissions():null); List<NamespacePermissionEnum> rhsNamespacePermissions; rhsNamespacePermissions = ((that.namespacePermissions!= null)?that.getNamespacePermissions():null); if (!strategy.equals(LocatorUtils.property(thisLocator, "namespacePermissions", lhsNamespacePermissions), LocatorUtils.property(thatLocator, "namespacePermissions", rhsNamespacePermissions), lhsNamespacePermissions, rhsNamespacePermissions, (this.namespacePermissions!= null), (that.namespacePermissions!= null))) { return false; } } return true; }
public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator, Object object, EqualsStrategy2 strategy) { if ((object == null)||(this.getClass()!= object.getClass())) { return false; } if (this == object) { return true; } final NamespaceAuthorization that = ((NamespaceAuthorization) object); { String lhsNamespace; lhsNamespace = this.getNamespace(); String rhsNamespace; rhsNamespace = that.getNamespace(); if (!strategy.equals(LocatorUtils.property(thisLocator, "namespace", lhsNamespace), LocatorUtils.property(thatLocator, "namespace", rhsNamespace), lhsNamespace, rhsNamespace, (this.namespace!= null), (that.namespace!= null))) { return false; } } { List<NamespacePermissionEnum> lhsNamespacePermissions; lhsNamespacePermissions = ((this.namespacePermissions!= null)?this.getNamespacePermissions():null); List<NamespacePermissionEnum> rhsNamespacePermissions; rhsNamespacePermissions = ((that.namespacePermissions!= null)?that.getNamespacePermissions():null); if (!strategy.equals(LocatorUtils.property(thisLocator, "namespacePermissions", lhsNamespacePermissions), LocatorUtils.property(thatLocator, "namespacePermissions", rhsNamespacePermissions), lhsNamespacePermissions, rhsNamespacePermissions, (this.namespacePermissions!= null), (that.namespacePermissions!= null))) { return false; } } return true; }
public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator, Object object, EqualsStrategy2 strategy) { if ((object == null)||(this.getClass()!= object.getClass())) { return false; } if (this == object) { return true; } final NamespaceAuthorization that = ((NamespaceAuthorization) object); { String lhsNamespace; lhsNamespace = this.getNamespace(); String rhsNamespace; rhsNamespace = that.getNamespace(); if (!strategy.equals(LocatorUtils.property(thisLocator, "namespace", lhsNamespace), LocatorUtils.property(thatLocator, "namespace", rhsNamespace), lhsNamespace, rhsNamespace, (this.namespace!= null), (that.namespace!= null))) { return false; } } { List<NamespacePermissionEnum> lhsNamespacePermissions; lhsNamespacePermissions = ((this.namespacePermissions!= null)?this.getNamespacePermissions():null); List<NamespacePermissionEnum> rhsNamespacePermissions; rhsNamespacePermissions = ((that.namespacePermissions!= null)?that.getNamespacePermissions():null); if (!strategy.equals(LocatorUtils.property(thisLocator, "namespacePermissions", lhsNamespacePermissions), LocatorUtils.property(thatLocator, "namespacePermissions", rhsNamespacePermissions), lhsNamespacePermissions, rhsNamespacePermissions, (this.namespacePermissions!= null), (that.namespacePermissions!= null))) { return false; } } return true; }
public int hashCode(ObjectLocator locator, HashCodeStrategy2 strategy) { int currentHashCode = 1; { String theNamespace; theNamespace = this.getNamespace(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "namespace", theNamespace), currentHashCode, theNamespace, (this.namespace!= null)); } { List<NamespacePermissionEnum> theNamespacePermissions; theNamespacePermissions = ((this.namespacePermissions!= null)?this.getNamespacePermissions():null); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "namespacePermissions", theNamespacePermissions), currentHashCode, theNamespacePermissions, (this.namespacePermissions!= null)); } return currentHashCode; }
public int hashCode(ObjectLocator locator, HashCodeStrategy2 strategy) { int currentHashCode = 1; { String theNamespace; theNamespace = this.getNamespace(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "namespace", theNamespace), currentHashCode, theNamespace, (this.namespace!= null)); } { List<NamespacePermissionEnum> theNamespacePermissions; theNamespacePermissions = ((this.namespacePermissions!= null)?this.getNamespacePermissions():null); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "namespacePermissions", theNamespacePermissions), currentHashCode, theNamespacePermissions, (this.namespacePermissions!= null)); } return currentHashCode; }
public int hashCode(ObjectLocator locator, HashCodeStrategy2 strategy) { int currentHashCode = 1; { String theNamespace; theNamespace = this.getNamespace(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "namespace", theNamespace), currentHashCode, theNamespace, (this.namespace!= null)); } { List<NamespacePermissionEnum> theNamespacePermissions; theNamespacePermissions = ((this.namespacePermissions!= null)?this.getNamespacePermissions():null); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "namespacePermissions", theNamespacePermissions), currentHashCode, theNamespacePermissions, (this.namespacePermissions!= null)); } return currentHashCode; }
if (namespacePermissionsShouldBeCopiedAndSet == Boolean.TRUE) { List<NamespacePermissionEnum> sourceNamespacePermissions; sourceNamespacePermissions = ((this.namespacePermissions!= null)?this.getNamespacePermissions():null); @SuppressWarnings("unchecked") List<NamespacePermissionEnum> copyNamespacePermissions = ((List<NamespacePermissionEnum> ) strategy.copy(LocatorUtils.property(locator, "namespacePermissions", sourceNamespacePermissions), sourceNamespacePermissions, (this.namespacePermissions!= null)));
if (namespacePermissionsShouldBeCopiedAndSet == Boolean.TRUE) { List<NamespacePermissionEnum> sourceNamespacePermissions; sourceNamespacePermissions = ((this.namespacePermissions!= null)?this.getNamespacePermissions():null); @SuppressWarnings("unchecked") List<NamespacePermissionEnum> copyNamespacePermissions = ((List<NamespacePermissionEnum> ) strategy.copy(LocatorUtils.property(locator, "namespacePermissions", sourceNamespacePermissions), sourceNamespacePermissions, (this.namespacePermissions!= null)));
if (namespacePermissionsShouldBeCopiedAndSet == Boolean.TRUE) { List<NamespacePermissionEnum> sourceNamespacePermissions; sourceNamespacePermissions = ((this.namespacePermissions!= null)?this.getNamespacePermissions():null); @SuppressWarnings("unchecked") List<NamespacePermissionEnum> copyNamespacePermissions = ((List<NamespacePermissionEnum> ) strategy.copy(LocatorUtils.property(locator, "namespacePermissions", sourceNamespacePermissions), sourceNamespacePermissions, (this.namespacePermissions!= null)));