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


Java CredentialsMatcher类代码示例

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


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

示例1: assertCredentialsMatch

import org.apache.shiro.authc.credential.CredentialsMatcher; //导入依赖的package包/类
@Override
    protected void assertCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) throws AuthenticationException {
        CredentialsMatcher cm = getCredentialsMatcher();
        if (cm != null) {
            if (!cm.doCredentialsMatch(token, info)) {
                //not successful - throw an exception to indicate this:
                String msg = "Submitted credentials for token [" + token + "] did not match the expected credentials.";
                throw new IncorrectCredentialsException(msg);
            }else {
                //记录登陆日志
/*                ShiroUser shiroUser = (ShiroUser)(info.getPrincipals().getPrimaryPrincipal());
                Log log = LogBuilder.OP_LOG.buildCommonLog("登陆", shiroUser.getClientIp(), shiroUser.getLoginName());
                logService.log(log);*/
            }
        } else {
            throw new AuthenticationException("A CredentialsMatcher must be configured in order to verify " +
                    "credentials during authentication.  If you do not wish for credentials to be examined, you " +
                    "can configure an " + AllowAllCredentialsMatcher.class.getName() + " instance.");
        }
    }
 
开发者ID:liaojiacan,项目名称:zkAdmin,代码行数:21,代码来源:UserRealm.java

示例2: jdbcRealm

import org.apache.shiro.authc.credential.CredentialsMatcher; //导入依赖的package包/类
@Bean(name = "mainRealm")
@ConditionalOnMissingBean(name = "mainRealm")
@ConditionalOnProperty(prefix = "shiro.realm.jdbc", name = "enabled", havingValue = "true")
@DependsOn(value = {"dataSource", "lifecycleBeanPostProcessor", "credentialsMatcher"})
public Realm jdbcRealm(DataSource dataSource, CredentialsMatcher credentialsMatcher) {
    JdbcRealm realm = new JdbcRealm();

    if (shiroJdbcRealmProperties.getAuthenticationQuery() != null) {
        realm.setAuthenticationQuery(shiroJdbcRealmProperties.getAuthenticationQuery());
    }
    if (shiroJdbcRealmProperties.getUserRolesQuery() != null) {
        realm.setUserRolesQuery(shiroJdbcRealmProperties.getUserRolesQuery());
    }
    if (shiroJdbcRealmProperties.getPermissionsQuery() != null) {
        realm.setPermissionsQuery(shiroJdbcRealmProperties.getPermissionsQuery());
    }
    if (shiroJdbcRealmProperties.getSalt() != null) {
        realm.setSaltStyle(shiroJdbcRealmProperties.getSalt());
    }
    realm.setPermissionsLookupEnabled(shiroJdbcRealmProperties.isPermissionsLookupEnabled());
    realm.setDataSource(dataSource);
    realm.setCredentialsMatcher(credentialsMatcher);

    return realm;
}
 
开发者ID:storezhang,项目名称:utils,代码行数:26,代码来源:ShiroAutoConfiguration.java

示例3: AuthenticatingRealm

