Added getUser method
@@ -22,6 +22,7 @@ package com.orientechnologies.orient.server.network.protocol.http.command;
import com.orientechnologies.orient.server.config.OServerConfiguration;
import com.orientechnologies.orient.server.network.protocol.http.OHttpRequest;
import com.orientechnologies.orient.server.network.protocol.http.OHttpResponse;
+import com.orientechnologies.orient.server.network.protocol.http.OHttpSession;
import com.orientechnologies.orient.server.network.protocol.http.OHttpUtils;
import java.io.IOException;
@@ -109,8 +110,29 @@ public abstract class OServerCommandAuthenticatedServerAbstract extends OServerC
sendJsonError(iResponse, OHttpUtils.STATUS_AUTH_CODE, OHttpUtils.STATUS_AUTH_DESCRIPTION, OHttpUtils.CONTENT_TEXT_PLAIN,
"401 Unauthorized.", header);
} else {
- iResponse.send(OHttpUtils.STATUS_AUTH_CODE, OHttpUtils.STATUS_AUTH_DESCRIPTION, OHttpUtils.CONTENT_TEXT_PLAIN,
- "401 Unauthorized.", header);
+ iResponse
+ .send(OHttpUtils.STATUS_AUTH_CODE, OHttpUtils.STATUS_AUTH_DESCRIPTION, OHttpUtils.CONTENT_TEXT_PLAIN, "401 Unauthorized.",
+ header);
+ }
+ }
+
+ public String getUser(final OHttpRequest iRequest) {
+ OHttpSession session = server.getHttpSessionManager().getSession(iRequest.sessionId);
+ if (session != null) {
+ return session.getUserName();
+ }
+ if (iRequest.authorization != null) {
+ // GET CREDENTIALS
+ final String[] authParts = iRequest.authorization.split(":");
+ if (authParts.length == 2) {
+ return authParts[0];
+ }
}
+ return null;
+
+ }
+
+ public String getResource() {
+ return resource;
}
}
