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

Java MessagePolicy类代码示例

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

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



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

示例1: testFailLoginInvalidMethod

import javax.security.auth.message.MessagePolicy; //导入依赖的package包/类
/**
 * Tests the login endpoint PUT operation.
 */
@Test(expected = AuthException.class)
public void testFailLoginInvalidMethod() throws Exception {

    final TestServerAuthModule module = new TestServerAuthModule();
    final MessagePolicy mockRequestPolicy = mock(MessagePolicy.class);
    when(mockRequestPolicy.isMandatory()).thenReturn(true);

    final CallbackHandler h = mock(CallbackHandler.class);
    module.initialize(mockRequestPolicy, null, h, options);

    final MessageInfo messageInfo = mock(MessageInfo.class);

    final HttpServletRequest servletRequest = mock(HttpServletRequest.class);
    when(servletRequest.getMethod()).thenReturn("PUT");
    when(servletRequest.isSecure()).thenReturn(true);
    when(servletRequest.getRequestURI()).thenReturn("/util/j_security_check");
    when(servletRequest.getContextPath()).thenReturn("/util");
    when(servletRequest.getParameter("state")).thenReturn("/rooted/page");
    when(servletRequest.getParameter("nonce")).thenReturn("abc");
    when(messageInfo.getRequestMessage()).thenReturn(servletRequest);

    final Subject client = new Subject();
    module.validateRequest(messageInfo, client, null);
}
 
开发者ID:trajano,项目名称:jaspic-tester,代码行数:28,代码来源:TestServerAuthModuleTest.java


示例2: testFailLoginInvalidState

import javax.security.auth.message.MessagePolicy; //导入依赖的package包/类
/**
 * Tests the login endpoint GET operation.
 */
@Test(expected = AuthException.class)
public void testFailLoginInvalidState() throws Exception {

    final TestServerAuthModule module = new TestServerAuthModule();
    final MessagePolicy mockRequestPolicy = mock(MessagePolicy.class);
    when(mockRequestPolicy.isMandatory()).thenReturn(true);

    final CallbackHandler h = mock(CallbackHandler.class);
    module.initialize(mockRequestPolicy, null, h, options);

    final MessageInfo messageInfo = mock(MessageInfo.class);

    final HttpServletRequest servletRequest = mock(HttpServletRequest.class);
    when(servletRequest.getMethod()).thenReturn("GET");
    when(servletRequest.isSecure()).thenReturn(true);
    when(servletRequest.getRequestURI()).thenReturn("/util/j_security_check");
    when(servletRequest.getContextPath()).thenReturn("/util");
    when(servletRequest.getParameter("state")).thenReturn("http://www.trajano.net/");
    when(messageInfo.getRequestMessage()).thenReturn(servletRequest);

    final Subject client = new Subject();
    module.validateRequest(messageInfo, client, null);
}
 
开发者ID:trajano,项目名称:jaspic-tester,代码行数:27,代码来源:TestServerAuthModuleTest.java


示例3: testFailLoginInvalidState2

import javax.security.auth.message.MessagePolicy; //导入依赖的package包/类
/**
 * Tests the login endpoint GET operation.
 */
@Test(expected = AuthException.class)
public void testFailLoginInvalidState2() throws Exception {

    final TestServerAuthModule module = new TestServerAuthModule();
    final MessagePolicy mockRequestPolicy = mock(MessagePolicy.class);
    when(mockRequestPolicy.isMandatory()).thenReturn(true);

    final CallbackHandler h = mock(CallbackHandler.class);
    module.initialize(mockRequestPolicy, null, h, options);

    final MessageInfo messageInfo = mock(MessageInfo.class);

    final HttpServletRequest servletRequest = mock(HttpServletRequest.class);
    when(servletRequest.getMethod()).thenReturn("GET");
    when(servletRequest.isSecure()).thenReturn(true);
    when(servletRequest.getRequestURI()).thenReturn("/util/j_security_check");
    when(servletRequest.getContextPath()).thenReturn("/util");
    when(servletRequest.getParameter("state")).thenReturn("some/non/rooted/page");
    when(messageInfo.getRequestMessage()).thenReturn(servletRequest);

    final Subject client = new Subject();
    module.validateRequest(messageInfo, client, null);
}
 