import org.apache.shiro.authc.credential.CredentialsMatcher; //导入依赖的package包/类
public AuthenticatingRealm(CacheManager cacheManager, CredentialsMatcher matcher) {
    authenticationTokenClass = UsernamePasswordToken.class;

    //retain backwards compatibility for Shiro 1.1 and earlier.  Setting to true by default will probably cause
    //unexpected results for existing applications:
    this.authenticationCachingEnabled = false;

    int instanceNumber = INSTANCE_COUNT.getAndIncrement();
    this.authenticationCacheName = getClass().getName() + DEFAULT_AUTHORIZATION_CACHE_SUFFIX;
    if (instanceNumber > 0) {
        this.authenticationCacheName = this.authenticationCacheName + "." + instanceNumber;
    }

    if (cacheManager != null) {
        setCacheManager(cacheManager);
    }
    if (matcher != null) {
        setCredentialsMatcher(matcher);
    }
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:21,代码来源:AuthenticatingRealm.java

示例4: AuthorizingRealm

import org.apache.shiro.authc.credential.CredentialsMatcher; //导入依赖的package包/类
public AuthorizingRealm(CacheManager cacheManager, CredentialsMatcher matcher) {
    super();
    if (cacheManager != null) setCacheManager(cacheManager);
    if (matcher != null) setCredentialsMatcher(matcher);

    this.authorizationCachingEnabled = true;
    this.permissionResolver = new WildcardPermissionResolver();

    int instanceNumber = INSTANCE_COUNT.getAndIncrement();
    this.authorizationCacheName = getClass().getName() + DEFAULT_AUTHORIZATION_CACHE_SUFFIX;
    if (instanceNumber > 0) {
        this.authorizationCacheName = this.authorizationCacheName + "." + instanceNumber;
    }
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:15,代码来源:AuthorizingRealm.java

示例5: assertCredentialsMatch

import org.apache.shiro.authc.credential.CredentialsMatcher; //导入依赖的package包/类
/**
 * Asserts that the submitted {@code AuthenticationToken}'s credentials match the stored account
 * {@code AuthenticationInfo}'s credentials, and if not, throws an {@link AuthenticationException}.
 *
 * @param token the submitted authentication token
 * @param info  the AuthenticationInfo corresponding to the given {@code token}
 * @throws AuthenticationException if the token's credentials do not match the stored account credentials.
 */
protected void assertCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) throws AuthenticationException {
    CredentialsMatcher cm = getCredentialsMatcher();
    if (cm != null) {
        if (!cm.doCredentialsMatch(token, info)) {
            //not successful - throw an exception to indicate this:
            String msg = "Submitted credentials for token [" + token + "] did not match the expected credentials.";
            throw new IncorrectCredentialsException(msg);
        }
    } else {
        throw new AuthenticationException("A CredentialsMatcher must be configured in order to verify " +
                "credentials during authentication.  If you do not wish for credentials to be examined, you " +
                "can configure an " + AllowAllCredentialsMatcher.class.getName() + " instance.");
    }
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:23,代码来源:AuthenticatingRealm.java

示例6: isValidCredentials

import org.apache.shiro.authc.credential.CredentialsMatcher; //导入依赖的package包/类
/**
 * Checks to see if the credentials in token match the credentials stored on user
 *
 * @param token the username/password token containing the credentials to verify
 * @param user object containing the stored credentials
 * @return true if credentials match, false otherwise
 */
private boolean isValidCredentials(final UsernamePasswordToken token, final CUser user) {
  boolean credentialsValid = false;

  AuthenticationInfo info = createAuthenticationInfo(user);
  CredentialsMatcher matcher = getCredentialsMatcher();
  if (matcher != null) {
    if (matcher.doCredentialsMatch(token, info)) {
      credentialsValid = true;
    }
  }

  return credentialsValid;
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:21,代码来源:AuthenticatingRealmImpl.java

示例7: provideCredentialsMatcher

import org.apache.shiro.authc.credential.CredentialsMatcher; //导入依赖的package包/类
/**
 * When annotations activated, you'll need to hash passwords in your configured Realm (i.e.: shiro.ini file)
 * @return credentialsMatcher singleton implementation for this application
 */
//@Provides
//@Singleton
public CredentialsMatcher provideCredentialsMatcher(){
	HashedCredentialsMatcher matcher = new HashedCredentialsMatcher();
	matcher.setHashAlgorithmName(CREDENTIALS_MATCHER_ALGORITHM_NAME);
	return matcher;
}
 
开发者ID:pabiagioli,项目名称:secure-rest-webapp-archetype,代码行数:12,代码来源:BootstrapShiroModule.java

示例8: provideCredentialsMatcher

import org.apache.shiro.authc.credential.CredentialsMatcher; //导入依赖的package包/类
/**
 * When annotations activated, you'll need to hash passwords in your configured Realm (i.e.: shiro.ini file)
 * @return credentialsMatcher singleton implementation for this application
 */
//@Provides
//@Singleton
public CredentialsMatcher provideCredentialsMatcher(){
	logger.entry();
	HashedCredentialsMatcher matcher = new HashedCredentialsMatcher();
	matcher.setHashAlgorithmName(CREDENTIALS_MATCHER_ALGORITHM_NAME);
	logger.exit(matcher);
	return matcher;
}
 
开发者ID:pabiagioli,项目名称:shiro-guice-async-webapp,代码行数:14,代码来源:BootstrapShiroModule.java

示例9: whenPasswordIsGeneratedTheCredentialsShouldMatch

import org.apache.shiro.authc.credential.CredentialsMatcher; //导入依赖的package包/类
/**
 * This test verifies that the AbstractHash and Salt are functioning
 * correctly.
 */
@Test
public void whenPasswordIsGeneratedTheCredentialsShouldMatch() {
	final CredentialsMatcher matcher = new SecurityModule(null).matcher();
	final String salt = "abc";
	final String plainPassword = "password";
	final String hashedPassword = new UserFactory().hashPassword(plainPassword, salt);
	final AuthenticationInfo info = new SimpleAccount("admin", hashedPassword, SaltTool.getFullSalt(salt), "testrealm");
	final AuthenticationToken token = new UsernamePasswordToken("admin", plainPassword);
	assertThat(matcher.doCredentialsMatch(token, info), is(true));
}
 
开发者ID:devhub-tud,项目名称:devhub-prototype,代码行数:15,代码来源:TestCredentialsMatcher.java

示例10: setupShiro

import org.apache.shiro.authc.credential.CredentialsMatcher; //导入依赖的package包/类
protected static void setupShiro() {
    IniSecurityManagerFactory factory = new IniSecurityManagerFactory(); // ("classpath:shiro.ini");
    DefaultSecurityManager dsm = (DefaultSecurityManager) factory.getInstance();
    passwordService = (DefaultPasswordService) factory.getBeans().get("passwordService");
    passwordMatcher = (CredentialsMatcher) factory.getBeans().get("passwordMatcher");
    setSecurityManager(dsm);
}
 
开发者ID:Multifarious,项目名称:shiro-jdbi-realm,代码行数:8,代码来源:AbstractShiroTest.java

示例11: setAuthzCredentialsMatcher

import org.apache.shiro.authc.credential.CredentialsMatcher; //导入依赖的package包/类
public void setAuthzCredentialsMatcher(CredentialsMatcher authzCredentialsMatcher) {
    this.authzCredentialsMatcher = authzCredentialsMatcher;
}
 
开发者ID:monkeyk,项目名称:oauth2-shiro,代码行数:4,代码来源:OAuth2CredentialsMatcher.java

示例12: setResourcesCredentialsMatcher

import org.apache.shiro.authc.credential.CredentialsMatcher; //导入依赖的package包/类
public void setResourcesCredentialsMatcher(CredentialsMatcher resourcesCredentialsMatcher) {
    this.resourcesCredentialsMatcher = resourcesCredentialsMatcher;
}
 
开发者ID:monkeyk,项目名称:oauth2-shiro,代码行数:4,代码来源:OAuth2CredentialsMatcher.java

示例13: ShiroDbRealm

import org.apache.shiro.authc.credential.CredentialsMatcher; //导入依赖的package包/类
public ShiroDbRealm(CacheManager cacheManager, CredentialsMatcher matcher) {
    super(cacheManager, matcher);
}
 
开发者ID:TomChen001,项目名称:xmanager,代码行数:4,代码来源:ShiroDbRealm.java

示例14: SimpleAuthorizingRealm

import org.apache.shiro.authc.credential.CredentialsMatcher; //导入依赖的package包/类
public SimpleAuthorizingRealm(CacheManager cacheManager, CredentialsMatcher matcher) {
    super(cacheManager, matcher);
    setAuthenticationTokenClass(SimpleShiroToken.class); // 非常非常重要,与SecurityUtils.getSubject().login是对应关系!!!
}
 
开发者ID:TopCoderMyDream,项目名称:LuliChat,代码行数:5,代码来源:SimpleAuthorizingRealm.java

示例15: credentialsMatcher

import org.apache.shiro.authc.credential.CredentialsMatcher; //导入依赖的package包/类
@Bean(name="credentialsMatcher")
public CredentialsMatcher credentialsMatcher(){
	return new PasswordMatcher();
}
 
开发者ID:ranji1221,项目名称:lemcloud,代码行数:5,代码来源:ShiroConfig.java


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