List of usage examples for org.apache.shiro.crypto.hash.format ParsableHashFormat parse
Hash parse(String formatted);
From source file:com.masslink.idea.zigbee.shiro.UserPasswordService.java
License:Apache License
@Override public boolean passwordsMatch(Object submittedPlaintext, String encrypted) { ByteSource plaintextBytes = createByteSource(submittedPlaintext); if (encrypted == null || encrypted.length() == 0) { return plaintextBytes == null || plaintextBytes.isEmpty(); } else if (plaintextBytes == null || plaintextBytes.isEmpty()) { return false; }/*from w ww . j a v a2 s . c o m*/ HashFormat discoveredFormat = this.hashFormatFactory.getInstance(encrypted); if (discoveredFormat != null && discoveredFormat instanceof ParsableHashFormat) { ParsableHashFormat parsableHashFormat = (ParsableHashFormat) discoveredFormat; Hash savedHash = parsableHashFormat.parse(encrypted); return passwordsMatch(submittedPlaintext, savedHash); } HashRequest request = createHashRequest(plaintextBytes); Hash computed = this.hashService.computeHash(request); String formatted = this.hashFormat.format(computed); return encrypted.equals(formatted); }