org.apache.shiro.authc.credential.SimpleCredentialsMatcher Java Examples

The following examples show how to use org.apache.shiro.authc.credential.SimpleCredentialsMatcher. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApiKeyRealm.java    From emodb with Apache License 2.0 6 votes vote down vote up
public ApiKeyRealm(String name, CacheManager cacheManager, AuthIdentityReader<ApiKey> authIdentityReader,
                   PermissionReader permissionReader, @Nullable String anonymousId) {
    super(null, AnonymousCredentialsMatcher.anonymousOrMatchUsing(new SimpleCredentialsMatcher()));


    _authIdentityReader = checkNotNull(authIdentityReader, "authIdentityReader");
    _permissionReader = checkNotNull(permissionReader, "permissionReader");
    _anonymousId = anonymousId;

    setName(checkNotNull(name, "name"));
    setAuthenticationTokenClass(ApiKeyAuthenticationToken.class);
    setPermissionResolver(permissionReader.getPermissionResolver());
    setRolePermissionResolver(createRolePermissionResolver());
    setCacheManager(prepareCacheManager(cacheManager));
    setAuthenticationCachingEnabled(true);
    setAuthorizationCachingEnabled(true);

    // By default Shiro calls clearCache() for each user when they are logged out in order to prevent stale
    // credentials from being cached.  However, if the cache manager implements InvalidatingCacheManager then it has
    // its own internal listeners that will invalidate the cache on any updates, making this behavior unnecessarily
    // expensive.
    _clearCaches = cacheManager != null && !(cacheManager instanceof InvalidatableCacheManager);
    _log.debug("Clearing of caches for realm {} is {}", name, _clearCaches ? "enabled" : "disabled");
}
 
Example #2
Source File: HttpSecurityIT.java    From attic-aurora with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
  ini = new Ini();
  credentialsMatcher = SimpleCredentialsMatcher.class;

  Ini.Section users = ini.addSection(IniRealm.USERS_SECTION_NAME);
  users.put(ROOT.getUserName(), COMMA_JOINER.join(ROOT.getPassword(), ADMIN_ROLE));
  users.put(WFARNER.getUserName(), COMMA_JOINER.join(WFARNER.getPassword(), ENG_ROLE));
  users.put(UNPRIVILEGED.getUserName(), UNPRIVILEGED.getPassword());
  users.put(
      BACKUP_SERVICE.getUserName(),
      COMMA_JOINER.join(BACKUP_SERVICE.getPassword(), BACKUP_ROLE));
  users.put(
      DEPLOY_SERVICE.getUserName(),
      COMMA_JOINER.join(DEPLOY_SERVICE.getPassword(), DEPLOY_ROLE));

  Ini.Section roles = ini.addSection(IniRealm.ROLES_SECTION_NAME);
  roles.put(ADMIN_ROLE, "*");
  roles.put(ENG_ROLE, "thrift.AuroraSchedulerManager:*");
  roles.put(BACKUP_ROLE, "thrift.AuroraAdmin:listBackups");
  roles.put(
      DEPLOY_ROLE,
      "thrift.AuroraSchedulerManager:killTasks:"
          + ADS_STAGING_JOB.getRole()
          + ":"
          + ADS_STAGING_JOB.getEnvironment()
          + ":"
          + ADS_STAGING_JOB.getName());

  auroraAdmin = createMock(AnnotatedAuroraAdmin.class);
  afterAuthCalls = new AtomicInteger();
}
 
Example #3
Source File: PlainCredentialsHashingStrategy.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
public PlainCredentialsHashingStrategy() {
   credentialsMatcher = new SimpleCredentialsMatcher();
}
 
Example #4
Source File: ShiroRealm.java    From usergrid with Apache License 2.0 4 votes vote down vote up
public ShiroRealm() {
    super( new MemoryConstrainedCacheManager(), new SimpleCredentialsMatcher() );
}