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


Java ClientInfoHolder类代码示例

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


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

示例1: loginUnsuccessfully

import org.jasig.inspektr.common.web.ClientInfoHolder; //导入依赖的package包/类
@Override
protected MockHttpServletResponse loginUnsuccessfully(final String username, final String fromAddress)
        throws Exception {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    final MockHttpServletResponse response = new MockHttpServletResponse();
    request.setMethod("POST");
    request.setParameter("username", username);
    request.setRemoteAddr(fromAddress);
    final MockRequestContext context = new MockRequestContext();
    context.setCurrentEvent(new Event("", "error"));
    request.setAttribute("flowRequestContext", context);
    ClientInfoHolder.setClientInfo(new ClientInfo(request));

    getThrottle().preHandle(request, response, null);

    try {
        authenticationManager.authenticate(AuthenticationTransaction.wrap(badCredentials(username)));
    } catch (final AuthenticationException e) {
        getThrottle().postHandle(request, response, null, null);
        return response;
    }
    fail("Expected AbstractAuthenticationException");
    return null;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:25,代码来源:InspektrThrottledSubmissionByIpAddressAndUsernameHandlerInterceptorAdapterTests.java

示例2: recordThrottle

import org.jasig.inspektr.common.web.ClientInfoHolder; //导入依赖的package包/类
@Override
protected void recordThrottle(final HttpServletRequest request) {
    super.recordThrottle(request);
    final String userToUse = constructUsername(request, getUsernameParameter());
    final ClientInfo clientInfo = ClientInfoHolder.getClientInfo();
    final AuditPointRuntimeInfo auditPointRuntimeInfo = new AuditPointRuntimeInfo() {
        private static final long serialVersionUID = 1L;

        @Override
        public String asString() {
            return String.format("%s.recordThrottle()", this.getClass().getName());
        }
    };
    final AuditActionContext context = new AuditActionContext(
            userToUse,
            userToUse,
            INSPEKTR_ACTION,
            this.applicationCode,
            new java.util.Date(),
            clientInfo.getClientIpAddress(),
            clientInfo.getServerIpAddress(),
            auditPointRuntimeInfo);
    this.auditTrailManager.record(context);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:25,代码来源:InspektrThrottledSubmissionByIpAddressAndUsernameHandlerInterceptorAdapter.java

示例3: loginUnsuccessfully

import org.jasig.inspektr.common.web.ClientInfoHolder; //导入依赖的package包/类
@Override
protected MockHttpServletResponse loginUnsuccessfully(final String username, final String fromAddress)
        throws Exception {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    final MockHttpServletResponse response = new MockHttpServletResponse();
    request.setMethod("POST");
    request.setParameter("username", username);
    request.setRemoteAddr(fromAddress);
    final MockRequestContext context = new MockRequestContext();
    context.setCurrentEvent(new Event("", "error"));
    request.setAttribute("flowRequestContext", context);
    ClientInfoHolder.setClientInfo(new ClientInfo(request));

    getThrottle().preHandle(request, response, null);

    try {
        authenticationManager.authenticate(badCredentials(username));
    } catch (final AuthenticationException e) {
        getThrottle().postHandle(request, response, null, null);
        return response;
    }
    fail("Expected AuthenticationException");
    return null;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:25,代码来源:InspektrThrottledSubmissionByIpAddressAndUsernameHandlerInterceptorAdapterTests.java

示例4: exceedsThreshold

import org.jasig.inspektr.common.web.ClientInfoHolder; //导入依赖的package包/类
@Override
protected boolean exceedsThreshold(final HttpServletRequest request) {
    final String query = "SELECT AUD_DATE FROM COM_AUDIT_TRAIL WHERE AUD_CLIENT_IP = ? AND AUD_USER = ? "
            + "AND AUD_ACTION = ? AND APPLIC_CD = ? AND AUD_DATE >= ? ORDER BY AUD_DATE DESC";
    final String userToUse = constructUsername(request, getUsernameParameter());
    final Calendar cutoff = Calendar.getInstance();
    cutoff.add(Calendar.SECOND, -1 * getFailureRangeInSeconds());
    final ClientInfo clientInfo = ClientInfoHolder.getClientInfo();
    final String remoteAddress = clientInfo.getClientIpAddress();
    final List<Timestamp> failures = this.jdbcTemplate.query(
            query,
            new Object[] {remoteAddress, userToUse, this.authenticationFailureCode, this.applicationCode, cutoff.getTime()},
            new int[] {Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP},
            new RowMapper<Timestamp>() {
                @Override
                public Timestamp mapRow(final ResultSet resultSet, final int i) throws SQLException {
                    return resultSet.getTimestamp(1);
                }
            });
    if (failures.size() < 2) {
        return false;
    }
    // Compute rate in submissions/sec between last two authn failures and compare with threshold
    return NUMBER_OF_MILLISECONDS_IN_SECOND / (failures.get(0).getTime() - failures.get(1).getTime()) > getThresholdRate();
}
 
开发者ID:xuchengdong,项目名称:cas4.1.9,代码行数:26,代码来源:InspektrThrottledSubmissionByIpAddressAndUsernameHandlerInterceptorAdapter.java

示例5: constructKey

import org.jasig.inspektr.common.web.ClientInfoHolder; //导入依赖的package包/类
@Override
protected String constructKey(final HttpServletRequest request) {
    final String username = request.getParameter(getUsernameParameter());

    if (username == null) {
        return request.getRemoteAddr();
    }

    return ClientInfoHolder.getClientInfo().getClientIpAddress() + ';' + username.toLowerCase();
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:11,代码来源:InMemoryThrottledSubmissionByIpAddressAndUsernameHandlerInterceptorAdapter.java

示例6: exceedsThreshold

import org.jasig.inspektr.common.web.ClientInfoHolder; //导入依赖的package包/类
@Override
protected boolean exceedsThreshold(final HttpServletRequest request) {
    if (this.dataSource != null && this.jdbcTemplate != null) {
        final String userToUse = constructUsername(request, getUsernameParameter());
        final Calendar cutoff = Calendar.getInstance();
        cutoff.add(Calendar.SECOND, -1 * getFailureRangeInSeconds());

        final ClientInfo clientInfo = ClientInfoHolder.getClientInfo();
        final String remoteAddress = clientInfo.getClientIpAddress();

        final List<Timestamp> failures = this.jdbcTemplate.query(
                sqlQueryAudit,
                new Object[]{remoteAddress, userToUse, this.authenticationFailureCode,
                        this.applicationCode, cutoff.getTime()},
                new int[]{Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP},
                new RowMapper<Timestamp>() {
                    @Override
                    public Timestamp mapRow(final ResultSet resultSet, final int i) throws SQLException {
                        return resultSet.getTimestamp(1);
                    }
                });
        if (failures.size() < 2) {
            return false;
        }
        // Compute rate in submissions/sec between last two authn failures and compare with threshold
        return NUMBER_OF_MILLISECONDS_IN_SECOND / (failures.get(0).getTime() - failures.get(1).getTime()) > getThresholdRate();
    }
    logger.debug("No data source is defined for {}. Ignoring threshold checking",
            this.getName());
    return false;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:32,代码来源:InspektrThrottledSubmissionByIpAddressAndUsernameHandlerInterceptorAdapter.java

示例7: recordThrottle

import org.jasig.inspektr.common.web.ClientInfoHolder; //导入依赖的package包/类
@Override
protected void recordThrottle(final HttpServletRequest request) {
    if (this.dataSource != null && this.jdbcTemplate != null) {
        super.recordThrottle(request);
        final String userToUse = constructUsername(request, getUsernameParameter());
        final ClientInfo clientInfo = ClientInfoHolder.getClientInfo();
        final AuditPointRuntimeInfo auditPointRuntimeInfo = new AuditPointRuntimeInfo() {
            private static final long serialVersionUID = 1L;

            @Override
            public String asString() {
                return String.format("%s.recordThrottle()", this.getClass().getName());
            }
        };
        final AuditActionContext context = new AuditActionContext(
                userToUse,
                userToUse,
                INSPEKTR_ACTION,
                this.applicationCode,
                new java.util.Date(),
                clientInfo.getClientIpAddress(),
                clientInfo.getServerIpAddress(),
                auditPointRuntimeInfo);
        this.auditTrailManager.record(context);
    } else {
        logger.debug("No data source is defined for {}. Ignoring audit record-keeping",
                this.getName());
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:30,代码来源:InspektrThrottledSubmissionByIpAddressAndUsernameHandlerInterceptorAdapter.java

示例8: constructKey

import org.jasig.inspektr.common.web.ClientInfoHolder; //导入依赖的package包/类
@Override
protected String constructKey(final HttpServletRequest request) {
    return ClientInfoHolder.getClientInfo().getClientIpAddress();
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:5,代码来源:InMemoryThrottledSubmissionByIpAddressHandlerInterceptorAdapter.java

示例9: setUp

import org.jasig.inspektr.common.web.ClientInfoHolder; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    ClientInfoHolder.setClientInfo(CLIENT_INFO);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:5,代码来源:AbstractThrottledSubmissionHandlerInterceptorAdapterTests.java

示例10: tearDown

import org.jasig.inspektr.common.web.ClientInfoHolder; //导入依赖的package包/类
@After
public void tearDown() throws Exception {
    ClientInfoHolder.setClientInfo(null);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:5,代码来源:AbstractThrottledSubmissionHandlerInterceptorAdapterTests.java


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