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


Java ProviderNotFoundException类代码示例

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


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

示例1: authenticate

import org.springframework.security.authentication.ProviderNotFoundException; //导入依赖的package包/类
/**
 *
 * @param authentication
 * @return Authentication
 */
@Override
public Authentication authenticate(Authentication authentication) {
    Realm realm;
    Set<GrantedAuthority> auths = new HashSet<>();
    try {
        realm = getTomcatContextRealm();
        if(realm instanceof NullRealm) {
            throw new ProviderNotFoundException("No Realms configured for Jwala to Authenticate");
        }
        Principal principal = realm.authenticate(authentication.getName(),
                authentication.getCredentials().toString());
        if (principal == null) {
            throw new BadCredentialsException("Username or Password not found.");
        } else {
            if (principal instanceof GenericPrincipal) {
                String[] roles = ((GenericPrincipal) principal).getRoles();
                for (String role : roles) {
                    auths.add(new SimpleGrantedAuthority(role));
                }
            }
            GrantedAuthoritiesMapperImpl grantedAuthoritiesMapper = new GrantedAuthoritiesMapperImpl();
            return new UsernamePasswordAuthenticationToken(authentication.getName(),
                    authentication.getCredentials(), grantedAuthoritiesMapper.mapAuthorities(auths));
        }
    } catch (AttributeNotFoundException | InstanceNotFoundException | MBeanException | ReflectionException e) {
        LOGGER.error("Error getting realms", e);
        throw new ProviderNotFoundException(e.getMessage());
    }
}
 
开发者ID:cerner,项目名称:jwala,代码行数:35,代码来源:JwalaAuthenticationProvider.java

示例2: authenticate

import org.springframework.security.authentication.ProviderNotFoundException; //导入依赖的package包/类
/**
 * Iterates over the internal list of authentication providers an tries to authenticate.
 * 
 * @param authentication
 *            The authentication.
 * @return The resulting authentication.
 */
public Authentication authenticate(Authentication authentication) {
    ProviderManager providerManager = getManager();
    if (providerManager != null) {
        try {
            return providerManager.authenticate(authentication);
        } catch (ProviderNotFoundException e) {
            // will be thrown if there is no supporting provider, ignore it since we are not
            // calling supports methods of the registered providers
        }
    }
    return null;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:20,代码来源:AuthenticationProviderManagement.java

示例3: noAuthDetailsException

import org.springframework.security.authentication.ProviderNotFoundException; //导入依赖的package包/类
private ProviderNotFoundException noAuthDetailsException(String name) {
	return new ProviderNotFoundException("Auth details '" + name + "' are not configured");
}
 
开发者ID:reportportal,项目名称:service-authorization,代码行数:4,代码来源:AuthConfigService.java


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