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


Java AttributeList.add方法代码示例

如果您正苦于以下问题:Java AttributeList.add方法的具体用法?Java AttributeList.add怎么用?Java AttributeList.add使用的例子?那么, 这里精选的代码示例或许能为您提供帮助。

以下是net.jradius.packet.attribute.AttributeListAttributeList.add方法的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: 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

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

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

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

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

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

示例10: authenticate

import net.jradius.packet.attribute.AttributeList; //导入方法依赖的package包/类
@Override
public RadiusResponse 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));

    if (StringUtils.isNotBlank(this.nasIpAddress)) {
        attributeList.add(new Attr_NASIPAddress(this.nasIpAddress));
    }
    if (StringUtils.isNotBlank(this.nasIpv6Address)) {
        attributeList.add(new Attr_NASIPv6Address(this.nasIpv6Address));
    }
    if (StringUtils.isNotBlank(this.nasIdentifier)) {
        attributeList.add(new Attr_NASIdentifier(this.nasIdentifier));
    }

    if (this.nasPort != -1) {
        attributeList.add(new Attr_NASPort(this.nasPort));
    }
    if (this.nasPortId != -1) {
        attributeList.add(new Attr_NASPortId(this.nasPortId));
    }
    if (this.nasRealPort != -1) {
        attributeList.add(new Attr_NASRealPort(this.nasRealPort));
    }
    if (this.nasPortType != -1) {
        attributeList.add(new Attr_NASPortType(this.nasPortType));
    }

    RadiusClient client = null;
    try {
        client = this.radiusClientFactory.newInstance();
        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) {
            final AccessAccept acceptedResponse = (AccessAccept) response;

            return new RadiusResponse(acceptedResponse.getCode(),
                    acceptedResponse.getIdentifier(),
                    acceptedResponse.getAttributes().getAttributeList());
        }
    } catch (final Exception e) {
        throw new PreventedException(e);
    } finally {
        if (client != null) {
            client.close();
        }
    }
    return null;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:61,代码来源:JRadiusServerImpl.java

示例11: authenticate

import net.jradius.packet.attribute.AttributeList; //导入方法依赖的package包/类
@Override
public RadiusResponse 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));

    if (StringUtils.isNotBlank(this.nasIpAddress)) {
        attributeList.add(new Attr_NASIPAddress(this.nasIpAddress));
    }
    if (StringUtils.isNotBlank(this.nasIpv6Address)) {
        attributeList.add(new Attr_NASIPv6Address(this.nasIpv6Address));
    }

    if (this.nasPort != -1) {
        attributeList.add(new Attr_NASPort(this.nasPort));
    }
    if (this.nasPortId != -1) {
        attributeList.add(new Attr_NASPortId(this.nasPortId));
    }
    if (this.nasIdentifier != -1) {
        attributeList.add(new Attr_NASIdentifier(this.nasIdentifier));
    }
    if (this.nasRealPort != -1) {
        attributeList.add(new Attr_NASRealPort(this.nasRealPort));
    }
    if (this.nasPortType != -1) {
        attributeList.add(new Attr_NASPortType(this.nasPortType));
    }
    
    RadiusClient client = null;
    try {
        client = this.radiusClientFactory.newInstance();
        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) {
            final AccessAccept acceptedResponse = (AccessAccept) response;
           
            return new RadiusResponse(acceptedResponse.getCode(),
                    acceptedResponse.getIdentifier(),
                    acceptedResponse.getAttributes().getAttributeList());
        }
    } catch (final Exception e) {
        throw new PreventedException(e);            
    } finally {
        if (client != null) {
            client.close();
        }
    }
    return null;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:61,代码来源:JRadiusServerImpl.java

示例12: authenticate

import net.jradius.packet.attribute.AttributeList; //导入方法依赖的package包/类
@Override
public RadiusResponse authenticate(final String username, final String password) throws Exception {

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

    if (StringUtils.isNotBlank(this.nasIpAddress)) {
        attributeList.add(new Attr_NASIPAddress(this.nasIpAddress));
    }
    if (StringUtils.isNotBlank(this.nasIpv6Address)) {
        attributeList.add(new Attr_NASIPv6Address(this.nasIpv6Address));
    }

    if (this.nasPort != -1) {
        attributeList.add(new Attr_NASPort(this.nasPort));
    }
    if (this.nasPortId != -1) {
        attributeList.add(new Attr_NASPortId(this.nasPortId));
    }
    if (StringUtils.isNotBlank(this.nasIdentifier)) {
        attributeList.add(new Attr_NASIdentifier(this.nasIdentifier));
    }
    if (this.nasRealPort != -1) {
        attributeList.add(new Attr_NASRealPort(this.nasRealPort));
    }
    if (this.nasPortType != -1) {
        attributeList.add(new Attr_NASPortType(this.nasPortType));
    }
    
    RadiusClient client = null;
    try {
        client = this.radiusClientFactory.newInstance();
        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) {
            final List<RadiusAttribute> attributes = response.getAttributes().getAttributeList();
            LOGGER.debug("Radius response code [{}] accepted with attributes [{}] and identifier [{}]",
                    response.getCode(), attributes, response.getIdentifier());
            
            return new RadiusResponse(response.getCode(),
                    response.getIdentifier(),
                    attributes);
        }
        LOGGER.debug("Response is not recognized");
    } finally {
        if (client != null) {
            client.close();
        }
    }
    return null;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:62,代码来源:JRadiusServerImpl.java

