javax.servlet.http.HttpServletRequestWrapper.getUserPrincipal()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(167)

本文整理了Java中javax.servlet.http.HttpServletRequestWrapper.getUserPrincipal()方法的一些代码示例,展示了HttpServletRequestWrapper.getUserPrincipal()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpServletRequestWrapper.getUserPrincipal()方法的具体详情如下:
包路径:javax.servlet.http.HttpServletRequestWrapper
类名称:HttpServletRequestWrapper
方法名:getUserPrincipal

HttpServletRequestWrapper.getUserPrincipal介绍

[英]The default behavior of this method is to return getUserPrincipal() on the wrapped request object.
[中]此方法的默认行为是在包装的请求对象上返回getUserPrincipal()。

代码示例

代码示例来源:origin: cloudfoundry/uaa

  1. @Override
  2. public Principal getUserPrincipal() {
  3. return super.getUserPrincipal();
  4. }

代码示例来源:origin: apache/geode

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public Principal getUserPrincipal() {
  6. if (outerRequest != null) {
  7. return outerRequest.getUserPrincipal();
  8. } else {
  9. return super.getUserPrincipal();
  10. }
  11. }

代码示例来源:origin: apache/shiro

  1. public Principal getUserPrincipal() {
  2. Principal userPrincipal;
  3. Object scPrincipal = getSubjectPrincipal();
  4. if (scPrincipal != null) {
  5. if (scPrincipal instanceof Principal) {
  6. userPrincipal = (Principal) scPrincipal;
  7. } else {
  8. userPrincipal = new ObjectPrincipal(scPrincipal);
  9. }
  10. } else {
  11. userPrincipal = super.getUserPrincipal();
  12. }
  13. return userPrincipal;
  14. }

代码示例来源:origin: apache/hbase

  1. @Test
  2. public void testFilter() throws Exception {
  3. FilterConfig config = mockConfig("myuser");
  4. StaticUserFilter suf = new StaticUserFilter();
  5. suf.init(config);
  6. ArgumentCaptor<HttpServletRequestWrapper> wrapperArg =
  7. ArgumentCaptor.forClass(HttpServletRequestWrapper.class);
  8. FilterChain chain = mock(FilterChain.class);
  9. suf.doFilter(mock(HttpServletRequest.class), mock(ServletResponse.class),
  10. chain);
  11. Mockito.verify(chain).doFilter(wrapperArg.capture(), Mockito.<ServletResponse>anyObject());
  12. HttpServletRequestWrapper wrapper = wrapperArg.getValue();
  13. assertEquals("myuser", wrapper.getUserPrincipal().getName());
  14. assertEquals("myuser", wrapper.getRemoteUser());
  15. suf.destroy();
  16. }

代码示例来源:origin: com.atlassian.jira/jira-core

  1. @Override
  2. public Principal getUserPrincipal()
  3. {
  4. Principal userPrincipal = super.getUserPrincipal();
  5. return userPrincipal;
  6. }

代码示例来源:origin: com.liferay.portal/portal-kernel

  1. public Principal getUserPrincipal() {
  2. if (_userPrincipal != null) {
  3. return _userPrincipal;
  4. }
  5. else {
  6. return super.getUserPrincipal();
  7. }
  8. }

代码示例来源:origin: com.butor/butor-web

  1. @Override
  2. public Principal getUserPrincipal() {
  3. if (principal == null) {
  4. return super.getUserPrincipal();
  5. }
  6. return principal;
  7. }
  8. }

代码示例来源:origin: com.github.wuic/wuic-servlet

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public Principal getUserPrincipal() {
  6. // Synchronized access
  7. synchronized (mutex) {
  8. return super.getUserPrincipal();
  9. }
  10. }

代码示例来源:origin: GluuFederation/oxTrust

  1. @Override
  2. public Principal getUserPrincipal() {
  3. Principal principal = super.getUserPrincipal();
  4. if (principal != null)
  5. return principal;
  6. else
  7. return userPrincipal;
  8. }

