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


Java ServerAuthContext.validateRequest方法代码示例

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


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

示例1: testSuccessfulJASPI

import javax.security.auth.message.config.ServerAuthContext; //导入方法依赖的package包/类
public void testSuccessfulJASPI() throws Exception
{
   AuthConfigProvider provider = factory.getConfigProvider(layer, appId, null);
   ServerAuthConfig serverConfig = provider.getServerAuthConfig(layer, appId, new AppCallbackHandler("jduke",
         "theduke".toCharArray()));
   assertNotNull("ServerAuthConfig is not null", serverConfig);

   MessageInfo mi = new GenericMessageInfo(new Object(), new Object());
   String authContextID = serverConfig.getAuthContextID(mi);
   assertNotNull("AuthContext ID != null", authContextID);
   ServerAuthContext sctx = serverConfig.getAuthContext(authContextID, new Subject(), new HashMap());
   assertNotNull("ServerAuthContext != null", sctx);
   Subject clientSubject = new Subject();
   Subject serviceSubject = new Subject();
   AuthStatus status = sctx.validateRequest(mi, clientSubject, serviceSubject);
   assertEquals(AuthStatus.SUCCESS, status);
}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:18,代码来源:JASPILoginModuleDelgateUnitTestCase.java

示例2: testUnSuccessfulJASPI

import javax.security.auth.message.config.ServerAuthContext; //导入方法依赖的package包/类
public void testUnSuccessfulJASPI() throws Exception
{
   AuthConfigProvider provider = factory.getConfigProvider(layer, appId, null);
   ServerAuthConfig serverConfig = provider.getServerAuthConfig(layer, appId, new AppCallbackHandler("jduke",
         "badpwd".toCharArray()));
   assertNotNull("ServerAuthConfig is not null", serverConfig);

   MessageInfo mi = new GenericMessageInfo(new Object(), new Object());
   String authContextID = serverConfig.getAuthContextID(mi);
   assertNotNull("AuthContext ID != null", authContextID);
   ServerAuthContext sctx = serverConfig.getAuthContext(authContextID, new Subject(), new HashMap());
   assertNotNull("ServerAuthContext != null", sctx);
   Subject clientSubject = new Subject();
   Subject serviceSubject = new Subject();
   try
   {
      AuthStatus status = sctx.validateRequest(mi, clientSubject, serviceSubject);
      assertEquals(AuthStatus.FAILURE, status);
   }
   catch (AuthException ae)
   {
      // Pass
   }
}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:25,代码来源:JASPILoginModuleDelgateUnitTestCase.java

示例3: testSuccessfulJASPI

import javax.security.auth.message.config.ServerAuthContext; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void testSuccessfulJASPI() throws Exception
{
   AuthConfigProvider provider = factory.getConfigProvider(layer, appId, null);
   ServerAuthConfig serverConfig = provider.getServerAuthConfig(layer, appId, new AppCallbackHandler("anil",
         "anilpwd".toCharArray()));
   assertNotNull("ServerAuthConfig is not null", serverConfig);

   MessageInfo mi = new GenericMessageInfo(new Object(), new Object());
   String authContextID = serverConfig.getAuthContextID(mi);
   assertNotNull("AuthContext ID != null", authContextID);
   ServerAuthContext sctx = serverConfig.getAuthContext(authContextID, new Subject(), new HashMap());
   assertNotNull("ServerAuthContext != null", sctx);
   Subject clientSubject = new Subject();
   Subject serviceSubject = new Subject();
   AuthStatus status = sctx.validateRequest(mi, clientSubject, serviceSubject);
   assertEquals(AuthStatus.SUCCESS, status);
}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:19,代码来源:JASPIWorkflowUnitTestCase.java

示例4: testUnSuccessfulJASPI

import javax.security.auth.message.config.ServerAuthContext; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void testUnSuccessfulJASPI() throws Exception
{
   AuthConfigProvider provider = factory.getConfigProvider(layer, appId, null);
   ServerAuthConfig serverConfig = provider.getServerAuthConfig(layer, appId, new AppCallbackHandler("anil",
         "badpwd".toCharArray()));
   assertNotNull("ServerAuthConfig is not null", serverConfig);

   validateJAASConfiguration();
   MessageInfo mi = new GenericMessageInfo(new Object(), new Object());
   String authContextID = serverConfig.getAuthContextID(mi);
   assertNotNull("AuthContext ID != null", authContextID);
   ServerAuthContext sctx = serverConfig.getAuthContext(authContextID, new Subject(), new HashMap());
   assertNotNull("ServerAuthContext != null", sctx);
   Subject clientSubject = new Subject();
   Subject serviceSubject = new Subject();
   try
   {
      AuthStatus status = sctx.validateRequest(mi, clientSubject, serviceSubject);
      assertEquals(AuthStatus.FAILURE, status);
   }
   catch (AuthException ae)
   {
      //Ignore - we are fine
   }
}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:27,代码来源:JASPIWorkflowUnitTestCase.java

