當前位置: 首頁>>代碼示例>>Java>>正文


Java GeneralSecurityException.printStackTrace方法代碼示例

本文整理匯總了Java中java.security.GeneralSecurityException.printStackTrace方法的典型用法代碼示例。如果您正苦於以下問題:Java GeneralSecurityException.printStackTrace方法的具體用法?Java GeneralSecurityException.printStackTrace怎麽用?Java GeneralSecurityException.printStackTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.security.GeneralSecurityException的用法示例。


在下文中一共展示了GeneralSecurityException.printStackTrace方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: MailSender

import java.security.GeneralSecurityException; //導入方法依賴的package包/類
public MailSender() {
    this.mExecutor = Executors.newSingleThreadExecutor();
    this.host = App.sp.getString(Tags.SP_MAIL_HOST, null);
    String port = App.sp.getString(Tags.SP_MAIL_PORT, null);
    this.email = App.sp.getString(Tags.SP_MAIL_SEND_MAIL, null);
    this.password = App.sp.getString(Tags.SP_MAIL_SEND_PASSWORD, null);
    this.name = App.sp.getString(Tags.SP_MAIL_SEND_NAME, App.me().getString(R.string.app_name));
    this.receiveAddress = App.sp.getString(Tags.SP_MAIL_RECEIVE_MAIL, null);

    Properties props = new Properties();
    props.setProperty("mail.transport.protocol", "smtp");
    props.setProperty("mail.host", host);
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.port", port);
    props.put("mail.smtp.socketFactory.port", port);
    try {
        MailSSLSocketFactory sf = new MailSSLSocketFactory();
        sf.setTrustAllHosts(true);
        props.put("mail.smtp.ssl.enable", "true");
        props.put("mail.smtp.ssl.socketFactory", sf);
    } catch (GeneralSecurityException e) {
        Toast.makeText(App.me(), e.getMessage(), Toast.LENGTH_SHORT).show();
        e.printStackTrace();
    }
    session = Session.getDefaultInstance(props, this);
}
 
開發者ID:dss886,項目名稱:Transmis,代碼行數:27,代碼來源:MailSender.java

示例2: BlowFishKey

import java.security.GeneralSecurityException; //導入方法依賴的package包/類
/**
 * @param blowfishKey
 * @param publicKey
 */
public BlowFishKey(byte[] blowfishKey, RSAPublicKey publicKey)
{
	writeC(0x00);
	byte[] encrypted =null;
	try
	{
		Cipher rsaCipher = Cipher.getInstance("RSA/ECB/nopadding");
        rsaCipher.init(Cipher.ENCRYPT_MODE, publicKey);
        encrypted = rsaCipher.doFinal(blowfishKey);
	}
	catch(GeneralSecurityException e)
	{
		_log.severe("Error While encrypting blowfish key for transmision (Crypt error)");
		e.printStackTrace();
	}
	writeD(encrypted.length);
	writeB(encrypted);
}
 
開發者ID:L2jBrasil,項目名稱:L2jBrasil,代碼行數:23,代碼來源:BlowFishKey.java

示例3: verifyApply

import java.security.GeneralSecurityException; //導入方法依賴的package包/類
/**
 * Test method for {@link ThresholdExpiredCRLRevocationPolicy#apply(java.security.cert.X509CRL)}.
 */
