当前位置: 首页>>代码示例>>Java>>正文


Java WSO2Constants类代码示例

本文整理汇总了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;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:26,代码来源:KeyStoreMgtUtil.java

示例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;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:46,代码来源:KeyStoreMgtUtil.java

示例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;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:46,代码来源:KeyStoreMgtUtil.java


注:本文中的org.wso2.carbon.utils.WSO2Constants类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。