开发者ID:trajano,项目名称:jaspic-tester,代码行数:27,代码来源:TestServerAuthModuleTest.java


示例4: testFailLoginInvalidState3

import javax.security.auth.message.MessagePolicy; //导入依赖的package包/类
/**
 * Tests the login endpoint GET operation.
 */
@Test(expected = AuthException.class)
public void testFailLoginInvalidState3() throws Exception {

    final TestServerAuthModule module = new TestServerAuthModule();
    final MessagePolicy mockRequestPolicy = mock(MessagePolicy.class);
    when(mockRequestPolicy.isMandatory()).thenReturn(true);

    final CallbackHandler h = mock(CallbackHandler.class);
    module.initialize(mockRequestPolicy, null, h, options);

    final MessageInfo messageInfo = mock(MessageInfo.class);

    final HttpServletRequest servletRequest = mock(HttpServletRequest.class);
    when(servletRequest.getMethod()).thenReturn("GET");
    when(servletRequest.isSecure()).thenReturn(true);
    when(servletRequest.getRequestURI()).thenReturn("/util/j_security_check");
    when(servletRequest.getContextPath()).thenReturn("/util");
    when(servletRequest.getParameter("state")).thenReturn("/foo/../../abc");
    when(messageInfo.getRequestMessage()).thenReturn(servletRequest);

    final Subject client = new Subject();
    module.validateRequest(messageInfo, client, null);
}
 
开发者ID:trajano,项目名称:jaspic-tester,代码行数:27,代码来源:TestServerAuthModuleTest.java


示例5: testFailLoginInvalidState4

import javax.security.auth.message.MessagePolicy; //导入依赖的package包/类
/**
 * Tests the login endpoint GET operation.
 */
@Test(expected = AuthException.class)
public void testFailLoginInvalidState4() throws Exception {

    final TestServerAuthModule module = new TestServerAuthModule();
    final MessagePolicy mockRequestPolicy = mock(MessagePolicy.class);
    when(mockRequestPolicy.isMandatory()).thenReturn(true);

    final CallbackHandler h = mock(CallbackHandler.class);
    module.initialize(mockRequestPolicy, null, h, options);

    final MessageInfo messageInfo = mock(MessageInfo.class);

    final HttpServletRequest servletRequest = mock(HttpServletRequest.class);
    when(servletRequest.getMethod()).thenReturn("GET");
    when(servletRequest.isSecure()).thenReturn(true);
    when(servletRequest.getRequestURI()).thenReturn("/util/j_security_check");
    when(servletRequest.getContextPath()).thenReturn("/util");
    when(servletRequest.getParameter("state")).thenReturn("//url.com/foo/../../abc");
    when(messageInfo.getRequestMessage()).thenReturn(servletRequest);

    final Subject client = new Subject();
    module.validateRequest(messageInfo, client, null);
}
 
开发者ID:trajano,项目名称:jaspic-tester,代码行数:27,代码来源:TestServerAuthModuleTest.java


示例6: testFailLoginMissingNonce

import javax.security.auth.message.MessagePolicy; //导入依赖的package包/类
/**
 * Tests the login endpoint GET operation.
 */
@Test(expected = AuthException.class)
public void testFailLoginMissingNonce() throws Exception {

    final TestServerAuthModule module = new TestServerAuthModule();
    final MessagePolicy mockRequestPolicy = mock(MessagePolicy.class);
    when(mockRequestPolicy.isMandatory()).thenReturn(true);

    final CallbackHandler h = mock(CallbackHandler.class);
    module.initialize(mockRequestPolicy, null, h, options);

    final MessageInfo messageInfo = mock(MessageInfo.class);

    final HttpServletRequest servletRequest = mock(HttpServletRequest.class);
    when(servletRequest.getMethod()).thenReturn("GET");
    when(servletRequest.isSecure()).thenReturn(true);
    when(servletRequest.getRequestURI()).thenReturn("/util/j_security_check");
    when(servletRequest.getContextPath()).thenReturn("/util");
    when(servletRequest.getParameter("state")).thenReturn("/www.trajano.net/");
    when(messageInfo.getRequestMessage()).thenReturn(servletRequest);

    final Subject client = new Subject();
    module.validateRequest(messageInfo, client, null);
}
 
