本文整理汇总了Java中javax.security.auth.message.MessageInfo类的典型用法代码示例。如果您正苦于以下问题:Java MessageInfo类的具体用法?Java MessageInfo怎么用?Java MessageInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MessageInfo类属于javax.security.auth.message包,在下文中一共展示了MessageInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: validateRequest
import javax.security.auth.message.MessageInfo; //导入依赖的package包/类
@Override
public AuthStatus validateRequest(MessageInfo messageInfo, Subject clientSubject, Subject serviceSubject) throws AuthException {
HttpServletRequest request = (HttpServletRequest) messageInfo.getRequestMessage();
LOGGER.log(Level.FINE, "Validating request @" + request.getMethod() + " " + request.getRequestURI());
String login = (String) request.getSession().getAttribute("login");
String groups = (String) request.getSession().getAttribute("groups");
CallerPrincipalCallback callerPrincipalCallback = new CallerPrincipalCallback(clientSubject, login);
GroupPrincipalCallback groupPrincipalCallback = new GroupPrincipalCallback(clientSubject, new String[]{groups});
Callback[] callbacks = new Callback[]{callerPrincipalCallback, groupPrincipalCallback};
try {
callbackHandler.handle(callbacks);
} catch (IOException | UnsupportedCallbackException e) {
throw new AuthException(e.getMessage());
}
return AuthStatus.SUCCESS;
}
开发者ID:polarsys,项目名称:eplmp,代码行数:22,代码来源:SessionSAM.java
示例2: validateRequest
import javax.security.auth.message.MessageInfo; //导入依赖的package包/类
@Override
public AuthStatus validateRequest(MessageInfo messageInfo, Subject clientSubject, Subject serviceSubject) throws AuthException {
HttpServletRequest request = (HttpServletRequest) messageInfo.getRequestMessage();
LOGGER.log(Level.FINE, "Validating request @" + request.getMethod() + " " + request.getRequestURI());
CallerPrincipalCallback callerPrincipalCallback = new CallerPrincipalCallback(clientSubject, "");
GroupPrincipalCallback groupPrincipalCallback = new GroupPrincipalCallback(clientSubject, new String[]{UserGroupMapping.GUEST_ROLE_ID});
Callback[] callbacks = {callerPrincipalCallback, groupPrincipalCallback};
try {
callbackHandler.handle(callbacks);
} catch (IOException | UnsupportedCallbackException e) {
throw new AuthException(e.getMessage());
}
return AuthStatus.SUCCESS;
}
开发者ID:polarsys,项目名称:eplmp,代码行数:20,代码来源:GuestSAM.java
示例3: validateRequest
import javax.security.auth.message.MessageInfo; //导入依赖的package包/类
@Override
public AuthStatus validateRequest(MessageInfo messageInfo, Subject clientSubject, Subject serviceSubject) throws AuthException {
HttpServletRequest request = (HttpServletRequest) messageInfo.getRequestMessage();
HttpServletResponse response = (HttpServletResponse) messageInfo.getResponseMessage();
AuthServices.addCORSHeaders(response);
LOGGER.log(Level.FINE, "validateRequest @" + request.getMethod() + " " + request.getRequestURI());
if (isOptionsRequest(request)) {
return AuthStatus.SUCCESS;
}
CustomSAM module = getModule(messageInfo);
if (module != null) {
return module.validateRequest(messageInfo, clientSubject, serviceSubject);
}
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
return AuthStatus.FAILURE;
}
开发者ID:polarsys,项目名称:eplmp,代码行数:24,代码来源:CustomServerAuthContext.java
示例4: secureResponse
import javax.security.auth.message.MessageInfo; //导入依赖的package包/类
@Override
public AuthStatus secureResponse(MessageInfo messageInfo, Subject serviceSubject) throws AuthException {
HttpServletRequest request = (HttpServletRequest) messageInfo.getRequestMessage();
HttpServletResponse response = (HttpServletResponse) messageInfo.getResponseMessage();
AuthServices.addCORSHeaders(response);
LOGGER.log(Level.FINE, "secureResponse @" + request.getMethod() + " " + request.getRequestURI());
if (isOptionsRequest(request)) {
return AuthStatus.SEND_SUCCESS;
}
CustomSAM module = getModule(messageInfo);
if (module != null) {
return module.secureResponse(messageInfo, serviceSubject);
}
return AuthStatus.SEND_FAILURE;
}
开发者ID:polarsys,项目名称:eplmp,代码行数:22,代码来源:CustomServerAuthContext.java
示例5: cleanSubject
import javax.security.auth.message.MessageInfo; //导入依赖的package包/类
/**
* Removes the <code>authenticated</code> group and the user ID from the
* principal set.
*
* @param messageInfo
* message info
* @param subject
* subject
*/
@Override
public void cleanSubject(final MessageInfo messageInfo,
final Subject subject) throws AuthException {
final HttpServletRequest req = (HttpServletRequest) messageInfo.getRequestMessage();
final String subjectCookie = getSubject(req);
final Iterator<Principal> iterator = subject.getPrincipals().iterator();
while (iterator.hasNext()) {
final Principal principal = iterator.next();
if ("authenticated".equals(principal.getName())) {
iterator.remove();
}
if (principal.getName().equals(subjectCookie)) {
iterator.remove();
}
}
// Does nothing.
}
开发者ID:trajano,项目名称:jaspic-tester,代码行数:29,代码来源:TestServerAuthModule.java
示例6: testFailLoginInvalidMethod
import javax.security.auth.message.MessageInfo; //导入依赖的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
示例7: testFailLoginInvalidState
import javax.security.auth.message.MessageInfo; //导入依赖的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
示例8: testFailLoginInvalidState2
import javax.security.auth.message.MessageInfo; //导入依赖的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
示例9: testFailLoginInvalidState3
import javax.security.auth.message.MessageInfo; //导入依赖的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
示例10: testFailLoginInvalidState4
import javax.security.auth.message.MessageInfo; //导入依赖的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
示例11: testFailLoginMissingNonce
import javax.security.auth.message.MessageInfo; //导入依赖的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
示例12: testFailLoginMissingState
import javax.security.auth.message.MessageInfo; //导入依赖的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
示例13: testFailLoginNotSecure
import javax.security.auth.message.MessageInfo; //导入依赖的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
示例14: testNoAuthNeededWithoutSSL
import javax.security.auth.message.MessageInfo; //导入依赖的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
示例15: testNoAuthNeededWithSSL
import javax.security.auth.message.MessageInfo; //导入依赖的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
示例16: testSSLRequired
import javax.security.auth.message.MessageInfo; //导入依赖的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
示例17: testContext2
import javax.security.auth.message.MessageInfo; //导入依赖的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
示例18: testFailLoginInvalidMethod
import javax.security.auth.message.MessageInfo; //导入依赖的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
示例19: testFailLoginInvalidState4
import javax.security.auth.message.MessageInfo; //导入依赖的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
示例20: cleanSubject
import javax.security.auth.message.MessageInfo; //导入依赖的package包/类
/**
* Cleans off the user principal and group principal from the subject.
*
* @param messageInfo
* message info
* @param subject
* subject
*/
@Override
public void cleanSubject(final MessageInfo messageInfo,
final Subject subject) throws AuthException {
final Iterator<Principal> i = subject.getPrincipals().iterator();
while (i.hasNext()) {
final Principal principal = i.next();
if (principal instanceof UserPrincipal) {
i.remove();
}
if (principal instanceof GroupPrincipal) {
i.remove();
}
}
}
开发者ID:trajano,项目名称:openid-connect,代码行数:24,代码来源:OpenIdConnectAuthModule.java
注:本文中的javax.security.auth.message.MessageInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论