Search in sources :

Example 1 with AccessAccept

use of org.forgerock.openam.radius.common.AccessAccept in project OpenAM by OpenRock.

the class OpenAMAuthHandler method allowAccessAndTerminateProcess.

/**
     * Sends RADIUS AccessAccept response and cleans up the cache and authentication context.
     *
     * @param respHandler
     * @param holder
     * @throws RadiusProcessingException
     */
private void allowAccessAndTerminateProcess(RadiusResponse response, ContextHolder holder) throws RadiusProcessingException {
    response.setResponsePacket(new AccessAccept());
    response.setUniversalId(holder.getUniversalId());
    terminateAuthnProcess(holder);
}
Also used : AccessAccept(org.forgerock.openam.radius.common.AccessAccept)

Example 2 with AccessAccept

use of org.forgerock.openam.radius.common.AccessAccept in project OpenAM by OpenRock.

the class AcceptAllHandler method handle.

@Override
public void handle(RadiusRequest request, RadiusResponse response, RadiusRequestContext reqCtx) throws RadiusProcessingException {
    final AccessAccept resp = new AccessAccept();
    response.setResponsePacket(resp);
    return;
}
Also used : AccessAccept(org.forgerock.openam.radius.common.AccessAccept)

Example 3 with AccessAccept

use of org.forgerock.openam.radius.common.AccessAccept in project OpenAM by OpenRock.

the class ConsoleClient method run.

/**
     * Calls the server in a thread.
     */
@Override
public void run() {
    try {
        final DatagramChannel chan = DatagramChannel.open();
        // request id
        short reqId = 1;
        final SecureRandom random = new SecureRandom();
        final InetSocketAddress serverAddr = new InetSocketAddress(this.host, this.port);
        final NASIPAddressAttribute nasAddr = new NASIPAddressAttribute(InetAddress.getLocalHost());
        final NASPortAttribute nasPort = new NASPortAttribute(chan.socket().getLocalPort());
        StateAttribute state = null;
        // String username = "boydmr"; // TODO: restore
        final String username = getUserInputFor("Username", null);
        // String passwordOrAnswer = "password"; // TODO: restore
        String passwordOrAnswer = getUserInputFor("Password", null);
        System.out.println();
        boolean finished = false;
        // ready for writing
        final ByteBuffer bufIn = ByteBuffer.allocate(4096);
        while (!finished) {
            final RequestAuthenticator reqAuthR = new RequestAuthenticator(random, this.secret);
            final AccessRequest req = new AccessRequest(reqId++, reqAuthR);
            req.addAttribute(new UserNameAttribute(username));
            req.addAttribute(new UserPasswordAttribute(req.getAuthenticator(), this.secret, passwordOrAnswer));
            req.addAttribute(nasAddr);
            req.addAttribute(nasPort);
            if (state != null) {
                req.addAttribute(state);
            }
            final ByteBuffer reqBuf = ByteBuffer.wrap(req.getOctets());
            if (logTraffic) {
                System.out.println("Packet To " + host + ":" + port);
                System.out.println(RadiusRequestContext.getPacketRepresentation(req));
            }
            chan.send(reqBuf, serverAddr);
            // now handle responses possibly sending additional requests
            chan.receive(bufIn);
            // prepare buffer for reading out
            bufIn.flip();
            final Packet res = PacketFactory.toPacket(bufIn);
            // prepare buffer for next response
            bufIn.clear();
            if (logTraffic) {
                System.out.println("Packet From " + host + ":" + port);
                System.out.println(RadiusRequestContext.getPacketRepresentation(res));
            }
            if (res instanceof AccessReject) {
                System.out.println("---> Sorry. Not Authenticated.");
                System.out.println();
                finished = true;
            } else if (res instanceof AccessAccept) {
                System.out.println("---> SUCCESS! You've Authenticated!");
                System.out.println();
                finished = true;
            } else if (res instanceof AccessChallenge) {
                final AccessChallenge chng = (AccessChallenge) res;
                state = (StateAttribute) getAttribute(StateAttribute.class, res);
                final ReplyMessageAttribute msg = (ReplyMessageAttribute) getAttribute(ReplyMessageAttribute.class, res);
                String message = null;
                if (msg != null) {
                    message = msg.getMessage();
                }
                passwordOrAnswer = getUserInputFor("Answer", message);
                System.out.println();
            }
        }
    } catch (final Exception e) {
        e.printStackTrace();
    }
}
Also used : StateAttribute(org.forgerock.openam.radius.common.StateAttribute) Packet(org.forgerock.openam.radius.common.Packet) RequestAuthenticator(org.forgerock.openam.radius.common.RequestAuthenticator) AccessRequest(org.forgerock.openam.radius.common.AccessRequest) InetSocketAddress(java.net.InetSocketAddress) DatagramChannel(java.nio.channels.DatagramChannel) SecureRandom(java.security.SecureRandom) NASIPAddressAttribute(org.forgerock.openam.radius.common.packet.NASIPAddressAttribute) ByteBuffer(java.nio.ByteBuffer) IOException(java.io.IOException) ReplyMessageAttribute(org.forgerock.openam.radius.common.ReplyMessageAttribute) UserNameAttribute(org.forgerock.openam.radius.common.UserNameAttribute) AccessReject(org.forgerock.openam.radius.common.AccessReject) NASPortAttribute(org.forgerock.openam.radius.common.packet.NASPortAttribute) AccessChallenge(org.forgerock.openam.radius.common.AccessChallenge) UserPasswordAttribute(org.forgerock.openam.radius.common.UserPasswordAttribute) AccessAccept(org.forgerock.openam.radius.common.AccessAccept)

Aggregations

AccessAccept (org.forgerock.openam.radius.common.AccessAccept)3 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 ByteBuffer (java.nio.ByteBuffer)1 DatagramChannel (java.nio.channels.DatagramChannel)1 SecureRandom (java.security.SecureRandom)1 AccessChallenge (org.forgerock.openam.radius.common.AccessChallenge)1 AccessReject (org.forgerock.openam.radius.common.AccessReject)1 AccessRequest (org.forgerock.openam.radius.common.AccessRequest)1 Packet (org.forgerock.openam.radius.common.Packet)1 ReplyMessageAttribute (org.forgerock.openam.radius.common.ReplyMessageAttribute)1 RequestAuthenticator (org.forgerock.openam.radius.common.RequestAuthenticator)1 StateAttribute (org.forgerock.openam.radius.common.StateAttribute)1 UserNameAttribute (org.forgerock.openam.radius.common.UserNameAttribute)1 UserPasswordAttribute (org.forgerock.openam.radius.common.UserPasswordAttribute)1 NASIPAddressAttribute (org.forgerock.openam.radius.common.packet.NASIPAddressAttribute)1 NASPortAttribute (org.forgerock.openam.radius.common.packet.NASPortAttribute)1