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

Java AccessAccept类代码示例

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

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



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

示例1: authenticate

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

import net.jradius.packet.AccessAccept; //导入依赖的package包/类
/** 
 * @see net.jradius.standard.RadiusStandard#checkPacket(net.jradius.packet.RadiusPacket)
 */
public void checkPacket(RadiusPacket p, long[] ignore) throws StandardViolatedException
{
    LinkedList missing = new LinkedList();
    
    switch(p.getCode())
    {
    	case AccessRequest.CODE:
    	    checkMissing(p, missing, requiredAccessRequest, ignore);
    		break;

    	case AccessAccept.CODE:
    	    checkMissing(p, missing, requiredAccessAccept, ignore);
			break;

    	case AccessReject.CODE:
			break;

    	case AccountingRequest.CODE:
    	    checkMissing(p, missing, requiredAccounting, ignore);
    		break;
    }
    if (!missing.isEmpty())
        throw new StandardViolatedException(this.getClass(), missing);
}
 
开发者ID:coova,项目名称:jradius,代码行数:28,代码来源:WISPrStandard.java


示例3: onPostAuthentication

import net.jradius.packet.AccessAccept; //导入依赖的package包/类
public void onPostAuthentication(JRadiusRequest request) throws RadiusException 
{ 
    RadiusPacket rep = request.getReplyPacket();
    boolean success = (rep instanceof AccessAccept && request.getReturnValue() != JRadiusServer.RLM_MODULE_REJECT);
    RadiusLog.debug("Authentication: " + request + " was" + (success ? "" : " NOT") + " sucessful");
    if (success)
    {
        Long sessionTimeout = (Long)rep.getAttributeValue(Attr_SessionTimeout.TYPE);
        if (checkSessionState(ACCT_STARTED))
        {
            if (sessionTimeout != null)
            {
                Long sessionTime = getSessionTime();
                if (sessionTime != null)
                {
                    // Compensate the sessionTimeout for re-authentications
                    sessionTimeout = new Long(sessionTimeout.longValue() - sessionTime.longValue());
                }
            }
        }
        else
        {
            setSessionState(AUTH_ACCEPTED);
        }
        setIdleTimeout((Long)rep.getAttributeValue(Attr_IdleTimeout.TYPE));
        setInterimInterval((Long)rep.getAttributeValue(Attr_AcctInterimInterval.TYPE));
        setSessionTimeout(sessionTimeout);
    }
    else
    {
        setSessionState(AUTH_REJECTED);
    }
}
 
开发者ID:coova,项目名称:jradius,代码行数:34,代码来源:RadiusSession.java


示例4: handle

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


示例5: authenticate

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


示例6: authenticate

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


示例7: authenticate

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


示例8: onInit

import net.jradius.packet.AccessAccept; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void onInit() {
    send(request(getNasID(), getUser(), getPassword()), expectValidResponse(AccessAccept.class, AccessChallenge.class, AccessReject.class));
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:6,代码来源:RadiusAuthDetector.java


示例9: handle

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


示例10: checkPacket

import net.jradius.packet.AccessAccept; //导入依赖的package包/类
/** 
 * @see net.jradius.standard.RadiusStandard#checkPacket(net.jradius.packet.RadiusPacket)
 */
public void checkPacket(RadiusPacket p, long[] ignore) throws StandardViolatedException
{
    LinkedList missing = new LinkedList();
    boolean testAs8021X = false;
    
    if (isIEEE8021XRequired()) testAs8021X = true;
    else testAs8021X = p.findAttribute(Attr_EAPMessage.TYPE) != null;
    
    switch(p.getCode())
    {
    		case AccessRequest.CODE:
    		    checkMissing(p, missing, requiredAccessRequest, ignore);
    		    checkMissing(p, missing, testAs8021X ? requiredEAPAccessRequest : requiredUAMAccessRequest, ignore);
    			break;

    		case AccessChallenge.CODE:
    		    if (testAs8021X) checkMissing(p, missing, requiredEAPAccessChallenge, ignore);
    			break;

    		case AccessAccept.CODE:
    		    checkMissing(p, missing, requiredAccessAccept, ignore);
    			if (testAs8021X) checkMissing(p, missing, requiredEAPAccessAccept, ignore);
				break;

    		case AccountingRequest.CODE:
    		{
    		    checkMissing(p, missing, requiredAccountingRequest, ignore);

    		    switch(((AccountingRequest)p).getAccountingStatusType())
    		    {
    		    	case AccountingRequest.ACCT_STATUS_START:
    		    	    // no additional requirements
    		    		break;
    		    	case AccountingRequest.ACCT_STATUS_STOP:
    		    	    checkMissing(p, missing, requiredAccountingStopRequest, ignore);
    		    		// fall through
    		    	case AccountingRequest.ACCT_STATUS_INTERIM:
    		    	    checkMissing(p, missing, requiredAccountingInterimRequest, ignore);
    		    		break;
    		    }
    		}
    		break;
    }
    
    if (!missing.isEmpty())
        throw new StandardViolatedException(this.getClass(), missing);
}
 
开发者ID:coova,项目名称:jradius,代码行数:51,代码来源:IRAPStandard.java


示例11: handle

import net.jradius.packet.AccessAccept; //导入依赖的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.AccessAccept类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java GuiActionRunner类代码示例发布时间:2022-05-22
下一篇:
Java CmisRuntimeException类代码示例发布时间: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