Fix bugs for AaaManger and RADIUS
Change-Id: I112a3207ccd9b580e59e8ec328cb6db1e32ca38a
diff --git a/src/main/java/org/onosproject/aaa/AaaManager.java b/src/main/java/org/onosproject/aaa/AaaManager.java
old mode 100644
new mode 100755
index 30ef879..0339a7e
--- a/src/main/java/org/onosproject/aaa/AaaManager.java
+++ b/src/main/java/org/onosproject/aaa/AaaManager.java
@@ -349,6 +349,16 @@
sendPacketToSupplicant(eth, stateMachine.supplicantConnectpoint());
break;
+ case EAPOL.EAPOL_LOGOFF:
+ if (stateMachine.state() == stateMachine.STATE_AUTHORIZED) {
+ try {
+ stateMachine.logoff();
+ } catch (StateMachineException e) {
+ e.printStackTrace();
+ }
+ }
+
+ break;
case EAPOL.EAPOL_PACKET:
RADIUS radiusPayload;
// check if this is a Response/Identify or a Response/TLS
@@ -380,8 +390,10 @@
stateMachine.identifier(),
eapPacket);
- radiusPayload.setAttribute(RADIUSAttribute.RADIUS_ATTR_STATE,
- stateMachine.challengeState());
+ if (stateMachine.challengeState() != null) {
+ radiusPayload.setAttribute(RADIUSAttribute.RADIUS_ATTR_STATE,
+ stateMachine.challengeState());
+ }
radiusPayload.addMessageAuthenticator(AaaManager.this.radiusSecret);
sendRadiusPacket(radiusPayload);
}
@@ -390,8 +402,10 @@
// request id access to RADIUS
radiusPayload = getRadiusPayload(stateMachine, stateMachine.identifier(), eapPacket);
- radiusPayload.setAttribute(RADIUSAttribute.RADIUS_ATTR_STATE,
- stateMachine.challengeState());
+ if (stateMachine.challengeState() != null) {
+ radiusPayload.setAttribute(RADIUSAttribute.RADIUS_ATTR_STATE,
+ stateMachine.challengeState());
+ }
stateMachine.setRequestAuthenticator(radiusPayload.generateAuthCode());
radiusPayload.addMessageAuthenticator(AaaManager.this.radiusSecret);
@@ -432,8 +446,11 @@
Ethernet eth;
switch (radiusPacket.getCode()) {
case RADIUS.RADIUS_CODE_ACCESS_CHALLENGE:
- byte[] challengeState =
- radiusPacket.getAttribute(RADIUSAttribute.RADIUS_ATTR_STATE).getValue();
+ RADIUSAttribute radiusAttrState = radiusPacket.getAttribute(RADIUSAttribute.RADIUS_ATTR_STATE);
+ byte[] challengeState = null;
+ if (radiusAttrState != null) {
+ challengeState = radiusAttrState.getValue();
+ }
eapPayload = radiusPacket.decapsulateMessage();
stateMachine.setChallengeInfo(eapPayload.getIdentifier(), challengeState);
eth = buildEapolResponse(stateMachine.supplicantAddress(),