开发者ID:trajano,项目名称:jaspic-tester,代码行数:27,代码来源:TestServerAuthModuleTest.java


示例7: testFailLoginMissingState

import javax.security.auth.message.MessagePolicy; //导入依赖的package包/类
/**
 * Tests the login endpoint GET operation.
 */
@Test(expected = AuthException.class)
public void testFailLoginMissingState() throws Exception {

    final TestServerAuthModule module = new TestServerAuthModule();
    final MessagePolicy mockRequestPolicy = mock(MessagePolicy.class);
    when(mockRequestPolicy.isMandatory()).thenReturn(true);

    final CallbackHandler h = mock(CallbackHandler.class);
    module.initialize(mockRequestPolicy, null, h, options);

    final MessageInfo messageInfo = mock(MessageInfo.class);

    final HttpServletRequest servletRequest = mock(HttpServletRequest.class);
    when(servletRequest.getMethod()).thenReturn("GET");
    when(servletRequest.isSecure()).thenReturn(true);
    when(servletRequest.getRequestURI()).thenReturn("/util/j_security_check");
    when(servletRequest.getContextPath()).thenReturn("/util");
    when(messageInfo.getRequestMessage()).thenReturn(servletRequest);

    final Subject client = new Subject();
    module.validateRequest(messageInfo, client, null);
}
 
开发者ID:trajano,项目名称:jaspic-tester,代码行数:26,代码来源:TestServerAuthModuleTest.java


示例8: testFailLoginNotSecure

import javax.security.auth.message.MessagePolicy; //导入依赖的package包/类
/**
 * Tests the login endpoint GET operation.
 */
@Test(expected = AuthException.class)
public void testFailLoginNotSecure() throws Exception {

    final TestServerAuthModule module = new TestServerAuthModule();
    final MessagePolicy mockRequestPolicy = mock(MessagePolicy.class);
    when(mockRequestPolicy.isMandatory()).thenReturn(true);

    final CallbackHandler h = mock(CallbackHandler.class);
    module.initialize(mockRequestPolicy, null, h, options);

    final MessageInfo messageInfo = mock(MessageInfo.class);

    final HttpServletRequest servletRequest = mock(HttpServletRequest.class);
    when(servletRequest.getMethod()).thenReturn("GET");
    when(servletRequest.isSecure()).thenReturn(false);
    when(servletRequest.getRequestURI()).thenReturn("/util/j_security_check");
    when(servletRequest.getContextPath()).thenReturn("/util");
    when(messageInfo.getRequestMessage()).thenReturn(servletRequest);

    final Subject client = new Subject();
    module.validateRequest(messageInfo, client, null);
}
 
开发者ID:trajano,项目名称:jaspic-tester,代码行数:26,代码来源:TestServerAuthModuleTest.java


示例9: testNoAuthNeededWithoutSSL

import javax.security.auth.message.MessagePolicy; //导入依赖的package包/类
/**
 * The policy has determined it is not mandatory without SSL.
 */
@Test
public void testNoAuthNeededWithoutSSL() throws Exception {

    final TestServerAuthModule module = new TestServerAuthModule();
    final CallbackHandler h = mock(CallbackHandler.class);

    final MessagePolicy mockRequestPolicy = mock(MessagePolicy.class);
    when(mockRequestPolicy.isMandatory()).thenReturn(false);

    module.initialize(mockRequestPolicy, null, h, options);

    final MessageInfo messageInfo = mock(MessageInfo.class);

    final HttpServletRequest servletRequest = mock(HttpServletRequest.class);
    when(servletRequest.getMethod()).thenReturn("GET");
    when(servletRequest.isSecure()).thenReturn(false);
    when(servletRequest.getRequestURI()).thenReturn("/util/ejb2");
    when(servletRequest.getContextPath()).thenReturn("/util");
    when(messageInfo.getRequestMessage()).thenReturn(servletRequest);

    final Subject client = new Subject();
    assertEquals(AuthStatus.SUCCESS, module.validateRequest(messageInfo, client, null));
    verifyZeroInteractions(h);
}
 
