本文整理匯總了Java中org.wso2.carbon.utils.WSO2Constants類的典型用法代碼示例。如果您正苦於以下問題:Java WSO2Constants類的具體用法?Java WSO2Constants怎麽用?Java WSO2Constants使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
WSO2Constants類屬於org.wso2.carbon.utils包,在下文中一共展示了WSO2Constants類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: verifyCertExistence
import org.wso2.carbon.utils.WSO2Constants; //導入依賴的package包/類
/**
* Check whether the certificate is available in the file system
*
* @param fileName file name
* @param configurationContext configuration context of the current message
*/
private static boolean verifyCertExistence(String fileName, ConfigurationContext configurationContext) {
String workDir = (String) configurationContext.getProperty(ServerConstants.WORK_DIR);
String filePath = workDir + File.separator + "pub_certs" + File.separator + fileName;
File pubCert = new File(workDir + File.separator + "pub_certs" + File.separator + fileName);
//if cert is still available then exit
if (pubCert.exists()) {
Map fileResourcesMap = (Map) configurationContext.getProperty(WSO2Constants.FILE_RESOURCE_MAP);
if (fileResourcesMap == null) {
fileResourcesMap = new Hashtable();
configurationContext.setProperty(WSO2Constants.FILE_RESOURCE_MAP, fileResourcesMap);
}
if (fileResourcesMap.get(fileName) == null) {
fileResourcesMap.put(fileName, filePath);
}
return true;
}
return false;
}
示例2: dumpCert
import org.wso2.carbon.utils.WSO2Constants; //導入依賴的package包/類
/**
* Dumping the generated pub. cert to a file
*
* @param configurationContext
* @param cert content of the certificate
* @param fileName file name
* @return file system location of the pub. cert
*/
public static String dumpCert(ConfigurationContext configurationContext, byte[] cert,
String fileName) {
if (!verifyCertExistence(fileName, configurationContext)) {
String workDir = (String) configurationContext.getProperty(ServerConstants.WORK_DIR);
File pubCert = new File(workDir + File.separator + "pub_certs");
if (fileName == null) {
fileName = String.valueOf(System.currentTimeMillis() + new SecureRandom().nextDouble()) + ".cert";
}
if (!pubCert.exists()) {
pubCert.mkdirs();
}
String filePath = workDir + File.separator + "pub_certs" + File.separator + fileName;
OutputStream outStream = null;
try {
outStream = new FileOutputStream(filePath);
outStream.write(cert);
} catch (Exception e) {
String msg = "Error when writing the public certificate to a file";
log.error(msg);
throw new SecurityException("msg", e);
} finally {
IdentityIOStreamUtils.flushOutputStream(outStream);
IdentityIOStreamUtils.closeOutputStream(outStream);
}
Map fileResourcesMap = (Map) configurationContext.getProperty(WSO2Constants.FILE_RESOURCE_MAP);
if (fileResourcesMap == null) {
fileResourcesMap = new Hashtable();
configurationContext.setProperty(WSO2Constants.FILE_RESOURCE_MAP, fileResourcesMap);
}
fileResourcesMap.put(fileName, filePath);
}
return WSO2Constants.ContextPaths.DOWNLOAD_PATH + "?id=" + fileName;
}
示例3: dumpCert
import org.wso2.carbon.utils.WSO2Constants; //導入依賴的package包/類
/**
* Dumping the generated pub. cert to a file
*
* @param configurationContext
* @param cert content of the certificate
* @param fileName file name
* @return file system location of the pub. cert
*/
public static String dumpCert(ConfigurationContext configurationContext, byte[] cert,
String fileName) {
if (!verifyCertExistence(fileName, configurationContext)) {
String workDir = (String) configurationContext.getProperty(ServerConstants.WORK_DIR);
File pubCert = new File(workDir + File.separator + "pub_certs");
if (fileName == null) {
fileName = String.valueOf(System.currentTimeMillis() + Math.random()) + ".cert";
}
if (!pubCert.exists()) {
pubCert.mkdirs();
}
String filePath = workDir + File.separator + "pub_certs" + File.separator + fileName;
OutputStream outStream = null;
try {
outStream = new FileOutputStream(filePath);
outStream.write(cert);
} catch (Exception e) {
String msg = "Error when writing the public certificate to a file";
log.error(msg);
throw new SecurityException("msg", e);
} finally {
IdentityIOStreamUtils.flushOutputStream(outStream);
IdentityIOStreamUtils.closeOutputStream(outStream);
}
Map fileResourcesMap = (Map) configurationContext.getProperty(WSO2Constants.FILE_RESOURCE_MAP);
if (fileResourcesMap == null) {
fileResourcesMap = new Hashtable();
configurationContext.setProperty(WSO2Constants.FILE_RESOURCE_MAP, fileResourcesMap);
}
fileResourcesMap.put(fileName, filePath);
}
return WSO2Constants.ContextPaths.DOWNLOAD_PATH + "?id=" + fileName;
}