示例13: handle

import net.jradius.packet.attribute.AttributeList; //导入方法依赖的package包/类
public boolean handle(JRadiusRequest jRequest)
{
    try
    {
        /*
         * Gather some information about the JRadius request
         */
        int type = jRequest.getType();
        AttributeList ci = jRequest.getConfigItems();
        RadiusPacket req = jRequest.getRequestPacket();
        RadiusPacket rep = jRequest.getReplyPacket();

        /*
         * Find the username in the request packet
         */
        String username = (String)req.getAttributeValue(Attr_UserName.TYPE);

        /*
         * See if this is a local user, otherwise we will reject (though, you may
         * want to return "ok" if you have modules configured after jradius in FreeRADIUS)
         */
        LocalUser u = (LocalUser) users.get(username);
        
        if (u == null)
        {
            // Unknown username, so let the RADIUS server sort it out.
            RadiusLog.info("Ignoring unknown username: " + username);
            return false;
        }

        switch (type)
        {
        	case JRadiusServer.JRADIUS_authorize:
        	{
        	    /*
        	     * We know the user, lets inform FreeRADIUS of the user's
        	     * password so that FreeRADIUS may perform the required
        	     * authentication checks.
        	     */
        		//ci.add(new Attr_AuthType(Attr_AuthType.Local)); // Auth locally
                ci.add(new Attr_UserPassword(u.password));      // FreeRADIUS 1.0
                ci.add(new Attr_CleartextPassword(u.password)); // FreeRADIUS 2.0
        	}
        	break;
                
        	case JRadiusServer.JRADIUS_post_auth:
        	{
        	    if (rep instanceof AccessAccept)
        	    {
        	        /*
        	         * FreeRADIUS has returned after the authentication checks and the
        	         * user's credentials worked. Since we are now returning an AccessAccept,
        	         * we will the packet with the attributes configured for the user.
        	         */
        	        rep.addAttributes(u.getAttributeList());
        	        //RadiusLog.info("Authentication successful for username: " + username);
        	    }
        	    else
        	    {
        	        RadiusLog.info("Authentication failed for username: " + username);
        	    }
        	}
        	break;
        }
    }
    catch (RadiusException e)
    {
        e.printStackTrace();
    }
    
    /*
     * Everything worked out well, from the perspective of this module.
     */
    jRequest.setReturnValue(JRadiusServer.RLM_MODULE_UPDATED);
    return false;
}
 
开发者ID:coova,项目名称:jradius,代码行数:77,代码来源:LocalUsersHandler.java

示例14: setPlainTextPassword

import net.jradius.packet.attribute.AttributeList; //导入方法依赖的package包/类
protected void setPlainTextPassword(JRadiusRequest request, String password, boolean overwrite)
{
    AttributeList ci = request.getConfigItems();
    ci.add(AttributeFactory.newAttribute(Attr_CleartextPassword.TYPE, password, false), overwrite);
    ci.add(AttributeFactory.newAttribute(Attr_UserPassword.TYPE, password, false), overwrite);
}
 
开发者ID:coova,项目名称:jradius,代码行数:7,代码来源:RadiusSessionHandler.java

示例15: handle

import net.jradius.packet.attribute.AttributeList; //导入方法依赖的package包/类
public boolean handle(JRadiusRequest request) throws Exception
{
    JRadiusSession session = (JRadiusSession) request.getSession();
    if (session == null) return noSessionFound(request);

    RadiusPacket req = request.getRequestPacket();
    RadiusPacket rep = request.getReplyPacket();
    AttributeList ci = request.getConfigItems();
    
    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;

    req.addAttribute(new Attr_JRadiusSessionId(session.getSessionKey()));
    
    otpRequest.setAccessRequest((RadiusRequest)req);

    RadiusResponse resp = otpRequest.getAccessResponse();
    
    if (resp == null)
    {
        ci.add(new Attr_AuthType(Attr_AuthType.Reject));
        request.setReturnValue(JRadiusServer.RLM_MODULE_REJECT);
        return true;
    }
    
    RadiusLog.debug(
            "------------------------------------------------\n"+
            "OTP Proxy Response:\n" + resp.toString()+
            "------------------------------------------------\n");
    
    if (resp instanceof AccessAccept)
    {
        AttributeList attrs = resp.getAttributes();
        attrs.remove(Attr_Class.TYPE);
        attrs.remove(Attr_State.TYPE);
        attrs.remove(Attr_EAPMessage.TYPE);
        attrs.remove(Attr_MessageAuthenticator.TYPE);
        rep.addAttributes(attrs);
        return false;
    }
    
    ci.add(new Attr_AuthType(Attr_AuthType.Reject));
    request.setReturnValue(JRadiusServer.RLM_MODULE_REJECT);
    return true;
}
 
开发者ID:coova,项目名称:jradius,代码行数:56,代码来源:OTPProxyPostAuthHandler.java


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