@@ -221,7 +221,7 @@ protected void writeCookies(BaseResponse response, HttpResponse responseObj) {
221221 }
222222
223223 public static class AuthorizationInfo {
224- public String user ;
224+ public String fullUserName ;
225225 public String password ;
226226 public String cluster ;
227227 }
@@ -246,13 +246,14 @@ public boolean parseAuth(BaseRequest request, AuthorizationInfo authInfo) {
246246 // Note that password may contain colon, so can not simply use a
247247 // colon to split.
248248 int index = authString .indexOf (":" );
249- authInfo .user = authString .substring (0 , index );
250- final String [] elements = authInfo .user .split ("@" );
249+ authInfo .fullUserName = authString .substring (0 , index );
250+ final String [] elements = authInfo .fullUserName .split ("@" );
251251 if (elements != null && elements .length < 2 ) {
252- authInfo .user = ClusterNamespace .getUserFullName (SystemInfoService .DEFAULT_CLUSTER , authInfo .user );
252+ authInfo .fullUserName = ClusterNamespace .getUserFullName (SystemInfoService .DEFAULT_CLUSTER ,
253+ authInfo .fullUserName );
253254 authInfo .cluster = SystemInfoService .DEFAULT_CLUSTER ;
254255 } else if (elements != null && elements .length == 2 ) {
255- authInfo .user = ClusterNamespace .getUserFullName (elements [1 ], elements [0 ]);
256+ authInfo .fullUserName = ClusterNamespace .getUserFullName (elements [1 ], elements [0 ]);
256257 authInfo .cluster = elements [1 ];
257258 }
258259 authInfo .password = authString .substring (index + 1 );
@@ -272,10 +273,10 @@ private AuthorizationInfo checkAndGetUser(BaseRequest request) throws DdlExcepti
272273 if (!parseAuth (request , authInfo )) {
273274 throw new UnauthorizedException ("Need auth information." );
274275 }
275- byte [] hashedPasswd = catalog .getUserMgr ().getPassword (authInfo .user );
276+ byte [] hashedPasswd = catalog .getUserMgr ().getPassword (authInfo .fullUserName );
276277 if (hashedPasswd == null ) {
277278 // No such user
278- throw new DdlException ("No such user(" + authInfo .user + ")" );
279+ throw new DdlException ("No such user(" + authInfo .fullUserName + ")" );
279280 }
280281 if (!MysqlPassword .checkPlainPass (hashedPasswd , authInfo .password )) {
281282 throw new DdlException ("Password error" );
@@ -285,21 +286,19 @@ private AuthorizationInfo checkAndGetUser(BaseRequest request) throws DdlExcepti
285286
286287 protected void checkAdmin (BaseRequest request ) throws DdlException {
287288 final AuthorizationInfo authInfo = checkAndGetUser (request );
288- if (!catalog .getUserMgr ().isAdmin (authInfo .user )) {
289+ if (!catalog .getUserMgr ().isAdmin (authInfo .fullUserName )) {
289290 throw new DdlException ("Administrator needed" );
290291 }
291292 }
292293
293- protected void checkReadPriv (BaseRequest request , String db ) throws DdlException {
294- final AuthorizationInfo authInfo = checkAndGetUser (request );
295- if (!catalog .getUserMgr ().checkAccess (authInfo .user , db , AccessPrivilege .READ_ONLY )) {
294+ protected void checkReadPriv (String fullUserName , String fullDbName ) throws DdlException {
295+ if (!catalog .getUserMgr ().checkAccess (fullUserName , fullDbName , AccessPrivilege .READ_ONLY )) {
296296 throw new DdlException ("Read Privilege needed" );
297297 }
298298 }
299299
300- protected void checkWritePriv (BaseRequest request , String db ) throws DdlException {
301- final AuthorizationInfo authInfo = checkAndGetUser (request );
302- if (!catalog .getUserMgr ().checkAccess (authInfo .user , db , AccessPrivilege .READ_WRITE )) {
300+ protected void checkWritePriv (String fullUserName , String fullDbName ) throws DdlException {
301+ if (!catalog .getUserMgr ().checkAccess (fullUserName , fullDbName , AccessPrivilege .READ_WRITE )) {
303302 throw new DdlException ("Write Privilege needed" );
304303 }
305304 }
0 commit comments