Skip to content

Commit bb6a2ee

Browse files
committed
More external authentication changes
1 parent 8a1d1ca commit bb6a2ee

File tree

6 files changed

+36
-15
lines changed

6 files changed

+36
-15
lines changed

src/dpi/include/dpiException.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ enum DpiError // error type
4949
DpiErrNoEnv = 003, // "No OCI environment handle created"
5050
DpiErrInvalidState = 004, // "Invalid state while working with timestamp"
5151
DpiErrUninitialized = 005, // "Uninitialized state while working with timestamp"
52+
DpiErrPasswdExtAuth = 006, // "password specified with external authentication"
5253
};
5354

5455

src/dpi/src/dpiConnImpl.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
# include <dpiUtils.h>
4343
#endif
4444

45+
#ifndef DPIEXCEPTIONIMPL_ORACLE
46+
# include <dpiExceptionImpl.h>
47+
#endif
48+
4549
#include <iostream>
4650

4751
using namespace std;
@@ -88,7 +92,12 @@ try : env_(env), pool_(NULL),
8892
ociCallEnv(OCIHandleAlloc((void *)envh_, (dvoid **)&auth_,
8993
OCI_HTYPE_AUTHINFO, 0, (dvoid **)0), envh_);
9094

91-
if (!isExternalAuth)
95+
if (isExternalAuth)
96+
{
97+
if (password.length())
98+
throw ExceptionImpl(DpiErrPasswdExtAuth);
99+
}
100+
else
92101
{
93102
ociCall(OCIAttrSet((void *)auth_, OCI_HTYPE_AUTHINFO,
94103
(void *)user.data(), (ub4) user.length(),
@@ -228,8 +237,10 @@ void ConnImpl::release()
228237
ociCall(OCIAttrGet(sessh_, OCI_HTYPE_SESSION, &hasTxn_, NULL,
229238
OCI_ATTR_TRANSACTION_IN_PROGRESS, errh_), errh_);
230239
#endif
240+
231241
if(hasTxn_)
232242
rollback();
243+
233244
if (pool_)
234245
pool_->releaseConnection(this);
235246
else if (env_)

src/dpi/src/dpiExceptionImpl.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,18 @@ using namespace std;
4444
PRIVATE DATA
4545
---------------------------------------------------------------------------*/
4646

47+
// don't forget to add comma for previously last message after you add a new
48+
// error message
49+
4750
static const char *dpiErrors[] =
4851
{
4952
"not an error", // DpiErrNoError
5053
"internal error", // DpiErrInternal
5154
"could not get OCI error message", // DpiErrUnkOciError
52-
"no OCI environment handle created" // DpiErrNoEnv
53-
"invalid state while working with timestamp" // DpiErrInvalidState
54-
"uninitialized state while working with timestamp" // DpiErrUninitialized
55+
"no OCI environment handle created", // DpiErrNoEnv
56+
"invalid state while working with timestamp", // DpiErrInvalidState
57+
"uninitialized state while working with timestamp", // DpiErrUninitialized
58+
"password specified with external authentication" // DpiErrPasswdExtAuth
5559
};
5660

5761

src/dpi/src/dpiPoolImpl.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ using namespace std;
6060

6161

6262
/*****************************************************************************/
63-
/*
63+
/*
6464
DESCRIPTION
6565
Constructor for the PoolImpl class.
6666
@@ -95,6 +95,9 @@ PoolImpl::PoolImpl(EnvImpl *env, OCIEnv *envh,
9595

9696
unsigned char spoolMode = OCI_SPOOL_ATTRVAL_NOWAIT; // spoolMode is a ub1
9797

98+
if (isExternalAuth && password.length())
99+
throw ExceptionImpl(DpiErrPasswdExtAuth);
100+
98101
ociCallEnv(OCIHandleAlloc((void *)envh_, (dvoid **)&errh_,
99102
OCI_HTYPE_ERROR, 0, (dvoid **)0), envh_);
100103

src/njs/src/njsOracle.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ void Oracledb::SetConnectionClass (Local<String> property, Local<Value> value,
441441
DESCRIPTION
442442
Get Accessor of isExternalAuth property
443443
*/
444-
Handle<Value> Oracledb::GetIsExternalAuth ( Local<String> property,
444+
Handle<Value> Oracledb::GetIsExternalAuth(Local<String> property,
445445
const AccessorInfo& info )
446446
{
447447
HandleScope scope;
@@ -451,12 +451,13 @@ Handle<Value> Oracledb::GetIsExternalAuth ( Local<String> property,
451451
return scope.Close(value);
452452
}
453453

454+
454455
/*****************************************************************************/
455456
/*
456457
DESCRIPTION
457458
Set Accessor of isExternalAuth property
458459
*/
459-
void Oracledb::SetIsExternalAuth ( Local<String> property, Local<Value> value,
460+
void Oracledb::SetIsExternalAuth(Local<String> property, Local<Value> value,
460461
const AccessorInfo& info )
461462
{
462463
HandleScope scope;
@@ -496,16 +497,17 @@ Handle<Value> Oracledb::GetConnection(const Arguments& args)
496497
NJS_GET_STRING_FROM_JSON ( connBaton->connStr, connBaton->error,
497498
connProps, "connectString", 0, exitGetConnection );
498499

499-
connBaton->stmtCacheSize = oracledb->stmtCacheSize_;
500500
connBaton->connClass = oracledb->connClass_;
501-
connBaton->isExternalAuth = oracledb->isExternalAuth_;
502501

503-
// the above properties may be overriden if provided as call parameters
502+
// the following properties will be overriden if provided as call parameters
503+
504+
connBaton->stmtCacheSize = oracledb->stmtCacheSize_;
505+
connBaton->isExternalAuth = oracledb->isExternalAuth_;
504506

505507
NJS_GET_UINT_FROM_JSON ( connBaton->stmtCacheSize, connBaton->error,
506508
connProps, "stmtCacheSize", 0, exitGetConnection );
507-
NJS_GET_BOOL_FROM_JSON ( connBaton->isExternalAuth, connBaton->error,
508-
connProps, "isExternalAuth", 0, exitGetConnection );
509+
NJS_GET_BOOL_FROM_JSON ( connBaton->isExternalAuth, connBaton->error,
510+
connProps, "isExternalAuth", 0, exitGetConnection );
509511

510512
connBaton->oracledb = oracledb;
511513
connBaton->dpienv = oracledb->dpienv_;

src/njs/src/njsOracle.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class Oracledb: public ObjectWrap
103103
static Handle<Value> GetConnectionClass (Local<String> property,
104104
const AccessorInfo& info );
105105
static Handle<Value> GetIsExternalAuth(Local<String> property,
106-
const AccessorInfo& info);
106+
const AccessorInfo& info);
107107

108108
// Define Setter Accessors to Properties
109109
static void SetPoolMin(Local<String> property,Local<Value> value,
@@ -127,7 +127,7 @@ class Oracledb: public ObjectWrap
127127
static void SetConnectionClass (Local<String> property, Local<Value> value,
128128
const AccessorInfo& info );
129129
static void SetIsExternalAuth(Local<String> property,Local<Value> value,
130-
const AccessorInfo& info);
130+
const AccessorInfo& info);
131131

132132

133133
Oracledb();
@@ -180,7 +180,7 @@ typedef struct connectionBaton
180180
Oracledb *oracledb;
181181

182182
connectionBaton() : user(""), pswrd(""), connStr(""), connClass(""),
183-
isExternalAuth(false), error("" ),
183+
isExternalAuth(false), error(""),
184184
poolMax(0), poolMin(0), poolIncrement(0),
185185
poolTimeout(0), stmtCacheSize(0), maxRows(0),
186186
outFormat(0), dpienv(NULL),

0 commit comments

Comments
 (0)