Skip to content

Commit c1ddf3b

Browse files
committed
Remove debug changes
1 parent 79dd9c8 commit c1ddf3b

File tree

4 files changed

+56
-6
lines changed

4 files changed

+56
-6
lines changed

java/src/hdf/hdf5lib/structs/H5FD_ros3_fapl_t.java

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,20 @@ public class H5FD_ros3_fapl_t implements Serializable {
5454
private String secret_id;
5555
/** key "secret key" or "access key" for authenticating request */
5656
private String secret_key;
57+
/** token "session token" or "access token" for authenticating request */
58+
private String session_token;
5759

5860
/**
5961
* Create a "default" fapl_t structure, for anonymous access.
6062
*/
6163
public H5FD_ros3_fapl_t()
6264
{
6365
/* H5FD_ros3_fapl_t("", "", ""); */ /* defer */
64-
this.version = 1;
66+
this.version = 1; /* H5FD_CURR_ROS3_FAPL_T_VERSION */
6567
this.aws_region = "";
6668
this.secret_id = "";
6769
this.secret_key = "";
70+
this.session_token = "";
6871
}
6972

7073
/**
@@ -83,6 +86,27 @@ public H5FD_ros3_fapl_t(String region, String id, String key)
8386
this.aws_region = region;
8487
this.secret_id = id;
8588
this.secret_key = key;
89+
this.session_token = "";
90+
}
91+
92+
/**
93+
* Create a fapl_t structure with the specified components.
94+
* If all are the empty string, is anonymous (non-authenticating).
95+
* Region and ID must both be supplied for authentication.
96+
*
97+
* @param region "aws region" for authenticating request
98+
* @param id "secret id" or "access id" for authenticating request
99+
* @param key "secret key" or "access key" for authenticating request
100+
* @param key "session token" or "access token" for authenticating request
101+
*/
102+
public H5FD_ros3_fapl_t(String region, String id, String key, String token)
103+
{
104+
this.version = 1; /* must equal H5FD_CURR_ROS3_FAPL_T_VERSION */
105+
/* as found in H5FDros3.h */
106+
this.aws_region = region;
107+
this.secret_id = id;
108+
this.secret_key = key;
109+
this.session_token = token;
86110
}
87111

88112
@Override
@@ -102,6 +126,8 @@ public boolean equals(Object o)
102126
return false;
103127
if (!this.secret_id.equals(other.secret_id))
104128
return false;
129+
if (!this.session_token.equals(other.session_token))
130+
return false;
105131
return true;
106132
}
107133

@@ -114,6 +140,7 @@ public int hashCode()
114140
k += this.aws_region.length();
115141
k += this.secret_id.length();
116142
k += this.secret_key.length();
143+
k += this.session_token.length();
117144
return k;
118145
}
119146

@@ -122,6 +149,6 @@ public String toString()
122149
{
123150
return "H5FD_ros3_fapl_t (Version:" + this.version + ") {"
124151
+ "\n aws_region : " + this.aws_region + "\n secret_id : " + this.secret_id +
125-
"\n secret_key : " + this.secret_key + "\n}\n";
152+
"\n secret_key : " + this.secret_key + "\n session_token : " + this.session_token + "\n}\n";
126153
}
127154
}

java/src/jni/h5pFAPLImp.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1ros3(JNIEnv *env, jclass clss, jlong fapl_id)
796796
jstring j_aws = NULL;
797797
jstring j_id = NULL;
798798
jstring j_key = NULL;
799+
jstring j_tok = NULL;
799800
#endif /* H5_HAVE_ROS3_VFD */
800801
jobject ret_obj = NULL;
801802

@@ -825,6 +826,12 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1ros3(JNIEnv *env, jclass clss, jlong fapl_id)
825826
}
826827
args[2].l = j_key;
827828

829+
if (NULL == (j_key = ENVPTR->NewStringUTF(ENVONLY, fa.session_token))) {
830+
CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE);
831+
H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_fapl_ros3: out of memory - can't create session_token string");
832+
}
833+
args[3].l = j_tok;
834+
828835
CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5FD_ros3_fapl_t",
829836
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", args, ret_obj);
830837
#else
@@ -921,7 +928,25 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1ros3(JNIEnv *env, jclass clss, jlong fapl_id,
921928
else
922929
memset(instance.secret_key, 0, H5FD_ROS3_MAX_SECRET_KEY_LEN + 1);
923930

924-
if (instance.aws_region[0] != '\0' && instance.secret_id[0] != '\0' && instance.secret_key[0] != '\0')
931+
if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "session_token", "Ljava/lang/String;")))
932+
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
933+
934+
if (NULL == (j_str = (jstring)ENVPTR->GetObjectField(ENVONLY, fapl_config, fid)))
935+
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
936+
937+
if (j_str) {
938+
PIN_JAVA_STRING(ENVONLY, j_str, str, NULL, "H5Pset_fapl_ros3: fapl_config session_token not pinned");
939+
940+
strncpy(instance.session_token, str, H5FD_ROS3_MAX_SESSION_TOKEN_LEN + 1);
941+
instance.secret_key[H5FD_ROS3_MAX_SESSION_TOKEN_LEN] = '\0';
942+
943+
UNPIN_JAVA_STRING(ENVONLY, j_str, str);
944+
str = NULL;
945+
}
946+
else
947+
memset(instance.session_token, 0, H5FD_ROS3_MAX_SESSION_TOKEN_LEN + 1);
948+
949+
if (instance.aws_region[0] != '\0' && instance.secret_id[0] != '\0' && instance.secret_key[0] != '\0' && instance.session_token[0] != '\0')
925950
instance.authenticate = true;
926951

927952
if (H5Pset_fapl_ros3((hid_t)fapl_id, &instance) < 0)

src/H5FDs3comms.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ H5FD__s3comms_s3r_getsize(s3r_t *handle)
676676
/* Parse received headers to extract "Content-Length" from response
677677
* headers, storing file size at handle->filesize.
678678
*/
679-
printf("\nHEADER RESPONSE:%s\n",header_response);
679+
680680
if (NULL == (start = HDstrcasestr(header_response, "\r\nContent-Length: ")))
681681
HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "could not find \"Content-Length\" in response");
682682

@@ -1522,7 +1522,6 @@ H5FD__s3comms_parse_url(const char *url, const char *fapl_endpoint)
15221522
if (CURLUE_OK != rc && CURLUE_NO_QUERY != rc)
15231523
HGOTO_ERROR(H5E_VFL, H5E_CANTCREATE, NULL, "unable to get url query");
15241524

1525-
printf("PURL:\n--%s\n--%s\n--%s\n--%s\n--%s\n",purl->scheme,purl->host,purl->port,purl->path,purl->query);
15261525
ret_value = purl;
15271526

15281527
done:

tools/lib/h5tools_utils.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,6 @@ h5tools_parse_ros3_fapl_tuple(const char *tuple_str, int delim, H5FD_ros3_fapl_e
10501050
else {
10511051
ccred[3] = (const char *)s3cred[3];
10521052
}
1053-
printf("\ncreds:%s::%s::%s::%s:\n",ccred[0],ccred[1],ccred[2],ccred[3]);
10541053

10551054
if (0 == h5tools_populate_ros3_fapl(fapl_config_out, ccred))
10561055
H5TOOLS_GOTO_ERROR(FAIL, "failed to populate S3 VFD FAPL config");

0 commit comments

Comments
 (0)