Example usage for org.apache.shiro.authc.credential CredentialsMatcher CredentialsMatcher

List of usage examples for org.apache.shiro.authc.credential CredentialsMatcher CredentialsMatcher

Introduction

In this page you can find the example usage for org.apache.shiro.authc.credential CredentialsMatcher CredentialsMatcher.

Prototype

CredentialsMatcher

Source Link

Usage

From source file:graphene.security.integrated.GrapheneSecurityRealm.java

License:Apache License

public GrapheneSecurityRealm() {
    setName(REALM_NAME);//from   w w  w  .j  a  v  a 2  s . c o  m
    // setCredentialsMatcher(new PasswordMatcher());
    setCredentialsMatcher(new CredentialsMatcher() {
        private final PasswordHash hasher = new PasswordHash();

        @Override
        public boolean doCredentialsMatch(final AuthenticationToken token, final AuthenticationInfo info) {

            boolean doesMatch = false;
            try {
                if (info.getCredentials() == null) {
                    logger.warn("Credentials from AuthenticationInfo was null");
                }
                if (token.getCredentials() == null) {
                    logger.warn("Credentials from Token was null");
                }
                doesMatch = hasher.validatePassword((char[]) token.getCredentials(),
                        (String) info.getCredentials());
            } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
                logger.error("Could not perform credential match because of " + e.getMessage());

            }
            return doesMatch;
        }
    });
}

From source file:graphene.security.noop.NoSecurityRealm.java

License:Apache License

public NoSecurityRealm() {
    setName(REALM_NAME);//from  w  ww . ja  v  a  2  s. co  m
    setCredentialsMatcher(new CredentialsMatcher() {
        @Override
        public boolean doCredentialsMatch(final AuthenticationToken token, final AuthenticationInfo info) {
            // This is why it's called the NoSecurityRealm, we're always
            // returning true.
            return true;
        }
    });
}

From source file:graphene.security.tomcat.preaa.PreAASecurityRealm.java

License:Apache License

public PreAASecurityRealm(final Logger logger, final RequestGlobals rq) {
    this.rq = rq;
    this.logger = logger;

    logger.debug("Created " + REALM_NAME);
    setName(REALM_NAME);/*from w w  w  .  j  av  a2s .  c o m*/
    setCredentialsMatcher(new CredentialsMatcher() {
        @Override
        public boolean doCredentialsMatch(final AuthenticationToken token, final AuthenticationInfo info) {

            logger.debug("doCredentialsMatch " + rq.getHTTPServletRequest().getRemoteUser());

            return true;
        }
    });
}

From source file:org.sonatype.nexus.rutauth.internal.RutAuthRealm.java

License:Open Source License

@Inject
public RutAuthRealm(final RealmManager realmManager, final List<UserManager> userManagers) {
    this.realmManager = checkNotNull(realmManager);
    this.userManagers = checkNotNull(userManagers);
    setName(ID);/*  ww  w  .j ava 2  s .  c o  m*/
    // Any credentials will be a match as we only get the principal
    setCredentialsMatcher(new CredentialsMatcher() {
        @Override
        public boolean doCredentialsMatch(final AuthenticationToken token, final AuthenticationInfo info) {
            return true;
        }
    });
}