diff --git a/ga4gh-bundle-management-service/src/main/java/org/irods/jargon/ga4gh/dos/bundle/impl/ExplodedDosServiceImpl.java b/ga4gh-bundle-management-service/src/main/java/org/irods/jargon/ga4gh/dos/bundle/impl/ExplodedDosServiceImpl.java index 7d09198..cee849c 100644 --- a/ga4gh-bundle-management-service/src/main/java/org/irods/jargon/ga4gh/dos/bundle/impl/ExplodedDosServiceImpl.java +++ b/ga4gh-bundle-management-service/src/main/java/org/irods/jargon/ga4gh/dos/bundle/impl/ExplodedDosServiceImpl.java @@ -41,6 +41,7 @@ import org.irods.jargon.ga4gh.dos.exception.DosDataNotFoundException; import org.irods.jargon.ga4gh.dos.exception.DosSystemException; import org.irods.jargon.ga4gh.dos.model.AccessMethod; +import org.irods.jargon.ga4gh.dos.utils.DataUtils; import org.irods.jargon.ga4gh.dos.utils.ExplodedBundleMetadataUtils; import org.irods.jargon.ticket.TicketAdminService; import org.irods.jargon.ticket.TicketServiceFactory; @@ -277,9 +278,9 @@ private void addAccessUrls(IrodsDataObject irodsDataObject, IRODSFile irodsFile) if (!this.getDosConfiguration().getDrsRestUrlEndpoint().isEmpty()) { irodsAccessMethod = new IrodsAccessMethod(); - irodsAccessMethod.setHeaders(new ArrayList()); - irodsAccessMethod.setRegion(""); - irodsAccessMethod.setUrl(""); + irodsAccessMethod.setHeaders(null); + irodsAccessMethod.setRegion(null); + irodsAccessMethod.setUrl(null); irodsAccessMethod.setAccessId(DosService.ACCESS_REST); irodsAccessMethod.setType(org.irods.jargon.ga4gh.dos.model.AccessMethod.TypeEnum.HTTPS); irodsDataObject.getIrodsAccessMethods().add(irodsAccessMethod); @@ -342,6 +343,7 @@ public IrodsAccessMethod createAccessUrlForDataObject(final String dataObjectId, sb.append(ticketId); irodsAccessMethod.setHeaders(new ArrayList()); irodsAccessMethod.getHeaders().add(sb.toString()); + irodsAccessMethod.getHeaders().add(DataUtils.basicAuthTokenForPublic()); log.info("irodsAccessMethod:{}", irodsAccessMethod); return irodsAccessMethod; } catch (JargonException e) { diff --git a/ga4gh-common/src/main/java/org/irods/jargon/ga4gh/dos/utils/DataUtils.java b/ga4gh-common/src/main/java/org/irods/jargon/ga4gh/dos/utils/DataUtils.java index eaffd60..500c6bd 100644 --- a/ga4gh-common/src/main/java/org/irods/jargon/ga4gh/dos/utils/DataUtils.java +++ b/ga4gh-common/src/main/java/org/irods/jargon/ga4gh/dos/utils/DataUtils.java @@ -8,6 +8,7 @@ import java.net.URLEncoder; import java.time.OffsetDateTime; import java.time.ZoneOffset; +import java.util.Base64; import java.util.Date; import org.irods.jargon.core.exception.JargonException; @@ -121,4 +122,22 @@ public static String encodeIrodsAbsolutePath(final String path, final String enc } } + /** + * Create a basic auth token for 'public' + * + * @return {@code String} with the basic auth token + */ + public static String basicAuthTokenForPublic() { + + StringBuilder sb = new StringBuilder(); + sb.append("Basic "); + + StringBuilder toEncode = new StringBuilder(); + toEncode.append("public"); + toEncode.append(":"); + + sb.append(Base64.getEncoder().encodeToString(toEncode.toString().getBytes())); + return sb.toString(); + } + } diff --git a/ga4gh-common/src/main/java/org/irods/jargon/ga4gh/dos/utils/Ga4ghVersion.java b/ga4gh-common/src/main/java/org/irods/jargon/ga4gh/dos/utils/Ga4ghVersion.java index 380129a..24cfd82 100644 --- a/ga4gh-common/src/main/java/org/irods/jargon/ga4gh/dos/utils/Ga4ghVersion.java +++ b/ga4gh-common/src/main/java/org/irods/jargon/ga4gh/dos/utils/Ga4ghVersion.java @@ -1,5 +1,5 @@ package org.irods.jargon.ga4gh.dos.utils; public final class Ga4ghVersion { public static String VERSION="0.0.1-SNAPSHOT"; - public static String BUILD_TIME="2019-09-16T14:17:15Z"; + public static String BUILD_TIME="2019-09-30T16:28:27Z"; } diff --git a/ga4gh-dos-service/src/main/java/org/irods/jargon/ga4gh/dos/api/ObjectsApiController.java b/ga4gh-dos-service/src/main/java/org/irods/jargon/ga4gh/dos/api/ObjectsApiController.java index 0e79dcf..4bfe6c8 100644 --- a/ga4gh-dos-service/src/main/java/org/irods/jargon/ga4gh/dos/api/ObjectsApiController.java +++ b/ga4gh-dos-service/src/main/java/org/irods/jargon/ga4gh/dos/api/ObjectsApiController.java @@ -217,10 +217,15 @@ public ResponseEntity getObject( for (IrodsAccessMethod irodsAccessMethod : irodsDataObject.getIrodsAccessMethods()) { AccessMethod accessMethod = new AccessMethod(); accessMethod.setAccessId(irodsAccessMethod.getAccessId()); - AccessURL accessURL = new AccessURL(); - accessURL.setHeaders(irodsAccessMethod.getHeaders()); - accessURL.setUrl(irodsAccessMethod.getUrl()); - accessMethod.setRegion(irodsAccessMethod.getRegion()); + + AccessURL accessURL = null; + if (irodsAccessMethod.getUrl() != null) { + accessURL = new AccessURL(); + accessURL.setHeaders(irodsAccessMethod.getHeaders()); + accessURL.setUrl(irodsAccessMethod.getUrl()); + accessMethod.setRegion(irodsAccessMethod.getRegion()); + } + accessMethod.setAccessUrl(accessURL); accessMethod.setType(irodsAccessMethod.getType()); accessMethods.add(accessMethod); diff --git a/ga4gh-dos-service/src/main/java/org/irods/jargon/ga4gh/dos/security/SecurityConfiguration.java b/ga4gh-dos-service/src/main/java/org/irods/jargon/ga4gh/dos/security/SecurityConfiguration.java index 1ffd6cb..ac69cb9 100644 --- a/ga4gh-dos-service/src/main/java/org/irods/jargon/ga4gh/dos/security/SecurityConfiguration.java +++ b/ga4gh-dos-service/src/main/java/org/irods/jargon/ga4gh/dos/security/SecurityConfiguration.java @@ -17,7 +17,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { private static final String[] AUTH_WHITELIST = { // -- swagger ui "/api-docs", "/swagger-resources", "/swagger-resources/**", "/configuration/ui", "/configuration/security", - "/swagger-ui.html", "/webjars/**", "/objects/**" + "/swagger-ui.html", "/webjars/**" // other public endpoints of your API may be appended to this array };