Skip to content

Commit

Permalink
#8 fixes for fileBytes and access url
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-conway committed Sep 30, 2019
1 parent bcc9a5c commit f354ef8
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -277,9 +278,9 @@ private void addAccessUrls(IrodsDataObject irodsDataObject, IRODSFile irodsFile)

if (!this.getDosConfiguration().getDrsRestUrlEndpoint().isEmpty()) {
irodsAccessMethod = new IrodsAccessMethod();
irodsAccessMethod.setHeaders(new ArrayList<String>());
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);
Expand Down Expand Up @@ -342,6 +343,7 @@ public IrodsAccessMethod createAccessUrlForDataObject(final String dataObjectId,
sb.append(ticketId);
irodsAccessMethod.setHeaders(new ArrayList<String>());
irodsAccessMethod.getHeaders().add(sb.toString());
irodsAccessMethod.getHeaders().add(DataUtils.basicAuthTokenForPublic());
log.info("irodsAccessMethod:{}", irodsAccessMethod);
return irodsAccessMethod;
} catch (JargonException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

}
Original file line number Diff line number Diff line change
@@ -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";
}
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,15 @@ public ResponseEntity<Ga4ghObject> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down

0 comments on commit f354ef8

Please sign in to comment.