public class AuthStateModel extends Object
Modifier and Type | Class and Description |
---|---|
static class |
AuthStateModel.GeoVelocityResponse
Response to
AuthStateModel GeoVelocity analysis request |
static class |
AuthStateModel.ModelEntry
Represents a single known source for authentication for a given user
|
static class |
AuthStateModel.ModelEntryUpdate
Information used in a model update request
|
Constructor and Description |
---|
AuthStateModel(String subject)
Create new state model for user
|
Modifier and Type | Method and Description |
---|---|
AuthStateModel.GeoVelocityResponse |
geoVelocityAnalyzeLatest(Double maxKmPerSecond)
Perform geo-velocity analysis using the latest entries in the model
|
static AuthStateModel |
get(String user,
StateCursor<AuthStateModel> s,
PruningStrategy ps)
Retrieve state object for user
|
Map<String,AuthStateModel.ModelEntry> |
getEntries()
Get entries associated with model
|
String |
getSubject()
Get subject associated with model
|
void |
set(StateCursor<AuthStateModel> s,
PruningStrategy ps)
Persist state using state interface
|
void |
setEntries(Map<String,AuthStateModel.ModelEntry> entries)
Set entries associated with model
|
void |
setSubject(String subject)
Set subject associated with model
|
ArrayList<AbstractMap.SimpleEntry<String,AuthStateModel.ModelEntry>> |
timeSortedEntries()
Return all entries in AuthStateModel as an array list, sorted by timestamp
|
Boolean |
updateEntry(AuthStateModel.ModelEntryUpdate request)
Update state entry for user to indicate authentication from address setting specified timestamp
on the entry
|
Boolean |
updateEntry(String ipaddr,
org.joda.time.DateTime timestamp,
Double latitude,
Double longitude)
Update state entry for user to indicate authentication from address setting specified timestamp
on the entry
|
Boolean |
updateEntry(String ipaddr,
Double latitude,
Double longitude)
Update state entry for user to indicate authentication from address
|
public AuthStateModel(String subject)
subject
- Subject user namepublic Boolean updateEntry(String ipaddr, Double latitude, Double longitude)
Note this function does not write the new state, set must be called to make changes permanent.
This variant of the method will use the current time as the timestamp for the authentication event, instead of accepting a parameter indicating the timestamp to associate with the event.
This variant of updateEntry does not support including a user agent with the update, pass ModelEntryUpdate for that.
ipaddr
- IP address to update state withlatitude
- IP address's latitudelongitude
- IP address's longitudepublic Boolean updateEntry(String ipaddr, org.joda.time.DateTime timestamp, Double latitude, Double longitude)
Note this function does not write the new state, set must be called to make changes permanent.
This variant of updateEntry does not support including a user agent with the update, pass ModelEntryUpdate for that.
ipaddr
- IP address to update state withtimestamp
- Timestamp to associate with updatelatitude
- IP address's latitudelongitude
- IP address's longitudepublic Boolean updateEntry(AuthStateModel.ModelEntryUpdate request)
Note this function does not write the new state, set must be called to make changes permanent.
request
- ModelEntryUpdatepublic Map<String,AuthStateModel.ModelEntry> getEntries()
public void setEntries(Map<String,AuthStateModel.ModelEntry> entries)
entries
- Mappublic String getSubject()
public void setSubject(String subject)
subject
- Subject stringpublic static AuthStateModel get(String user, StateCursor<AuthStateModel> s, PruningStrategy ps) throws StateException
user
- Subject name to retrieve state fors
- Initialized state cursor for requestps
- Pruning strategyAuthStateModel
or null if it does not existStateException
- StateExceptionpublic void set(StateCursor<AuthStateModel> s, PruningStrategy ps) throws StateException
Calling set will also commit and close the cursor.
s
- Initialized state cursor for requestps
- Pruning strategyStateException
- StateExceptionpublic AuthStateModel.GeoVelocityResponse geoVelocityAnalyzeLatest(Double maxKmPerSecond)
The latest entry in the model (e.g., last known authentication event) is compared against the entry that precedes it. If long/lat information is available, this information is used to calculate the distance between the events and the amount of time that passed between the events.
If geo-velocity analysis was possible, a GeoVelocityResponse is returned, null if not.
maxKmPerSecond
- The maximum KM per second to use for the analysispublic ArrayList<AbstractMap.SimpleEntry<String,AuthStateModel.ModelEntry>> timeSortedEntries()
Copyright © 2022. All rights reserved.