• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java RadiusPacket类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.jradius.packet.RadiusPacket的典型用法代码示例。如果您正苦于以下问题:Java RadiusPacket类的具体用法?Java RadiusPacket怎么用?Java RadiusPacket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RadiusPacket类属于net.jradius.packet包,在下文中一共展示了RadiusPacket类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: authenticate

import net.jradius.packet.RadiusPacket; //导入依赖的package包/类
@Override
public boolean authenticate(final String username, final String password) throws PreventedException {

    final AttributeList attributeList = new AttributeList();
    attributeList.add(new Attr_UserName(username));
    attributeList.add(new Attr_UserPassword(password));

    RadiusClient client = null;
    try {
        client = this.radiusClientFactory.newInstance();
        LOGGER.debug("Created RADIUS client instance {}", client);

        final AccessRequest request = new AccessRequest(client, attributeList);
        final RadiusPacket response = client.authenticate(
                request,
                RadiusClient.getAuthProtocol(this.protocol.getName()),
                this.retries);

        LOGGER.debug("RADIUS response from {}: {}",
                client.getRemoteInetAddress().getCanonicalHostName(),
                response.getClass().getName());

        if (response instanceof AccessAccept) {
            return true;
        }
    } catch (final Exception e) {
        throw new PreventedException(e);
    } finally {
        if (client != null) {
            client.close();
        }
    }
    return false;
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:35,代码来源:JRadiusServerImpl.java


示例2: getKeyFromAttributeType

import net.jradius.packet.RadiusPacket; //导入依赖的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();
}
 
开发者ID:coova,项目名称:jradius,代码行数:18,代码来源:RadiusSessionKeyProvider.java


示例3: checkPacket

import net.jradius.packet.RadiusPacket; //导入依赖的package包/类
/** 
 * @see net.jradius.standard.RadiusStandard#checkPacket(net.jradius.packet.RadiusPacket)
 */
public void checkPacket(RadiusPacket p, long[] ignore) throws StandardViolatedException
{
    LinkedList missing = new LinkedList();
    
    switch(p.getCode())
    {
    	case AccessRequest.CODE:
    	    checkMissing(p, missing, requiredAccessRequest, ignore);
    		break;

    	case AccessAccept.CODE:
    	    checkMissing(p, missing, requiredAccessAccept, ignore);
			break;

    	case AccessReject.CODE:
			break;

    	case AccountingRequest.CODE:
    	    checkMissing(p, missing, requiredAccounting, ignore);
    		break;
    }
    if (!missing.isEmpty())
        throw new StandardViolatedException(this.getClass(), missing);
}
 
开发者ID:coova,项目名称:jradius,代码行数:28,代码来源:WISPrStandard.java


示例4: setupRequest

import net.jradius.packet.RadiusPacket; //导入依赖的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);
    }
}
 
开发者ID:coova,项目名称:jradius,代码行数:20,代码来源:EAPTTLSAuthenticator.java


示例5: checkStandard

import net.jradius.packet.RadiusPacket; //导入依赖的package包/类
private void checkStandard(RadiusStandard radiusStandard, RadiusPacket p)
{
    if (radiusStandard != null)
    {
        try
        {
            radiusStandard.checkPacket(p);
        }
        catch (StandardViolatedException e)
        {
            setStatus(radiusStandard.getName() + " standard violated");
            logErr.println(radiusStandard.getName() + " Standard Violated: " + p.getClass().getName());
            logErr.println(logSepLine);
            logErr.println("Missing attributes:");
            logErr.println(e.listAttributes("\n") + "\n");
            logErr.flush();
        }
    }
}
 
开发者ID:coova,项目名称:jradius,代码行数:20,代码来源:JRadiusSimulator.java


示例6: writeResponse

import net.jradius.packet.RadiusPacket; //导入依赖的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();
  }
 
开发者ID:coova,项目名称:jradius,代码行数:24,代码来源:RadSecProcessor.java


示例7: 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;
}
 
开发者ID:coova,项目名称:jradius,代码行数:25,代码来源:OTPProxyAccountingHandler.java


示例8: packPacket

import net.jradius.packet.RadiusPacket; //导入依赖的package包/类
public void packPacket(RadiusPacket packet, String sharedSecret, ByteBuffer buffer, boolean onWire) throws IOException
{
    if (packet == null)
    {
        throw new IllegalArgumentException("Packet is null.");
    }

    int initialPosition = buffer.position();
    buffer.position(initialPosition + 12);
    packAttributeList(packet.getAttributes(), buffer, onWire);

    int finalPosition = buffer.position();
    int totalLength = finalPosition - initialPosition;
    int attributesLength = totalLength - 12;
    
    try
    {
    	buffer.position(initialPosition);
    	packHeader(buffer, packet, attributesLength, sharedSecret);
    	buffer.position(finalPosition);
    }
    catch(Exception e)
    {
        RadiusLog.warn(e.getMessage(), e);
    }
}
 
开发者ID:coova,项目名称:jradius,代码行数:27,代码来源:FreeRadiusFormat.java


示例9: receive

import net.jradius.packet.RadiusPacket; //导入依赖的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;
}
 
开发者ID:coova,项目名称:jradius,代码行数:27,代码来源:UDPClientTransport.java


示例10: processChallenge

import net.jradius.packet.RadiusPacket; //导入依赖的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());
}
 
开发者ID:coova,项目名称:jradius,代码行数:24,代码来源:EAPAuthenticator.java


示例11: processRequest

import net.jradius.packet.RadiusPacket; //导入依赖的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);
}
 
开发者ID:coova,项目名称:jradius,代码行数:17,代码来源:MSCHAPv1Authenticator.java


示例12: processRequest

