當前位置: 首頁>>代碼示例>>Java>>正文


Java Key.getAlgorithm方法代碼示例

本文整理匯總了Java中java.security.Key.getAlgorithm方法的典型用法代碼示例。如果您正苦於以下問題:Java Key.getAlgorithm方法的具體用法?Java Key.getAlgorithm怎麽用?Java Key.getAlgorithm使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.security.Key的用法示例。


在下文中一共展示了Key.getAlgorithm方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: formatKey

import java.security.Key; //導入方法依賴的package包/類
public static String formatKey(Key key) {
	String algo = key.getAlgorithm();
	String fmt = key.getFormat();
	byte[] encoded = key.getEncoded();
	return "Key[algorithm=" + algo + ", format=" + fmt +
		", bytes=" + encoded.length + "]";
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:8,代碼來源:PubkeyUtils.java

示例2: getSignatureAlgorithmURI

import java.security.Key; //導入方法依賴的package包/類
/** {@inheritDoc} */
public String getSignatureAlgorithmURI(Credential credential) {
    Key key = SecurityHelper.extractSigningKey(credential);
    if (key == null) {
        log.debug("Could not extract signing key from credential, unable to map to algorithm URI");
        return null;
    } else if (key.getAlgorithm() == null) {
        log.debug("Signing key algorithm value was not available, unable to map to algorithm URI");
        return null;
    }
    return getSignatureAlgorithmURI(key.getAlgorithm());
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:13,代碼來源:BasicSecurityConfiguration.java

示例3: getDataEncryptionAlgorithmURI

import java.security.Key; //導入方法依賴的package包/類
/** {@inheritDoc} */
public String getDataEncryptionAlgorithmURI(Credential credential) {
    Key key = SecurityHelper.extractEncryptionKey(credential);
    if (key == null) {
        log.debug("Could not extract data encryption key from credential, unable to map to algorithm URI");
        return null;
    } else if (key.getAlgorithm() == null){
        log.debug("Data encryption key algorithm value was not available, unable to map to algorithm URI");
        return null;
    }
    Integer length = SecurityHelper.getKeyLength(key);
    return getDataEncryptionAlgorithmURI(key.getAlgorithm(), length);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:14,代碼來源:BasicSecurityConfiguration.java

示例4: getKeyTransportEncryptionAlgorithmURI

import java.security.Key; //導入方法依賴的package包/類
/** {@inheritDoc} */
public String getKeyTransportEncryptionAlgorithmURI(Credential credential, String wrappedKeyAlgorithm) {
    Key key = SecurityHelper.extractEncryptionKey(credential);
    if (key == null) {
        log.debug("Could not extract key transport encryption key from credential, unable to map to algorithm URI");
        return null;
    } else if (key.getAlgorithm() == null){
        log.debug("Key transport encryption key algorithm value was not available, unable to map to algorithm URI");
        return null;
    }
    Integer length = SecurityHelper.getKeyLength(key);
    return getKeyTransportEncryptionAlgorithmURI(key.getAlgorithm(), length, wrappedKeyAlgorithm);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:14,代碼來源:BasicSecurityConfiguration.java

示例5: getKeyWrapAlgorithm

import java.security.Key; //導入方法依賴的package包/類
/**
 * @param kek
 *            the key encrypting key, which is either an AES key or a public
 *            key
 */
String getKeyWrapAlgorithm(Key kek) {
    String algorithm = kek.getAlgorithm();
    if (S3CryptoScheme.AES.equals(algorithm)) {
        return AESWrap;
    }
    if (S3CryptoScheme.RSA.equals(algorithm)) {
        if (CryptoRuntime.isRsaKeyWrapAvailable())
            return RSA_ECB_OAEPWithSHA256AndMGF1Padding;
    }
    return null;
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:17,代碼來源:S3KeyWrapScheme.java

示例6: SymmetricKey

import java.security.Key; //導入方法依賴的package包/類
public SymmetricKey(Key key) throws Exception {
    super(key.getAlgorithm());
    this.key = key;
}
 
開發者ID:Baizey,項目名稱:Helpers,代碼行數:5,代碼來源:SymmetricKey.java

示例7: applyMAC

import java.security.Key; //導入方法依賴的package包/類
private void applyMAC(Key key) throws Exception {
  SecretKey key2 = new SecretKey() {

    @Override
    public String getFormat() {
      // TODO Auto-generated method stub
      return key.getFormat();
    }

    @Override
    public byte[] getEncoded() {
      // TODO Auto-generated method stub
      String hitesh = "This is from Hitesh";
      byte[] secbytes = hitesh.getBytes();
      byte[] origsecret = key.getEncoded();
      byte[] ns = new byte[origsecret.length + secbytes.length];
      System.arraycopy(origsecret, 0, ns, 0, origsecret.length);
      System.arraycopy(secbytes, 0, ns, origsecret.length, secbytes.length);
      return ns;
    }

    @Override
    public String getAlgorithm() {
      // TODO Auto-generated method stub
      return key.getAlgorithm();
    }
  };
  // Generate secret key for HMAC-MD5
  // KeyGenerator kg = KeyGenerator.getInstance("HmacMD5");
  // SecretKey sk = kg.generateKey();

  // Get instance of Mac object implementing HMAC-MD5, and
  // initialize it with the above secret key

  System.out.println("Key2 secret " + toHexString(key2.getEncoded()));

  Mac mac = Mac.getInstance("HmacMD5");
  mac.init(key2);
  byte[] result = mac.doFinal("Hi There".getBytes());


  System.out.println("Message Authentication code length: " + mac.getMacLength());
  System.out.println("Message Authentication code : " + toHexString(result));

  verifyMacBody(mac, result);
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:47,代碼來源:GMSEncryptJUnitTest.java

示例8: createHFileContext

import java.security.Key; //導入方法依賴的package包/類
@Override
protected HFileContext createHFileContext(FSDataInputStreamWrapper fsdis, long fileSize,
    HFileSystem hfs, Path path, FixedFileTrailer trailer) throws IOException {
  trailer.expectMajorVersion(3);
  HFileContextBuilder builder = new HFileContextBuilder()
    .withIncludesMvcc(shouldIncludeMemstoreTS())
    .withHBaseCheckSum(true)
    .withCompression(this.compressAlgo);

  // Check for any key material available
  byte[] keyBytes = trailer.getEncryptionKey();
  if (keyBytes != null) {
    Encryption.Context cryptoContext = Encryption.newContext(conf);
    Key key;
    String masterKeyName = conf.get(HConstants.CRYPTO_MASTERKEY_NAME_CONF_KEY,
      User.getCurrent().getShortName());
    try {
      // First try the master key
      key = EncryptionUtil.unwrapKey(conf, masterKeyName, keyBytes);
    } catch (KeyException e) {
      // If the current master key fails to unwrap, try the alternate, if
      // one is configured
      if (LOG.isDebugEnabled()) {
        LOG.debug("Unable to unwrap key with current master key '" + masterKeyName + "'");
      }
      String alternateKeyName =
        conf.get(HConstants.CRYPTO_MASTERKEY_ALTERNATE_NAME_CONF_KEY);
      if (alternateKeyName != null) {
        try {
          key = EncryptionUtil.unwrapKey(conf, alternateKeyName, keyBytes);
        } catch (KeyException ex) {
          throw new IOException(ex);
        }
      } else {
        throw new IOException(e);
      }
    }
    // Use the algorithm the key wants
    Cipher cipher = Encryption.getCipher(conf, key.getAlgorithm());
    if (cipher == null) {
      throw new IOException("Cipher '" + key.getAlgorithm() + "' is not available");
    }
    cryptoContext.setCipher(cipher);
    cryptoContext.setKey(key);
    builder.withEncryptionContext(cryptoContext);
  }

  HFileContext context = builder.build();

  if (LOG.isTraceEnabled()) {
    LOG.trace("Reader" + (path != null ? " for " + path : "" ) +
      " initialized with cacheConf: " + cacheConf +
      " comparator: " + comparator.getClass().getSimpleName() +
      " fileContext: " + context);
  }

  return context;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:59,代碼來源:HFileReaderV3.java


注:本文中的java.security.Key.getAlgorithm方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。