本文整理汇总了Java中net.jradius.exception.RadiusException类的典型用法代码示例。如果您正苦于以下问题:Java RadiusException类的具体用法?Java RadiusException怎么用?Java RadiusException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RadiusException类属于net.jradius.exception包,在下文中一共展示了RadiusException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPostProcessing
import net.jradius.exception.RadiusException; //导入依赖的package包/类
public void onPostProcessing(JRadiusRequest request) throws RadiusException
{
// If we have a session, fire off events
switch(request.getType())
{
case JRadiusServer.JRADIUS_authorize:
onAuthorization(request);
break;
case JRadiusServer.JRADIUS_post_auth:
onPostAuthentication(request);
break;
case JRadiusServer.JRADIUS_preacct:
onAccounting(request);
break;
}
}
示例2: getKeyFromAttributeType
import net.jradius.exception.RadiusException; //导入依赖的package包/类
protected Serializable getKeyFromAttributeType(RadiusPacket req, long type, boolean required) throws RadiusException
{
RadiusAttribute a = req.findAttribute(type);
if (a == null)
{
if (required)
{
a = AttributeFactory.newAttribute(type, null, false);
throw new RadiusException("Missing required attribute: " + a.getAttributeName());
}
return null;
}
AttributeValue v = a.getValue();
return v.toString();
}
示例3: setupRequest
import net.jradius.exception.RadiusException; //导入依赖的package包/类
/**
* @throws NoSuchAlgorithmException
* @see net.jradius.client.auth.RadiusAuthenticator#setupRequest(net.jradius.client.RadiusClient, net.jradius.packet.RadiusPacket)
*/
public void setupRequest(RadiusClient c, RadiusPacket p) throws RadiusException, NoSuchAlgorithmException
{
super.setupRequest(c, p);
tunnelRequest = new AccessRequest(tunneledAttributes);
AttributeList attrs = tunnelRequest.getAttributes();
if (attrs.get(Attr_UserName.TYPE) == null)
attrs.add(AttributeFactory.copyAttribute(username, false));
if (attrs.get(Attr_UserPassword.TYPE) == null)
attrs.add(AttributeFactory.copyAttribute(password, false));
tunnelAuth.setupRequest(c, tunnelRequest);
if (!(tunnelAuth instanceof PAPAuthenticator)) // do not encode pap password
{
tunnelAuth.processRequest(tunnelRequest);
}
}
示例4: doTunnelAuthentication
import net.jradius.exception.RadiusException; //导入依赖的package包/类
protected boolean doTunnelAuthentication(byte id, byte[] in) throws RadiusException, SSLException, NoSuchAlgorithmException
{
byte []out;
if (in != null && in.length > 0)
{
out = tunnelAuth.doEAP(in);
}
else
{
out = tunnelAuth.eapResponse(EAP_IDENTITY, (byte)0, getUsername());
}
putAppBuffer(out);
return true;
}
示例5: writeResponse
import net.jradius.exception.RadiusException; //导入依赖的package包/类
public void writeResponse(JRadiusRequest request, ByteBuffer buffer, OutputStream outputStream) throws IOException, RadiusException, InvalidKeyException, NoSuchAlgorithmException
{
if (Configuration.isDebug())
request.printDebugInfo();
RadiusPacket[] rp = request.getPackets();
RadiusRequest req = (RadiusRequest) rp[0];
RadiusResponse res = (RadiusResponse) rp[1];
String sharedSecret = (String) req.getAttributeValue(Attr_SharedSecret.TYPE);
RadiusFormat format = RadiusFormat.getInstance();
MessageAuthenticator.generateResponseMessageAuthenticator(req, res, sharedSecret);
res.generateAuthenticator(req.getAuthenticator(), sharedSecret);
buffer.clear();
format.packPacket(res, sharedSecret, buffer, true);
outputStream.write(buffer.array(), 0, buffer.position());
outputStream.flush();
}
示例6: updateAccounting
import net.jradius.exception.RadiusException; //导入依赖的package包/类
public void updateAccounting(AccountingRequest acctRequest) throws RadiusException
{
AccountingRequest newRequest = new AccountingRequest(radiusClient, reqList);
AttributeList attrs = acctRequest.getAttributes();
for (Iterator i=attrs.getAttributeList().iterator(); i.hasNext();)
{
RadiusAttribute at = (RadiusAttribute)i.next();
long type = at.getFormattedType();
if (type == Attr_AcctInputOctets.TYPE ||
type == Attr_AcctOutputOctets.TYPE ||
type == Attr_AcctInputGigawords.TYPE ||
type == Attr_AcctOutputGigawords.TYPE ||
type == Attr_AcctInputPackets.TYPE ||
type == Attr_AcctOutputPackets.TYPE ||
type == Attr_AcctTerminateCause.TYPE ||
type == Attr_AcctSessionStartTime.TYPE ||
type == Attr_AcctDelayTime.TYPE ||
type == Attr_AcctSessionTime.TYPE ||
type == Attr_AcctStatusType.TYPE)
newRequest.addAttribute(AttributeFactory.newAttribute(type, at.getValue().getBytes(), false));
}
radiusClient.accounting(newRequest, 2);
}
示例7: getSession
import net.jradius.exception.RadiusException; //导入依赖的package包/类
public JRadiusSession getSession(JRadiusRequest request, Serializable key) throws RadiusException
{
Element element = sessionCache.get(key);
JRadiusSession session = null;
if (element != null)
{
session = (JRadiusSession) element.getValue();
}
if (session == null && request != null)
{
SessionFactory sf = getSessionFactory(request.getSender());
session = sf.getSession(request, key);
if (session != null)
{
put(session.getJRadiusKey(), session);
put(session.getSessionKey(), session);
}
}
if (session == null) return null;
return session;
}
示例8: receive
import net.jradius.exception.RadiusException; //导入依赖的package包/类
protected RadiusResponse receive(RadiusRequest req) throws Exception
{
if (statusListener != null)
{
statusListener.onBeforeReceive(this);
}
byte replyBytes[] = new byte[RadiusPacket.MAX_PACKET_LENGTH];
DatagramPacket reply = new DatagramPacket(replyBytes, replyBytes.length);
socket.receive(reply);
RadiusPacket replyPacket = PacketFactory.parse(reply, req.isRecyclable());
if (!(replyPacket instanceof RadiusResponse))
{
throw new RadiusException("Received something other than a RADIUS Response to a Request");
}
if (statusListener != null)
{
statusListener.onAfterReceive(this, replyPacket);
}
return (RadiusResponse)replyPacket;
}
示例9: processChallenge
import net.jradius.exception.RadiusException; //导入依赖的package包/类
/**
* EAP requires a challenge/response. The request packet is reset with a new
* RADIUS identifier and the EAP-Message is encoded.
* @throws NoSuchAlgorithmException
* @see net.jradius.client.auth.RadiusAuthenticator#processChallenge(net.jradius.packet.RadiusPacket, net.jradius.packet.RadiusPacket)
*/
public void processChallenge(RadiusPacket p, RadiusPacket r) throws RadiusException, NoSuchAlgorithmException
{
super.processChallenge(p, r);
p.setIdentifier(-1);
byte[] eapReply = AttributeFactory.assembleAttributeList(r.getAttributes(), AttributeDictionary.EAP_MESSAGE);
byte[] eapMessage = doEAP(eapReply);
RadiusAttribute a = p.findAttribute(AttributeDictionary.EAP_MESSAGE);
if (a != null) p.removeAttribute(a);
AttributeFactory.addToAttributeList(p.getAttributes(),
AttributeDictionary.EAP_MESSAGE, eapMessage, p.isRecyclable());
RadiusLog.debug("Sending Challenge:\n" + p.toString());
}
示例10: processRequest
import net.jradius.exception.RadiusException; //导入依赖的package包/类
public void processRequest(RadiusPacket p) throws RadiusException, NoSuchAlgorithmException
{
if (password == null) throw new RadiusException("no password given");
p.removeAttribute(password);
RadiusAttribute attr;
byte authChallenge[] = RadiusRandom.getBytes(16);
byte chapResponse[] = MSCHAP.doMSCHAPv1(password.getValue().getBytes(), authChallenge);
p.addAttribute(attr = AttributeFactory.newAttribute("MS-CHAP-Challenge"));
attr.setValue(authChallenge);
p.addAttribute(attr = AttributeFactory.newAttribute("MS-CHAP-Response"));
attr.setValue(chapResponse);
}
示例11: processRequest
import net.jradius.exception.RadiusException; //导入依赖的package包/类
public void processRequest(RadiusPacket p) throws RadiusException, NoSuchAlgorithmException
{
if (password == null) throw new RadiusException("no password given");
p.removeAttribute(password);
RadiusAttribute attr;
byte authChallenge[] = RadiusRandom.getBytes(16);
byte chapResponse[] = CHAP.chapResponse((byte)p.getIdentifier(), password.getValue().getBytes(), authChallenge);
p.addAttribute(attr = AttributeFactory.newAttribute("CHAP-Challenge"));
attr.setValue(authChallenge);
p.addAttribute(attr = AttributeFactory.newAttribute("CHAP-Password"));
attr.setValue(chapResponse);
}
示例12: setupRequest
import net.jradius.exception.RadiusException; //导入依赖的package包/类
/**
* @param c The RadiusClient context being used
* @param p Setup the Authenticator with packet data
* @throws RadiusException
* @throws NoSuchAlgorithmException
*/
public void setupRequest(RadiusClient c, RadiusPacket p) throws RadiusException, NoSuchAlgorithmException
{
RadiusAttribute a;
client = c;
if (username == null)
{
a = p.findAttribute(AttributeDictionary.USER_NAME);
if (a == null)
throw new RadiusException("You must at least have a User-Name attribute in a Access-Request");
username = AttributeFactory.copyAttribute(a, false);
}
if (password == null)
{
a = p.findAttribute(AttributeDictionary.USER_PASSWORD);
if (a != null)
{
password = AttributeFactory.copyAttribute(a, false);
}
}
}
示例13: handleRadiusException
import net.jradius.exception.RadiusException; //导入依赖的package包/类
protected int handleRadiusException(JRadiusRequest request, RadiusException e)
{
JRadiusSession session = request.getSession();
String error = e.getMessage();
RadiusLog.warn(error);
if (session != null)
{
try
{
session.getLogEntry(request).addMessage(error);
}
catch (RadiusException re)
{
RadiusLog.problem(request, session, re, re.getMessage());
}
// lets not remove the session and let it expire, or maybe
// this was a RADIUS retransmission that should simply be forgotten
//session.setSessionState(JRadiusSession.RADIUS_ERROR);
//sessionManager.removeSession(session);
}
return (e instanceof RadiusSecurityException) ? JRadiusServer.RLM_MODULE_REJECT : JRadiusServer.RLM_MODULE_FAIL;
}
示例14: parse
import net.jradius.exception.RadiusException; //导入依赖的package包/类
/**
* Parse a UDP RADIUS message
* @param dp The Datagram to be parsed
* @return Returns the RadiusPacket
* @throws RadiusException
*/
public static RadiusPacket parse(DatagramPacket dp, boolean pool) throws RadiusException
{
ByteBuffer buffer = ByteBuffer.wrap(dp.getData(), dp.getOffset(), dp.getLength());
RadiusPacket rp = null;
try
{
rp = parseUDP(buffer, pool);
}
catch (IOException e)
{
RadiusLog.error(e.getMessage(), e);
}
return rp;
}
示例15: attributeFromString
import net.jradius.exception.RadiusException; //导入依赖的package包/类
/**
* Parses a string to create a RadiusAttribute. Will either return the
* attribute, or throw an Exception.
* @param src The source String
* @return Returns the RadiusAttribute parsed from String
* @throws RadiusException
* @throws UnknownAttributeException
*/
public static RadiusAttribute attributeFromString(String src) throws RadiusException, UnknownAttributeException
{
String parts[] = src.split("=", 2);
if (parts.length == 2)
{
String attribute = parts[0].trim();
String value = parts[1].trim();
char q = value.charAt(0);
if (q == value.charAt(value.length() - 1) && (q == '\'' || q == '"'))
{
value = value.substring(1, value.length() - 1);
}
return newAttribute(attribute, value, "=");
}
throw new RadiusException("Syntax error for attributes: " + src);
}