当前位置: 首页>>代码示例>>Java>>正文


Java NoSuchAlgorithmException类代码示例

本文整理汇总了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);
}
 
开发者ID:Fatlonder,项目名称:E-Clinic,代码行数:18,代码来源:AdminClinicServiceImpl.java

示例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;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:21,代码来源:AddSSLCertificateWindow.java

示例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");
    }
}
 
开发者ID:INAETICS,项目名称:Drones-Simulator,代码行数:25,代码来源:RabbitConnection.java

示例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()]);
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:23,代码来源:KeyStoresTrustManager.java

示例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);
	}
}
 
开发者ID:swxiao,项目名称:bubble2,代码行数:25,代码来源:HttpUtils.java

示例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();
}
 
开发者ID:yulele166,项目名称:pub-service,代码行数:19,代码来源:StringUtil.java

示例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();
}
 
开发者ID:xipki,项目名称:xitk,代码行数:17,代码来源:DfltConcurrentContentSigner.java

示例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;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:DuoWeb.java

示例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;
}
 
开发者ID:rapid-io,项目名称:rapid-io-android,代码行数:27,代码来源:SubscriptionDiskCache.java

示例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()));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:Security.java

示例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);
}
 
开发者ID:luisbraganca,项目名称:file-transfer,代码行数:18,代码来源:HtmlPage.java

示例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();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:URICertStore.java

示例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;
}
 
开发者ID:videgro,项目名称:Ships,代码行数:25,代码来源:DigitalSignature.java

示例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);
    }
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:20,代码来源:SslContextProvider.java


注:本文中的java.security.NoSuchAlgorithmException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。