本文整理汇总了Java中javax.security.auth.message.module.ServerAuthModule类的典型用法代码示例。如果您正苦于以下问题:Java ServerAuthModule类的具体用法?Java ServerAuthModule怎么用?Java ServerAuthModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServerAuthModule类属于javax.security.auth.message.module包,在下文中一共展示了ServerAuthModule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerServerAuthModule
import javax.security.auth.message.module.ServerAuthModule; //导入依赖的package包/类
/**
* Registers a server auth module as the one and only module for the application corresponding to
* the given servlet context.
* <p/>
* <p/>
* This will override any other modules that have already been registered, either via proprietary
* means or using the standard API.
*
* @param serverAuthModule the server auth module to be registered
* @param servletContext the context of the app for which the module is registered
* @return A String identifier assigned by an underlying factory corresponding to an underlying factory-factory-factory registration
*/
public static String registerServerAuthModule(ServerAuthModule serverAuthModule, ServletContext servletContext) {
// Register the factory-factory-factory for the SAM
String registrationId = AuthConfigFactory.getFactory().registerConfigProvider(
new DefaultAuthConfigProvider(serverAuthModule),
"HttpServlet",
getAppContextID(servletContext),
"Default single SAM authentication config provider"
);
// Remember the registration ID returned by the factory, so we can unregister the JASPIC module when the web module
// is undeployed. JASPIC being the low level API that it is won't do this automatically.
servletContext.setAttribute(CONTEXT_REGISTRATION_ID, registrationId);
return registrationId;
}
示例2: DefaultServerAuthConfig
import javax.security.auth.message.module.ServerAuthModule; //导入依赖的package包/类
public DefaultServerAuthConfig(String layer, String appContext, CallbackHandler handler,
Map<String, String> providerProperties, ServerAuthModule serverAuthModule) {
this.layer = layer;
this.appContext = appContext;
this.handler = handler;
this.providerProperties = providerProperties;
this.serverAuthModule = serverAuthModule;
}
示例3: createSAM
import javax.security.auth.message.module.ServerAuthModule; //导入依赖的package包/类
@SuppressWarnings(
{"unchecked", "rawtypes"})
private ServerAuthModule createSAM(ClassLoader moduleCL, String name) throws Exception
{
Class clazz = SecurityActions.loadClass(moduleCL, name);
Constructor ctr = clazz.getConstructor(new Class[0]);
return (ServerAuthModule) ctr.newInstance(new Object[0]);
}
示例4: testSecureMessage
import javax.security.auth.message.module.ServerAuthModule; //导入依赖的package包/类
@Test
public void testSecureMessage() throws Exception {
final Subject subject = new Subject();
final Principal groupPrincipal = mock(Principal.class);
when(groupPrincipal.getName()).thenReturn("authenticated");
subject.getPrincipals().add(groupPrincipal);
final Principal userPrincipal = mock(Principal.class);
when(userPrincipal.getName()).thenReturn("https://[email protected]");
subject.getPrincipals().add(userPrincipal);
final MessageInfo messageInfo = mock(MessageInfo.class);
final HttpSession session = mock(HttpSession.class);
when(session.getAttribute("X-Subject")).thenReturn("https://[email protected]");
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/secure_page");
when(servletRequest.getContextPath()).thenReturn("/util");
when(servletRequest.getSession()).thenReturn(session);
when(servletRequest.getSession(false)).thenReturn(session);
when(messageInfo.getRequestMessage()).thenReturn(servletRequest);
final CallbackHandler h = mock(CallbackHandler.class);
final ServerAuthModule sam = new TestServerAuthModule();
final MessagePolicy mockRequestPolicy = mock(MessagePolicy.class);
when(mockRequestPolicy.isMandatory()).thenReturn(true);
sam.initialize(mockRequestPolicy, null, h, options);
assertEquals(AuthStatus.SUCCESS, sam.validateRequest(messageInfo, null, subject));
}
示例5: testSecureMessage
import javax.security.auth.message.module.ServerAuthModule; //导入依赖的package包/类
@Test
public void testSecureMessage() throws Exception {
final Subject subject = new Subject();
final Principal groupPrincipal = mock(Principal.class);
when(groupPrincipal.getName()).thenReturn("authenticated");
subject.getPrincipals().add(groupPrincipal);
final Principal userPrincipal = mock(Principal.class);
when(userPrincipal.getName()).thenReturn("https://[email protected]");
subject.getPrincipals().add(userPrincipal);
final MessageInfo messageInfo = mock(MessageInfo.class);
final Cookie[] cookies = new Cookie[] {
new Cookie("X-Subject", "https://[email protected]"),
new Cookie("not-relevant", "foo")
};
final HttpServletRequest servletRequest = mock(HttpServletRequest.class);
when(servletRequest.getMethod()).thenReturn("POST");
when(servletRequest.isSecure()).thenReturn(true);
when(servletRequest.getRequestURI()).thenReturn("/util/secure_page");
when(servletRequest.getContextPath()).thenReturn("/util");
when(servletRequest.getCookies()).thenReturn(cookies);
when(messageInfo.getRequestMessage()).thenReturn(servletRequest);
final CallbackHandler h = mock(CallbackHandler.class);
final ServerAuthModule sam = new TestServerAuthModule();
final MessagePolicy mockRequestPolicy = mock(MessagePolicy.class);
when(mockRequestPolicy.isMandatory()).thenReturn(true);
sam.initialize(mockRequestPolicy, null, h, options);
assertEquals(AuthStatus.SUCCESS, sam.validateRequest(messageInfo, null, subject));
}
示例6: createSAM
import javax.security.auth.message.module.ServerAuthModule; //导入依赖的package包/类
@SuppressWarnings({"rawtypes", "unchecked"})
private ServerAuthModule createSAM(ClassLoader moduleCL, String name )
throws Exception
{
Class clazz = SecurityActions.loadClass(moduleCL, name);
Constructor ctr = clazz.getConstructor(new Class[0]);
return (ServerAuthModule) ctr.newInstance(new Object[0]);
}
示例7: JBossServerAuthContext
import javax.security.auth.message.module.ServerAuthModule; //导入依赖的package包/类
public JBossServerAuthContext(List<ServerAuthModule> modules,
Map<String,Map> moduleNameToOptions, CallbackHandler cbh) throws AuthException
{
this.modules = modules;
this.moduleOptionsByName = moduleNameToOptions;
for(ServerAuthModule sam:modules)
{
sam.initialize(null, null, cbh,
moduleOptionsByName.get(sam.getClass().getName()));
}
}
示例8: cleanSubject
import javax.security.auth.message.module.ServerAuthModule; //导入依赖的package包/类
/**
* @see ServerAuthContext#cleanSubject(javax.security.auth.message.MessageInfo, javax.security.auth.Subject)
*/
public void cleanSubject(MessageInfo messageInfo, Subject subject) throws AuthException
{
for(ServerAuthModule sam:modules)
{
sam.cleanSubject(messageInfo, subject);
}
}
示例9: secureResponse
import javax.security.auth.message.module.ServerAuthModule; //导入依赖的package包/类
/**
* @see ServerAuthContext#secureResponse(javax.security.auth.message.MessageInfo, javax.security.auth.Subject)
*/
public AuthStatus secureResponse(MessageInfo messageInfo, Subject serviceSubject) throws AuthException
{
AuthStatus status = null;
for(ServerAuthModule sam:modules)
{
status = sam.secureResponse(messageInfo, serviceSubject);
}
return status;
}
示例10: validateRequest
import javax.security.auth.message.module.ServerAuthModule; //导入依赖的package包/类
/**
* @see ServerAuthContext#validateRequest(javax.security.auth.message.MessageInfo, javax.security.auth.Subject, javax.security.auth.Subject)
*/
public AuthStatus validateRequest(MessageInfo messageInfo, Subject clientSubject,
Subject serviceSubject) throws AuthException
{
List<ServerAuthModule> supportingModules = new ArrayList<ServerAuthModule>();
Class requestType = messageInfo.getRequestMessage().getClass();
Class[] requestInterfaces = requestType.getInterfaces();
List<Class> intfaee = Arrays.asList(requestInterfaces);
for(ServerAuthModule sam:modules)
{
List<Class> supportedTypes = Arrays.asList(sam.getSupportedMessageTypes());
//Check the interfaces
for(Class clazz:intfaee)
{
if(supportedTypes.contains(clazz) && !supportingModules.contains(sam))
supportingModules.add(sam);
}
//Check the class type also
if((supportedTypes.contains(Object.class) || supportedTypes.contains(requestType))
&& !supportingModules.contains(sam))
supportingModules.add(sam);
}
if(supportingModules.size() == 0)
throw PicketBoxMessages.MESSAGES.noServerAuthModuleForRequestType(requestType);
AuthStatus authStatus = invokeModules(messageInfo, clientSubject, serviceSubject);
return authStatus;
}
示例11: TestServerAuthConfig
import javax.security.auth.message.module.ServerAuthModule; //导入依赖的package包/类
public TestServerAuthConfig(String layer, String appContext, CallbackHandler handler,
Map<String, String> providerProperties, ServerAuthModule serverAuthModule) {
this.layer = layer;
this.appContext = appContext;
this.handler = handler;
this.providerProperties = providerProperties;
this.serverAuthModule = serverAuthModule;
}
示例12: TestServerAuthConfig
import javax.security.auth.message.module.ServerAuthModule; //导入依赖的package包/类
public TestServerAuthConfig(String layer, String appContext, CallbackHandler handler, Map<String, String> providerProperties, ServerAuthModule serverAuthModule) {
this.layer = layer;
this.appContext = appContext;
this.handler = handler;
this.providerProperties = providerProperties;
this.serverAuthModule = serverAuthModule;
}
示例13: TheServerAuthConfig
import javax.security.auth.message.module.ServerAuthModule; //导入依赖的package包/类
public TheServerAuthConfig(String layer, String appContext, CallbackHandler handler,
Map<String, String> providerProperties, ServerAuthModule serverAuthModule) {
this.layer = layer;
this.appContext = appContext;
this.handler = handler;
this.providerProperties = providerProperties;
this.serverAuthModule = serverAuthModule;
}
示例14: DefaultServerAuthContext
import javax.security.auth.message.module.ServerAuthModule; //导入依赖的package包/类
public DefaultServerAuthContext(CallbackHandler handler, ServerAuthModule serverAuthModule) throws AuthException {
this.serverAuthModule = serverAuthModule;
serverAuthModule.initialize(null, null, handler, Collections.<String, String>emptyMap());
}
示例15: DefaultAuthConfigProvider
import javax.security.auth.message.module.ServerAuthModule; //导入依赖的package包/类
public DefaultAuthConfigProvider(ServerAuthModule serverAuthModule) {
this.serverAuthModule = serverAuthModule;
}