当前位置: 首页>>代码示例>>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;未经允许,请勿转载。