开发者ID:trajano,项目名称:jaspic-tester,代码行数:28,代码来源:TestServerAuthModuleTest.java


示例10: testNoAuthNeededWithSSL

import javax.security.auth.message.MessagePolicy; //导入依赖的package包/类
/**
 * The policy has determined it is not mandatory.
 */
@Test
public void testNoAuthNeededWithSSL() throws Exception {

    final TestServerAuthModule module = new TestServerAuthModule();
    final MessagePolicy mockRequestPolicy = mock(MessagePolicy.class);
    when(mockRequestPolicy.isMandatory()).thenReturn(false);

    final CallbackHandler h = mock(CallbackHandler.class);
    module.initialize(mockRequestPolicy, null, h, options);

    final MessageInfo messageInfo = mock(MessageInfo.class);

    final HttpServletRequest servletRequest = mock(HttpServletRequest.class);
    when(servletRequest.getMethod()).thenReturn("GET");
    when(servletRequest.isSecure()).thenReturn(true);
    when(servletRequest.getRequestURI()).thenReturn("/util/ejb2");
    when(servletRequest.getContextPath()).thenReturn("/util");
    when(messageInfo.getRequestMessage()).thenReturn(servletRequest);

    final Subject client = new Subject();
    assertEquals(AuthStatus.SUCCESS, module.validateRequest(messageInfo, client, null));
    verifyZeroInteractions(h);
}
 
开发者ID:trajano,项目名称:jaspic-tester,代码行数:27,代码来源:TestServerAuthModuleTest.java


示例11: testSSLRequired

import javax.security.auth.message.MessagePolicy; //导入依赖的package包/类
@Test
public void testSSLRequired() throws Exception {

    final TestServerAuthModule module = new TestServerAuthModule();
    final MessagePolicy mockRequestPolicy = mock(MessagePolicy.class);
    when(mockRequestPolicy.isMandatory()).thenReturn(true);

    module.initialize(mockRequestPolicy, null, null, options);

    final MessageInfo messageInfo = mock(MessageInfo.class);

    final HttpServletRequest servletRequest = mock(HttpServletRequest.class);
    when(servletRequest.getMethod()).thenReturn("GET");
    when(servletRequest.isSecure()).thenReturn(false);
    when(servletRequest.getRequestURI()).thenReturn("/util/ejb2");
    when(servletRequest.getContextPath()).thenReturn("/util");
    when(messageInfo.getRequestMessage()).thenReturn(servletRequest);

    final HttpServletResponse servletResponse = mock(HttpServletResponse.class);
    when(messageInfo.getResponseMessage()).thenReturn(servletResponse);

    final Subject client = new Subject();
    assertEquals(AuthStatus.SEND_FAILURE, module.validateRequest(messageInfo, client, null));
    verify(servletResponse).sendError(HttpURLConnection.HTTP_FORBIDDEN, "SSL Required");
}
 
开发者ID:trajano,项目名称:jaspic-tester,代码行数:26,代码来源:TestServerAuthModuleTest.java


示例12: testFailLoginInvalidMethod

import javax.security.auth.message.MessagePolicy; //导入依赖的package包/类
/**
 * Tests the login endpoint PUT operation.
 */
