|
|
@ -38,8 +38,6 @@ import org.apache.http.entity.ContentType;
|
|
|
|
import org.apache.http.entity.StringEntity;
|
|
|
|
import org.apache.http.entity.StringEntity;
|
|
|
|
import org.apache.http.protocol.HTTP;
|
|
|
|
import org.apache.http.protocol.HTTP;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.ProxyResponse;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.ProxyResponse;
|
|
|
|
import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.annotation.MultipartConfig;
|
|
|
|
import javax.servlet.annotation.MultipartConfig;
|
|
|
|
import javax.servlet.annotation.WebServlet;
|
|
|
|
import javax.servlet.annotation.WebServlet;
|
|
|
@ -66,11 +64,6 @@ public class LoginHandler extends HttpServlet {
|
|
|
|
protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
|
|
|
|
protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
validateLoginRequest(req, resp);
|
|
|
|
validateLoginRequest(req, resp);
|
|
|
|
DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance()
|
|
|
|
|
|
|
|
.getDeviceManagementConfig();
|
|
|
|
|
|
|
|
String adminUsername = deviceManagementConfig.getIdentityConfigurations().getAdminUsername();
|
|
|
|
|
|
|
|
String adminPwd = deviceManagementConfig.getIdentityConfigurations().getAdminPassword();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HttpSession httpSession = req.getSession(false);
|
|
|
|
HttpSession httpSession = req.getSession(false);
|
|
|
|
if (httpSession != null) {
|
|
|
|
if (httpSession != null) {
|
|
|
|
httpSession.invalidate();
|
|
|
|
httpSession.invalidate();
|
|
|
@ -120,7 +113,7 @@ public class LoginHandler extends HttpServlet {
|
|
|
|
// default login
|
|
|
|
// default login
|
|
|
|
HttpPost apiRegEndpoint = new HttpPost(serverUrl + HandlerConstants.APP_REG_ENDPOINT);
|
|
|
|
HttpPost apiRegEndpoint = new HttpPost(serverUrl + HandlerConstants.APP_REG_ENDPOINT);
|
|
|
|
apiRegEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder()
|
|
|
|
apiRegEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder()
|
|
|
|
.encodeToString((adminUsername + HandlerConstants.COLON + adminPwd).getBytes()));
|
|
|
|
.encodeToString((username + HandlerConstants.COLON + password).getBytes()));
|
|
|
|
apiRegEndpoint.setHeader(HTTP.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString());
|
|
|
|
apiRegEndpoint.setHeader(HTTP.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString());
|
|
|
|
apiRegEndpoint.setEntity(constructAppRegPayload(tags));
|
|
|
|
apiRegEndpoint.setEntity(constructAppRegPayload(tags));
|
|
|
|
|
|
|
|
|
|
|
|