See: Description
Interface | Description |
---|---|
AccountingClientSessionActivity |
An AccountingClientSessionActivity represents an accounting session for Diameter accounting clients.
|
AccountingServerSessionActivity |
An AccountingServerSessionActivity represents an accounting session for Diameter accounting clients.
|
AccountingSessionActivity |
Superinterface for accounting activities.
|
AvpFilter | |
BaseActivity |
An activity created by the base RA via its provider.
|
DiameterActivity |
Represents a session with a Diameter peer.
|
DiameterActivityContextInterfaceFactory |
Interface for factory implemented by the SLEE to create ACIs.
|
DiameterAvp |
Diameter Attribute Value Pair (AVP).
|
DiameterCommand |
Diameter command.
|
DiameterHeader |
Interface to allow applications to retrieve Diameter header fields should they need to.
|
DiameterMessage |
A Diameter message containing a command code and a collection of AVPs.
|
DiameterMessageFactory |
Factory to create instances of
DiameterAvp , DiameterMessage . |
DiameterProvider |
The interface used by an SBB to interact with the Diameter RA.
|
GroupedAvp |
A GroupedAvp represents a Diameter Grouped AVP type.
|
UndefinedAvp |
Represents an AVP that was not recognised by the stack.
|
Versions |
Class | Description |
---|---|
AccountingSessionState |
Enumeration of Accounting session states.
|
AvpFilterContext | |
DiameterAvpCodes |
Diameter AVP code constants defined by the specification.
|
DiameterAvpType |
Enumerated type class to identify AVP value types.
|
DiameterResultCode |
Contains constants for result codes defined by Diameter Base specification.
|
SessionBinding |
The Session-Binding AVP (AVP Code 270) is of type Unsigned32, and MAY
be present in application-specific authorization answer messages.
|
Exception | Description |
---|---|
AvpNotAllowedException |
Thrown when an AVP is not allowed to be added to a Diameter command or grouped AVP type.
|
ConfigurationException | |
CreateActivityException |
Thrown when an activity cannot be created for any reason.
|
DecodeException |
Exception thrown when decoding Diameter data such as AVPs.
|
NoPeersAvailableException | |
NoSuchAvpException |
Thrown when an AVP supplied to one of the API calls was not known.
|
RouteException | |
SendException |
The Diameter Base Resource Adaptor allows SLEE services to construct messages using the Diameter protocol, and send those requests to a Diameter server. The Base RA can also be used to construct and send extension messages.
SBBs obtain a DiameterProvider
instance via JNDI
by specifying an appropriate <resource-adaptor-entity-binding> entry in the SBB deployment descriptor.
The DiameterProvider
provides a factory
(DiameterMessageFactory
) that is used to
create Diameter AVPs and Diameter messages.
The DiameterProvider interface provides methods that allow SBBs to send synchronous Diameter requests, and a method to create a DiameterActivity to send requests asynchronously.
Diameter requests consist of a DiameterMessage containing the command code and Attribute Value Pair (AVP) data. Responses consist of a DiameterMessage with the result in appropriate AVPs as defined by the Diameter application being used. DiameterMessage implementations are either returned from synchronous method invocations or fired as events in the asynchronous case.
Asynchronous requests are sent by first creating an activity, attaching to the activity then invoking the sendMessage method on the activity. When the request completes, an event is fired on the activity.
DiameterMessageFactory messageFactory = diameterProvider.getDiameterMessageFactory(); DiameterCommand command = messageFactory.createCommand(TEST_AUTH_COMMAND_CODE, 10000, "TAR", "Test-Auth-Request", true, true); DiameterAvp[] avps = new DiameterAvp[]{ messageFactory.createAvp(DiameterAvpCodes.AUTH_APPLICATION_ID, 1), messageFactory.createAvp(DiameterAvpCodes.USER_NAME, "user@domain.com"), messageFactory.createAvp(DiameterAvpCodes.RE_AUTH_REQUEST_TYPE, ReAuthRequestType.AUTHORIZE_ONLY) }; DiameterMessage message = messageFactory.createMessage(command, avps); message.setDestinationRealm(new DiameterIdentity("diameter-server")); message.setDestinationHost(new DiameterIdentity("opencloud")); DiameterActivity activity = diameterProvider.createActivity(); ActivityContextInterface diameterACI = diameterACIFactory.getActivityContextInterface(activity); diameterACI.attach(getSbbLocalObject()); activity.sendMessage(message);
getDiameterActivity()
method used here is simply a helper method that uses
SbbContext.getActivities() to retrieve the Diameter activity that this SBB is attached to.)
The Re-Auth-Request message is defined by Diameter, therefore the message factory provides a named constructor
for this message, and the ReAuthRequest interface has set methods for each AVP it can contain.
DiameterActivity activity = getDiameterActivity(); if(activity == null) { trace(Level.SEVERE, "Could not get attached activity"); return; } DiameterMessageFactory messageFactory = activity.getDiameterMessageFactory(); ReAuthRequest reAuthRequest = messageFactory.createReAuthRequest(); reAuthRequest.setAuthApplicationId(10000); reAuthRequest.setUserName("user@domain.com"); reAuthRequest.setReAuthRequestType(ReAuthRequestType.AUTHORIZE_ONLY); activity.sendMessage(reAuthRequest);
public void onReAuthAnswer(ReAuthAnswer reAuthAnswer, ActivityContextInterface aci) { trace(Level.FINE, "ReAuthAnswer " + reAuthAnswer); String sessionID = reAuthAnswer.getSessionId(); if(DiameterResultCode.DIAMETER_SUCCESS == reAuthAnswer.getResultCode()) { trace(Level.FINE, "ReAuth success for session " + sessionID); } else { trace(Level.FINE, "ReAuth failure for session " + sessionID); trace(Level.FINE, "Reason: " + reAuthAnswer.getErrorMessage()); } }
public void onExtensionMessage(ExtensionDiameterMessage event, ActivityContextInterface avi) { trace(Level.FINE, "ExtensionMessage " + event); DiameterCommand command = event.getCommand(); if(TEST_AUTH_COMMAND_CODE == command.getCode()) { DiameterAvp[] avps = event.getAvps(); for (int i = 0; i < avps.length; i++) { DiameterAvp avp = avps[i]; int code = avp.getCode(); switch(code) { case DiameterAvpCodes.SESSION_ID: trace(Level.FINE, "Session-Id " + avp.stringValue()); break; case DiameterAvpCodes.RESULT_CODE: trace(Level.FINE, "Result-Code " + avp.longValue()); break; /* ... etc ... */ default: trace(Level.WARNING, "Unknown AVP code for TestAuth message: " + code); } } } else { trace(Level.WARNING, "Unknown command code: " + command.getCode()); } }
Synchronous requests are sent by calling
DiameterProvider.sendSyncMessage(DiameterMessage)
Note: The synchronous API should only be used for simple test services that are not expected to run at high loads. The resource adaptor does not currently implement timeouts for synchronous requests, so SBBs may block indefinitely. Services that use the synchronous model also do not scale well.
DiameterMessageFactory messageFactory = diameterProvider.getDiameterMessageFactory(); DiameterCommand command = messageFactory.createCommand(TEST_AUTH_COMMAND_CODE, 10000, "TAR", "Test-Auth-Request", true, true); DiameterAvp[] avps = new DiameterAvp[]{ messageFactory.createAvp(DiameterAvpCodes.AUTH_APPLICATION_ID, 1), messageFactory.createAvp(DiameterAvpCodes.USER_NAME, "user@domain.com"), messageFactory.createAvp(DiameterAvpCodes.RE_AUTH_REQUEST_TYPE, ReAuthRequestType.AUTHORIZE_ONLY) }; DiameterMessage message = messageFactory.createMessage(command, avps); message.setDestinationRealm(new DiameterIdentity("diameter-server")); message.setDestinationHost(new DiameterIdentity("opencloud")); DiameterMessage answer = diameterProvider.sendSyncMessage(message); // Process answer