當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。