use of com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState in project photon-model by vmware.
the class AuthCredentialsOperationProcessingChainTest method testPlainTextCredentials.
@Test
public void testPlainTextCredentials() throws Throwable {
// do NOT init EncryptionUtils
AuthCredentialsServiceState credentials = createCredentials("username", "password", false);
assertEquals("username", credentials.userEmail);
assertNotNull(credentials.privateKey);
assertFalse(credentials.privateKey.startsWith(EncryptionUtils.ENCRYPTION_PREFIX));
String publicKey = "-----BEGIN CERTIFICATE-----\nABC\n-----END CERTIFICATE-----";
credentials = createCredentialsWithKeys(publicKey, "-----BEGIN PRIVATE KEY-----\nDEF\n-----END PRIVATE KEY-----");
assertEquals(publicKey, credentials.publicKey);
assertNotNull(credentials.privateKey);
assertFalse(credentials.privateKey.startsWith(EncryptionUtils.ENCRYPTION_PREFIX));
}
use of com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState in project photon-model by vmware.
the class AuthCredentialsOperationProcessingChainTest method createCredentials.
protected AuthCredentialsServiceState createCredentials(String username, String password, boolean isSystem) throws Throwable {
AuthCredentialsServiceState credentials = new AuthCredentialsServiceState();
credentials.userEmail = username;
credentials.privateKey = password;
credentials.type = AuthCredentialsType.Password.toString();
if (isSystem) {
credentials.customProperties = new HashMap<>();
credentials.customProperties.put(CUSTOM_PROP_CREDENTIALS_SCOPE, CredentialsScope.SYSTEM.toString());
}
return injectOperationProcessingChain(postServiceSynchronously(AuthCredentialsService.FACTORY_LINK, credentials, AuthCredentialsServiceState.class));
}
use of com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState in project photon-model by vmware.
the class AuthCredentialsOperationProcessingChainTest method createCredentialsWithKeys.
protected AuthCredentialsServiceState createCredentialsWithKeys(String publicKey, String privateKey) throws Throwable {
AuthCredentialsServiceState credentials = new AuthCredentialsServiceState();
credentials.publicKey = publicKey;
credentials.privateKey = privateKey;
credentials.type = AuthCredentialsType.PublicKey.toString();
return injectOperationProcessingChain(postServiceSynchronously(AuthCredentialsService.FACTORY_LINK, credentials, AuthCredentialsServiceState.class));
}
use of com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState in project photon-model by vmware.
the class EndpointRemovalTaskServiceTest method createAuthCredentials.
private static void createAuthCredentials(BaseModelTest test, String endpointLink, List<String> tenantLinks) throws Throwable {
AuthCredentialsServiceState auth = new AuthCredentialsServiceState();
auth.userEmail = "email";
auth.privateKey = "pass";
auth.customProperties = new HashMap<>();
auth.tenantLinks = tenantLinks;
auth.customProperties.put(CUSTOM_PROP_ENDPOINT_LINK, endpointLink);
test.postServiceSynchronously(AuthCredentialsService.FACTORY_LINK, auth, AuthCredentialsServiceState.class);
}
use of com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState in project photon-model by vmware.
the class AuthTranslationService method translateCredentials.
private AuthCredentialsServiceState translateCredentials(Operation op) {
AuthSecrets secrets = op.getBody(AuthSecrets.class);
if (secrets.environmentName == null) {
secrets.environmentName = "Unknown";
}
AuthCredentialsServiceState authState = new AuthCredentialsServiceState();
authState.tenantLinks = secrets.tenantLinks;
switch(secrets.environmentName) {
case ComputeDescriptionService.ComputeDescription.ENVIRONMENT_NAME_AWS:
authState.privateKey = secrets.privateKey;
authState.privateKeyId = secrets.privateKeyId;
break;
default:
authState.userLink = secrets.client_id;
authState.userEmail = secrets.client_email;
authState.privateKey = secrets.private_key;
authState.privateKeyId = secrets.private_key_id;
authState.tokenReference = secrets.token_uri;
authState.type = secrets.type;
}
return authState;
}
Aggregations