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


Java RadiusAttribute类代码示例

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


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

示例1: getKeyFromAttributeType

import net.jradius.packet.attribute.RadiusAttribute; //导入依赖的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: createNamedValueCellEditor

import net.jradius.packet.attribute.RadiusAttribute; //导入依赖的package包/类
private JComboBox createNamedValueCellEditor(String attributeName)
{
    JComboBox comboBox = (JComboBox)namedValueComponentCache.get(attributeName);
    if (comboBox != null) return comboBox;
    try
    {
        RadiusAttribute attribute = AttributeFactory.newAttribute(attributeName);
        NamedValue namedValue = (NamedValue)attribute.getValue();
        NamedValueMap valueMap = namedValue.getMap();
        Long[] possibleValues = valueMap.getKnownValues();
        comboBox = new JComboBox();
        for (int i=0; i<possibleValues.length;i++)
        {
            comboBox.addItem(valueMap.getNamedValue(possibleValues[i]));
        }
        namedValueComponentCache.put(attributeName, comboBox);
    }
    catch (Exception e) { e.printStackTrace(); }
    return comboBox;
}
 
开发者ID:coova,项目名称:jradius,代码行数:21,代码来源:JRadiusSimulator.java

示例3: updateAccounting

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

示例4: processChallenge

import net.jradius.packet.attribute.RadiusAttribute; //导入依赖的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

示例5: processRequest

import net.jradius.packet.attribute.RadiusAttribute; //导入依赖的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

示例6: processRequest

import net.jradius.packet.attribute.RadiusAttribute; //导入依赖的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

示例7: setupRequest

import net.jradius.packet.attribute.RadiusAttribute; //导入依赖的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

示例8: verifyRequest

import net.jradius.packet.attribute.RadiusAttribute; //导入依赖的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

示例9: authenticateUsernamePasswordInternal

import net.jradius.packet.attribute.RadiusAttribute; //导入依赖的package包/类
@Override
protected final HandlerResult authenticateUsernamePasswordInternal(final UsernamePasswordCredential credential)
        throws GeneralSecurityException, PreventedException {

    final String password = getPasswordEncoder().encode(credential.getPassword());
    final String username = credential.getUsername();
    
    for (final RadiusServer radiusServer : this.servers) {
        logger.debug("Attempting to authenticate {} at {}", username, radiusServer);
        try {
            final RadiusResponse response = radiusServer.authenticate(username, password);
            if (response != null) {
                final Map<String, Object> attributes = new HashMap<>();
                for (final RadiusAttribute attribute : response.getAttributes()) {
                    attributes.put(attribute.getAttributeName(), attribute.getValue().toString());
                }
                return createHandlerResult(credential, this.principalFactory.createPrincipal(username, attributes),
                        new ArrayList<MessageDescriptor>());
            }
                            
            if (!this.failoverOnAuthenticationFailure) {
                throw new FailedLoginException("Radius authentication failed for user " + username);
            }
            logger.debug("failoverOnAuthenticationFailure enabled -- trying next server");
        } catch (final PreventedException e) {
            if (!this.failoverOnException) {
                throw e;
            }
            logger.warn("failoverOnException enabled -- trying next server.", e);
        }
    }
    throw new FailedLoginException("Radius authentication failed for user " + username);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:34,代码来源:RadiusAuthenticationHandler.java

示例10: getLogEntry

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

示例11: getAppSessionKey

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

示例12: handle

import net.jradius.packet.attribute.RadiusAttribute; //导入依赖的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

示例13: handle

import net.jradius.packet.attribute.RadiusAttribute; //导入依赖的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

示例14: handle

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

示例15: addAttribute

import net.jradius.packet.attribute.RadiusAttribute; //导入依赖的package包/类
public AttributesTableEntry addAttribute(String attributeName) throws RadiusException
{
    RadiusAttribute attribute = AttributeFactory.newAttribute(attributeName);
    AttributesTableEntry entry = new AttributesTableEntry();
    entry.setAttributeName(attributeName);
    entry.setValueClass(attribute.getValue().getClass());
    entries.add(entry);
    return entry;
}
 
开发者ID:coova,项目名称:jradius,代码行数:10,代码来源:AttributesTableModel.java


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