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


Java AttributeList类代码示例

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


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

示例1: authenticate

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

import net.jradius.packet.attribute.AttributeList; //导入依赖的package包/类
public static void addAccessAcceptAttribtues(JRadiusSession session, AttributeList attrs)
{
    String s;
    Long i;

    if ((s = session.getUsername()) != null)
    {
        attrs.remove(Attr_UserName.TYPE);
        attrs.add(new Attr_UserName(s));
    }
    if ((i = session.getSessionTimeout()) != null)
    {
        attrs.remove(Attr_SessionTimeout.TYPE);
        attrs.add(new Attr_SessionTimeout(i));
    }
    if ((i = session.getIdleTimeout()) != null && i.longValue() > 0)
    {
        attrs.remove(Attr_IdleTimeout.TYPE);
        attrs.add(new Attr_IdleTimeout(i));
    }
    if ((i = session.getInterimInterval()) != null && i.longValue() > 0)
    {
        attrs.remove(Attr_AcctInterimInterval.TYPE);
        attrs.add(new Attr_AcctInterimInterval(i));
    }
}
 
开发者ID:coova,项目名称:jradius,代码行数:27,代码来源:RadiusSessionSupportExt.java

示例3: setupRequest

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

示例4: updateAccounting

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

示例5: recycle

import net.jradius.packet.attribute.AttributeList; //导入依赖的package包/类
public static void recycle(RadiusPacket p) 
{
    synchronized (p) 
    {
        AttributeList list = p.getAttributes();
        list.clear();
        
        if (pktObjectPool != null && p.recyclable)
        {
            try
            {
                pktObjectPool.returnObject(new Integer(p.getCode()), p);
                // System.err.print("Recycled packet "+p.toString());
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
        }
        
        // poolStatus();
        // AttributeFactory.poolStatus();
    }
}
 
开发者ID:coova,项目名称:jradius,代码行数:25,代码来源:PacketFactory.java

示例6: request

import net.jradius.packet.attribute.AttributeList; //导入依赖的package包/类
private static RequestBuilder<AttributeList> request(final String nasID, final String user, final String password) {
    LogUtils.debugf(RadiusAuthDetector.class, "request: nasID = %s, user = %s, password = %s", nasID, user, password);
    
    return new RequestBuilder<AttributeList>() {

        public AttributeList getRequest() {
        	final AttributeList attributes = new AttributeList();
        	attributes.add(new Attr_UserName(user));
        	attributes.add(new Attr_NASIdentifier(nasID));
        	attributes.add(new Attr_UserPassword(password));
        	return attributes;
        }
        
    };
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:16,代码来源:RadiusAuthDetector.java

示例7: getClient

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

示例8: promptAttribute

import net.jradius.packet.attribute.AttributeList; //导入依赖的package包/类
private void promptAttribute(String attr, AttributeList list)
 {
try
{
    // Standard Attributes:
    System.err.print(attr + ": ");
    System.err.flush();
  		String input = new BufferedReader(new InputStreamReader(System.in)).readLine();
    list.add(AttributeFactory.newAttribute(attr, input, "="));
}
catch (Exception e)
{
    RadiusLog.error(e.getMessage());
}
 }
 
开发者ID:coova,项目名称:jradius,代码行数:16,代码来源:JAASAuthenticationTest.java

示例9: getLogEntry

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

示例10: getAppSessionKey

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

示例11: handle

import net.jradius.packet.attribute.AttributeList; //导入依赖的package包/类
public boolean handle(JRadiusRequest request) throws RadiusException
{
    RadiusPacket req = request.getRequestPacket();
    AttributeList ci = request.getConfigItems();

    JRadiusSession session = request.getSession();
    JRadiusLogEntry logEntry = session.getLogEntry(request);
    
    // We set the type at every stage... the function, in fact,
    // only really sets the type when appropriate.
    if (logEntry != null)
    {
    	logEntry.init(request, session);
    }
    
    // Put some internal values into the ConfigItems for
    // easy processing of JRadius reuqests/sessions.
    
    if (ci.get(Attr_JRadiusSessionId.TYPE) == null)
    {
        ci.add(AttributeFactory.newAttribute(Attr_JRadiusSessionId.TYPE, session.getSessionKey(), false));
    }
    
    if (ci.get(Attr_JRadiusRequestId.TYPE) == null)
    {
        ci.add(AttributeFactory.newAttribute(Attr_JRadiusRequestId.TYPE, Integer.toString(req.getIdentifier()), false));
    }

    return session.onPreProcessing(request);
}
 
开发者ID:coova,项目名称:jradius,代码行数:31,代码来源:InitSessionHandler.java

示例12: handle

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

示例14: setupRequest

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

示例15: RadiusPacket

import net.jradius.packet.attribute.AttributeList; //导入依赖的package包/类
/**
 * Constructs a RadiusPacket with an AttributeList
 * @param list Initial AttributeList
 */
public RadiusPacket(AttributeList list)
{
    if (list != null)
    {
        attributes.copy(list, recyclable);
    }
}
 
开发者ID:coova,项目名称:jradius,代码行数:12,代码来源:RadiusPacket.java


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