@Test(expected = AuthException.class)
public void testFailLoginInvalidMethod() throws Exception {

    final TestServerAuthModule module = new TestServerAuthModule();
    final MessagePolicy mockRequestPolicy = mock(MessagePolicy.class);
    when(mockRequestPolicy.isMandatory()).thenReturn(true);

    final CallbackHandler h = mock(CallbackHandler.class);
    module.initialize(mockRequestPolicy, null, h, options);

    final MessageInfo messageInfo = mock(MessageInfo.class);

    final HttpServletRequest servletRequest = mock(HttpServletRequest.class);
    when(servletRequest.getMethod()).thenReturn("PUT");
    when(servletRequest.isSecure()).thenReturn(true);
    when(servletRequest.getRequestURI()).thenReturn("/util/j_security_check");
    when(servletRequest.getContextPath()).thenReturn("/util");
    when(servletRequest.getParameter("state")).thenReturn("/rooted/page");
    when(messageInfo.getRequestMessage()).thenReturn(servletRequest);

    final Subject client = new Subject();
    module.validateRequest(messageInfo, client, null);
}
 
开发者ID:trajano,项目名称:jaspic-tester,代码行数:27,代码来源:TestServerAuthModuleTest.java


示例13: testFailLoginInvalidState4

import javax.security.auth.message.MessagePolicy; //导入依赖的package包/类
/**
 * Tests the login endpoint GET operation.
 */
@Test(expected = AuthException.class)
public void testFailLoginInvalidState4() throws Exception {

    final TestServerAuthModule module = new TestServerAuthModule();
    final MessagePolicy mockRequestPolicy = mock(MessagePolicy.class);
    when(mockRequestPolicy.isMandatory()).thenReturn(true);

    final CallbackHandler h = mock(CallbackHandler.class);
    module.initialize(mockRequestPolicy, null, h, options);

    final MessageInfo messageInfo = mock(MessageInfo.class);

    final HttpServletRequest servletRequest = mock(HttpServletRequest.class);
    when(servletRequest.getMethod()).thenReturn("GET");
    when(servletRequest.isSecure()).thenReturn(true);
    when(servletRequest.getRequestURI()).thenReturn("/util/j_security_check");
    when(servletRequest.getContextPath()).thenReturn("/util");
    when(servletRequest.getParameter("state")).thenReturn("//url.com/foo/../../../abc");
    when(messageInfo.getRequestMessage()).thenReturn(servletRequest);

    final Subject client = new Subject();
    module.validateRequest(messageInfo, client, null);
}
 
开发者ID:trajano,项目名称:jaspic-tester,代码行数:27,代码来源:TestServerAuthModuleTest.java


示例14: testLogin

import javax.security.auth.message.MessagePolicy; //导入依赖的package包/类
/**
 * Tests the login endpoint GET operation.
 */
@Test
public void testLogin() throws Exception {

    final TestServerAuthModule module = new TestServerAuthModule();
    final MessagePolicy mockRequestPolicy = mock(MessagePolicy.class);
    when(mockRequestPolicy.isMandatory()).thenReturn(true);

    final CallbackHandler h = mock(CallbackHandler.class);
    module.initialize(mockRequestPolicy, null, h, options);

    final MessageInfo messageInfo = mock(MessageInfo.class);

    final HttpServletRequest servletRequest = mock(HttpServletRequest.class);
    when(servletRequest.getMethod()).thenReturn("GET");
    when(servletRequest.isSecure()).thenReturn(true);
    when(servletRequest.getRequestURI()).thenReturn("/util/j_security_check");
    when(servletRequest.getContextPath()).thenReturn("/util");
    when(servletRequest.getParameter("state")).thenReturn("/");
    when(servletRequest.getRequestDispatcher(Matchers.anyString())).thenReturn(mock(RequestDispatcher.class));
    when(messageInfo.getRequestMessage()).thenReturn(servletRequest);

    final Subject client = new Subject();
    assertEquals(AuthStatus.SEND_SUCCESS, module.validateRequest(messageInfo, client, null));
    verifyZeroInteractions(h);
}
 
开发者ID:trajano,项目名称:jaspic-tester,代码行数:29,代码来源:TestServerAuthModuleTest.java


示例15: initialize

