use of com.sun.identity.authentication.modules.radius.RADIUSServer in project OpenAM by OpenRock.
the class RadiusConn method sendPacket.
/**
* Finds an available server and then sends a packet to that servers.
*
* @param packet the packet.
* @throws IOException if there is a problem.
* @throws RejectException if there is a problem.
* @throws ChallengeException if there is a problem.
*/
private void sendPacket(Packet packet) throws IOException, RejectException, ChallengeException {
Packet res = null;
RADIUSServer server = null;
while (res == null) {
server = getOnlineServer();
if (debug.messageEnabled()) {
debug.message("Using " + server + " for contact RADIUS");
}
try {
send(packet, server);
res = receive();
if (res instanceof AccessReject) {
throw new RejectException((AccessReject) res);
} else if (res instanceof AccessChallenge) {
throw new ChallengeException((AccessChallenge) res);
}
} catch (IOException ioe) {
if (ioe instanceof ConnectException || ioe instanceof SocketTimeoutException) {
if (debug.messageEnabled()) {
debug.message("Moving server to offline state - " + server);
}
synchronized (SERVER_STATUS) {
SERVER_STATUS.put(server, Boolean.FALSE);
}
synchronized (SERVER_MONITOR_LOCK) {
if (serverMonitor == null || serverMonitor.scheduledExecutionTime() == -1) {
serverMonitor = new RADIUSMonitor();
SystemTimer.getTimer().schedule(serverMonitor, new Date(((System.currentTimeMillis()) / 1000) * 1000));
}
}
} else {
throw ioe;
}
}
}
}
Aggregations