List of usage examples for org.apache.shiro.util ByteSource isEmpty
boolean isEmpty();
From source file:com.masslink.idea.zigbee.shiro.UserPasswordService.java
License:Apache License
@Override public Hash hashPassword(Object plaintext) throws IllegalArgumentException { ByteSource plaintextBytes = createByteSource(plaintext); if (plaintextBytes == null || plaintextBytes.isEmpty()) { return null; }/*from w w w.j a v a 2 s .co m*/ HashRequest request = createHashRequest(plaintextBytes); return hashService.computeHash(request); }
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 a 2 s. c o m HashRequest request = buildHashRequest(plaintextBytes, savedPassword); Hash computed = this.hashService.computeHash(request); return savedPassword.equals(computed); }
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; }/*ww w . ja v a 2 s . co 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); }