Package java.security

Examples of java.security.Key

Keys are generally obtained through key generators, certificates, or various Identity classes used to manage keys. Keys may also be obtained from key specifications (transparent representations of the underlying key material) through the use of a key factory (see {@link KeyFactory}).

A Key should use KeyRep as its serialized representation. Note that a serialized Key may contain sensitive information which should not be exposed in untrusted environments. See the Security Appendix of the Serialization Specification for more information. @see PublicKey @see PrivateKey @see KeyPair @see KeyPairGenerator @see KeyFactory @see KeyRep @see java.security.spec.KeySpec @see Identity @see Signer @version 1.57 06/04/21 @author Benjamin Renaud


      try {
        File centraViewLicenseFile = LicenseUtil.getCentraViewLicenseFile(dataSource);
        byte[] encyptedData = LicenseUtil.readLicenseFileFromDisk(centraViewLicenseFile);
        byte[] encryptedLicenseFile = LicenseUtil.getLicenseFromLicenseFile(encyptedData);
        byte[] encryptedKey = LicenseUtil.getKeyFromLicenseFile(encyptedData);
        Key blowfishKey = LicenseUtil.decryptBlowfishKey(encryptedKey);

        Properties licenseFile = LicenseUtil.decryptLicenseFile(blowfishKey, encyptedData);
        licenseInstanceVO.updateLicenseInformation(licenseFile);

        count++;
View Full Code Here


      props.setProperty(PROPS_INDIVIDUAL_KEY, individualName);
      props.setProperty(PROPS_CV_VERSION_KEY, CentraViewConfiguration.getVersion());
      logger.debug("fetchLicenseFile: ServerProperties being sent: ");
      logger.debug(props);

      Key blowfishKey = LicenseUtil.generateBlowfishKey();
      byte[] encryptedServerData = LicenseUtil.encryptServerData(blowfishKey, props);
      byte[] encryptedBlowfishKey = LicenseUtil.encryptBlowfishKey(blowfishKey);
      Byte[] byteArrayServerData = (Byte[])LicenseUtil.convertToObjectArray(encryptedServerData);
      Byte[] byteArrayKeyData = (Byte[])LicenseUtil.convertToObjectArray(encryptedBlowfishKey);
      byte[] encryptedResponse = LicenseUtil.obtainLicenseFile(byteArrayKeyData, byteArrayServerData);
      logger.debug("fetchLicenseFile: Response Size: "+encryptedResponse.length+" bytes.");
      if (encryptedResponse.length < 1) {
        throw new AxisFault(SERVER_DOWN_MESSAGE);
      }
      logger.debug("fetchLicenseFile: Writing new license to disk.");
      File centraViewLicenseFile = LicenseUtil.getCentraViewLicenseFile(dataSource);
      LicenseUtil.writeLicenseFileToDisk(encryptedResponse, centraViewLicenseFile);
      logger.debug("fetchLicenseFile: Decrpting License.");
      byte[] encryptedLicenseFile = LicenseUtil.getLicenseFromLicenseFile(encryptedResponse);
      byte[] encryptedKey = LicenseUtil.getKeyFromLicenseFile(encryptedResponse);
      Key newBlowfishKey = LicenseUtil.decryptBlowfishKey(encryptedKey);
      Properties licenseFile = LicenseUtil.decryptLicenseFile(newBlowfishKey, encryptedLicenseFile);
      logger.debug("fetchLicenseFile: The recieved license file:");
      logger.debug(licenseFile);
      //do SHA to make sure is valid
      //save data to database.
View Full Code Here

    return returnByteArray;
  } //end of encryptServerData method

  private static final Key generateBlowfishKey()
  {
    Key key = null;
    try {
      KeyGenerator keyGenerator = KeyGenerator.getInstance("Blowfish");
      keyGenerator.init(128);
      key = keyGenerator.generateKey();
    } catch (Exception e) {
View Full Code Here

    
     * @return a new SymmetricCryptor
     * @throws CryptoException
     */
    public static SymmetricCryptor getSymmectricCryptor() throws CryptoException {
        Key key = generateKey();
       
        return new SymmetricCryptor(key);
    }
View Full Code Here

    ArgCheck.isNotNull(keyResource);
    InputStream stream = keyResource.openStream();
    try {
        KeyStore store = KeyStore.getInstance("JCEKS"); //$NON-NLS-1$
        store.load(stream, DEFAULT_STORE_PASSWORD.toCharArray());
        Key key = store.getKey(DEFAULT_ALIAS, DEFAULT_STORE_PASSWORD.toCharArray());
        return new SymmetricCryptor(key);
        } catch (GeneralSecurityException e) {
            throw new CryptoException(e);
    } finally {
      stream.close();
View Full Code Here

     * @param key
     * @return a new SymmetricCryptor
     * @throws CryptoException
     */
    public static SymmetricCryptor getSymmectricCryptor(byte[] key) throws CryptoException {
        Key secretKey = new SecretKeySpec(key, DEFAULT_SYM_KEY_ALGORITHM);
        return new SymmetricCryptor(secretKey);
    }
View Full Code Here

  {
    // Create the key manager factory used to extract the server key
       
    KeyStore key_store = loadKeyStore();
   
    final Key key = key_store.getKey( alias, SESecurityManager.SSL_PASSWORD.toCharArray());
   
    if ( key == null ){
     
      return( null );
    }
View Full Code Here

        System.out.println("store.load(null, password.toCharArray());");
        //System.out.println("keystore provider="+store.getProvider().getName());
        Enumeration<String> en = store.aliases();
        while (en.hasMoreElements()) {
            String alias = en.nextElement();
            Key key = store.getKey(alias, password.toCharArray());
            System.out.println("KeyFactory keyFactory = KeyFactory.getInstance(\"" + key.getAlgorithm() + "\");");
            System.out.println("store.load(null, password.toCharArray());");
            String pkFormat = key.getFormat();
            String encoded = StringUtils.convertBytesToHex(key.getEncoded());
            System.out.println(pkFormat + "EncodedKeySpec keySpec = new " + pkFormat + "EncodedKeySpec(getBytes(\""
                    + encoded + "\"));");
            System.out.println("PrivateKey privateKey = keyFactory.generatePrivate(keySpec);");
            System.out.println("Certificate[] certs = {");
            for (Certificate cert : store.getCertificateChain(alias)) {
View Full Code Here

      }
    } else {
      c = _contextCipher;
    }

    Key ret;

    try {   
      c.init(Cipher.UNWRAP_MODE, _key);
      ret = c.unwrap(encryptedBytes, jceKeyAlgorithm, Cipher.SECRET_KEY);
     
View Full Code Here

    */
   public Key getKey(String alias, String serviceAuthToken) throws Exception
   {
      log.debug(this + " got request for key with alias '" + alias + "'");
  
      Key key = keyStore.getKey(alias, keyStorePassword);
  
      if (key == null || key instanceof PublicKey)
      {
         return key;
      }
View Full Code Here

TOP

Related Classes of java.security.Key

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.