本文整理汇总了Java中net.jradius.packet.RadiusPacket.getAttributeValue方法的典型用法代码示例。如果您正苦于以下问题:Java RadiusPacket.getAttributeValue方法的具体用法?Java RadiusPacket.getAttributeValue怎么用?Java RadiusPacket.getAttributeValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.jradius.packet.RadiusPacket
的用法示例。
在下文中一共展示了RadiusPacket.getAttributeValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
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;
}
示例2: onPostAuthentication
import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
public void onPostAuthentication(JRadiusRequest request) throws RadiusException
{
RadiusPacket rep = request.getReplyPacket();
boolean success = (rep instanceof AccessAccept && request.getReturnValue() != JRadiusServer.RLM_MODULE_REJECT);
RadiusLog.debug("Authentication: " + request + " was" + (success ? "" : " NOT") + " sucessful");
if (success)
{
Long sessionTimeout = (Long)rep.getAttributeValue(Attr_SessionTimeout.TYPE);
if (checkSessionState(ACCT_STARTED))
{
if (sessionTimeout != null)
{
Long sessionTime = getSessionTime();
if (sessionTime != null)
{
// Compensate the sessionTimeout for re-authentications
sessionTimeout = new Long(sessionTimeout.longValue() - sessionTime.longValue());
}
}
}
else
{
setSessionState(AUTH_ACCEPTED);
}
setIdleTimeout((Long)rep.getAttributeValue(Attr_IdleTimeout.TYPE));
setInterimInterval((Long)rep.getAttributeValue(Attr_AcctInterimInterval.TYPE));
setSessionTimeout(sessionTimeout);
}
else
{
setSessionState(AUTH_REJECTED);
}
}
示例3: init
import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
public void init(JRadiusRequest request, JRadiusSession session) throws RadiusException
{
RadiusPacket req = request.getRequestPacket();
setType(request);
// The client IP should never be changing
if (getClientIPAddress() == null)
{
InetAddress clientAddress = (InetAddress) req.getAttributeValue(Attr_ClientIPAddress.TYPE);
if (clientAddress != null)
setClientIPAddress(clientAddress.getHostAddress());
}
// We want the original NAS-Identifier, not any rewrite
// Grab the value at the first call to InitHandler
if (getNasIdentifier() == null)
{
String nasId = (String) req.getAttributeValue(Attr_NASIdentifier.TYPE);
setNasIdentifier(nasId);
}
if (getUserName() == null)
setUserName(session.getUsername());
if (getRealm() == null)
setRealm(session.getRealm());
// The inbound request should be got at the preacct or authorize
// at the first position in the chain
if (getInboundRequest() == null)
setInboundRequest(req.toString(false, true));
}
示例4: handle
import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
public boolean handle(JRadiusRequest request) throws Exception
{
RadiusPacket req = request.getRequestPacket();
if (req.getCode() < 1024) return false;
byte[] hwAddress = (byte[])req.getAttributeValue(Attr_DHCPClientHardwareAddress.TYPE);
if (hwAddress == null) throw new DHCPException("no hardware address");
return handle(request, hwAddress, getDefaultPool());
}
示例5: handle
import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
public boolean handle(JRadiusRequest request) throws Exception
{
JRadiusSession session = request.getSession();
if (session == null) return noSessionFound(request);
// System.err.println(this.getClass().getName());
RadiusPacket req = request.getRequestPacket();
byte[] packetClass = (byte[])req.getAttributeValue(Attr_Class.TYPE);
byte[][] sessionClass = session.getRadiusClass();
if (packetClass != null || sessionClass != null)
{
if (sessionClass == null)
{
session.addLogMessage(request, "Request has Class attribute when it should not");
}
else
{
session.addLogMessage(request, "Missing Class Attribute (added)");
req.removeAttribute(Attr_Class.TYPE);
for (byte[] a : sessionClass) {
req.addAttribute(AttributeFactory.newAttribute(Attr_Class.TYPE, a, req.isRecyclable()));
}
}
}
if (req instanceof AccessRequest)
{
byte[] sessionState = session.getRadiusState();
if (sessionState != null)
{
// System.out.println("Missing State Attribute (added) "+sessionState.length+" "+sessionState[0]);
req.overwriteAttribute(AttributeFactory.newAttribute(Attr_State.TYPE, sessionState, req.isRecyclable()));
}
}
return false;
}
示例6: handle
import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
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;
}
示例7: reverseAccounting
import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
protected void reverseAccounting(RadiusPacket req) throws RadiusException
{
Long octetsIn = (Long)req.getAttributeValue(Attr_AcctInputOctets.TYPE);
Long octetsOut = (Long)req.getAttributeValue(Attr_AcctOutputOctets.TYPE);
Long gigaIn = (Long)req.getAttributeValue(Attr_AcctInputGigawords.TYPE);
Long gigaOut = (Long)req.getAttributeValue(Attr_AcctOutputGigawords.TYPE);
Long packetsIn = (Long)req.getAttributeValue(Attr_AcctInputPackets.TYPE);
Long packetsOut = (Long)req.getAttributeValue(Attr_AcctOutputPackets.TYPE);
if (octetsIn != null && octetsOut != null)
{
req.overwriteAttribute(AttributeFactory.newAttribute(Attr_AcctInputOctets.TYPE, octetsOut, req.isRecyclable()));
req.overwriteAttribute(AttributeFactory.newAttribute(Attr_AcctOutputOctets.TYPE, octetsIn, req.isRecyclable()));
}
if (gigaIn != null && gigaOut != null)
{
req.overwriteAttribute(AttributeFactory.newAttribute(Attr_AcctInputGigawords.TYPE, gigaOut, req.isRecyclable()));
req.overwriteAttribute(AttributeFactory.newAttribute(Attr_AcctOutputGigawords.TYPE, gigaIn, req.isRecyclable()));
}
if (packetsIn != null && packetsOut != null)
{
req.overwriteAttribute(AttributeFactory.newAttribute(Attr_AcctInputPackets.TYPE, packetsOut, req.isRecyclable()));
req.overwriteAttribute(AttributeFactory.newAttribute(Attr_AcctOutputPackets.TYPE, packetsIn, req.isRecyclable()));
}
}
示例8: handle
import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
public boolean handle(JRadiusRequest request) throws RadiusException
{
JRadiusSession session = request.getSession();
if (session == null) return noSessionFound(request);
RadiusPacket req = request.getRequestPacket();
byte[] bClass = (byte[]) req.getAttributeValue(Attr_Class.TYPE);
if (bClass != null)
{
String sClass = new String(bClass);
if (sClass.startsWith(ClassPrefix))
{
req.removeAttribute(Attr_Class.TYPE);
byte[][] classes = session.getRadiusClass();
if (classes != null)
{
for (byte[] c : classes)
{
RadiusAttribute cattr = AttributeFactory.newAttribute(Attr_Class.TYPE, c, req.isRecyclable());
req.addAttribute(cattr);
}
}
return false;
}
}
session.addLogMessage(request, "Accounting without Class Attribute");
return false;
}
示例9: handle
import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
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;
RadiusLog.debug("OTP Auth received: "+username+"/"+otpRequest.getUserName());
session.setUsername("OTP("+otpRequest.getUserName()+")");
session.setRealm(otpRequest.getRadiusRealm().getRealm());
setPlainTextPassword(request, otpRequest.getOtpPassword());
return false;
}
示例10: handle
import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
public boolean handle(JRadiusRequest request) throws Exception
{
Catalog catalog = getCatalog();
if (catalog != null)
{
JRCommand command;
if (request.getType() == JRadiusServer.JRADIUS_accounting)
{
RadiusPacket req = request.getRequestPacket();
Long i = (Long) req.getAttributeValue(AttributeDictionary.ACCT_STATUS_TYPE);
if (i != null)
{
String com = "other_accounting";
switch(i.intValue())
{
case AccountingRequest.ACCT_STATUS_START: com = "start_accounting"; break;
case AccountingRequest.ACCT_STATUS_STOP: com = "stop_accounting"; break;
case AccountingRequest.ACCT_STATUS_INTERIM: com = "interim_accounting"; break;
case AccountingRequest.ACCT_STATUS_ACCOUNTING_ON: com = "accounting_on"; break;
case AccountingRequest.ACCT_STATUS_ACCOUNTING_OFF: com = "accounting_off"; break;
}
command = (JRCommand)catalog.getCommand(com);
if (command != null) return execute(command, request);
}
}
command = (JRCommand)catalog.getCommand(request.getTypeString());
return execute(command, request);
}
return true;
}
示例11: handle
import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
public boolean handle(JRadiusRequest jRequest)
{
try
{
/*
* Gather some information about the JRadius request
*/
int type = jRequest.getType();
AttributeList ci = jRequest.getConfigItems();
RadiusPacket req = jRequest.getRequestPacket();
RadiusPacket rep = jRequest.getReplyPacket();
/*
* Find the username in the request packet
*/
String username = (String)req.getAttributeValue(Attr_UserName.TYPE);
/*
* See if this is a local user, otherwise we will reject (though, you may
* want to return "ok" if you have modules configured after jradius in FreeRADIUS)
*/
LocalUser u = (LocalUser) users.get(username);
if (u == null)
{
// Unknown username, so let the RADIUS server sort it out.
RadiusLog.info("Ignoring unknown username: " + username);
return false;
}
switch (type)
{
case JRadiusServer.JRADIUS_authorize:
{
/*
* We know the user, lets inform FreeRADIUS of the user's
* password so that FreeRADIUS may perform the required
* authentication checks.
*/
//ci.add(new Attr_AuthType(Attr_AuthType.Local)); // Auth locally
ci.add(new Attr_UserPassword(u.password)); // FreeRADIUS 1.0
ci.add(new Attr_CleartextPassword(u.password)); // FreeRADIUS 2.0
}
break;
case JRadiusServer.JRADIUS_post_auth:
{
if (rep instanceof AccessAccept)
{
/*
* FreeRADIUS has returned after the authentication checks and the
* user's credentials worked. Since we are now returning an AccessAccept,
* we will the packet with the attributes configured for the user.
*/
rep.addAttributes(u.getAttributeList());
//RadiusLog.info("Authentication successful for username: " + username);
}
else
{
RadiusLog.info("Authentication failed for username: " + username);
}
}
break;
}
}
catch (RadiusException e)
{
e.printStackTrace();
}
/*
* Everything worked out well, from the perspective of this module.
*/
jRequest.setReturnValue(JRadiusServer.RLM_MODULE_UPDATED);
return false;
}
示例12: initSession
import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
public void initSession(JRadiusRequest request) throws RadiusException
{
RadiusPacket req = request.getRequestPacket();
String username = (String)req.getAttributeValue(Attr_UserName.TYPE);
String realm = (String)req.getAttributeValue(Attr_Realm.TYPE);
String stripUsername = null;
if (username != null)
{
stripUsername = username;
if (realm == null)
{
String[] s = RadiusSessionSupport.splitUserName(username);
if (s != null && s.length == 2)
{
stripUsername = s[0];
realm = s[1];
}
}
else
{
stripUsername = (String)req.getAttributeValue(Attr_StrippedUserName.TYPE);
if (stripUsername == null) stripUsername = username;
}
}
setUsername(stripUsername);
setRealm(realm);
Long zero = new Long(0);
setSessionTime(zero);
setPacketsIn(zero);
setPacketsOut(zero);
setOctetsIn(zero);
setOctetsOut(zero);
setGigaWordsIn(zero);
setGigaWordsOut(zero);
setServiceType((Long)req.getAttributeValue(Attr_ServiceType.TYPE));
setNasPortType((Long)req.getAttributeValue(Attr_NASPortType.TYPE));
setConnectInfo((String)req.getAttributeValue(Attr_ConnectInfo.TYPE));
setCallingStationId((String)req.getAttributeValue(Attr_CallingStationId.TYPE));
setCalledStationId((String)req.getAttributeValue(Attr_CalledStationId.TYPE));
setSessionId((String) req.getAttributeValue(Attr_AcctSessionId.TYPE));
setNasIdentifier((String)req.getAttributeValue(Attr_NASIdentifier.TYPE));
InetAddress inet = (InetAddress) req.getAttributeValue(Attr_NASIPAddress.TYPE);
if (inet != null) setNasIPAddress(inet.getHostAddress());
inet = (InetAddress) req.getAttributeValue(Attr_FramedIPAddress.TYPE);
if (inet != null) setFramedIPAddress(inet.getHostAddress());
if (getNasIdentifier() == null) setNasIdentifier(getNasIPAddress());
}
示例13: handle
import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
/**
* This handler is to be chained before the actual InitSessionHandler.
* In the event the request is the inner request of a TLS tunnel, the associated
* session if found and configured.
* @see net.jradius.handler.PacketHandler#handle(net.jradius.server.JRadiusRequest)
*/
public boolean handle(JRadiusRequest request) throws RadiusException
{
int type = request.getType();
RadiusPacket req = request.getRequestPacket();
String fullUserName = (String) req.getAttributeValue(Attr_UserName.TYPE);
String stripUserName = null;
String realm = null;
JRadiusSession session = request.getSession();
if (fullUserName == null) return false;
stripUserName = fullUserName;
String[] s = RadiusSessionSupport.splitUserName(stripUserName);
if (s != null && s.length == 2)
{
stripUserName = s[0];
realm = s[1];
}
if (type == JRadiusServer.JRADIUS_authorize &&
req.findAttribute(Attr_FreeRADIUSProxiedTo.TYPE) != null)
{
// If we are proxy-ing the request to ourselves,
// this is an inner-tunnel authentication.
RadiusSessionKeyProvider skp = (RadiusSessionKeyProvider)JRadiusSessionManager.getManager(request.getSender()).getSessionKeyProvider(request.getSender());
Element element = tlsTunnels.get(skp.getTunneledRequestKey(request));
if (element == null) return false;
String sessionKey = (String)element.getValue();
if (sessionKey == null)
{
request.setReturnValue(JRadiusServer.RLM_MODULE_REJECT);
return true;
}
session = JRadiusSessionManager.getManager(request.getSender()).getSession(request, sessionKey);
if (session == null) throw new RadiusException("Could not find on-going tunneled session: " + sessionKey);
session.setSecured(true);
session.setUsername(stripUserName);
session.setRealm(realm);
request.setSession(session);
String r = (String)req.getAttributeValue(Attr_Realm.TYPE);
if (r != null)
{
if ("DEFAULT".equals(r))
{
r = realm;
}
if (!isLocalRealm(r))
{
session.setProxyToRealm(r);
}
}
}
return false;
}
示例14: handle
import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
public boolean handle(JRadiusRequest request) throws Exception
{
RadiusPacket req = request.getRequestPacket();
AttributeList ci = request.getConfigItems();
JRadiusSession session = request.getSession();
String username = (String) req.getAttributeValue(Attr_UserName.TYPE);
String realm = session.getRealm();
Attr_EAPType eap = (Attr_EAPType) req.findAttribute(Attr_EAPType.TYPE);
if (eap != null)
{
NamedValue eapv = (NamedValue)eap.getValue();
String eapType = eapv.getValueString();
if (session.isSecured())
{
Catalog catalog = getCatalog();
if (catalog != null && chainName != null)
{
JRCommand c = (JRCommand)catalog.getCommand(chainName);
if (c == null)
{
RadiusLog.error("There is no command '" + chainName + "' in catalog " + getCatalogName());
return false;
}
return execute(c, request);
}
}
else if ((Attr_EAPType.Identity.equals(eapType) ||
Attr_EAPType.NAK.equals(eapType) ||
Attr_EAPType.EAPTTLS.equals(eapType) ||
Attr_EAPType.PEAP.equals(eapType)) &&
((anonUserName != null && anonUserName.equals(username)) ||
terminatedRealms.containsKey(realm)))
{
// Here we are returning NOOP so that TTLS or PEAP tunnels
// can terminate at this radius server and we can proxy the tunneled credentials.
RadiusSessionKeyProvider skp = (RadiusSessionKeyProvider)JRadiusSessionManager.getManager(request.getSender()).getSessionKeyProvider(request.getSender());
// Rewrite the log type (not an authorization, but a tunnel
// termination)
session.getLogEntry(request).setType("tls-tunnel");
// Force the local handling of the tunnel (do not proxy)
ci.remove(Attr_ProxyToRealm.TYPE);
// Record the session as a tls tunnel
tlsTunnels.put(new Element(skp.getTunneledRequestKey(request), session.getSessionKey()));
RadiusLog.info("EAP-TTLS Termination: username = " + username + ", session = " + session.getSessionKey());
return true;
}
}
return false;
}
示例15: handle
import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
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();
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;
req.addAttribute(new Attr_JRadiusSessionId(session.getSessionKey()));
otpRequest.setAccessRequest((RadiusRequest)req);
RadiusResponse resp = otpRequest.getAccessResponse();
if (resp == null)
{
ci.add(new Attr_AuthType(Attr_AuthType.Reject));
request.setReturnValue(JRadiusServer.RLM_MODULE_REJECT);
return true;
}
RadiusLog.debug(
"------------------------------------------------\n"+
"OTP Proxy Response:\n" + resp.toString()+
"------------------------------------------------\n");
if (resp instanceof AccessAccept)
{
AttributeList attrs = resp.getAttributes();
attrs.remove(Attr_Class.TYPE);
attrs.remove(Attr_State.TYPE);
attrs.remove(Attr_EAPMessage.TYPE);
attrs.remove(Attr_MessageAuthenticator.TYPE);
rep.addAttributes(attrs);
return false;
}
ci.add(new Attr_AuthType(Attr_AuthType.Reject));
request.setReturnValue(JRadiusServer.RLM_MODULE_REJECT);
return true;
}