/** * Create an instance of {@link AwsCredential } * */ public AwsCredential createAwsCredential() { return new AwsCredential(); }
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { { String theAwsAccessKey; theAwsAccessKey = this.getAwsAccessKey(); strategy.appendField(locator, this, "awsAccessKey", buffer, theAwsAccessKey, (this.awsAccessKey!= null)); } { String theAwsSecretKey; theAwsSecretKey = this.getAwsSecretKey(); strategy.appendField(locator, this, "awsSecretKey", buffer, theAwsSecretKey, (this.awsSecretKey!= null)); } { String theAwsSessionToken; theAwsSessionToken = this.getAwsSessionToken(); strategy.appendField(locator, this, "awsSessionToken", buffer, theAwsSessionToken, (this.awsSessionToken!= null)); } { XMLGregorianCalendar theAwsSessionExpirationTime; theAwsSessionExpirationTime = this.getAwsSessionExpirationTime(); strategy.appendField(locator, this, "awsSessionExpirationTime", buffer, theAwsSessionExpirationTime, (this.awsSessionExpirationTime!= null)); } return buffer; }
@Override public AwsCredential getNewAwsCredential() throws Exception { AwsCredential awsCredential = new AwsCredential(); GregorianCalendar cal = new GregorianCalendar(); cal.setTimeInMillis(System.currentTimeMillis() + 1000); awsCredential.setAwsSessionExpirationTime(DatatypeFactory.newInstance().newXMLGregorianCalendar(cal)); return awsCredential; } };
@Override public AWSCredentials getCredentials() { AwsCredential herdAwsCredential = herdAWSCredentialsProvider.getAwsCredential(); return new BasicSessionCredentials(herdAwsCredential.getAwsAccessKey(), herdAwsCredential.getAwsSecretKey(), herdAwsCredential.getAwsSessionToken()); }
public Object copyTo(ObjectLocator locator, Object target, CopyStrategy2 strategy) { final Object draftCopy = ((target == null)?createNewInstance():target); if (draftCopy instanceof AwsCredential) { final AwsCredential copy = ((AwsCredential) draftCopy); if (awsAccessKeyShouldBeCopiedAndSet == Boolean.TRUE) { String sourceAwsAccessKey; sourceAwsAccessKey = this.getAwsAccessKey(); String copyAwsAccessKey = ((String) strategy.copy(LocatorUtils.property(locator, "awsAccessKey", sourceAwsAccessKey), sourceAwsAccessKey, (this.awsAccessKey!= null))); copy.setAwsAccessKey(copyAwsAccessKey); } else { if (awsAccessKeyShouldBeCopiedAndSet == Boolean.FALSE) { if (awsSecretKeyShouldBeCopiedAndSet == Boolean.TRUE) { String sourceAwsSecretKey; sourceAwsSecretKey = this.getAwsSecretKey(); String copyAwsSecretKey = ((String) strategy.copy(LocatorUtils.property(locator, "awsSecretKey", sourceAwsSecretKey), sourceAwsSecretKey, (this.awsSecretKey!= null))); copy.setAwsSecretKey(copyAwsSecretKey); } else { if (awsSecretKeyShouldBeCopiedAndSet == Boolean.FALSE) { if (awsSessionTokenShouldBeCopiedAndSet == Boolean.TRUE) { String sourceAwsSessionToken; sourceAwsSessionToken = this.getAwsSessionToken(); String copyAwsSessionToken = ((String) strategy.copy(LocatorUtils.property(locator, "awsSessionToken", sourceAwsSessionToken), sourceAwsSessionToken, (this.awsSessionToken!= null))); copy.setAwsSessionToken(copyAwsSessionToken); } else { if (awsSessionTokenShouldBeCopiedAndSet == Boolean.FALSE) { if (awsSessionExpirationTimeShouldBeCopiedAndSet == Boolean.TRUE) {
.getTemporarySecurityCredentials(awsHelper.getAwsParamsDto(), UUID.randomUUID().toString(), roleArn, durationSeconds, awsPolicyBuilder.build()); AwsCredential awsCredential = new AwsCredential(); awsCredential.setAwsAccessKey(credentials.getAccessKeyId()); awsCredential.setAwsSecretKey(credentials.getSecretAccessKey()); awsCredential.setAwsSessionToken(credentials.getSessionToken()); awsCredential.setAwsSessionExpirationTime(HerdDateUtils.getXMLGregorianCalendarValue(credentials.getExpiration())); return awsCredential;
private void getStorageUnitDownloadCredentialResponse(MockCloseableHttpResponse response, URI uri) throws UnsupportedCharsetException, JAXBException { StorageUnitDownloadCredential storageUnitDownloadCredential = new StorageUnitDownloadCredential(); AwsCredential awsCredential = new AwsCredential(); awsCredential.setAwsAccessKey(uri.toString()); storageUnitDownloadCredential.setAwsCredential(awsCredential); response.setEntity(getHttpEntity(storageUnitDownloadCredential)); } }
@Test public void testGetBusinessObjectDataDownloadCredential1() throws Exception { DownloaderInputManifestDto manifest = new DownloaderInputManifestDto(); manifest.setNamespace("test1"); manifest.setBusinessObjectDefinitionName("test2"); manifest.setBusinessObjectFormatUsage("test3"); manifest.setBusinessObjectFormatFileType("test4"); manifest.setBusinessObjectFormatVersion("test5"); manifest.setPartitionValue("test6"); manifest.setSubPartitionValues(Arrays.asList("test7", "test8")); manifest.setBusinessObjectDataVersion("test9"); String storageName = "test10"; StorageUnitDownloadCredential storageUnitDownloadCredential = downloaderWebClient.getStorageUnitDownloadCredential(manifest, storageName); Assert.assertNotNull(storageUnitDownloadCredential); AwsCredential awsCredential = storageUnitDownloadCredential.getAwsCredential(); Assert.assertNotNull(awsCredential); Assert.assertEquals("https://testWebServiceHostname:1234/herd-app/rest/storageUnits/download/credential/namespaces/test1" + "/businessObjectDefinitionNames/test2/businessObjectFormatUsages/test3/businessObjectFormatFileTypes/test4/businessObjectFormatVersions/test5" + "/partitionValues/test6/businessObjectDataVersions/test9/storageNames/test10?subPartitionValues=test7%7Ctest8", awsCredential.getAwsAccessKey()); }
/** * Retrieves a fresh set of credentials if there is no current cached credentials, or the session has expired. Otherwise, returns the cached credentials. */ @Override public AwsCredential getAwsCredential() { if (sessionExpirationTime == null || System.currentTimeMillis() >= sessionExpirationTime) { try { currentAwsCredentials = getNewAwsCredential(); } catch (Exception e) { LOGGER.warn("Error retrieving new credentials. {}", e.toString(), e); throw new IllegalStateException(e); } sessionExpirationTime = currentAwsCredentials.getAwsSessionExpirationTime().toGregorianCalendar().getTimeInMillis(); } return currentAwsCredentials; } }
public Object copyTo(ObjectLocator locator, Object target, CopyStrategy2 strategy) { final Object draftCopy = ((target == null)?createNewInstance():target); if (draftCopy instanceof AwsCredential) { final AwsCredential copy = ((AwsCredential) draftCopy); if (awsAccessKeyShouldBeCopiedAndSet == Boolean.TRUE) { String sourceAwsAccessKey; sourceAwsAccessKey = this.getAwsAccessKey(); String copyAwsAccessKey = ((String) strategy.copy(LocatorUtils.property(locator, "awsAccessKey", sourceAwsAccessKey), sourceAwsAccessKey, (this.awsAccessKey!= null))); copy.setAwsAccessKey(copyAwsAccessKey); } else { if (awsAccessKeyShouldBeCopiedAndSet == Boolean.FALSE) { if (awsSecretKeyShouldBeCopiedAndSet == Boolean.TRUE) { String sourceAwsSecretKey; sourceAwsSecretKey = this.getAwsSecretKey(); String copyAwsSecretKey = ((String) strategy.copy(LocatorUtils.property(locator, "awsSecretKey", sourceAwsSecretKey), sourceAwsSecretKey, (this.awsSecretKey!= null))); copy.setAwsSecretKey(copyAwsSecretKey); } else { if (awsSecretKeyShouldBeCopiedAndSet == Boolean.FALSE) { if (awsSessionTokenShouldBeCopiedAndSet == Boolean.TRUE) { String sourceAwsSessionToken; sourceAwsSessionToken = this.getAwsSessionToken(); String copyAwsSessionToken = ((String) strategy.copy(LocatorUtils.property(locator, "awsSessionToken", sourceAwsSessionToken), sourceAwsSessionToken, (this.awsSessionToken!= null))); copy.setAwsSessionToken(copyAwsSessionToken); } else { if (awsSessionTokenShouldBeCopiedAndSet == Boolean.FALSE) { if (awsSessionExpirationTimeShouldBeCopiedAndSet == Boolean.TRUE) {
.getTemporarySecurityCredentials(awsHelper.getAwsParamsDto(), UUID.randomUUID().toString(), roleArn, durationSeconds, awsPolicyBuilder.build()); AwsCredential awsCredential = new AwsCredential(); awsCredential.setAwsAccessKey(credentials.getAccessKeyId()); awsCredential.setAwsSecretKey(credentials.getSecretAccessKey()); awsCredential.setAwsSessionToken(credentials.getSessionToken()); awsCredential.setAwsSessionExpirationTime(HerdDateUtils.getXMLGregorianCalendarValue(credentials.getExpiration())); return awsCredential;
@Override public AWSCredentials getCredentials() { AwsCredential herdAwsCredential = herdAWSCredentialsProvider.getAwsCredential(); return new BasicSessionCredentials(herdAwsCredential.getAwsAccessKey(), herdAwsCredential.getAwsSecretKey(), herdAwsCredential.getAwsSessionToken()); }
private void getBusinessObjectDataUploadCredentialResponse(MockCloseableHttpResponse response, URI uri) throws UnsupportedCharsetException, JAXBException { BusinessObjectDataUploadCredential businessObjectDataUploadCredential = new BusinessObjectDataUploadCredential(); AwsCredential awsCredential = new AwsCredential(); awsCredential.setAwsAccessKey(uri.toString()); businessObjectDataUploadCredential.setAwsCredential(awsCredential); response.setEntity(getHttpEntity(businessObjectDataUploadCredential)); }
@Test public void testGetBusinessObjectDataUploadCredential1() throws Exception { DataBridgeBaseManifestDto manifest = new DataBridgeBaseManifestDto(); manifest.setNamespace("test1"); manifest.setBusinessObjectDefinitionName("test2"); manifest.setBusinessObjectFormatUsage("test3"); manifest.setBusinessObjectFormatFileType("test4"); manifest.setBusinessObjectFormatVersion("test5"); manifest.setPartitionValue("test6"); manifest.setSubPartitionValues(Arrays.asList("test7", "test8")); String storageName = "test8"; Integer businessObjectDataVersion = 1234; Boolean createNewVersion = false; uploaderWebClient.getRegServerAccessParamsDto().setUseSsl(false); BusinessObjectDataUploadCredential businessObjectDataUploadCredential = uploaderWebClient.getBusinessObjectDataUploadCredential(manifest, storageName, businessObjectDataVersion, createNewVersion); Assert.assertNotNull(businessObjectDataUploadCredential); AwsCredential awsCredential = businessObjectDataUploadCredential.getAwsCredential(); Assert.assertNotNull(awsCredential); Assert.assertEquals("http://testWebServiceHostname:1234/herd-app/rest/businessObjectData/upload/credential/namespaces/test1" + "/businessObjectDefinitionNames/test2/businessObjectFormatUsages/test3/businessObjectFormatFileTypes/test4/businessObjectFormatVersions/test5" + "/partitionValues/test6?storageName=test8&subPartitionValues=test7%7Ctest8&businessObjectDataVersion=1234&createNewVersion=false", awsCredential.getAwsAccessKey()); }
/** * Retrieves a fresh set of credentials if there is no current cached credentials, or the session has expired. Otherwise, returns the cached credentials. */ @Override public AwsCredential getAwsCredential() { if (sessionExpirationTime == null || System.currentTimeMillis() >= sessionExpirationTime) { try { currentAwsCredentials = getNewAwsCredential(); } catch (Exception e) { LOGGER.warn("Error retrieving new credentials. {}", e.toString(), e); throw new IllegalStateException(e); } sessionExpirationTime = currentAwsCredentials.getAwsSessionExpirationTime().toGregorianCalendar().getTimeInMillis(); } return currentAwsCredentials; } }
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { { String theAwsAccessKey; theAwsAccessKey = this.getAwsAccessKey(); strategy.appendField(locator, this, "awsAccessKey", buffer, theAwsAccessKey, (this.awsAccessKey!= null)); } { String theAwsSecretKey; theAwsSecretKey = this.getAwsSecretKey(); strategy.appendField(locator, this, "awsSecretKey", buffer, theAwsSecretKey, (this.awsSecretKey!= null)); } { String theAwsSessionToken; theAwsSessionToken = this.getAwsSessionToken(); strategy.appendField(locator, this, "awsSessionToken", buffer, theAwsSessionToken, (this.awsSessionToken!= null)); } { XMLGregorianCalendar theAwsSessionExpirationTime; theAwsSessionExpirationTime = this.getAwsSessionExpirationTime(); strategy.appendField(locator, this, "awsSessionExpirationTime", buffer, theAwsSessionExpirationTime, (this.awsSessionExpirationTime!= null)); } return buffer; }
public Object copyTo(ObjectLocator locator, Object target, CopyStrategy2 strategy) { final Object draftCopy = ((target == null)?createNewInstance():target); if (draftCopy instanceof AwsCredential) { final AwsCredential copy = ((AwsCredential) draftCopy); if (awsAccessKeyShouldBeCopiedAndSet == Boolean.TRUE) { String sourceAwsAccessKey; sourceAwsAccessKey = this.getAwsAccessKey(); String copyAwsAccessKey = ((String) strategy.copy(LocatorUtils.property(locator, "awsAccessKey", sourceAwsAccessKey), sourceAwsAccessKey, (this.awsAccessKey!= null))); copy.setAwsAccessKey(copyAwsAccessKey); } else { if (awsAccessKeyShouldBeCopiedAndSet == Boolean.FALSE) { if (awsSecretKeyShouldBeCopiedAndSet == Boolean.TRUE) { String sourceAwsSecretKey; sourceAwsSecretKey = this.getAwsSecretKey(); String copyAwsSecretKey = ((String) strategy.copy(LocatorUtils.property(locator, "awsSecretKey", sourceAwsSecretKey), sourceAwsSecretKey, (this.awsSecretKey!= null))); copy.setAwsSecretKey(copyAwsSecretKey); } else { if (awsSecretKeyShouldBeCopiedAndSet == Boolean.FALSE) { if (awsSessionTokenShouldBeCopiedAndSet == Boolean.TRUE) { String sourceAwsSessionToken; sourceAwsSessionToken = this.getAwsSessionToken(); String copyAwsSessionToken = ((String) strategy.copy(LocatorUtils.property(locator, "awsSessionToken", sourceAwsSessionToken), sourceAwsSessionToken, (this.awsSessionToken!= null))); copy.setAwsSessionToken(copyAwsSessionToken); } else { if (awsSessionTokenShouldBeCopiedAndSet == Boolean.FALSE) { if (awsSessionExpirationTimeShouldBeCopiedAndSet == Boolean.TRUE) {
/** * Create an instance of {@link AwsCredential } * */ public AwsCredential createAwsCredential() { return new AwsCredential(); }
@Test public void testGetBusinessObjectDataUploadCredential3() throws Exception { DataBridgeBaseManifestDto manifest = new DataBridgeBaseManifestDto(); manifest.setNamespace("test1"); manifest.setBusinessObjectDefinitionName("test2"); manifest.setBusinessObjectFormatUsage("test3"); manifest.setBusinessObjectFormatFileType("test4"); manifest.setBusinessObjectFormatVersion("test5"); manifest.setPartitionValue("test6"); manifest.setSubPartitionValues(Arrays.asList("test7", "test8")); String storageName = "test8"; Integer businessObjectDataVersion = null; Boolean createNewVersion = true; uploaderWebClient.getRegServerAccessParamsDto().setUseSsl(true); BusinessObjectDataUploadCredential businessObjectDataUploadCredential = uploaderWebClient.getBusinessObjectDataUploadCredential(manifest, storageName, businessObjectDataVersion, createNewVersion); Assert.assertNotNull(businessObjectDataUploadCredential); AwsCredential awsCredential = businessObjectDataUploadCredential.getAwsCredential(); Assert.assertNotNull(awsCredential); Assert.assertEquals("https://testWebServiceHostname:1234/herd-app/rest/businessObjectData/upload/credential/namespaces/test1" + "/businessObjectDefinitionNames/test2/businessObjectFormatUsages/test3/businessObjectFormatFileTypes/test4/businessObjectFormatVersions/test5" + "/partitionValues/test6?storageName=test8&subPartitionValues=test7%7Ctest8&createNewVersion=true", awsCredential.getAwsAccessKey()); }
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { { String theAwsAccessKey; theAwsAccessKey = this.getAwsAccessKey(); strategy.appendField(locator, this, "awsAccessKey", buffer, theAwsAccessKey, (this.awsAccessKey!= null)); } { String theAwsSecretKey; theAwsSecretKey = this.getAwsSecretKey(); strategy.appendField(locator, this, "awsSecretKey", buffer, theAwsSecretKey, (this.awsSecretKey!= null)); } { String theAwsSessionToken; theAwsSessionToken = this.getAwsSessionToken(); strategy.appendField(locator, this, "awsSessionToken", buffer, theAwsSessionToken, (this.awsSessionToken!= null)); } { XMLGregorianCalendar theAwsSessionExpirationTime; theAwsSessionExpirationTime = this.getAwsSessionExpirationTime(); strategy.appendField(locator, this, "awsSessionExpirationTime", buffer, theAwsSessionExpirationTime, (this.awsSessionExpirationTime!= null)); } return buffer; }