代码示例来源:origin: fcrepo3/fcrepo

  1. @Override
  2. public Principal getUserPrincipal() {
  3. //this order reinforces that container-supplied userPrincipal should not be overridden in setUserPrincipal()
  4. Principal userPrincipal = super.getUserPrincipal();
  5. if (userPrincipal == null) {
  6. userPrincipal = this.userPrincipal;
  7. }
  8. return userPrincipal;
  9. }

代码示例来源:origin: org.fcrepo/fcrepo-server

  1. @Override
  2. public Principal getUserPrincipal() {
  3. //this order reinforces that container-supplied userPrincipal should not be overridden in setUserPrincipal()
  4. Principal userPrincipal = super.getUserPrincipal();
  5. if (userPrincipal == null) {
  6. userPrincipal = this.userPrincipal;
  7. }
  8. return userPrincipal;
  9. }

代码示例来源:origin: com.force.sdk/force-oauth

  1. @Override
  2. public Principal getUserPrincipal() {
  3. return userP != null ? userP : super.getUserPrincipal();
  4. }

代码示例来源:origin: forcedotcom/java-sdk

  1. @Override
  2. public Principal getUserPrincipal() {
  3. return userP != null ? userP : super.getUserPrincipal();
  4. }

代码示例来源:origin: Jasig/uPortal

  1. @Override
  2. public Principal getUserPrincipal() {
  3. this.checkState();
  4. return super.getUserPrincipal();
  5. }

代码示例来源:origin: org.picketlink/picketlink-federation

  1. @Override
  2. public Principal getUserPrincipal() {
  3. HttpSession session = getSession(false);
  4. if (session != null) {
  5. return (Principal) session.getAttribute(GeneralConstants.PRINCIPAL_ID);
  6. }
  7. return super.getUserPrincipal();
  8. }
  9. };

代码示例来源:origin: org.jasig.portal/uPortal-rendering

  1. @Override
  2. public Principal getUserPrincipal() {
  3. this.checkState();
  4. return super.getUserPrincipal();
  5. }

代码示例来源:origin: picketlink/picketlink

  1. @Override
  2. public Principal getUserPrincipal() {
  3. HttpSession session = getSession(false);
  4. if (session != null) {
  5. return (Principal) session.getAttribute(GeneralConstants.PRINCIPAL_ID);
  6. }
  7. return super.getUserPrincipal();
  8. }
  9. };

代码示例来源:origin: org.apache.wink/wink-server

  1. @Override
  2. public Principal getUserPrincipal() {
  3. return getCorrectRequest().getUserPrincipal();
  4. }

代码示例来源:origin: org.jboss.seam/jboss-seam

  1. @Override
  2. public Principal getUserPrincipal()
  3. {
  4. return seamSecurityIsActive() ? identity.getPrincipal() : super.getUserPrincipal();
  5. }

代码示例来源:origin: ch.cern.hadoop/hadoop-common

  1. @Test
  2. public void testFilter() throws Exception {
  3. FilterConfig config = mockConfig("myuser");
  4. StaticUserFilter suf = new StaticUserFilter();
  5. suf.init(config);
  6. ArgumentCaptor<HttpServletRequestWrapper> wrapperArg =
  7. ArgumentCaptor.forClass(HttpServletRequestWrapper.class);
  8. FilterChain chain = mock(FilterChain.class);
  9. suf.doFilter(mock(HttpServletRequest.class), mock(ServletResponse.class),
  10. chain);
  11. Mockito.verify(chain).doFilter(wrapperArg.capture(), Mockito.<ServletResponse>anyObject());
  12. HttpServletRequestWrapper wrapper = wrapperArg.getValue();
  13. assertEquals("myuser", wrapper.getUserPrincipal().getName());
  14. assertEquals("myuser", wrapper.getRemoteUser());
  15. suf.destroy();
  16. }

相关文章

HttpServletRequestWrapper类方法