本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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));
}
}
}
示例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;
}
示例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);
}
}
示例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
}*/
}
示例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;
}
}
示例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();
}
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}