本文整理汇总了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;
}