@Test
public void verifyApply() {
    try {
        this.policy.apply(this.crl);
        if (this.expected != null) {
            Assert.fail("Expected exception of type " + this.expected.getClass());
        }
    } catch (final GeneralSecurityException e) {
        if (this.expected == null) {
            e.printStackTrace();
            Assert.fail("Revocation check failed unexpectedly with exception: " + e);
        } else {
            final Class<?> expectedClass = this.expected.getClass();
            final Class<?> actualClass = e.getClass();
            Assert.assertTrue(
                    String.format("Expected exception of type %s but got %s", expectedClass, actualClass),
                    expectedClass.isAssignableFrom(actualClass));
        }
    }
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:24,代碼來源:ThresholdExpiredCRLRevocationPolicyTests.java

示例4: getNTLM2Response

import java.security.GeneralSecurityException; //導入方法依賴的package包/類
public static byte[] getNTLM2Response(byte[] nTOWFv1,
                byte[] serverChallenge,
                byte[] clientChallenge)
{
    byte[] sessionHash = new byte[8];

    try {
        MessageDigest md5;
        md5 = MessageDigest.getInstance("MD5");
        md5.update(serverChallenge);
        md5.update(clientChallenge, 0, 8);
        System.arraycopy(md5.digest(), 0, sessionHash, 0, 8);
    } catch (GeneralSecurityException gse) {
        if (log.level > 0)
            gse.printStackTrace(log);
        throw new RuntimeException("MD5", gse);
    }

    byte[] key = new byte[21];
    System.arraycopy(nTOWFv1, 0, key, 0, 16);
    byte[] ntResponse = new byte[24];
    E(key, sessionHash, ntResponse);

    return ntResponse;
}
 
開發者ID:archos-sa,項目名稱:aos-FileCoreLibrary,代碼行數:26,代碼來源:NtlmPasswordAuthentication.java

示例5: testApply

import java.security.GeneralSecurityException; //導入方法依賴的package包/類
/**
 * Test method for {@link ThresholdExpiredCRLRevocationPolicy#apply(java.security.cert.X509CRL)}.
 */
@Test
public void testApply() {
    try {
        this.policy.apply(this.crl);
        if (this.expected != null) {
            Assert.fail("Expected exception of type " + this.expected.getClass());
        }
    } catch (final GeneralSecurityException e) {
        if (this.expected == null) {
            e.printStackTrace();
            Assert.fail("Revocation check failed unexpectedly with exception: " + e);
        } else {
            final Class<?> expectedClass = this.expected.getClass();
            final Class<?> actualClass = e.getClass();
            Assert.assertTrue(
                    String.format("Expected exception of type %s but got %s", expectedClass, actualClass),
                    expectedClass.isAssignableFrom(actualClass));
        }
    }
}
 
開發者ID:luotuo,項目名稱:cas4.0.x-server-wechat,代碼行數:24,代碼來源:ThresholdExpiredCRLRevocationPolicyTests.java

示例6: loadTheKey

import java.security.GeneralSecurityException; //導入方法依賴的package包/類
private String loadTheKey() {
    String data = load(THEKEY);
    debug("loadTheKey-data:" + data);
    if (EMPTY.equals(data)) {
        debug("WARN!!!!!!!! 404 EMPTY");
        return EMPTY;
    }
    try {
        String msg = AESCrypt.decrypt(defaultKey, data);
        debug("loadTheKey-msg:" + msg);
        return msg;
    } catch (GeneralSecurityException e) {
        e.printStackTrace();
    }
    return EMPTY;
}
 
開發者ID:mrqyoung,項目名稱:SMS302,代碼行數:17,代碼來源:DataHelper.java

示例7: hmac_sha

import java.security.GeneralSecurityException; //導入方法依賴的package包/類
/**
 * This method uses the JCE to provide the crypto algorithm.
 * HMAC computes a Hashed Message Authentication Code with the
 * crypto hash algorithm as a parameter.
 *
 * @param crypto   the crypto algorithm (HmacSHA1, HmacSHA256,
 *                 HmacSHA512)
 * @param keyBytes the bytes to use for the HMAC key
 * @param text     the message or text to be authenticated
 */
private static byte[] hmac_sha(String crypto, byte[] keyBytes,
                               byte[] text) {
    try {
        Mac hmac;
        hmac = Mac.getInstance(crypto);
        SecretKeySpec macKey =
                new SecretKeySpec(keyBytes, "RAW");
        hmac.init(macKey);
        return hmac.doFinal(text);
    } catch (GeneralSecurityException gse) {
        gse.printStackTrace();
        throw new UndeclaredThrowableException(gse);

    }
}
 
開發者ID:privacyidea,項目名稱:privacyidea-authenticator,代碼行數:26,代碼來源:OTPGenerator.java

示例8: BlowFishKey

import java.security.GeneralSecurityException; //導入方法依賴的package包/類
/**
 * @param decrypt
 */
public BlowFishKey(byte[] decrypt, RSAPrivateKey privateKey)
{
	super(decrypt);
	int size = readD();
	byte[] tempKey = readB(size);
	try
	{
		byte [] tempDecryptKey;
		Cipher rsaCipher = Cipher.getInstance("RSA/ECB/nopadding");
        rsaCipher.init(Cipher.DECRYPT_MODE, privateKey);
        tempDecryptKey = rsaCipher.doFinal(tempKey);
        // there are nulls before the key we must remove them
        int i = 0;
        int len = tempDecryptKey.length;
        for(; i < len; i++)
        {
        	if(tempDecryptKey[i] != 0)
        		break;
        }
        _key = new byte[len-i];
        System.arraycopy(tempDecryptKey,i,_key,0,len-i);
	}
	catch(GeneralSecurityException e)
	{
		_log.severe("Error While decrypting blowfish key (RSA)");
		e.printStackTrace();
	}
	/*catch(IOException ioe)
	{
		//TODO: manage
	}*/

}
 
開發者ID:L2jBrasil,項目名稱:L2jBrasil,代碼行數:37,代碼來源:BlowFishKey.java

示例9: encryptWithAes

import java.security.GeneralSecurityException; //導入方法依賴的package包/類
public static String encryptWithAes(String body, String key, String ifError, long sessionId,
                                    @KeyLocationPolicy int keyLocationPolicy) {
    try {
        return "AES" + String.valueOf(keyLocationPolicy) + String.valueOf(sessionId)
                + ":" + AESCrypt.encrypt(key, body);
    } catch (GeneralSecurityException e) {
        e.printStackTrace();
        return ifError;
    }
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:11,代碼來源:CryptHelper.java

示例10: insertRandomSession

import java.security.GeneralSecurityException; //導入方法依賴的package包/類
private void insertRandomSession() {
    byte[] date = ByteBuffer.allocate(Long.SIZE / Byte.SIZE).putLong(new Date().getTime()).array();
    try {
        User user = new UserServiceImpl(getActivity()).getUserByUserName(USER_NAME);
        Session randomSession = new Session(0l, CryptoUtils.handleByteArrayCrypto(date, user, 1), null, "Vienna", user.getCryptoKeyIV());
        SessionService sessionService = new SessionServiceImpl(getActivity());
        sessionService.insertSession(randomSession);
        Log.d("HomeFragment", sessionService.getAllSessions().toString());
    } catch (GeneralSecurityException e) {
        e.printStackTrace();
    }
}
 
開發者ID:ProjektMedInf,項目名稱:WiFiSDCryptoLocker,代碼行數:13,代碼來源:HomeFragment.java

示例11: createMac

import java.security.GeneralSecurityException; //導入方法依賴的package包/類
private Mac createMac() {
    Mac mac;
    try {
        mac = javax.crypto.Mac.getInstance("HmacSHA1");
        mac.init(secretKey);
    } catch (GeneralSecurityException e) {
        e.printStackTrace();
        throw new IllegalArgumentException(e);
    }
    return mac;
}
 
開發者ID:lqxue,項目名稱:QiNiuTest,代碼行數:12,代碼來源:Auth.java

示例12: encrypt

import java.security.GeneralSecurityException; //導入方法依賴的package包/類
private String encrypt(CmsCryptoDES crypto) {
  try {
    return crypto.encrypt("$OO_GLOBAL{globalcloudvar1}");
  } catch (GeneralSecurityException e) {
    e.printStackTrace();
  }
  return null;
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:9,代碼來源:CmsUtilTest.java

示例13: getOrdersForStep

import java.security.GeneralSecurityException; //導入方法依賴的package包/類
@Override
protected List<CmsActionOrderSimple> getOrdersForStep(ExecutionContext context, int step) {
  CmsOpsProcedure procedure = procedure(context);
  try {
    return cmsClient.getActionOrders(procedure, step);
  } catch (GeneralSecurityException e) {
    e.printStackTrace();
  }
  return Collections.emptyList();
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:11,代碼來源:ProcedureRunnerImpl.java

示例14: keepTheKey

import java.security.GeneralSecurityException; //導入方法依賴的package包/類
boolean keepTheKey(String msg) {
    try {
        String data = AESCrypt.encrypt(defaultKey, msg);
        keep(THEKEY, data);
        return true;
    } catch (GeneralSecurityException e) {
        e.printStackTrace();
    }
    return false;
}
 
開發者ID:mrqyoung,項目名稱:SMS302,代碼行數:11,代碼來源:DataHelper.java

示例15: getCode

import java.security.GeneralSecurityException; //導入方法依賴的package包/類
public static String getCode(String secret) {
	try {
		code = TimeBasedOneTimePasswordUtil.generateCurrentNumberString(secret);
	} catch (GeneralSecurityException e) {
		e.printStackTrace();
	}
	return code;
}
 
開發者ID:WheezyGold7931,項目名稱:skLib,代碼行數:9,代碼來源:TwoFactor.java


注:本文中的java.security.GeneralSecurityException.printStackTrace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。