Example usage for org.apache.shiro.crypto.hash Hash isEmpty

List of usage examples for org.apache.shiro.crypto.hash Hash isEmpty

Introduction

In this page you can find the example usage for org.apache.shiro.crypto.hash Hash isEmpty.

Prototype

boolean isEmpty();

Source Link

Document

Returns true if the underlying wrapped byte array is null or empty (zero length), false otherwise.

Usage

From source file:com.masslink.idea.zigbee.shiro.UserPasswordService.java

License:Apache License

@Override
public boolean passwordsMatch(Object plaintext, Hash savedPassword) {
    ByteSource plaintextBytes = createByteSource(plaintext);
    if (savedPassword == null || savedPassword.isEmpty()) {
        return plaintextBytes == null || plaintextBytes.isEmpty();
    } else if (plaintextBytes == null || plaintextBytes.isEmpty()) {
        return false;
    }//from   w  ww.  ja v  a2 s.  c om
    HashRequest request = buildHashRequest(plaintextBytes, savedPassword);
    Hash computed = this.hashService.computeHash(request);
    return savedPassword.equals(computed);
}