Skip to content
This repository was archived by the owner on Mar 21, 2023. It is now read-only.

Commit 11ba1e2

Browse files
author
John Jacquay
committed
Added ticket support. refs #4933
1 parent a5093a1 commit 11ba1e2

File tree

5 files changed

+53
-2
lines changed

5 files changed

+53
-2
lines changed

collection.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ func getCollection(startPath string, recursive bool, con *Connection) (*Collecti
102102
if er := col.init(); er != nil {
103103
return nil, er
104104
}
105+
} else {
106+
if er := col.Open(); er != nil {
107+
return nil, er
108+
}
105109
}
106110

107111
return col, nil

connection.go

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ type ConnectionOptions struct {
176176

177177
Username string
178178
Password string
179+
Ticket string
179180
}
180181

181182
type Connection struct {
@@ -190,8 +191,8 @@ type Connection struct {
190191
// New creates a connection to an iRods iCAT server. EnvironmentDefined and UserDefined
191192
// constants are used in ConnectionOptions{ Type: ... }).
192193
// When EnvironmentDefined is specified, the options stored in ~/.irods/irods_environment.json will be used.
193-
// When UserDefined is specified you must also pass Host, Port, Username, and Zone. Password
194-
// should be set regardless.
194+
// When UserDefined is specified you must also pass Host, Port, Username, and Zone. Password
195+
// should be set unless using an anonymous user account with tickets.
195196
func New(opts ConnectionOptions) (*Connection, error) {
196197
con := new(Connection)
197198

@@ -233,9 +234,34 @@ func New(opts ConnectionOptions) (*Connection, error) {
233234
return nil, newError(Fatal, fmt.Sprintf("iRods Connect Failed: %v", C.GoString(errMsg)))
234235
}
235236

237+
if con.Options.Ticket != "" {
238+
if err := con.SetTicket(con.Options.Ticket); err != nil {
239+
return nil, err
240+
}
241+
}
242+
236243
return con, nil
237244
}
238245

246+
// SetTicket is equivalent to using the -t flag with icommands
247+
func (con *Connection) SetTicket(t string) error {
248+
var (
249+
status C.int
250+
errMsg *C.char
251+
)
252+
253+
con.Options.Ticket = t
254+
255+
ticket := C.CString(t)
256+
defer C.free(unsafe.Pointer(ticket))
257+
258+
if status = C.gorods_set_session_ticket(con.ccon, ticket, &errMsg); status != 0 {
259+
return newError(Fatal, fmt.Sprintf("iRods Set Ticket Failed: %v", C.GoString(errMsg)))
260+
}
261+
262+
return nil
263+
}
264+
239265
// Disconnect closes connection to iRods iCAT server, returns error on failure or nil on success
240266
func (con *Connection) Disconnect() error {
241267
if status := int(C.rcDisconnect(con.ccon)); status < 0 {

lib/build/libgorods.a

1.13 KB
Binary file not shown.

lib/include/wrapper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ int gorods_meta_collection(char *name, char *cwd, goRodsMetaResult_t* result, rc
5353
int gorods_mod_meta(char* type, char* path, char* oa, char* ov, char* ou, char* na, char* nv, char* nu, rcComm_t* conn, char** err);
5454
int gorods_add_meta(char* type, char* path, char* na, char* nv, char* nu, rcComm_t* conn, char** err);
5555
int gorods_rm_meta(char* type, char* path, char* oa, char* ov, char* ou, rcComm_t* conn, char** err);
56+
int gorods_set_session_ticket(rcComm_t *myConn, char *ticket, char** err);
5657

5758
int gorodsclearCollEnt( collEnt_t *collEnt );
5859
int gorodsFreeCollEnt( collEnt_t *collEnt );

lib/wrapper.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,26 @@ int gorods_connect(rcComm_t** conn, char* password, char** err) {
4747
return 0;
4848
}
4949

50+
int gorods_set_session_ticket(rcComm_t *myConn, char *ticket, char** err) {
51+
ticketAdminInp_t ticketAdminInp;
52+
int status;
53+
54+
ticketAdminInp.arg1 = "session";
55+
ticketAdminInp.arg2 = ticket;
56+
ticketAdminInp.arg3 = "";
57+
ticketAdminInp.arg4 = "";
58+
ticketAdminInp.arg5 = "";
59+
ticketAdminInp.arg6 = "";
60+
61+
status = rcTicketAdmin( myConn, &ticketAdminInp );
62+
63+
if ( status != 0 ) {
64+
sprintf(*err, "set ticket error %d \n", status);
65+
}
66+
67+
return status;
68+
}
69+
5070
int gorods_connect_env(rcComm_t** conn, char* host, int port, char* username, char* zone, char* password, char** err) {
5171
int status;
5272

0 commit comments

Comments
 (0)