Search in sources :

Example 1 with RADIUSServer

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;
            }
        }
    }
}
Also used : Packet(org.forgerock.openam.radius.common.Packet) DatagramPacket(java.net.DatagramPacket) SocketTimeoutException(java.net.SocketTimeoutException) AccessReject(org.forgerock.openam.radius.common.AccessReject) RADIUSServer(com.sun.identity.authentication.modules.radius.RADIUSServer) IOException(java.io.IOException) AccessChallenge(org.forgerock.openam.radius.common.AccessChallenge) Date(java.util.Date) ConnectException(java.net.ConnectException)

Aggregations

RADIUSServer (com.sun.identity.authentication.modules.radius.RADIUSServer)1 IOException (java.io.IOException)1 ConnectException (java.net.ConnectException)1 DatagramPacket (java.net.DatagramPacket)1 SocketTimeoutException (java.net.SocketTimeoutException)1 Date (java.util.Date)1 AccessChallenge (org.forgerock.openam.radius.common.AccessChallenge)1 AccessReject (org.forgerock.openam.radius.common.AccessReject)1 Packet (org.forgerock.openam.radius.common.Packet)1