import javax.security.auth.message.MessagePolicy; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void initialize(MessagePolicy messagePolicyReq, MessagePolicy messagePolicyResp, 
      CallbackHandler cbh, Map options) throws AuthException
{
   this.options = options;
   try
   {
      this.validateJAASConfiguration();
      loginContext = new LoginContext(loginContextName, cbh);
   }
   catch (LoginException e)
   {
      throw new RuntimeException(e.getLocalizedMessage());
   }

}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:17,代码来源:TestServerAuthModule.java


示例16: initialize

import javax.security.auth.message.MessagePolicy; //导入依赖的package包/类
public void initialize(MessagePolicy reqPolicy, MessagePolicy resPolicy,
        CallbackHandler cBH, Map opts)
        throws AuthException
{
    logger.fine("Configure WonderSAM");

    this.requestPolicy = reqPolicy;
    this.resPolicy = resPolicy;
    this.handler = cBH;
    this.opts = opts;

    try {
        // create the session resolver based on the specified class
        String smClass = (String) opts.get(SESSION_RESOLVER_OPT);
        sessionManager = createSessionManager(smClass);
        sessionManager.initialize(opts);

        // create the group resolver based on the specified class
        String grClass = (String) opts.get(GROUP_RESOLVER_OPT);
        groupManager = createGroupManager(grClass);
        groupManager.initialize(opts);
    } catch (IllegalStateException ise) {
        // make sure to log any errors
        logger.log(Level.WARNING, "Error instantiating helper", ise);
        throw ise;
    }
}
 
开发者ID:josmas,项目名称:openwonderland,代码行数:28,代码来源:WonderSAM.java


示例17: initialize

