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


Java RadiusClient.close方法代码示例

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


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

示例1: authenticate

import net.jradius.client.RadiusClient; //导入方法依赖的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: authenticate

import net.jradius.client.RadiusClient; //导入方法依赖的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

示例3: authenticate

import net.jradius.client.RadiusClient; //导入方法依赖的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

示例4: authenticate

import net.jradius.client.RadiusClient; //导入方法依赖的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


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