Class ResetWindowsPassword
- java.lang.Object
-
- org.jclouds.googlecomputeengine.compute.functions.ResetWindowsPassword
-
- All Implemented Interfaces:
com.google.common.base.Function<Map<String,?>,String>
,Function<Map<String,?>,String>
public class ResetWindowsPassword extends Object implements com.google.common.base.Function<Map<String,?>,String>
References: In brief, the sequence is:- Generate a temporary key for encrypting and decrypting the password
- Send the RSA public key to the instance, by settings its metadata
- Retrieve the result from the
Instance.SerialPortOutput
- Decode and decrypt the result.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ResetWindowsPassword(GoogleComputeEngineApi api, Crypto crypto, com.google.common.base.Predicate<AtomicReference<Operation>> operationDone, Json json)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
apply(Map<String,?> params)
protected String
decryptPassword(String message, KeyPair keys)
Decrypts the given password - the encrypted text is base64-encoded.protected Map<String,String>
extractKeyMetadata(KeyPair pair, String userName, String email)
Generates the metadata value for this keypair.
-
-
-
Field Detail
-
logger
@Named("jclouds.compute") protected Logger logger
-
-
Constructor Detail
-
ResetWindowsPassword
@Inject protected ResetWindowsPassword(GoogleComputeEngineApi api, Crypto crypto, com.google.common.base.Predicate<AtomicReference<Operation>> operationDone, Json json)
-
-
Method Detail
-
decryptPassword
protected String decryptPassword(String message, KeyPair keys) throws InvalidKeyException, IllegalBlockSizeException, BadPaddingException
Decrypts the given password - the encrypted text is base64-encoded. As per the GCE docs, assumes it was encrypted with algorithm "RSA/NONE/OAEPPadding", and UTF-8.
-
extractKeyMetadata
protected Map<String,String> extractKeyMetadata(KeyPair pair, String userName, String email) throws NoSuchAlgorithmException, InvalidKeySpecException
Generates the metadata value for this keypair. Extracts the public key's the RSA spec's modulus and exponent, encoded as Base-64, and an expires date.- Parameters:
pair
-- Returns:
- Throws:
NoSuchAlgorithmException
InvalidKeySpecException
-
-