import javax.security.auth.message.MessagePolicy; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public void initialize(MessagePolicy requestPolicy, MessagePolicy responsePolicy, CallbackHandler handler,
      Map options) throws AuthException
{
   this.requestPolicy = requestPolicy;
   this.responsePolicy = responsePolicy;
   this.handler = handler;
   this.options = options;
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:10,代码来源:SOAPClientAuthModule.java


示例18: testFailFromIOException

import javax.security.auth.message.MessagePolicy; //导入依赖的package包/类
/**
 * Tests when a servlet API method throws an exception
 */
@Test(expected = AuthException.class)
public void testFailFromIOException() throws Exception {

    final TestServerAuthModule module = new TestServerAuthModule();
    final MessagePolicy mockRequestPolicy = mock(MessagePolicy.class);
    when(mockRequestPolicy.isMandatory()).thenReturn(true);

    final CallbackHandler h = mock(CallbackHandler.class);
    module.initialize(mockRequestPolicy, null, h, options);

    final MessageInfo messageInfo = mock(MessageInfo.class);

    final HttpServletRequest servletRequest = mock(HttpServletRequest.class);
    when(servletRequest.getMethod()).thenReturn("GET");
    when(servletRequest.isSecure()).thenReturn(true);
    when(servletRequest.getRequestURI()).thenReturn("/util/j_security_check");
    when(servletRequest.getContextPath()).thenReturn("/util");
    when(servletRequest.getParameter("state")).thenReturn("/");
    when(servletRequest.getParameter("nonce")).thenReturn("abc");
    when(messageInfo.getRequestMessage()).thenReturn(servletRequest);

    final HttpServletResponse servletResponse = mock(HttpServletResponse.class);
    when(messageInfo.getResponseMessage()).thenReturn(servletResponse);

    final RequestDispatcher dispatcher = mock(RequestDispatcher.class);
    doThrow(IOException.class).when(dispatcher).forward(servletRequest, servletResponse);
    when(servletRequest.getRequestDispatcher(Matchers.anyString())).thenReturn(dispatcher);

    final Subject client = new Subject();
    assertEquals(AuthStatus.SEND_SUCCESS, module.validateRequest(messageInfo, client, null));
    verifyZeroInteractions(h);
}
 
开发者ID:trajano,项目名称:jaspic-tester,代码行数:36,代码来源:TestServerAuthModuleTest.java


示例19: testFailLoginPostMissingSession

import javax.security.auth.message.MessagePolicy; //导入依赖的package包/类
/**
 * No session when doing the login POST operation.
 */
@Test(expected = AuthException.class)
public void testFailLoginPostMissingSession() throws Exception {

    final TestServerAuthModule module = new TestServerAuthModule();
    final MessagePolicy mockRequestPolicy = mock(MessagePolicy.class);
    when(mockRequestPolicy.isMandatory()).thenReturn(true);

    final CallbackHandler h = mock(CallbackHandler.class);
    module.initialize(mockRequestPolicy, null, h, options);

    final MessageInfo messageInfo = mock(MessageInfo.class);

    final HttpServletRequest servletRequest = mock(HttpServletRequest.class);
    when(servletRequest.getMethod()).thenReturn("POST");
    when(servletRequest.isSecure()).thenReturn(true);
    when(servletRequest.getRequestURI()).thenReturn("/util/j_security_check");
    when(servletRequest.getContextPath()).thenReturn("/util");
    when(servletRequest.getParameter("state")).thenReturn("/");
    when(servletRequest.getParameter("nonce")).thenReturn("abcdefg");
    when(servletRequest.getParameter("j_username")).thenReturn("foofoo");
    when(servletRequest.getRequestDispatcher(Matchers.anyString())).thenReturn(mock(RequestDispatcher.class));
    when(messageInfo.getRequestMessage()).thenReturn(servletRequest);

    final HttpServletResponse servletResponse = mock(HttpServletResponse.class);
    when(messageInfo.getResponseMessage()).thenReturn(servletResponse);

    final Subject client = new Subject();
    assertEquals(AuthStatus.SEND_SUCCESS, module.validateRequest(messageInfo, client, null));
}
 
开发者ID:trajano,项目名称:jaspic-tester,代码行数:33,代码来源:TestServerAuthModuleTest.java


示例20: testFailLoginPostNonceMismatch

import javax.security.auth.message.MessagePolicy; //导入依赖的package包/类
/**
 * No session when doing the login POST operation.
 */
@Test(expected = AuthException.class)
public void testFailLoginPostNonceMismatch() throws Exception {

    final TestServerAuthModule module = new TestServerAuthModule();
    final MessagePolicy mockRequestPolicy = mock(MessagePolicy.class);
    when(mockRequestPolicy.isMandatory()).thenReturn(true);

    final CallbackHandler h = mock(CallbackHandler.class);
    module.initialize(mockRequestPolicy, null, h, options);

    final MessageInfo messageInfo = mock(MessageInfo.class);

    final HttpSession session = mock(HttpSession.class);
    when(session.getAttribute("X-Nonce")).thenReturn("abc");

    final HttpServletRequest servletRequest = mock(HttpServletRequest.class);
    when(servletRequest.getMethod()).thenReturn("POST");
    when(servletRequest.isSecure()).thenReturn(true);
    when(servletRequest.getRequestURI()).thenReturn("/util/j_security_check");
    when(servletRequest.getContextPath()).thenReturn("/util");
    when(servletRequest.getParameter("state")).thenReturn("/");
    when(servletRequest.getParameter("nonce")).thenReturn("abcdefg");
    when(servletRequest.getParameter("j_username")).thenReturn("foofoo");
    when(servletRequest.getSession()).thenReturn(session);
    when(servletRequest.getSession(false)).thenReturn(session);
    when(servletRequest.getRequestDispatcher(Matchers.anyString())).thenReturn(mock(RequestDispatcher.class));
    when(messageInfo.getRequestMessage()).thenReturn(servletRequest);

    final HttpServletResponse servletResponse = mock(HttpServletResponse.class);
    when(messageInfo.getResponseMessage()).thenReturn(servletResponse);

    final Subject client = new Subject();
    assertEquals(AuthStatus.SEND_SUCCESS, module.validateRequest(messageInfo, client, null));
}
 
开发者ID:trajano,项目名称:jaspic-tester,代码行数:38,代码来源:TestServerAuthModuleTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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