• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RadiusClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



RadiusClient类属于net.jradius.client包,在下文中一共展示了RadiusClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: setupRequest

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


示例3: OTPProxyRequest

import net.jradius.client.RadiusClient; //导入依赖的package包/类
public OTPProxyRequest(WebServiceListener wsListener, String userName, JRadiusRealm realm, Socket socket, BufferedReader reader, BufferedWriter writer) throws OTPProxyException
{
    this.wsListener = wsListener;
    this.userName = userName;
    this.otpName = RadiusRandom.getRandomString(16);
    this.otpPassword = RadiusRandom.getRandomString(16);
    this.socket = socket;
    this.reader = reader;
    this.writer = writer;
    this.radiusRealm = realm;

    try
    {
        radiusClient = new RadiusClient(InetAddress.getByName(this.radiusRealm.getServer()), this.radiusRealm.getSharedSecret());
    }
    catch (Exception e)
    {
        throw new OTPProxyException(e.getMessage());
    }
}
 
开发者ID:coova,项目名称:jradius,代码行数:21,代码来源:OTPProxyRequest.java


示例4: setupRequest

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


示例5: init

import net.jradius.client.RadiusClient; //导入依赖的package包/类
public void init() throws RadiusException
{
    super.init();
    tunnelAuth = RadiusClient.getAuthProtocol(getInnerProtocol());
    
    if (tunnelAuth == null ||
        tunnelAuth instanceof MSCHAPv2Authenticator ||
        tunnelAuth instanceof MSCHAPv1Authenticator ||
        tunnelAuth instanceof CHAPAuthenticator)
    {
        throw new RadiusException("You can not currently use " + tunnelAuth.getAuthName() +" within a TLS Tunnel because of limitations in Java 1.5.");
    }
}
 
开发者ID:coova,项目名称:jradius,代码行数:14,代码来源:EAPTTLSAuthenticator.java


示例6: setupRequest

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


示例7: newPacket

import net.jradius.client.RadiusClient; //导入依赖的package包/类
public static RadiusRequest newPacket(byte b, RadiusClient client, AttributeList list)
{
	RadiusRequest p = (RadiusRequest) newPacket(new Integer(b));
	p.setRadiusClient(client);
	p.getAttributes().add(list);
	return p;
}
 
开发者ID:coova,项目名称:jradius,代码行数:8,代码来源:PacketFactory.java


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


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


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


示例11: connect