import net.jradius.packet.RadiusPacket; //导入依赖的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);
}
 
开发者ID:coova,项目名称:jradius,代码行数:17,代码来源:CHAPAuthenticator.java


示例13: setupRequest

import net.jradius.packet.RadiusPacket; //导入依赖的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);
    	}
    }
}
 
开发者ID:coova,项目名称:jradius,代码行数:32,代码来源:RadiusAuthenticator.java


示例14: printDebugInfo

import net.jradius.packet.RadiusPacket; //导入依赖的package包/类
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());
    }
}
 
开发者ID:coova,项目名称:jradius,代码行数:27,代码来源:JRadiusRequest.java


示例15: verifyRequest

import net.jradius.packet.RadiusPacket; //导入依赖的package包/类
public static Boolean verifyRequest(RadiusPacket request, String sharedSecret) throws IOException, InvalidKeyException, NoSuchAlgorithmException
{
    byte[] hash = new byte[16];
    ByteBuffer buffer = ByteBuffer.allocate(4096);

    RadiusAttribute attr = request.findAttribute(AttributeDictionary.MESSAGE_AUTHENTICATOR);
    if (attr == null) return null;
    
    byte[] pval = attr.getValue().getBytes();
    attr.setValue(hash);
    
    format.packPacket(request, sharedSecret, buffer, true);
    System.arraycopy(MD5.hmac_md5(buffer.array(), 0, buffer.position(), sharedSecret.getBytes()), 0, hash, 0, 16);

    attr.setValue(pval);
    
    return new Boolean(Arrays.equals(pval, hash));
}
 
开发者ID:coova,项目名称:jradius,代码行数:19,代码来源:MessageAuthenticator.java


示例16: expectValidResponse

import net.jradius.packet.RadiusPacket; //导入依赖的package包/类
/**
 * @return
 */
private static ResponseValidator<RadiusPacket> expectValidResponse(final Class<?> accept, final Class<?> challenge, final Class<?> reject) {
    
    return new ResponseValidator<RadiusPacket>() {

        public boolean validate(final RadiusPacket response) {
        	return (accept.isInstance(response) || challenge.isInstance(response) || reject.isInstance(response));
        }
        
    };
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:14,代码来源:RadiusAuthDetector.java


示例17: getClient

import net.jradius.packet.RadiusPacket; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected Client<AttributeList, RadiusPacket> getClient() {
	final RadiusDetectorClient rdc = new RadiusDetectorClient();
    rdc.setAuthport(getAuthPort());
    rdc.setAcctPort(getAcctPort());
    rdc.setSecret(getSecret());
    rdc.setAuthenticator(getAuthenticator());
    return rdc;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:11,代码来源:RadiusAuthDetector.java


示例18: 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);
    }
}
 
开发者ID:coova,项目名称:jradius,代码行数:34,代码来源:RadiusSession.java


示例19: getRequestSessionKey

import net.jradius.packet.RadiusPacket; //导入依赖的package包/类
/**
 * Generates the session key for the given session. If the key is changing, as
 * in the case when we move from authentication to accounting, this method will
 * return an Object[2] which instructs the session manage to "rehash" the session
 * under a new key (for uniqueness).
 * 
 * @param request The JRadiusRequest
 * @return the session key, or an array of 2 keys, the second replacing the first
 * as the session hash key.
 * @throws RadiusException
 */
public Serializable getRequestSessionKey(JRadiusRequest request) throws RadiusException
{
    RadiusPacket req = request.getRequestPacket();
    
    if (req == null)
    {
        return null;
    }
    else if (req instanceof AccessRequest)
    {
        return getAccessRequestKey(request);
    }
    else if (req instanceof DHCPPacket)
    {
    	return getDHCPRequestKey(request);
    }
    else if (req instanceof AccountingRequest) 
    {
        int type = request.getType();
        int status = ((AccountingRequest)req).getAccountingStatusType();

        Serializable key = getAccountingRequestKey(request);

        if (type == JRadiusServer.JRADIUS_preacct && 
             (  status == AccountingRequest.ACCT_STATUS_START ||
                status == AccountingRequest.ACCT_STATUS_ACCOUNTING_ON) )
        {
            // rekey the request during pre-accounting
            return new Serializable[] { getAccessRequestKey(request), key };
        }

        return key;
    }
    
    return null;
}
 
开发者ID:coova,项目名称:jradius,代码行数:48,代码来源:RadiusSessionKeyProvider.java


示例20: getAccessRequestKey

import net.jradius.packet.RadiusPacket; //导入依赖的package包/类
/**
 * Generates a session hash key based on access-request attributes.
 * @param request The JRadiusRequest
 * @return the session key
 * @throws RadiusException
 */
public Serializable getAccessRequestKey(JRadiusRequest request) throws RadiusException
{
    RadiusPacket req = request.getRequestPacket();
    StringBuffer sb = new StringBuffer((String)request.getSender());
    sb.append(":").append(getKeyFromAttributeType(req, Attr_NASIPAddress.TYPE, true));
    sb.append(":").append(getKeyFromAttributeType(req, Attr_NASIdentifier.TYPE, false));
    sb.append(":").append(getKeyFromAttributeType(req, Attr_UserName.TYPE, false));
    sb.append(":").append(getKeyFromAttributeType(req, Attr_CallingStationId.TYPE, false));
    sb.append(":").append(getKeyFromAttributeType(req, Attr_CalledStationId.TYPE, false));
    return sb.toString();
}
 
开发者ID:coova,项目名称:jradius,代码行数:18,代码来源:RadiusSessionKeyProvider.java



注:本文中的net.jradius.packet.RadiusPacket类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NTLMScheme类代码示例发布时间:2022-05-22
下一篇:
Java Keymap类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap