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


Java ServerAuthContext类代码示例

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


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

示例1: getAuthContext

import javax.security.auth.message.config.ServerAuthContext; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * <p>
 * Augments the options with the properties specified and initializes the
 * module as mandatory or non-mandatory depending on whether the
 * authContextID is <code>null</code>.
 * </p>
 */
@Override
public ServerAuthContext getAuthContext(final String authContextID,
    final Subject serviceSubject,
    @SuppressWarnings("rawtypes") final Map properties) throws AuthException {

    @SuppressWarnings("rawtypes")
    final Map augmentedOptions = augmentProperties(properties);
    final TestServerAuthModule context = new TestServerAuthModule();

    if (authContextID == null) {
        context.initialize(NON_MANDATORY, NON_MANDATORY, handler, augmentedOptions);
    } else {
        context.initialize(MANDATORY, MANDATORY, handler, augmentedOptions);
    }
    return context;
}
 
开发者ID:trajano,项目名称:jaspic-tester,代码行数:25,代码来源:TestServerAuthModuleAuthConfig.java

示例2: testContext2

import javax.security.auth.message.config.ServerAuthContext; //导入依赖的package包/类
@Test
public void testContext2() 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 ServerAuthContext authContext = serverAuthConfig.getAuthContext(null, serviceSubject, null);
    assertNotNull(authContext);
}
 
开发者ID:trajano,项目名称:jaspic-tester,代码行数:21,代码来源:ApplicationManagedJaspicTest.java

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

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

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

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

示例7: testServerFactoryConfig

import javax.security.auth.message.config.ServerAuthContext; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void testServerFactoryConfig() throws Exception
{ 
   assertNotNull("AuthConfigFactory is ! null", factory); 
   AuthConfigProvider provider = factory.getConfigProvider("TEST", "APP", null);
   assertNotNull("AuthConfigProvider is ! null", provider);
   
   ServerAuthConfig serverConfig =
      provider.getServerAuthConfig("TEST", "APP", 
            new AppCallbackHandler("anil","anil".toCharArray()));
   assertNotNull("ServerAuthConfig ! 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); 
}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:19,代码来源:JASPIConfigUnitTestCase.java

示例8: testContext1

import javax.security.auth.message.config.ServerAuthContext; //导入依赖的package包/类
@Test
public void testContext1() 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);
}
 
开发者ID:trajano,项目名称:jaspic-tester,代码行数:37,代码来源:ApplicationManagedJaspicTest.java

示例9: getAuthContext

import javax.security.auth.message.config.ServerAuthContext; //导入依赖的package包/类
@Override
public ServerAuthContext getAuthContext(final String authContextID,
        final Subject serviceSubject,
        @SuppressWarnings("rawtypes") final Map properties) throws AuthException {

    final Map<?, ?> augmentedOptions = augmentProperties(properties);
    final OpenIdConnectAuthModule module = new OpenIdConnectAuthModule();

    if (authContextID == null) {
        module.initialize(NON_MANDATORY, NON_MANDATORY, handler, augmentedOptions);
    } else {
        module.initialize(MANDATORY, MANDATORY, handler, augmentedOptions);
    }
    return module;
}
 
开发者ID:trajano,项目名称:openid-connect,代码行数:16,代码来源:OpenIdConnectModuleConfig.java

示例10: getAuthContext

import javax.security.auth.message.config.ServerAuthContext; //导入依赖的package包/类
@Override
public ServerAuthContext getAuthContext(String authContextID, Subject serviceSubject, Map properties) throws AuthException {
    return new CustomServerAuthContext(serverAuthModules);
}
 
开发者ID:polarsys,项目名称:eplmp,代码行数:5,代码来源:CustomServerAuthConfig.java

示例11: getAuthContext

import javax.security.auth.message.config.ServerAuthContext; //导入依赖的package包/类
@Override
public ServerAuthContext getAuthContext(String authContextID, Subject serviceSubject,
                                        @SuppressWarnings("rawtypes") Map properties) throws AuthException {
    return new DefaultServerAuthContext(handler, serverAuthModule);
}
 
开发者ID:rdebusscher,项目名称:octopus-jsr375,代码行数:6,代码来源:DefaultServerAuthConfig.java

示例12: getAuthContext

import javax.security.auth.message.config.ServerAuthContext; //导入依赖的package包/类
@Override
public ServerAuthContext getAuthContext(String authContextID, Subject serviceSubject,
    @SuppressWarnings("rawtypes") Map properties) throws AuthException {
  return new YubiServerAuthContext(handler);
}
 
开发者ID:erik-wramner,项目名称:YubikeyAuth,代码行数:6,代码来源:YubiServerAuthConfig.java

示例13: JaspiServerAuthenticator

import javax.security.auth.message.config.ServerAuthContext; //导入依赖的package包/类
public JaspiServerAuthenticator(ServerAuthContext sctx)
{
   this.sctx = sctx;
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:5,代码来源:JaspiServerAuthenticator.java

示例14: enableServerAuthentication

import javax.security.auth.message.config.ServerAuthContext; //导入依赖的package包/类
public boolean enableServerAuthentication(Deployment dep, JBossWebservicesMetaData wsmd)
{
   String securityDomain = null;
   if (wsmd != null)
   {
      securityDomain = wsmd.getProperty(JaspiServerAuthenticator.JASPI_SECURITY_DOMAIN);
   }
   if (securityDomain == null)
   {
      return false;
   }
   ApplicationPolicy appPolicy = SecurityConfiguration.getApplicationPolicy(securityDomain);
   if (appPolicy == null)
   {
      Loggers.ROOT_LOGGER.noApplicationPolicy(securityDomain);
      return false;
   }
   BaseAuthenticationInfo bai = appPolicy.getAuthenticationInfo();
   if (bai == null || bai instanceof AuthenticationInfo)
   {
      Loggers.ROOT_LOGGER.noJaspiApplicationPolicy(securityDomain);
      return false;
   }
   JASPIAuthenticationInfo jai = (JASPIAuthenticationInfo) bai;

   String contextRoot = dep.getService().getContextRoot();
   String appId = "localhost " + contextRoot;
   AuthConfigFactory factory = AuthConfigFactory.getFactory();
   Properties properties = new Properties();
   AuthConfigProvider provider = new JBossWSAuthConfigProvider(properties, factory);
   provider = factory.getConfigProvider(JBossWSAuthConstants.SOAP_LAYER, appId, null);

   JBossCallbackHandler callbackHandler = new JBossCallbackHandler();
   try
   {
      ServerAuthConfig serverConfig = provider.getServerAuthConfig(JBossWSAuthConstants.SOAP_LAYER, appId,
            callbackHandler);
      Properties serverContextProperties = new Properties();
      serverContextProperties.put("security-domain", securityDomain);
      serverContextProperties.put("jaspi-policy", jai);
      Bus bus = dep.getAttachment(Bus.class);
      serverContextProperties.put(Bus.class, bus);
      String authContextID = dep.getSimpleName();
      ServerAuthContext sctx = serverConfig.getAuthContext(authContextID, null, serverContextProperties);
      JaspiServerAuthenticator serverAuthenticator = new JaspiServerAuthenticator(sctx);
      bus.getInInterceptors().add(new JaspiSeverInInterceptor(serverAuthenticator));
      bus.getOutInterceptors().add(new JaspiSeverOutInterceptor(serverAuthenticator));
      return true;
   }
   catch (Exception e)
   {
      Loggers.DEPLOYMENT_LOGGER.cannotCreateServerAuthContext(securityDomain, e);
   }
   return false;
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:56,代码来源:DefaultJASPIAuthenticationProvider.java

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


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