|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Objectdk.i1.diameter.session.BaseSession
public abstract class BaseSession
A basic implementation of a Diameter session It implements a state model as described in RFC3588 section 8.1, and takes care of generating unique session-ids.
Subclasses must override the methods:
Subclasses should override the methods: Subclasses may want to override the methods:handleRequest(Message)handleSTA(Message)calcNextTimeout() and handleTimeout()newStatePre(State,State,Message,int)newStatePost(State,State,Message,int)collectSTRInfo(Message,int)getDestinationRealm()
| Nested Class Summary | |
|---|---|
static class |
BaseSession.State
The state of a session, as per RFC3588 section 8.1 |
| Field Summary | |
|---|---|
protected SessionAuthTimers |
session_auth_timers
|
| Constructor Summary | |
|---|---|
BaseSession(int auth_app_id,
SessionManager session_manager)
Constructor for BaseSession |
|
| Method Summary | |
|---|---|
void |
addCommonStuff(Message request)
Add session-id, origin-host+realm and destination-realm to a request. |
int |
authAppId()
Retrieve the auth-application-id specified when creating this session. |
protected void |
authFailed(Message msg)
Tell BaseSession that (re-)authorization failed. |
boolean |
authInProgress()
Determine if authentication/(re-)authorization is currently in progress. |
protected void |
authInProgress(boolean auth_in_progress)
Update the auth-in-progress flag. |
protected void |
authSuccessful(Message msg)
Tell BaseSession that (re-)authorization succeeded. |
long |
calcNextTimeout()
Calculate the next timeout for this session. |
void |
closeSession(int termination_cause)
Close a session. |
protected void |
closeSession(Message msg,
int termination_cause)
Close a session. |
protected void |
collectSTRInfo(Message request,
int termination_cause)
Collect information to send in STR message The BaseSession implementation adds Session-Id, Origin-Host, Origin-Realm, Destination-Realm, Auth-Application-Id and Termination-Cause. |
long |
firstAuthTime()
Return the time when the session was first authorized. |
protected String |
getDestinationRealm()
Get a suitable Destination-Realm value. |
protected static int |
getResultCode(Message msg)
Extract the Result-Code AVP value from a message |
protected String |
getSessionIdOptionalPart()
Get optional part of Session-Id. |
void |
handleAnswer(Message answer,
Object state)
Handle an answer. |
protected int |
handleASR(Message msg)
Process an Abort-Session Request. |
void |
handleNonAnswer(int command_code,
Object state)
Handle a non-answer. |
protected int |
handleRAR(Message msg)
Process an Re-Auth Request. |
int |
handleRequest(Message request)
Handle a request regarding this session. |
void |
handleSTA(Message msg)
Process STA (or lack of STA). |
void |
handleTimeout()
Handle timeout event. |
void |
newStatePost(BaseSession.State prev_state,
BaseSession.State new_state,
Message msg,
int cause)
State transition hook. |
void |
newStatePre(BaseSession.State prev_state,
BaseSession.State new_state,
Message msg,
int cause)
State transition hook. |
void |
openSession()
Open a session. |
String |
sessionId()
Returns the session-id of the session. |
SessionManager |
sessionManager()
|
protected abstract void |
startAuth()
Start the session by sending the first authentication/authorization. |
protected abstract void |
startReauth()
Send re-authorization. |
BaseSession.State |
state()
Returns the current state of the session. |
boolean |
stateMaintained()
Return whether the server is maintaining state about this sessions. |
protected void |
stateMaintained(boolean state_maintained)
Specify if server is maintaining state |
protected void |
updateSessionTimeout(int session_timeout)
Update the session-timeout of this session. |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected SessionAuthTimers session_auth_timers
| Constructor Detail |
|---|
public BaseSession(int auth_app_id,
SessionManager session_manager)
auth_app_id - The authentication application-id that will be reported in AAR and STR requestssession_manager - The session manager that manages this session| Method Detail |
|---|
public final SessionManager sessionManager()
public final String sessionId()
sessionId in interface Sessionpublic final BaseSession.State state()
public final int authAppId()
public final boolean authInProgress()
protected final void authInProgress(boolean auth_in_progress)
public boolean stateMaintained()
protected void stateMaintained(boolean state_maintained)
state_maintained - If true STR will be sentpublic long firstAuthTime()
public int handleRequest(Message request)
handleRequest in interface Sessionrequest - The request
public void handleAnswer(Message answer,
Object state)
handleAnswer in interface Sessionanswer - The answer messagestate - The state object specified in sendRequest()
public void handleNonAnswer(int command_code,
Object state)
handleNonAnswer in interface Sessioncommand_code - The command_code from the original request.state - The state object specified in sendRequest()protected int handleRAR(Message msg)
protected int handleASR(Message msg)
protected void authSuccessful(Message msg)
msg - Message that caused the success. Can be null.protected void authFailed(Message msg)
msg - Message that caused the failure. Can be null.public void handleSTA(Message msg)
msg - The STA message or nullpublic long calcNextTimeout()
Example override:
public long calcNextTimeout() //In your session class
long timeout = BaseSession.calcNextTimeout();
timeout = Math.min(timeout, quota_timeout);
return timeout;
}
When overriding this method you should also override handleTimeout().
calcNextTimeout in interface Sessionpublic void handleTimeout()
handleTimeout in interface Session
public void newStatePre(BaseSession.State prev_state,
BaseSession.State new_state,
Message msg,
int cause)
prev_state - The current statenew_state - The next statemsg - The message that caused this transition. May be null if the transition is not caused by a message.cause - The termination cause. 0 if next_state is not discon.
public void newStatePost(BaseSession.State prev_state,
BaseSession.State new_state,
Message msg,
int cause)
prev_state - The previous statenew_state - The current (new) statemsg - The message that caused this transition. May be null if the transition was not caused by a message.cause - The termination cause. 0 if next_state is not discon.
public void openSession()
throws InvalidStateException
InvalidStateExceptionpublic void closeSession(int termination_cause)
termination_cause - The reason for closing the session. See
RFC3588 section 8.15 for details
protected void closeSession(Message msg,
int termination_cause)
msg - The message that caused this session to closetermination_cause - The termination-cause for the session.protected abstract void startAuth()
protected abstract void startReauth()
protected void updateSessionTimeout(int session_timeout)
session_timeout - The relative session-time in seconds
protected void collectSTRInfo(Message request,
int termination_cause)
request - The STR messagetermination_cause - The Termination-Cause for closing the session.protected String getDestinationRealm()
protected String getSessionIdOptionalPart()
protected static final int getResultCode(Message msg)
public void addCommonStuff(Message request)
request - The request that should have the 4 AVPs added.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||