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);
}
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;
}
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();
}
}
Aggregations