public boolean handle(JRadiusRequest request) throws Exception { RadiusPacket req = request.getRequestPacket(); RadiusPacket rep = request.getReplyPacket(); AttributeList ci = request.getConfigItems(); String u = (String) req.getAttributeValue(Attr_UserName.TYPE); String n = (String) req.getAttributeValue(Attr_NASIdentifier.TYPE); if ((username != null && username.equals(u)) || (nasid != null && nasid.equals(n))) { if (request.getType() == JRadiusServer.JRADIUS_authorize) { // Reject the user (which should be fine for monitoring) // and stop processing the current handler chain RadiusLog.info("Answering monitoring request: {User-Name = " + username + ", NAS-Identifier = " + nasid + "}"); if (replyMessage != null) { rep.addAttribute(new Attr_ReplyMessage(replyMessage)); } ci.add(new Attr_AuthType(Attr_AuthType.Reject)); } return true; } return false; }
public boolean handle(JRadiusRequest request) throws Exception { RadiusRequest req = (RadiusRequest) request.getRequestPacket(); RadiusResponse res = radiusClient.sendReceive(req, 3); request.setReplyPacket(res); return false; }
public void printDebugInfo() { if (Configuration.isDebug()) { RadiusPacket[] rp = this.getPackets(); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); // debug info: pw.println(">>> packets in request from \"" + getSender() + "\":"); for (int i=0; i < rp.length; i++) if (rp[i] != null) { pw.println("--- packet " + (i+1) + " of " + rp.length); pw.println(rp[i].toString()); } pw.println("Configuration Items:"); pw.println(getConfigItems().toString()); pw.flush(); RadiusLog.debug(sw.toString()); } }
/** * Add an attribute to the reply by adding to the reply packet, if one, * or the configItems. * @param a The RadiusAttribute */ public void addReplyAttribute(RadiusAttribute a) { if (hasReplyPacket()) try { getReplyPacket().addAttribute(a); } catch (RadiusException e) {} else getConfigItems().add(a); }
public String toString() { StringBuffer sb = new StringBuffer("{"); sb.append(" requester = ").append(getSender()); sb.append(", type = ").append(getTypeString()); sb.append(" }"); return sb.toString(); } }
public boolean handle(JRadiusRequest request) throws Exception JRadiusSession session = (JRadiusSession) request.getSession(); if (session == null) return noSessionFound(request); RadiusPacket req = request.getRequestPacket(); RadiusPacket rep = request.getReplyPacket(); AttributeList ci = request.getConfigItems(); if (request.getApplicationContext() == null) WebServiceListener wsListener = (WebServiceListener)request.getApplicationContext().getBean(listenerBean); if (wsListener == null) return false; OTPProxyRequest otpRequest = (OTPProxyRequest)wsListener.get(username); request.setReturnValue(JRadiusServer.RLM_MODULE_REJECT); return true; request.setReturnValue(JRadiusServer.RLM_MODULE_REJECT); return true;
AttributeList ci = request.getConfigItems(); RadiusPacket req = request.getRequestPacket(); RadiusPacket rep = request.getReplyPacket(); request.setReplyPacket(rep); request.setReturnValue(JRadiusServer.RLM_MODULE_UPDATED); request.setReturnValue(JRadiusServer.RLM_MODULE_UPDATED); return false;
JRadiusSessionManager sessionManager = JRadiusSessionManager.getManager(request.getSender()); JRadiusSession session = null; session = request.getSession(); mesg = mesg + ": " + request.getRequestPacket().toString(); request.setSession(session); result = request.getReturnValue(); logReturnCode(result, handler); if (stop) break; if (result == JRadiusServer.RLM_MODULE_REJECT && request.isAccountingRequest()) HandlerLogEvent log = new HandlerLogEvent(request, request.getSessionKey(), result); getEventDispatcher().post(log);
public boolean handle(JRadiusRequest request) throws RadiusException { RadiusPacket req = request.getRequestPacket(); AttributeList ci = request.getConfigItems(); JRadiusSession session = request.getSession(); if (session == null) return false; String proxyToRealm = session.getProxyToRealm(); if (proxyToRealm != null) { /* * If this session was the result of a terminated EAP Tunnel, * then proxy accounting to the home realm after adjusting * the User-Name to that in the EAP Tunnel. */ RadiusAttribute a; if ((a = req.findAttribute(Attr_StrippedUserName.TYPE)) != null) req.removeAttribute(a); if ((a = req.findAttribute(Attr_Realm.TYPE)) != null) req.removeAttribute(a); req.overwriteAttribute(new Attr_UserName(session.getUsername() + "@" + session.getRealm())); ci.add(new Attr_ProxyToRealm(proxyToRealm)); request.setReturnValue(JRadiusServer.RLM_MODULE_UPDATED); return true; } return false; } }
public boolean handle(JRadiusRequest request) throws RadiusException JRadiusSession session = request.getSession(); if (session == null) return noSessionFound(request); p = request.getReplyPacket(); p = request.getRequestPacket(); request.setReturnValue(JRadiusServer.RLM_MODULE_UPDATED); return false;
if (request.getType() == JRadiusServer.JRADIUS_accounting) RadiusPacket req = request.getRequestPacket(); Long i = (Long) req.getAttributeValue(AttributeDictionary.ACCT_STATUS_TYPE); if (i != null) command = (JRCommand)catalog.getCommand(request.getTypeString()); return execute(command, request);
public boolean handle(JRadiusRequest request) throws Exception { JRadiusSession session = (JRadiusSession) request.getSession(); if (session == null) return noSessionFound(request); RadiusPacket req = request.getRequestPacket(); String username = (String)req.getAttributeValue(Attr_UserName.TYPE); if (request.getApplicationContext() == null) { RadiusLog.error(this.getClass().getName()+" can only run when configured with Spring"); return false; } WebServiceListener wsListener = (WebServiceListener)request.getApplicationContext().getBean(listenerBean); if (wsListener == null) return false; OTPProxyRequest otpRequest = (OTPProxyRequest)wsListener.get(username); if (otpRequest == null) return false; otpRequest.updateAccounting((AccountingRequest)req); return false; } }
public boolean handle(JRadiusRequest request, byte[] hwAddress, AddressPool pool) throws Exception RadiusPacket req = request.getRequestPacket(); RadiusPacket rep = request.getReplyPacket(); request.setReplyPacket(rep);
public JRadiusLogEntry getLogEntry(JRadiusRequest request) throws RadiusException { AttributeList ci = request.getConfigItems(); RadiusAttribute a = ci.get(Attr_JRadiusRequestId.TYPE); String key; if (a != null) key = (String)a.getValue().getValueObject(); else key = Integer.toString((char)request.getRequestPacket().getIdentifier()); JRadiusLogEntry entry = getLogEntry(request, key); entry.setCode(new Integer(request.getReturnValue())); return entry; }
/** * Generates a session hash key based on dhcp-packet attributes. * @param request The JRadiusRequest * @return the session key * @throws RadiusException */ public Serializable getDHCPRequestKey(JRadiusRequest request) throws RadiusException { RadiusPacket req = request.getRequestPacket(); StringBuffer sb = new StringBuffer((String)request.getSender()); sb.append(":").append(getKeyFromAttributeType(req, Attr_DHCPGatewayIPAddress.TYPE, true)); sb.append(":").append(getKeyFromAttributeType(req, Attr_DHCPTransactionId.TYPE, true)); sb.append(":").append(getKeyFromAttributeType(req, Attr_DHCPClientHardwareAddress.TYPE, true)); return sb.toString(); }
RadiusPacket req = request.getRequestPacket(); RadiusPacket rep = request.getReplyPacket(); String errMessage = ""; RadiusException ex = null; RadiusLog.problem(request, request.getSession(), ex, errMessage.substring(2));
public boolean handle(JRadiusRequest request) throws RadiusException RadiusPacket req = request.getRequestPacket(); AttributeList ci = request.getConfigItems(); JRadiusSession session = request.getSession(); JRadiusLogEntry logEntry = session.getLogEntry(request);
public boolean onPreProcessing(JRadiusRequest request) throws RadiusException switch(request.getType()) if (!request.isAccountingRequest()) break; AccountingRequest accountingRequest = (AccountingRequest) request.getRequestPacket();
/** * Gets the session key based on the JRadiusSessionId attribute in the configItems. * @param request The JRadiusRequest * @return the session key * @throws RadiusException */ public Serializable getAppSessionKey(JRadiusRequest request) throws RadiusException { AttributeList ci = request.getConfigItems(); // If we already have seen this packet (in the chain or // within the same FreeRADIUS request - multiple calls to JRadius) // we can grab the JRadius-Session-Id. RadiusAttribute a = ci.get(Attr_JRadiusSessionId.TYPE); if (a != null) return a.getValue().getValueObject(); return null; }
RadiusPacket req = request.getRequestPacket(); int type = request.getType(); int status = ((AccountingRequest)req).getAccountingStatusType();