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


Java Crypto.encodedFile方法代码示例

本文整理汇总了Java中com.yahoo.athenz.auth.util.Crypto.encodedFile方法的典型用法代码示例。如果您正苦于以下问题:Java Crypto.encodedFile方法的具体用法?Java Crypto.encodedFile怎么用?Java Crypto.encodedFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.yahoo.athenz.auth.util.Crypto的用法示例。


在下文中一共展示了Crypto.encodedFile方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPrivateKey

import com.yahoo.athenz.auth.util.Crypto; //导入方法依赖的package包/类
@Override
public PrivateKey getPrivateKey(String service, String serverHostName,
        StringBuilder privateKeyId) {
    
    String privKeyName = System.getProperty(ATHENZ_PROP_PRIVATE_KEY);
    
    if (LOG.isDebugEnabled()) {
        LOG.debug("FilePrivateKeyStore: private key file=" + privKeyName);
    }
    
    if (privKeyName == null) {
        return null;
    }
    
    // check to see if this is running in dev mode and thus it's
    // a resource in our jar file
    
    String privKey = null;
    if (privKeyName.startsWith(ATHENZ_STR_JAR_RESOURCE)) {
        privKey = retrieveKeyFromResource(privKeyName.substring(ATHENZ_STR_JAR_RESOURCE.length()));
    } else {
        File privKeyFile = new File(privKeyName);
        privKey = Crypto.encodedFile(privKeyFile);
    }
    
    PrivateKey pkey = Crypto.loadPrivateKey(Crypto.ybase64DecodeString(privKey));
    if (pkey != null) {
        privateKeyId.append(System.getProperty(ATHENZ_PROP_PRIVATE_KEY_ID, "0"));
    }
    
    return pkey;
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:33,代码来源:FilePrivateKeyStore.java

示例2: testEnDecodedFile

import com.yahoo.athenz.auth.util.Crypto; //导入方法依赖的package包/类
@Test
public void testEnDecodedFile(){
    String encoded = Crypto.encodedFile(argFile);
    assertNotNull(encoded);
    
    String decoded = Crypto.ybase64DecodeString(encoded);
    assertEquals(decoded, "check\n");
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:9,代码来源:CryptoTest.java

示例3: testEncodedFileStream

import com.yahoo.athenz.auth.util.Crypto; //导入方法依赖的package包/类
@Test
public void testEncodedFileStream() throws Exception {
    try (FileInputStream in = new FileInputStream(argFile)) {
        String encoded = Crypto.encodedFile(in);
        assertNotNull(encoded);
        
        String decoded = Crypto.ybase64DecodeString(encoded);
        assertEquals(decoded, "check");
    } catch (Exception e){
        fail();
    }
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:13,代码来源:CryptoTest.java

示例4: zmsInit

import com.yahoo.athenz.auth.util.Crypto; //导入方法依赖的package包/类
private ZMSImpl zmsInit() {
    // we want to make sure we start we clean dir structure
    FileConnection.deleteDirectory(new File(ZMS_DATA_STORE_PATH));

    Authority principalAuthority = new com.yahoo.athenz.common.server.debug.DebugPrincipalAuthority();
    String unsignedCreds = "v=U1;d=user;n=user1";
    rsrcPrince = SimplePrincipal.create("user", "user1", unsignedCreds + ";s=signature",
            0, principalAuthority);
    ((SimplePrincipal) rsrcPrince).setUnsignedCreds(unsignedCreds);
    
    Mockito.when(mockDomRestRsrcCtx.request()).thenReturn(mockServletRequest);
    Mockito.when(mockDomRestRsrcCtx.principal()).thenReturn(rsrcPrince);
    Mockito.when(mockDomRsrcCtx.context()).thenReturn(mockDomRestRsrcCtx);
    Mockito.when(mockDomRsrcCtx.request()).thenReturn(mockServletRequest);
    Mockito.when(mockDomRsrcCtx.principal()).thenReturn(rsrcPrince);

    String pubKeyName = System.getProperty(ZMS_PROP_PUBLIC_KEY);
    File pubKeyFile = new File(pubKeyName);
    pubKey = Crypto.encodedFile(pubKeyFile);
    
    String privKeyName = System.getProperty(FilePrivateKeyStore.ATHENZ_PROP_PRIVATE_KEY);
    File privKeyFile = new File(privKeyName);
    privKey = Crypto.encodedFile(privKeyFile);

    adminUser = System.getProperty(ZMSConsts.ZMS_PROP_DOMAIN_ADMIN);
    
    System.setProperty(ZMSConsts.ZMS_PROP_FILE_STORE_PATH, "/tmp/zms_core_unit_tests/");
    System.clearProperty(ZMSConsts.ZMS_PROP_JDBC_RW_STORE);
    System.clearProperty(ZMSConsts.ZMS_PROP_JDBC_RO_STORE);
    
    ZMSImpl zmsObj = new ZMSImpl();
    zmsObj.serverPublicKeyMap.put("1", pubKeyK1);
    zmsObj.serverPublicKeyMap.put("2", pubKeyK2);
    ZMSImpl.serverHostName = "localhost";

    return zmsObj;
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:38,代码来源:ZMSImplTest.java

示例5: testCreateStore

import com.yahoo.athenz.auth.util.Crypto; //导入方法依赖的package包/类
@Test
public void testCreateStore() {
    
    File privKeyFile = new File("src/test/resources/zts_private.pem");
    String privKey = Crypto.encodedFile(privKeyFile);
    PrivateKey pkey = Crypto.loadPrivateKey(Crypto.ybase64DecodeString(privKey));
    
    ZMSFileChangeLogStoreFactory factory = new ZMSFileChangeLogStoreFactory();
    ChangeLogStore store = factory.create(ZTS_DATA_STORE_PATH, pkey, "0", null);
    assertNotNull(store);
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:12,代码来源:ZMSFileChangeLogStoreFactoryTest.java

示例6: setup

import com.yahoo.athenz.auth.util.Crypto; //导入方法依赖的package包/类
@BeforeMethod
public void setup() {

    // we want to make sure we start we clean dir structure

    ZMSFileChangeLogStore.deleteDirectory(new File(ZTS_DATA_STORE_PATH));

    File privKeyFile = new File(ZTS_PRIVATE_KEY);
    String privKey = Crypto.encodedFile(privKeyFile);
    
    privateKey = Crypto.loadPrivateKey(Crypto.ybase64DecodeString(privKey));
    
    ChangeLogStore structStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root",
            privateKey, "0");
    
    System.setProperty(ZTSConsts.ZTS_PROP_PROVIDER_ENDPOINTS, ".athenz2.com,.athenz.com");
    
    store = new DataStore(structStore, null);
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:20,代码来源:InstanceProviderManagerTest.java

示例7: setup

import com.yahoo.athenz.auth.util.Crypto; //导入方法依赖的package包/类
@BeforeMethod
public void setup() {

    // we want to make sure we start we clean dir structure

    ZMSFileChangeLogStore.deleteDirectory(new File(ZTS_DATA_STORE_PATH));
    
    String privKeyName = System.getProperty(FilePrivateKeyStore.ATHENZ_PROP_PRIVATE_KEY);
    File privKeyFile = new File(privKeyName);
    String privKey = Crypto.encodedFile(privKeyFile);
    
    privateKey = Crypto.loadPrivateKey(Crypto.ybase64DecodeString(privKey));
    
    /* create our data store */
    
    roleTokenDefaultTimeout = 2400;
    System.setProperty(ZTSConsts.ZTS_PROP_ROLE_TOKEN_DEFAULT_TIMEOUT,
            Integer.toString(roleTokenDefaultTimeout));
    
    roleTokenMaxTimeout = 96000;
    System.setProperty(ZTSConsts.ZTS_PROP_ROLE_TOKEN_MAX_TIMEOUT,
            Integer.toString(roleTokenMaxTimeout));

    System.setProperty(ZTSConsts.ZTS_PROP_AUTHORIZED_PROXY_USERS,
            "user_domain.proxy-user1,user_domain.proxy-user2");
    
    ChangeLogStore structStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root",
            privateKey, "0");

    CloudStore cloudStore = new CloudStore(null);
    cloudStore.setHttpClient(null);
    
    System.setProperty(ZTSConsts.ZTS_PROP_SELF_SIGNER_PRIVATE_KEY_FNAME,
            "src/test/resources/private_encrypted.key");
    System.setProperty(ZTSConsts.ZTS_PROP_SELF_SIGNER_PRIVATE_KEY_PASSWORD, "athenz");
    
    ZMSFileChangeLogStore.deleteDirectory(new File("/tmp/zts_server_cert_store"));
    System.setProperty(ZTSConsts.ZTS_PROP_CERT_FILE_STORE_PATH, "/tmp/zts_server_cert_store");
    
    store = new DataStore(structStore, cloudStore);
    zts = new ZTSImpl(cloudStore, store);
    ZTSImpl.serverHostName = "localhost";

    authorizer = new ZTSAuthorizer(store);
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:46,代码来源:ZTSImplTest.java

示例8: setup

import com.yahoo.athenz.auth.util.Crypto; //导入方法依赖的package包/类
@BeforeMethod
public void setup() {

    // we want to make sure we start we clean dir structure

    ZMSFileChangeLogStore.deleteDirectory(new File(ZTS_DATA_STORE_PATH));
    
    String privKeyName = System.getProperty(FilePrivateKeyStore.ATHENZ_PROP_PRIVATE_KEY);
    File privKeyFile = new File(privKeyName);
    String privKey = Crypto.encodedFile(privKeyFile);
    
    pkey = Crypto.loadPrivateKey(Crypto.ybase64DecodeString(privKey));
    
    userDomain = System.getProperty(ZTSConsts.ZTS_PROP_USER_DOMAIN, "user");
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:16,代码来源:DataStoreTest.java


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