Package org.duracloud.security.vote
Class UserIpLimitsAccessVoter
java.lang.Object
org.duracloud.security.vote.UserIpLimitsAccessVoter
- All Implemented Interfaces:
org.springframework.security.access.AccessDecisionVoter
public class UserIpLimitsAccessVoter
extends Object
implements org.springframework.security.access.AccessDecisionVoter
Votes on access depending on user IP limits. If IP limits are defined
for a user, then any requests made by that user must originate from
a valid IP range. If no IP limits are defined, ABSTAIN. If IP limits
are defined and the user's request is in a valid range, GRANT. If IP
limits are defined and the user's request is not in a defined valid range,
DENY.
- Author:
- Bill Branan Date: 04/15/15
-
Field Summary
Fields inherited from interface org.springframework.security.access.AccessDecisionVoter
ACCESS_ABSTAIN, ACCESS_DENIED, ACCESS_GRANTED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringgetUserIpLimits(org.springframework.security.core.Authentication auth) Retrieves the ip limits defined for a given userprotected booleanDetermines if a given IP address is in the given IP range.booleanThis methods returns true if the arg class is an instance of or subclass of FilterInvocation.booleansupports(org.springframework.security.access.ConfigAttribute configAttribute) This method always returns true because all configAttributes are able to be handled by this voter.intvote(org.springframework.security.core.Authentication auth, Object resource, Collection config) This method checks the IP limits of the principal and denys access if those limits exist and the request is coming from outside the specified range.
-
Constructor Details
-
UserIpLimitsAccessVoter
public UserIpLimitsAccessVoter()
-
-
Method Details
-
supports
public boolean supports(org.springframework.security.access.ConfigAttribute configAttribute) This method always returns true because all configAttributes are able to be handled by this voter.- Specified by:
supportsin interfaceorg.springframework.security.access.AccessDecisionVoter- Parameters:
configAttribute- any att- Returns:
- true
-
supports
This methods returns true if the arg class is an instance of or subclass of FilterInvocation. No other classes can be handled by this voter.- Specified by:
supportsin interfaceorg.springframework.security.access.AccessDecisionVoter- Parameters:
aClass- to be analyized for an AuthZ vote.- Returns:
- true if is an instance of or subclass of FilterInvocation
-
vote
public int vote(org.springframework.security.core.Authentication auth, Object resource, Collection config) This method checks the IP limits of the principal and denys access if those limits exist and the request is coming from outside the specified range.- Specified by:
votein interfaceorg.springframework.security.access.AccessDecisionVoter- Parameters:
auth- principal seeking AuthZresource- that is under protectionconfig- access-attributes defined on resource- Returns:
- vote (AccessDecisionVoter.ACCESS_GRANTED, ACCESS_DENIED, ACCESS_ABSTAIN)
-
getUserIpLimits
Retrieves the ip limits defined for a given user- Parameters:
auth- Authentication where user details can be found- Returns:
- user ip limits, or null if no limits are set
-
ipInRange
Determines if a given IP address is in the given IP range.- Parameters:
ipAddress- single IP addressrange- IP address range using CIDR notation- Returns:
- true if the address is in the range, false otherwise
-