示例5: testProvider

import javax.security.auth.message.config.ServerAuthContext; //导入方法依赖的package包/类
@Test
public void testProvider() throws Exception {

    final CallbackHandler h = mock(CallbackHandler.class);
    final Map<String, String> options = new HashMap<>();
    final AuthModuleConfigProvider provider = new AuthModuleConfigProvider(options, null);
    assertNull(provider.getClientAuthConfig("HttpServlet", "server1 /", h));

    final ServerAuthConfig serverAuthConfig = provider.getServerAuthConfig("HttpServlet", "server1 /", h);
    assertNotNull(serverAuthConfig);
    assertEquals("server1 /", serverAuthConfig.getAppContext());
    assertEquals("HttpServlet", serverAuthConfig.getMessageLayer());

    final Subject serviceSubject = new Subject();

    assertNull(serverAuthConfig.getAuthContextID(mock(MessageInfo.class)));

    final MessageInfo messageInfoMandatory = mock(MessageInfo.class);
    when(messageInfoMandatory.getMap()).thenReturn(Collections.singletonMap("javax.security.auth.message.MessagePolicy.isMandatory", "true"));

    final HttpSession session = mock(HttpSession.class);

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

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

    final String authContextID = serverAuthConfig.getAuthContextID(messageInfoMandatory);
    assertNotNull(authContextID);

    final ServerAuthContext authContext = serverAuthConfig.getAuthContext(authContextID, serviceSubject, new HashMap<>());
    assertNotNull(authContext);
    final AuthStatus validateRequest = authContext.validateRequest(messageInfoMandatory, null, serviceSubject);
    assertEquals(AuthStatus.SEND_SUCCESS, validateRequest);

    final AuthStatus secureResponse = authContext.secureResponse(messageInfoMandatory, serviceSubject);
    assertEquals(AuthStatus.SEND_SUCCESS, secureResponse);

    authContext.cleanSubject(messageInfoMandatory, serviceSubject);

    assertTrue(serverAuthConfig.isProtected());
    serverAuthConfig.refresh();
    provider.refresh();

}
 
开发者ID:trajano,项目名称:jaspic-tester,代码行数:52,代码来源:ApplicationManagedJaspicTest.java

示例6: testProvider

import javax.security.auth.message.config.ServerAuthContext; //导入方法依赖的package包/类
@Test
public void testProvider() throws Exception {

    final CallbackHandler h = mock(CallbackHandler.class);
    final Map<String, String> options = new HashMap<>();
    final AuthModuleConfigProvider provider = new AuthModuleConfigProvider(options, null);
    assertNull(provider.getClientAuthConfig("HttpServlet", "server1 /", h));

    final ServerAuthConfig serverAuthConfig = provider.getServerAuthConfig("HttpServlet", "server1 /", h);
    assertNotNull(serverAuthConfig);
    assertEquals("server1 /", serverAuthConfig.getAppContext());
    assertEquals("HttpServlet", serverAuthConfig.getMessageLayer());

    final Subject serviceSubject = new Subject();

    assertNull(serverAuthConfig.getAuthContextID(mock(MessageInfo.class)));

    final MessageInfo messageInfoMandatory = mock(MessageInfo.class);
    when(messageInfoMandatory.getMap()).thenReturn(Collections.singletonMap("javax.security.auth.message.MessagePolicy.isMandatory", "true"));

    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(messageInfoMandatory.getRequestMessage()).thenReturn(servletRequest);

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

    final String authContextID = serverAuthConfig.getAuthContextID(messageInfoMandatory);
    assertNotNull(authContextID);

    final ServerAuthContext authContext = serverAuthConfig.getAuthContext(authContextID, serviceSubject, new HashMap<>());
    assertNotNull(authContext);
    final AuthStatus validateRequest = authContext.validateRequest(messageInfoMandatory, null, serviceSubject);
    assertEquals(AuthStatus.SEND_SUCCESS, validateRequest);

    final AuthStatus secureResponse = authContext.secureResponse(messageInfoMandatory, serviceSubject);
    assertEquals(AuthStatus.SEND_SUCCESS, secureResponse);

    authContext.cleanSubject(messageInfoMandatory, serviceSubject);

    assertTrue(serverAuthConfig.isProtected());
    serverAuthConfig.refresh();
    provider.refresh();

}
 
开发者ID:trajano,项目名称:jaspic-tester,代码行数:49,代码来源:ApplicationManagedJaspicTest.java


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