当前位置: 首页>>代码示例>>Java>>正文


Java RadiusPacket.findAttribute方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: handle

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

示例6: 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 rep = request.getReplyPacket();

    if (!(rep instanceof AccessAccept ||
    		rep instanceof AccessChallenge)) return false;

    Object[] attrs = rep.findAttributes(Attr_Class.TYPE);
    if (attrs != null && session.getRadiusClass() == null)
    {
    	byte[][] classes = new byte[attrs.length][];
     for (int i = 0; i < attrs.length; i++)
     {
         RadiusAttribute attribute = (RadiusAttribute) attrs[i];
         classes[i] = (byte[]) attribute.getValue().getValueObject();
     }
     // System.err.println(this.getClass().getName() + " setting radiusClass");
     session.setRadiusClass(classes);
    }

    RadiusAttribute attr = rep.findAttribute(Attr_State.TYPE);
    if (attr != null)
    {
    	byte[] val = (byte[]) attr.getValue().getValueObject();
    	// System.err.println(this.getClass().getName() + " setting radiusState "+val.length+" "+val[0]);
     session.setRadiusState(val);
    }

    rep.overwriteAttribute(AttributeFactory.newAttribute(rep instanceof AccessAccept ? Attr_Class.TYPE : Attr_State.TYPE, 
    		(ClassPrefix + session.getSessionKey()).getBytes(), rep.isRecyclable()));
    
    return false;
}
 
开发者ID:coova,项目名称:jradius,代码行数:37,代码来源:PostAuthorizeClassHandler.java

示例7: checkMissing

import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
/**
    * Check for missing attributes in a RadiusPacket
    * @param p RadiusPacket to be checked
    * @param list list to append missing attributes to
    * @param check attributes to look for
    * @param ignore attributes to ignore
    */
   protected static void checkMissing(RadiusPacket p, List list, long[] check, long[] ignore)
   {
    for (int i=0; i < check.length; i++)
    {
        if (p.findAttribute(check[i]) == null)
        {
            if (ignore != null)
                for (int j=0; j < ignore.length; j++)
                    if (check[i] == ignore[j])
                        continue;
               list.add(new Long(check[i]));
        }
    }
}
 
开发者ID:coova,项目名称:jradius,代码行数:22,代码来源:RadiusStandard.java

示例8: processChallenge

import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
/**
 * If the protocol has a request/challenge process, this function must
 * be implemented.
 * @param request The original AccessRequest RadiusPacket
 * @param challenge The AccessChallenge packet
 * @throws RadiusException
 * @throws NoSuchAlgorithmException 
 */
public void processChallenge(RadiusPacket request, RadiusPacket challenge)  throws RadiusException, NoSuchAlgorithmException
{
	classAttribute = challenge.findAttribute(AttributeDictionary.CLASS);
    if (classAttribute != null)
    	request.overwriteAttribute(AttributeFactory.copyAttribute(classAttribute, false));
    
    stateAttribute = challenge.findAttribute(AttributeDictionary.STATE);
    if (stateAttribute != null)
    	request.overwriteAttribute(AttributeFactory.copyAttribute(stateAttribute, false));
}
 
开发者ID:coova,项目名称:jradius,代码行数:19,代码来源:RadiusAuthenticator.java

示例9: 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();
    boolean testAs8021X = false;
    
    if (isIEEE8021XRequired()) testAs8021X = true;
    else testAs8021X = p.findAttribute(Attr_EAPMessage.TYPE) != null;
    
    switch(p.getCode())
    {
    		case AccessRequest.CODE:
    		    checkMissing(p, missing, requiredAccessRequest, ignore);
    		    checkMissing(p, missing, testAs8021X ? requiredEAPAccessRequest : requiredUAMAccessRequest, ignore);
    			break;

    		case AccessChallenge.CODE:
    		    if (testAs8021X) checkMissing(p, missing, requiredEAPAccessChallenge, ignore);
    			break;

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

    		case AccountingRequest.CODE:
    		{
    		    checkMissing(p, missing, requiredAccountingRequest, ignore);

    		    switch(((AccountingRequest)p).getAccountingStatusType())
    		    {
    		    	case AccountingRequest.ACCT_STATUS_START:
    		    	    // no additional requirements
    		    		break;
    		    	case AccountingRequest.ACCT_STATUS_STOP:
    		    	    checkMissing(p, missing, requiredAccountingStopRequest, ignore);
    		    		// fall through
    		    	case AccountingRequest.ACCT_STATUS_INTERIM:
    		    	    checkMissing(p, missing, requiredAccountingInterimRequest, ignore);
    		    		break;
    		    }
    		}
    		break;
    }
    
    if (!missing.isEmpty())
        throw new StandardViolatedException(this.getClass(), missing);
}
 
开发者ID:coova,项目名称:jradius,代码行数:51,代码来源:IRAPStandard.java

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

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

示例12: verifyReply

import net.jradius.packet.RadiusPacket; //导入方法依赖的package包/类
public static Boolean verifyReply(byte[] requestAuth, RadiusPacket reply, String sharedSecret) throws IOException, InvalidKeyException, NoSuchAlgorithmException
{
    byte[] replyAuth = reply.getAuthenticator();
    byte[] hash = new byte[16];

    ByteBuffer buffer = ByteBuffer.allocate(4096);

    RadiusAttribute attr = reply.findAttribute(AttributeDictionary.MESSAGE_AUTHENTICATOR);
    if (attr == null) return null;
    
    byte[] pval = attr.getValue().getBytes();
    attr.setValue(hash);
    
    reply.setAuthenticator(requestAuth);

    format.packPacket(reply, sharedSecret, buffer, true);
    System.arraycopy(MD5.hmac_md5(buffer.array(), 0, buffer.position(), sharedSecret.getBytes()), 0, hash, 0, 16);

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


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