Package org.apache.shiro.util

Examples of org.apache.shiro.util.SimpleByteSource


    @Test
    public void testHashService() {
        DefaultHashService hashService = new DefaultHashService(); //默认算法SHA-512
        hashService.setHashAlgorithmName("SHA-512");
        hashService.setPrivateSalt(new SimpleByteSource("123")); //私盐,默认无
        hashService.setGeneratePublicSalt(true);//是否生成公盐,默认false
        hashService.setRandomNumberGenerator(new SecureRandomNumberGenerator());//用于生成公盐。默认就这个
        hashService.setHashIterations(1); //生成Hash值的迭代次数

        HashRequest request = new HashRequest.Builder()
View Full Code Here


        if (log.isTraceEnabled()) {
            log.trace("Incoming plaintext of size " + (plaintext != null ? plaintext.length : 0) + ".  Ciphertext " +
                    "byte array is size " + (output != null ? output.length : 0));
        }

        return new SimpleByteSource(output);

    }
View Full Code Here

        if (log.isTraceEnabled()) {
            log.trace("Attempting to decrypt incoming byte array of length " +
                    (ciphertext != null ? ciphertext.length : 0));
        }
        byte[] decrypted = crypt(ciphertext, key, iv, javax.crypto.Cipher.DECRYPT_MODE);
        return decrypted == null ? null : new SimpleByteSource(decrypted);
    }
View Full Code Here

     * @return encryption key in base64 encoding
     */
    public static String generateNewKey() {
        AesCipherService cipherService = new AesCipherService();
        Key newKey = cipherService.generateNewKey();
        return new SimpleByteSource(newKey.getEncoded()).toBase64();
    }
View Full Code Here

        FireLogger.logInfo("Realm {0} generated SimpleAuthenticationToken for user {1}", getName(), username);

        return new SimpleAuthenticationInfo(resolvedUser.getEmail(),
                resolvedPassword.getPassword(),
                new SimpleByteSource(resolvedPassword.getSalt()),
                getName());
    }
View Full Code Here

        if (log.isTraceEnabled()) {
            log.trace("Incoming plaintext of size " + (plaintext != null ? plaintext.length : 0) + ".  Ciphertext " +
                    "byte array is size " + (output != null ? output.length : 0));
        }

        return new SimpleByteSource(output);

    }
View Full Code Here

        if (log.isTraceEnabled()) {
            log.trace("Attempting to decrypt incoming byte array of length " +
                    (ciphertext != null ? ciphertext.length : 0));
        }
        byte[] decrypted = crypt(ciphertext, key, iv, javax.crypto.Cipher.DECRYPT_MODE);
        return decrypted == null ? null : new SimpleByteSource(decrypted);
    }
View Full Code Here

        if (numBytes <= 0) {
            throw new IllegalArgumentException("numBytes argument must be a positive integer (1 or larger)");
        }
        byte[] bytes = new byte[numBytes];
        this.secureRandom.nextBytes(bytes);
        return new SimpleByteSource(bytes);
    }
View Full Code Here

TOP

Related Classes of org.apache.shiro.util.SimpleByteSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.