import net.jradius.client.RadiusClient; //导入依赖的package包/类
public void connect(final InetAddress address, final int port, final int timeout) throws IOException, Exception {
    AttributeFactory.loadAttributeDictionary("net.jradius.dictionary.AttributeDictionaryImpl");
	m_radiusClient = new RadiusClient(address, getSecret(), getAuthPort(), getAcctPort(), convertTimeout(timeout));
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:5,代码来源:RadiusDetectorClient.java


示例12: handle

import net.jradius.client.RadiusClient; //导入依赖的package包/类
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException 
{
	for (int i = 0; i < callbacks.length; i++) 
	{
	    if (callbacks[i] instanceof TextOutputCallback) 
	    {
    		TextOutputCallback toc = (TextOutputCallback)callbacks[i];
    		switch (toc.getMessageType()) 
    		{
    			case TextOutputCallback.INFORMATION:
    			    System.out.println(toc.getMessage());
     		    	break;
    			case TextOutputCallback.ERROR:
    			    System.out.println("ERROR: " + toc.getMessage());
     		    	break;
    			case TextOutputCallback.WARNING:
    			    System.out.println("WARNING: " + toc.getMessage());
     		    	break;
    			default:
    			    throw new IOException("Unsupported message type: " + toc.getMessageType());
     		}
 	    } 
	    else if (callbacks[i] instanceof NameCallback) 
	    {
     		NameCallback nc = (NameCallback)callbacks[i];
     		System.err.print(nc.getPrompt());
     		System.err.flush();
     		nc.setName((new BufferedReader(new InputStreamReader(System.in))).readLine());
 	    } 
	    else if (callbacks[i] instanceof PasswordCallback) 
	    {
     		PasswordCallback pc = (PasswordCallback)callbacks[i];
     		System.err.print(pc.getPrompt());
     		System.err.flush();
     		pc.setPassword(readPassword(System.in));
	    } 
	    else if (callbacks[i] instanceof JRadiusCallback) 
	    {
	        JRadiusCallback rcb = (JRadiusCallback)callbacks[i];
	        RadiusClient rc = rcb.getRadiusClient();
	        AttributeList list = new AttributeList();
	        
	        rcb.setAuthAttributes(list);
	        rcb.setAcctAttributes(list);
	        
	        System.err.print("Radius Server: ");
     		System.err.flush();
	        rc.setRemoteInetAddress(InetAddress.getByName((new BufferedReader(new InputStreamReader(System.in))).readLine()));

	        System.err.print("Shared Secret: ");
     		System.err.flush();
	        rc.setSharedSecret((new BufferedReader(new InputStreamReader(System.in))).readLine());

	        System.err.print("Auth Protocol: ");
     		System.err.flush();
     		String input = new BufferedReader(new InputStreamReader(System.in)).readLine();
     		rcb.setRadiusAuthenticator(RadiusClient.getAuthProtocol(input));
     		
     		promptAttribute("NAS-Identifier", list);
	    } 
	    else 
	    {
     		throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
	    }
	}
}
 
开发者ID:coova,项目名称:jradius,代码行数:67,代码来源:JAASAuthenticationTest.java


示例13: setupRequest

import net.jradius.client.RadiusClient; //导入依赖的package包/类
public void setupRequest(RadiusClient c, RadiusPacket p) throws RadiusException, NoSuchAlgorithmException
{
    super.setupRequest(c, p);
    init();
}
 
开发者ID:coova,项目名称:jradius,代码行数:6,代码来源:EAPTLSAuthenticator.java


示例14: getAuthenticator

import net.jradius.client.RadiusClient; //导入依赖的package包/类
private RadiusAuthenticator getAuthenticator() throws Exception
{
    String authName = authTypeNames[authTypeComboBox.getSelectedIndex()];
    if (authName.startsWith("EAP-T") || authName.startsWith("PEAP"))
    {
        if (isJava14)
        {
            throw new Exception(authName + " not available with this Java version");
        }
        
        String s[] = authName.split("/");
        StringBuffer sb = new StringBuffer(s[0]);
        
        String v = tlsKeyFileTextField.getText();
        if (v != null && !"".equals(v))
        {
            sb.append(":keyFile=").append(v);
        }

        v = (String)tlsKeyFileTypeComboBox.getSelectedItem();
        if (v != null && !"".equals(v))
        {
            sb.append(":keyFileType=").append(v);
        }

        v = tlsKeyPasswordTextField.getText();
        if (v != null && !"".equals(v))
        {
            sb.append(":keyPassword=").append(v);
        }

        v = tlsCAFileTextField.getText();
        if (v != null && !"".equals(v))
        {
            sb.append(":caFile=").append(v);
        }
        
        v = (String)tlsCAFileTypeComboBox.getSelectedItem();
        if (v != null && !"".equals(v))
        {
            sb.append(":caFileType=").append(v);
        }

        v = tlsCAPasswordTextField.getText();
        if (v != null && !"".equals(v))
        {
            sb.append(":caPassword=").append(v);
        }
        
        if (tlsTrustAll.isSelected())
        {
            sb.append(":trustAll=true");
        }
        
        if (s.length == 2)
        {
            sb.append(":innerProtocol=").append(s[1]);
        }
        
        authName = sb.toString();
        System.out.println("Using Authenticator String: " + authName);
    }
    
    return RadiusClient.getAuthProtocol(authName);
}
 
开发者ID:coova,项目名称:jradius,代码行数:66,代码来源:JRadiusSimulator.java


示例15: afterPropertiesSet

import net.jradius.client.RadiusClient; //导入依赖的package包/类
public void afterPropertiesSet() throws Exception 
{
	radiusClient = new RadiusClient(InetAddress.getByName(radiusServer), sharedSecret, authPort, acctPort, 60);
	if (radiusClient == null) throw new RuntimeException("could not create RadSec proxy radius client");
}
 
开发者ID:coova,项目名称:jradius,代码行数:6,代码来源:SimpleProxyHandler.java


示例16: setRadiusClient

import net.jradius.client.RadiusClient; //导入依赖的package包/类
public void setRadiusClient(RadiusClient radiusClient) {
	this.radiusClient = radiusClient;
}
 
开发者ID:coova,项目名称:jradius,代码行数:4,代码来源:SimpleProxyHandler.java


示例17: JRadiusCallback

import net.jradius.client.RadiusClient; //导入依赖的package包/类
public JRadiusCallback(RadiusClient radiusClient)
{
    this.radiusClient = radiusClient;
}
 
开发者ID:coova,项目名称:jradius,代码行数:5,代码来源:JRadiusCallback.java


示例18: getRadiusClient

import net.jradius.client.RadiusClient; //导入依赖的package包/类
public RadiusClient getRadiusClient()
{
    return radiusClient;
}
 
开发者ID:coova,项目名称:jradius,代码行数:5,代码来源:JRadiusCallback.java


示例19: getClient

import net.jradius.client.RadiusClient; //导入依赖的package包/类
/**
 * @return Returns the client.
 */
public RadiusClient getClient()
{
    return client;
}
 
开发者ID:coova,项目名称:jradius,代码行数:8,代码来源:RadiusAuthenticator.java


示例20: setClient

import net.jradius.client.RadiusClient; //导入依赖的package包/类
/**
 * @param client The client to set.
 */
public void setClient(RadiusClient client)
{
    this.client = client;
}
 
开发者ID:coova,项目名称:jradius,代码行数:8,代码来源:RadiusAuthenticator.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CommonTextObjectFactories类代码示例发布时间:2022-05-22
下一篇:
Java Bootstrap类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap