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


Java PreAuthenticatedCredentialsNotFoundException类代码示例

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


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

示例1: loadUserByUsername

import org.springframework.security.web.authentication.preauth.PreAuthenticatedCredentialsNotFoundException; //导入依赖的package包/类
@Override
public UserDetails loadUserByUsername(String uName) throws UsernameNotFoundException {
    YourEntity yourEntity =  null;
    if (uName == null || uName.isEmpty()) {
        throw new PreAuthenticatedCredentialsNotFoundException("No User Email Address Supplied for Obtaining User, Ignoring!");
    }
        LOGGER.info("Authenticating:[{}]", uName);
        yourEntity = identityProviderEntityManager.findYourEntityByEmail(uName);
        if (yourEntity == null) {
            LOGGER.warn("YourEntity Object Not Found based Upon Email:[{}]",uName);
            throw new UsernameNotFoundException("No User with email address '" + uName + "' could be found.");
        }
    LOGGER.info("YourEntity Object Found based Upon Email:[{}]",uName);
    return new YourMicroserviceUserDetails(yourEntity);
}
 
开发者ID:jaschenk,项目名称:Your-Microservice,代码行数:16,代码来源:YourMicroserviceUserDetailsService.java

示例2: resolveBadRequestExceptions

import org.springframework.security.web.authentication.preauth.PreAuthenticatedCredentialsNotFoundException; //导入依赖的package包/类
@ExceptionHandler({org.springframework.http.converter.HttpMessageNotReadableException.class,
        PreAuthenticatedCredentialsNotFoundException.class})
@ResponseStatus(HttpStatus.BAD_REQUEST)  // 400
@ResponseBody
public String resolveBadRequestExceptions() {
    return "error";
}
 
开发者ID:jaschenk,项目名称:Your-Microservice,代码行数:8,代码来源:AuthenticationController.java

示例3: extractUsername

import org.springframework.security.web.authentication.preauth.PreAuthenticatedCredentialsNotFoundException; //导入依赖的package包/类
protected String extractUsername(HttpServletRequest request) {
    try {
        return (String)getPreAuthenticatedPrincipal(request);
    } catch (PreAuthenticatedCredentialsNotFoundException ex) {
        return null;
    }
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:8,代码来源:PreauthFilter.java

示例4: doFilterInternal

import org.springframework.security.web.authentication.preauth.PreAuthenticatedCredentialsNotFoundException; //导入依赖的package包/类
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
    String requestURI = request.getRequestURI();
    if (requestURI.startsWith("/human/") && !requestURI.startsWith("/human/register")) {
        String authUsername = getAuthUsername(request);
        String uriUsername = getUriUsername(requestURI);
        if (!authUsername.equals(uriUsername)) {
            throw new PreAuthenticatedCredentialsNotFoundException("Unauthorized access.");
        }
    }
    filterChain.doFilter(request, response);
}
 
开发者ID:aemreunal,项目名称:iBeaconServer,代码行数:13,代码来源:UserUrlFilter.java

示例5: getAuthUsername

import org.springframework.security.web.authentication.preauth.PreAuthenticatedCredentialsNotFoundException; //导入依赖的package包/类
private String getAuthUsername(HttpServletRequest request) {
    String authorizationString = request.getHeader("Authorization");
    if (authorizationString == null) {
        throw new PreAuthenticatedCredentialsNotFoundException("Unauthorized access. Please provide preemptive HTTP Basic authorization credentials with every request.");
    }
    authorizationString = authorizationString.substring("Basic".length()).trim();
    String credentials = new String(Base64.decode(authorizationString.getBytes()), Charset.forName("UTF-8"));
    return (credentials.split(":", 2))[0];
}
 
开发者ID:aemreunal,项目名称:iBeaconServer,代码行数:10,代码来源:UserUrlFilter.java

示例6: getPreAuthenticatedPrincipal

import org.springframework.security.web.authentication.preauth.PreAuthenticatedCredentialsNotFoundException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected Object getPreAuthenticatedPrincipal(HttpServletRequest request) {
    Object principal = request.getAttribute(m_principalRequestAttribute);
    
    if (principal == null) {
        throw new PreAuthenticatedCredentialsNotFoundException(m_principalRequestAttribute 
                + " attribute not found in request.");
    }

    return principal;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:13,代码来源:RequestAttributePreAuthenticationProcessingFilter.java

示例7: request_that_match_a_machine_path_should_receive_403

import org.springframework.security.web.authentication.preauth.PreAuthenticatedCredentialsNotFoundException; //导入依赖的package包/类
@Test
public void request_that_match_a_machine_path_should_receive_403() throws IOException, ServletException {
  request.setServletPath("/nsi/v2/provider");

  subject.commence(request, response, new PreAuthenticatedCredentialsNotFoundException("foo"));

  assertTrue(response.getStatus() == HttpServletResponse.SC_FORBIDDEN);
}
 
开发者ID:BandwidthOnDemand,项目名称:bandwidth-on-demand,代码行数:9,代码来源:BodAuthenticationEntryPointTest.java

示例8: request_that_dont_match_a_machine_path_should_see_redirect_to_splashPath

import org.springframework.security.web.authentication.preauth.PreAuthenticatedCredentialsNotFoundException; //导入依赖的package包/类
@Test
public void request_that_dont_match_a_machine_path_should_see_redirect_to_splashPath() throws IOException, ServletException{
  request.setServletPath("/bod");
  request.setPathInfo("/noc");

  subject.commence(request, response, new PreAuthenticatedCredentialsNotFoundException("foo"));

  assertTrue(response.getStatus() == HttpServletResponse.SC_MOVED_TEMPORARILY);
}
 
开发者ID:BandwidthOnDemand,项目名称:bandwidth-on-demand,代码行数:10,代码来源:BodAuthenticationEntryPointTest.java

示例9: getPreAuthenticatedPrincipal

import org.springframework.security.web.authentication.preauth.PreAuthenticatedCredentialsNotFoundException; //导入依赖的package包/类
@Override
protected Object getPreAuthenticatedPrincipal(HttpServletRequest request) {
    MetkaAuthenticationDetails details = buildDetails(request);
    if(!StringUtils.hasText(details.getSessionId())) {
        throw new PreAuthenticatedCredentialsNotFoundException("Shibboleth session id not found.");
    }
    String userName = details.getUserName();
    if(!StringUtils.hasText(userName)) {
        throw new PreAuthenticatedCredentialsNotFoundException("No user name for shibboleth session.");
    }
    return userName;
}
 
开发者ID:Tietoarkisto,项目名称:metka,代码行数:13,代码来源:ShibAuthFilter.java

示例10: throwAuthenticationException

import org.springframework.security.web.authentication.preauth.PreAuthenticatedCredentialsNotFoundException; //导入依赖的package包/类
@DELETE
@Path("security-401")
public void throwAuthenticationException() {
	throw new PreAuthenticatedCredentialsNotFoundException("message");
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:6,代码来源:ExceptionMapperResource.java

示例11: testPrincipalHeaderMissing

import org.springframework.security.web.authentication.preauth.PreAuthenticatedCredentialsNotFoundException; //导入依赖的package包/类
@Test(expected = PreAuthenticatedCredentialsNotFoundException.class)
public void testPrincipalHeaderMissing() {
	final HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
	filter.setExceptionIfHeaderMissing(true);
	Assert.assertNull(filter.getPreAuthenticatedPrincipal(request));
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:7,代码来源:ApiTokenAuthenticationFilterTest.java

示例12: toResponse

import org.springframework.security.web.authentication.preauth.PreAuthenticatedCredentialsNotFoundException; //导入依赖的package包/类
@Test
public void toResponse() {
	final PreAuthenticatedCredentialsNotFoundException exception = new PreAuthenticatedCredentialsNotFoundException("message-error");
	check(mock(new AuthenticationExceptionMapper()).toResponse(exception), 401,
			"{\"code\":\"security\",\"message\":\"message-error\",\"parameters\":null,\"cause\":null}");
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:7,代码来源:AuthenticationExceptionMapperTest.java


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