Code with Misuse: |
class BFProperties {
public static void setProperty(BFProps key, String value, boolean store) {
String strKey = key.name().toLowerCase();
String prop = sProperties.getProperty(strKey);
if ((prop == null) || !prop.equals(value)) {
if (BFProps.PROXY_PASSWORD.equals(key)) {
try {
Cipher c = Cipher.getInstance("AES");
byte[] secretKey = new byte[16];
secretKey[0]=78;
secretKey[1]=-44;
secretKey[2]=-10;
secretKey[3]=-42;
secretKey[4]=-44;
secretKey[5]=106;
secretKey[6]=-30;
secretKey[7]=-1;
secretKey[8]=-104;
secretKey[9]=105;
secretKey[10]=24;
secretKey[11]=-103;
secretKey[12]=-9;
secretKey[13]=-81;
secretKey[14]=-32;
secretKey[15]=95;
Key k = new SecretKeySpec(secretKey, "AES");
c.init(Cipher.ENCRYPT_MODE, k);
value = new String(c.doFinal(value.getBytes()));
} catch (NoSuchAlgorithmException e1) {
e1.printStackTrace();
} catch (NoSuchPaddingException e1) {
e1.printStackTrace();
} catch (InvalidKeyException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IllegalBlockSizeException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (BadPaddingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
sProperties.setProperty(strKey, value);
if (store) {
Properties props = new Properties();
try {
FileInputStream fIn = new FileInputStream(sUserPropertyFile);
props.load(fIn);
fIn.close();
props.setProperty(strKey, value);
FileOutputStream fOut = new FileOutputStream(sUserPropertyFile);
props.store(fOut, REGENERATION_WARNING);
fOut.close();
} catch (IOException e) {
sLogger.error("Exception occured", e);
} // try
} // if
updateSystemProperties();
} // if
} /* setProperty */
}
|
Code with Pattern(s): |
class SpecifyEncryptEncoding {
byte[] pattern(Key key, String value) throws BadPaddingException, InvalidKeyException, IllegalBlockSizeException, NoSuchAlgorithmException, NoSuchPaddingException, UnsupportedEncodingException {
Cipher c = Cipher.getInstance("AES");
c.init(Cipher.ENCRYPT_MODE, key);
return c.doFinal(value.getBytes("UTF8"));
}
}
|