![JAR search and dependency download from the Maven repository](/logo.png)
com.liumapp.certificate.generator.securityImpl.PasswordNeededChk Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of certificate-generator Show documentation
Show all versions of certificate-generator Show documentation
Generating RSA certificate for personal.
package com.liumapp.certificate.generator.securityImpl;
import com.liumapp.certificate.generator.config.Params;
import com.liumapp.certificate.generator.security.PasswordNeeded;
import com.liumapp.pattern.keystore.KeyStorePattern;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import sun.misc.BASE64Encoder;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
* Created by liumapp on 11/23/17.
* E-mail:[email protected]
* home-page:http://www.liumapp.com
*/
@Component
public class PasswordNeededChk implements PasswordNeeded {
@Autowired
private Params params;
@Override
public boolean chkPassword(KeyStorePattern keyStorePattern) throws UnsupportedEncodingException, NoSuchAlgorithmException {
return encodePassword(params.getGeneratorPd()).equals(encodePassword(keyStorePattern.getGeneratorPd()));
}
@Override
public String encodePassword(String password) throws NoSuchAlgorithmException, UnsupportedEncodingException {
MessageDigest md = MessageDigest.getInstance(params.getMessageDigestType());
BASE64Encoder base64Encoder = new BASE64Encoder();
return base64Encoder.encode(md.digest(password.getBytes(params.getEncoding())));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy