本文整理匯總了Java中java.security.NoSuchAlgorithmException類的典型用法代碼示例。如果您正苦於以下問題:Java NoSuchAlgorithmException類的具體用法?Java NoSuchAlgorithmException怎麽用?Java NoSuchAlgorithmException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
NoSuchAlgorithmException類屬於java.security包,在下文中一共展示了NoSuchAlgorithmException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updatePassword
import java.security.NoSuchAlgorithmException; //導入依賴的package包/類
@Override
public void updatePassword(AdminClinicForm value) throws PasswordException, RepositoryException, NoSuchAlgorithmException {
if (value.getCurrentPassword() == null || value.getConfirmPassword() == null || value.getNewPassword() == null) {
throw new PasswordException("Please fill all the required filds");
}
if (!value.getConfirmPassword().equals(value.getNewPassword())) {
throw new PasswordException("Password didnt match");
}
Adminclinic adminclinic = adminClinicRepository.findById(Integer.valueOf(value.getId()));
if (!encodehashPassword(value.getCurrentPassword()).equals(adminclinic.getPassCode())) {
throw new PasswordException("Old password didnt match");
}
adminclinic.setPassCode(encodehashPassword(value.getNewPassword()));
adminClinicRepository.update(adminclinic);
}
示例2: getCertificateBasicInfoModelList
import java.security.NoSuchAlgorithmException; //導入依賴的package包/類
private ArrayList<CertificateBasicInfoModel> getCertificateBasicInfoModelList() {
ArrayList<CertificateBasicInfoModel> certificateBasicInfoModels = new ArrayList<>();
for (CertificateResolverModel basicInfoModel : this.certificateResolverModels) {
try {
certificateBasicInfoModels.add(new CertificateBasicInfoModel(
basicInfoModel.getAlias(),
this.trustManager.getSha1Fingerprint(basicInfoModel.getCertificate()),
basicInfoModel.getCertificate().getIssuerDN().getName(),
basicInfoModel.getCertificate().getNotBefore(),
basicInfoModel.getCertificate().getNotAfter(),
basicInfoModel.getCertificate().getSigAlgName(),
this.trustManager.certificateToString(basicInfoModel.getCertificate()))
);
} catch (NoSuchAlgorithmException | CertificateEncodingException e) {
log.error("Cannot create certificate basic information model", e);
}
}
return certificateBasicInfoModels;
}
示例3: handleAuthentication
import java.security.NoSuchAlgorithmException; //導入依賴的package包/類
public KeeperException.Code
handleAuthentication(ServerCnxn cnxn, byte[] authData)
{
String id = new String(authData);
try {
String digest = generateDigest(id);
if (digest.equals(superDigest)) {
cnxn.addAuthInfo(new Id("super", ""));
}
cnxn.addAuthInfo(new Id(getScheme(), digest));
return KeeperException.Code.OK;
} catch (NoSuchAlgorithmException e) {
LOG.error("Missing algorithm",e);
}
return KeeperException.Code.AUTHFAILED;
}
開發者ID:didichuxing2,項目名稱:https-github.com-apache-zookeeper,代碼行數:17,代碼來源:DigestAuthenticationProvider.java
示例4: setConfig
import java.security.NoSuchAlgorithmException; //導入依賴的package包/類
/**
* Updates the connection config based on a discovered configuration.
* @param config The configuration.
*/
public void setConfig(Dictionary<String, String> config) {
this.connectionFactory = new ConnectionFactory();
if (config != null) {
String username = config.get("username");
this.connectionFactory.setUsername(username);
String password = config.get("password");
this.connectionFactory.setPassword(password);
try {
String uri = config.get("uri");
this.connectionFactory.setUri(uri);
this.getLogger().debug("Received configuration, RabbitMQ URI is {}", uri);
} catch (URISyntaxException | NoSuchAlgorithmException | KeyManagementException e) {
this.getLogger().error("Invalid URI found in configuration", e);
}
} else {
this.getLogger().debug("Unset RabbitMQ configuration");
}
}
示例5: KeyStoresTrustManager
import java.security.NoSuchAlgorithmException; //導入依賴的package包/類
public KeyStoresTrustManager(KeyStore... keyStores) throws NoSuchAlgorithmException, KeyStoreException {
super();
for (KeyStore keystore : keyStores) {
TrustManagerFactory factory = TrustManagerFactory.getInstance("JKS");
factory.init(keystore);
TrustManager[] tms = factory.getTrustManagers();
if (tms.length == 0) {
throw new NoSuchAlgorithmException("Unable to load keystore");
}
trustManagers.add((X509TrustManager) tms[0]);
}
//Build accepted issuers list
Set<X509Certificate> issuers = new HashSet<X509Certificate>();
for (X509TrustManager tm : trustManagers) {
for (X509Certificate issuer : tm.getAcceptedIssuers()) {
issuers.add(issuer);
}
}
acceptedIssuers = issuers.toArray(new X509Certificate[issuers.size()]);
}
示例6: getSSLSocketFactory
import java.security.NoSuchAlgorithmException; //導入依賴的package包/類
/**
* 獲取LayeredConnectionSocketFactory 使用ssl單向認證
*
* @date 2015年7月17日
* @return
*/
private LayeredConnectionSocketFactory getSSLSocketFactory() {
try {
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {
// 信任所有
public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
return true;
}
}).build();
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext,
SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
return sslsf;
} catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) {
logger.error(e.getMessage(), e);
throw new RuntimeException(e.getMessage(), e);
}
}
示例7: md5
import java.security.NoSuchAlgorithmException; //導入依賴的package包/類
public static String md5(String str, boolean zero) {
MessageDigest messageDigest = null;
try {
messageDigest = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException ex) {
ex.printStackTrace();
return null;
}
byte[] resultByte = messageDigest.digest(str.getBytes());
StringBuffer result = new StringBuffer();
for (int i = 0; i < resultByte.length; ++i) {
int v = 0xFF & resultByte[i];
if(v<16 && zero)
result.append("0");
result.append(Integer.toHexString(v));
}
return result.toString();
}
示例8: DfltConcurrentContentSigner
import java.security.NoSuchAlgorithmException; //導入依賴的package包/類
public DfltConcurrentContentSigner(boolean mac, List<XiContentSigner> signers,
Key signingKey) throws NoSuchAlgorithmException {
ParamUtil.requireNonEmpty("signers", signers);
this.mac = mac;
AlgorithmIdentifier algorithmIdentifier = signers.get(0).getAlgorithmIdentifier();
this.algorithmName = AlgorithmUtil.getSigOrMacAlgoName(algorithmIdentifier);
this.algorithmCode = AlgorithmUtil.getSigOrMacAlgoCode(algorithmIdentifier);
for (XiContentSigner signer : signers) {
this.signers.add(new ConcurrentBagEntrySigner(signer));
}
this.signingKey = signingKey;
this.name = "defaultSigner-" + NAME_INDEX.getAndIncrement();
}
示例9: verifyResponse
import java.security.NoSuchAlgorithmException; //導入依賴的package包/類
public static String verifyResponse(final String ikey, final String skey, final String akey, final String sig_response, final long time)
throws DuoWebException, NoSuchAlgorithmException, InvalidKeyException, IOException {
final String[] sigs = sig_response.split(":");
final String auth_sig = sigs[0];
final String app_sig = sigs[1];
String auth_user = parseVals(skey, auth_sig, AUTH_PREFIX, ikey, time);
String app_user = parseVals(akey, app_sig, APP_PREFIX, ikey, time);
if (!auth_user.equals(app_user)) {
throw new DuoWebException("Authentication failed.");
}
return auth_user;
}
示例10: get
import java.security.NoSuchAlgorithmException; //導入依賴的package包/類
@Nullable
public synchronized String get(@NonNull BaseCollectionSubscription subscription) throws IOException, JSONException, NoSuchAlgorithmException {
if(!mEnabled)
return null;
String fingerprint = subscription.getFingerprint();
DiskLruCache.Snapshot record = mCache.get(fingerprint);
if(record != null) {
InputStream inputstream = record.getInputStream(DEFAULT_INDEX);
byte[] rec = StreamUtility.toByteArray(inputstream);
String jsonValue = XorUtility.xor(rec, subscription.getAuthToken());
Logcat.d("Reading from subscription cache. key=%s; value=%s", fingerprint, jsonValue);
JSONArray documentIdArray = new JSONArray(jsonValue);
JSONArray documentArray = new JSONArray();
for(int i = 0; i < documentIdArray.length(); i++) {
String document = getDocument(subscription, documentIdArray.optString(i));
if(document == null) {
return null;
}
documentArray.put(new JSONObject(document));
}
return documentArray.toString();
}
Logcat.d("Reading from disk subscription cache. key=%s; value=null", fingerprint);
return null;
}
示例11: passwordHashStage1
import java.security.NoSuchAlgorithmException; //導入依賴的package包/類
/**
* Stage one password hashing, used in MySQL 4.1 password handling
*
* @param password
* plaintext password
*
* @return stage one hash of password
*
* @throws NoSuchAlgorithmException
* if the message digest 'SHA-1' is not available.
*/
static byte[] passwordHashStage1(String password) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("SHA-1");
StringBuilder cleansedPassword = new StringBuilder();
int passwordLength = password.length();
for (int i = 0; i < passwordLength; i++) {
char c = password.charAt(i);
if ((c == ' ') || (c == '\t')) {
continue; /* skip space in password */
}
cleansedPassword.append(c);
}
return md.digest(StringUtils.getBytes(cleansedPassword.toString()));
}
示例12: HtmlPage
import java.security.NoSuchAlgorithmException; //導入依賴的package包/類
public HtmlPage(String link) {
VBox root = new VBox();
Scene scene = new Scene(root);
setTitle("FileSend - Page");
final WebView browser = new WebView();
final WebEngine webEngine = browser.getEngine();
try {
httpsLoad(webEngine, link);
} catch (NoSuchAlgorithmException | KeyManagementException e) {
e.printStackTrace();
}
root.getChildren().add(browser);
VBox.setVgrow(browser, Priority.ALWAYS);
getIcons().add(new Image(getClass().getResourceAsStream(".." + File.separator + "images" + File.separator + "logo.png")));
setScene(scene);
setMaximized(true);
}
示例13: URICertStore
import java.security.NoSuchAlgorithmException; //導入依賴的package包/類
/**
* Creates a URICertStore.
*
* @param parameters specifying the URI
*/
URICertStore(CertStoreParameters params)
throws InvalidAlgorithmParameterException, NoSuchAlgorithmException {
super(params);
if (!(params instanceof URICertStoreParameters)) {
throw new InvalidAlgorithmParameterException
("params must be instanceof URICertStoreParameters");
}
this.uri = ((URICertStoreParameters) params).uri;
// if ldap URI, use an LDAPCertStore to fetch certs and CRLs
if (uri.getScheme().toLowerCase(Locale.ENGLISH).equals("ldap")) {
ldap = true;
ldapHelper = CertStoreHelper.getInstance("LDAP");
ldapCertStore = ldapHelper.getCertStore(uri);
ldapPath = uri.getPath();
// strip off leading '/'
if (ldapPath.charAt(0) == '/') {
ldapPath = ldapPath.substring(1);
}
}
try {
factory = CertificateFactory.getInstance("X.509");
} catch (CertificateException e) {
throw new RuntimeException();
}
}
示例14: sign
import java.security.NoSuchAlgorithmException; //導入依賴的package包/類
/**
* Create a signature with the private key
* @param data The data to sign
* @return Base64 encoded signature
*/
public String sign(final String data) {
final String tag = "sign - ";
String result = null;
try {
Signature rsa = Signature.getInstance(CryptConstants.ALGORITHM_SIGNATURE);
final PrivateKey key=retrievePrivateKey();
if (key!=null) {
rsa.initSign(key);
rsa.update(data.getBytes());
result = Base64.encodeToString(rsa.sign(),Base64.DEFAULT);
}
} catch (SignatureException | NoSuchAlgorithmException | InvalidKeyException e) {
Log.e(TAG, tag, e);
}
return result;
}
示例15: SslContextProvider
import java.security.NoSuchAlgorithmException; //導入依賴的package包/類
private SslContextProvider() {
// load SSL context
TrustManager[] trustManager = new TrustManager[]{X509TrustManagerFactory.getInstance()};
try {
this.sslContext = SSLContext.getInstance("TLSv1.2");
this.sslContext.init(null, trustManager, new SecureRandom());
// disable SSL session caching - we load SSL certificates dinamically so we need to ensure
// that we have up to date cached certificates list
this.sslContext.getClientSessionContext().setSessionCacheSize(1);
this.sslContext.getClientSessionContext().setSessionTimeout(1);
this.sslContext.getServerSessionContext().setSessionCacheSize(1);
this.sslContext.getServerSessionContext().setSessionTimeout(1);
} catch (NoSuchAlgorithmException | KeyManagementException e) {
LOG.error("Encountering security exception in SSL context", e);
throw new RuntimeException("Internal error with SSL context", e);
}
}