boolean authenticated = false;
try{
log.info("Entering RADIUS Validation...");
RadiusPacket accessRequest = new RadiusPacket(RadiusPacket.ACCESS_REQUEST);
RadiusAttribute userNameAttribute;
userNameAttribute = new RadiusAttribute(RadiusAttributeValues.USER_NAME, radUser.getBytes());
accessRequest.setAttribute(userNameAttribute);
accessRequest.setAttribute(new RadiusAttribute(RadiusAttributeValues.USER_PASSWORD, radPass.getBytes()));
RadiusPacket accessResponse = rc.authenticate(accessRequest);
switch(accessResponse.getPacketType()){
case RadiusPacket.ACCESS_ACCEPT:
log.debug("User " + radUser + " validated by RADIUS server");
setRADIUSAttributes(accessResponse);
authenticated = true;
break;
case RadiusPacket.ACCESS_REJECT:
log.warn("User " + radUser + " NOT validated by RADIUS server");
authenticated = false;
break;
case RadiusPacket.ACCESS_CHALLENGE:
String reply = new String(accessResponse.getAttribute(RadiusAttributeValues.REPLY_MESSAGE).getValue());
log.debug("User " + radUser + " Challenged with " + reply);
break;
default:
log.warn("Whoa, what kind of RadiusPacket is this? - " + accessResponse.getPacketType());
break;
}
}catch(InvalidParameterException ivpex){
log.info("InvalidParameterException: " + ivpex.getMessage());