Class BasicSecurityPolicy

java.lang.Object
net.solarnetwork.central.security.BasicSecurityPolicy
All Implemented Interfaces:
Serializable, SecurityPolicy

public class BasicSecurityPolicy extends Object implements SecurityPolicy, Serializable
Basic implementation of SecurityPolicy.
See Also:
  • Constructor Details

    • BasicSecurityPolicy

      public BasicSecurityPolicy(Set<Long> nodeIds, Set<String> sourceIds, Set<net.solarnetwork.domain.datum.Aggregation> aggregations, net.solarnetwork.domain.datum.Aggregation minAggregation, Set<LocationPrecision> locationPrecisions, LocationPrecision minLocationPrecision, Set<String> nodeMetadataPaths, Set<String> userMetadataPaths)
      Constructor.

      The notAfter property will be set to null (for no expiration date) and refreshable to false.

      Parameters:
      nodeIds - The node IDs to restrict to, or null for no restriction.
      sourceIds - The source ID to restrict to, or null for no restriction.
      aggregations - The aggregations to restrict to, or null for no restriction.
      minAggregation - If specified, a minimum aggregation level that is allowed.
      locationPrecisions - The location precisions to restrict to, or null for no restriction.
      minLocationPrecision - If specified, a minimum location precision that is allowed.
      nodeMetadataPaths - The SolarNodeMetadata paths to restrict to, or null for no restriction.
      userMetadataPaths - The UserNodeMetadata paths to restrict to, or null for no restriction.
    • BasicSecurityPolicy

      public BasicSecurityPolicy(Set<Long> nodeIds, Set<String> sourceIds, Set<net.solarnetwork.domain.datum.Aggregation> aggregations, net.solarnetwork.domain.datum.Aggregation minAggregation, Set<LocationPrecision> locationPrecisions, LocationPrecision minLocationPrecision, Set<String> nodeMetadataPaths, Set<String> userMetadataPaths, Instant notAfter, Boolean refreshAllowed)
      Constructor.
      Parameters:
      nodeIds - The node IDs to restrict to, or null for no restriction.
      sourceIds - The source ID to restrict to, or null for no restriction.
      aggregations - The aggregations to restrict to, or null for no restriction.
      minAggregation - If specified, a minimum aggregation level that is allowed.
      locationPrecisions - The location precisions to restrict to, or null for no restriction.
      minLocationPrecision - If specified, a minimum location precision that is allowed.
      nodeMetadataPaths - The SolarNodeMetadata paths to restrict to, or null for no restriction.
      userMetadataPaths - The UserNodeMetadata paths to restrict to, or null for no restriction.
      notAfter - A date after which the token is no longer valid, or null for no expiration.
      refreshAllowed - true if the token can be refreshed
      Since:
      2.0
    • BasicSecurityPolicy

      public BasicSecurityPolicy(Set<Long> nodeIds, Set<String> sourceIds, Set<net.solarnetwork.domain.datum.Aggregation> aggregations, net.solarnetwork.domain.datum.Aggregation minAggregation, Set<LocationPrecision> locationPrecisions, LocationPrecision minLocationPrecision, Set<String> nodeMetadataPaths, Set<String> userMetadataPaths, Set<String> apiPaths, Instant notAfter, Boolean refreshAllowed)
      Constructor.
      Parameters:
      nodeIds - The node IDs to restrict to, or null for no restriction.
      sourceIds - The source ID to restrict to, or null for no restriction.
      aggregations - The aggregations to restrict to, or null for no restriction.
      minAggregation - If specified, a minimum aggregation level that is allowed.
      locationPrecisions - The location precisions to restrict to, or null for no restriction.
      minLocationPrecision - If specified, a minimum location precision that is allowed.
      nodeMetadataPaths - The SolarNodeMetadata paths to restrict to, or null for no restriction.
      userMetadataPaths - The UserNodeMetadata paths to restrict to, or null for no restriction.
      apiPaths - The API paths to restrict to, or null for no restriction.
      notAfter - A date after which the token is no longer valid, or null for no expiration.
      refreshAllowed - true if the token can be refreshed
      Since:
      2.0
  • Method Details

    • builder

      public static BasicSecurityPolicy.Builder builder()
      Get a new builder instance.
      Returns:
      the new builder
      Since:
      2.0
    • getNodeIds

      public Set<Long> getNodeIds()
      Description copied from interface: SecurityPolicy
      Get a set of node IDs this policy applies to.
      Specified by:
      getNodeIds in interface SecurityPolicy
      Returns:
      set of node IDs, or null
    • getSourceIds

      public Set<String> getSourceIds()
      Description copied from interface: SecurityPolicy
      Get a set of source IDs this policy applies to.
      Specified by:
      getSourceIds in interface SecurityPolicy
      Returns:
      set of source IDs
    • getAggregations

      public Set<net.solarnetwork.domain.datum.Aggregation> getAggregations()
      Description copied from interface: SecurityPolicy
      Get a set of aggregations this policy applies to.
      Specified by:
      getAggregations in interface SecurityPolicy
      Returns:
      set of aggregations
    • getLocationPrecisions

      public Set<LocationPrecision> getLocationPrecisions()
      Description copied from interface: SecurityPolicy
      Get a location precision this policy applies to.
      Specified by:
      getLocationPrecisions in interface SecurityPolicy
      Returns:
      set of precisions
    • getMinAggregation

      public net.solarnetwork.domain.datum.Aggregation getMinAggregation()
      Description copied from interface: SecurityPolicy
      Get a minimum aggregation level this policy applies to.
      Specified by:
      getMinAggregation in interface SecurityPolicy
      Returns:
      The minimum aggregation level.
    • getMinLocationPrecision

      public LocationPrecision getMinLocationPrecision()
      Description copied from interface: SecurityPolicy
      Get a minimum location precision this policy applies to.
      Specified by:
      getMinLocationPrecision in interface SecurityPolicy
      Returns:
      The minimum location precision.
    • getNodeMetadataPaths

      public Set<String> getNodeMetadataPaths()
      Description copied from interface: SecurityPolicy
      Get a set of node metadata paths this policy applies to.
      Specified by:
      getNodeMetadataPaths in interface SecurityPolicy
      Returns:
      set of node metadata paths
    • getUserMetadataPaths

      public Set<String> getUserMetadataPaths()
      Description copied from interface: SecurityPolicy
      Get a set of user metadata paths this policy applies to.
      Specified by:
      getUserMetadataPaths in interface SecurityPolicy
      Returns:
      set of user metadata paths
    • getApiPaths

      public Set<String> getApiPaths()
      Description copied from interface: SecurityPolicy
      Get a set of API paths this policy allows.

      API paths are URL paths that support Ant-style patterns. If a path starts with ! then the match is inverted, so that any path not matching the pattern is allowed. Note that if any paths are defined here, then only paths that match some pattern are allowed. Or put another way, paths are denied unless some pattern matches.

      Specified by:
      getApiPaths in interface SecurityPolicy
      Returns:
      set of allowed API paths, or null or empty set if all paths are allowed
    • getNotAfter

      public Instant getNotAfter()
      Description copied from interface: SecurityPolicy
      Get a date after which a token is no longer valid.
      Specified by:
      getNotAfter in interface SecurityPolicy
      Returns:
      the expire date, or null for no expiration
    • isValidAt

      public boolean isValidAt(Instant timestamp)
      Description copied from interface: SecurityPolicy
      Test if the policy is valid at a specific date.
      Specified by:
      isValidAt in interface SecurityPolicy
      Parameters:
      timestamp - the time to test
      Returns:
      false if notAfter is set on the policy and timestamp is after that
    • getRefreshAllowed

      public Boolean getRefreshAllowed()
      Description copied from interface: SecurityPolicy
      Flag indicating if the token can be refreshed.
      Specified by:
      getRefreshAllowed in interface SecurityPolicy
      Returns:
      true if a token can be refreshed, false otherwise
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object