fixing formatting issues

merge-requests/1/head
Hasunie 7 years ago
parent 70f971cc26
commit 54e5fad42a

@ -352,12 +352,10 @@ public final class PluginConstants {
private WindowsEnrollmentProperties() { private WindowsEnrollmentProperties() {
throw new AssertionError(); throw new AssertionError();
} }
public static final String DEVICE_NAME = "DeviceName"; public static final String DEVICE_NAME = "DeviceName";
public static final String DEVICE_VERSION = "OSVersion"; public static final String DEVICE_VERSION = "OSVersion";
public static final String DEVICE_ID = "DeviceID"; public static final String DEVICE_ID = "DeviceID";
public static final String IMEI = "MobileEquipmentId"; public static final String IMEI = "MobileEquipmentId";
public static final String TYPE = "DeviceType"; public static final String TYPE = "DeviceType";
} }
} }

@ -43,6 +43,7 @@ public class StatusTag {
this.targetReference = targetReference; this.targetReference = targetReference;
this.data = data; this.data = data;
} }
public StatusTag(int commandId, int messageReference, int commandReference, String command, public StatusTag(int commandId, int messageReference, int commandReference, String command,
ChallengeTag challengeTag, String targetReference, String data) { ChallengeTag challengeTag, String targetReference, String data) {
this.commandId = commandId; this.commandId = commandId;
@ -142,15 +143,12 @@ public class StatusTag {
status.appendChild(targetReference); status.appendChild(targetReference);
} }
if (getChallenge() != null) { if (getChallenge() != null) {
getChallenge().buildChallengeElement(doc, status); getChallenge().buildChallengeElement(doc, status);
} }
if (getData() != null) { if (getData() != null) {
Element data = doc.createElement(Constants.DATA); Element data = doc.createElement(Constants.DATA);
data.appendChild(doc.createTextNode(getData())); data.appendChild(doc.createTextNode(getData()));
status.appendChild(data); status.appendChild(data);
} }
} }
} }

@ -244,10 +244,8 @@ public class OperationHandler {
updateStatus(deviceIdentifier.getId(), pendingDeviceInfoOperations); updateStatus(deviceIdentifier.getId(), pendingDeviceInfoOperations);
} }
} }
} }
public void updateDeviceInfoStatus(DeviceIdentifier deviceIdentifier) throws OperationManagementException { public void updateDeviceInfoStatus(DeviceIdentifier deviceIdentifier) throws OperationManagementException {
List<? extends Operation> pendingDeviceInfoOperations; List<? extends Operation> pendingDeviceInfoOperations;
try { try {
@ -669,14 +667,12 @@ public class OperationHandler {
public void checkForDeviceWipe(List<? extends Operation> pendingDeviceInfoOperations public void checkForDeviceWipe(List<? extends Operation> pendingDeviceInfoOperations
, DeviceIdentifier deviceIdentifier) throws OperationManagementException { , DeviceIdentifier deviceIdentifier) throws OperationManagementException {
for (Operation operation : pendingDeviceInfoOperations) { for (Operation operation : pendingDeviceInfoOperations) {
if (PluginConstants.OperationCodes.WIPE_DATA.equals(operation.getCode())) { if (PluginConstants.OperationCodes.WIPE_DATA.equals(operation.getCode())) {
operation.setStatus(Operation.Status.COMPLETED); operation.setStatus(Operation.Status.COMPLETED);
updateStatus(deviceIdentifier.getId(), pendingDeviceInfoOperations); updateStatus(deviceIdentifier.getId(), pendingDeviceInfoOperations);
} }
} }
} }
} }

@ -161,7 +161,6 @@ public class OperationReply {
} }
private SyncmlBody generateStatuses() { private SyncmlBody generateStatuses() {
SyncmlBody sourceSyncmlBody = syncmlDocument.getBody(); SyncmlBody sourceSyncmlBody = syncmlDocument.getBody();
SyncmlHeader sourceHeader = syncmlDocument.getHeader(); SyncmlHeader sourceHeader = syncmlDocument.getHeader();
StatusTag headerStatus; StatusTag headerStatus;
@ -183,7 +182,6 @@ public class OperationReply {
} else { } else {
for (StatusTag sourceStatus : sourceStatuses) { for (StatusTag sourceStatus : sourceStatuses) {
if (sourceStatus.getChallenge() != null && HEADER_COMMAND_TEXT.equals(sourceStatus.getCommand())) { if (sourceStatus.getChallenge() != null && HEADER_COMMAND_TEXT.equals(sourceStatus.getCommand())) {
headerStatus = headerStatus =
new StatusTag(headerCommandId, sourceHeader.getMsgID(), HEADER_STATUS_ID, new StatusTag(headerCommandId, sourceHeader.getMsgID(), HEADER_STATUS_ID,
HEADER_COMMAND_TEXT, challengeTag, sourceHeader.getSource().getLocURI(), HEADER_COMMAND_TEXT, challengeTag, sourceHeader.getSource().getLocURI(),
@ -239,7 +237,6 @@ public class OperationReply {
private void appendOperations(SyncmlBody syncmlBody) throws PolicyManagementException, private void appendOperations(SyncmlBody syncmlBody) throws PolicyManagementException,
FeatureManagementException, JSONException, SyncmlOperationException { FeatureManagementException, JSONException, SyncmlOperationException {
GetTag getElement = new GetTag(); GetTag getElement = new GetTag();
List<ItemTag> getElements = new ArrayList<>(); List<ItemTag> getElements = new ArrayList<>();
List<ExecuteTag> executeElements = new ArrayList<>(); List<ExecuteTag> executeElements = new ArrayList<>();

@ -100,7 +100,6 @@ public class EnrollmentServiceImpl implements EnrollmentService {
AdditionalContext additionalContext, AdditionalContext additionalContext,
Holder<RequestSecurityTokenResponse> response) Holder<RequestSecurityTokenResponse> response)
throws WindowsDeviceEnrolmentException, UnsupportedEncodingException, WAPProvisioningException { throws WindowsDeviceEnrolmentException, UnsupportedEncodingException, WAPProvisioningException {
String headerBinarySecurityToken = null; String headerBinarySecurityToken = null;
String headerTo = null; String headerTo = null;
String encodedWap; String encodedWap;
@ -221,14 +220,12 @@ public class EnrollmentServiceImpl implements EnrollmentService {
String signedCertEncodedString; String signedCertEncodedString;
X509Certificate signedCertificate; X509Certificate signedCertificate;
String provisioningXmlString; String provisioningXmlString;
CertificateManagementServiceImpl certMgtServiceImpl = CertificateManagementServiceImpl.getInstance(); CertificateManagementServiceImpl certMgtServiceImpl = CertificateManagementServiceImpl.getInstance();
Base64 base64Encoder = new Base64(); Base64 base64Encoder = new Base64();
try { try {
X509Certificate rootCACertificate = (X509Certificate) certMgtServiceImpl.getCACertificate(); X509Certificate rootCACertificate = (X509Certificate) certMgtServiceImpl.getCACertificate();
rootCertEncodedString = base64Encoder.encodeAsString(rootCACertificate.getEncoded()); rootCertEncodedString = base64Encoder.encodeAsString(rootCACertificate.getEncoded());
signedCertificate = certMgtServiceImpl.getSignedCertificateFromCSR(binarySecurityToken); signedCertificate = certMgtServiceImpl.getSignedCertificateFromCSR(binarySecurityToken);
signedCertEncodedString = base64Encoder.encodeAsString(signedCertificate.getEncoded()); signedCertEncodedString = base64Encoder.encodeAsString(signedCertificate.getEncoded());
@ -313,7 +310,6 @@ public class EnrollmentServiceImpl implements EnrollmentService {
Node pollValue = pollingAttributes.getNamedItem(PluginConstants.CertificateEnrolment.VALUE); Node pollValue = pollingAttributes.getNamedItem(PluginConstants.CertificateEnrolment.VALUE);
pollValue.setTextContent(pollingFrequency); pollValue.setTextContent(pollingFrequency);
provisioningXmlString = convertDocumentToString(document); provisioningXmlString = convertDocumentToString(document);
} catch (ParserConfigurationException e) { } catch (ParserConfigurationException e) {
throw new WAPProvisioningException("Problem occurred while creating configuration request", e); throw new WAPProvisioningException("Problem occurred while creating configuration request", e);
} catch (CertificateEncodingException e) { } catch (CertificateEncodingException e) {

@ -89,20 +89,16 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
(PluginConstants.SyncML.SYNCML_FIRST_SESSION_ID == sessionId)) { (PluginConstants.SyncML.SYNCML_FIRST_SESSION_ID == sessionId)) {
if (syncmlHeader.getCredential() != null) { if (syncmlHeader.getCredential() != null) {
token = syncmlHeader.getCredential().getData(); token = syncmlHeader.getCredential().getData();
MobileCacheEntry cacheToken = DeviceUtil.getTokenEntry(token); MobileCacheEntry cacheToken = DeviceUtil.getTokenEntry(token);
DeviceUtil.persistChallengeToken(token, deviceIdentifier.getId(), user); DeviceUtil.persistChallengeToken(token, deviceIdentifier.getId(), user);
PrivilegedCarbonContext carbonCtx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); PrivilegedCarbonContext carbonCtx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
carbonCtx.setTenantId(cacheToken.getTenanatID(), true); carbonCtx.setTenantId(cacheToken.getTenanatID(), true);
if ((cacheToken.getUsername() != null) && (cacheToken.getUsername().equals(user))) { if ((cacheToken.getUsername() != null) && (cacheToken.getUsername().equals(user))) {
if (modifyEnrollWithMoreDetail(request, cacheToken.getTenantDomain(), cacheToken.getTenanatID())) { if (modifyEnrollWithMoreDetail(request, cacheToken.getTenantDomain(), cacheToken.getTenanatID())) {
pendingOperations = operationHandler.getPendingOperations(syncmlDocument); pendingOperations = operationHandler.getPendingOperations(syncmlDocument);
operationHandler.checkForDeviceWipe(pendingOperations, deviceIdentifier); operationHandler.checkForDeviceWipe(pendingOperations, deviceIdentifier);
response = operationReply.generateReply(syncmlDocument, pendingOperations); response = operationReply.generateReply(syncmlDocument, pendingOperations);
return Response.status(Response.Status.OK).entity(response).build(); return Response.status(Response.Status.OK).entity(response).build();
} else { } else {
String msg = "Error occurred in while modify the enrollment."; String msg = "Error occurred in while modify the enrollment.";
log.error(msg); log.error(msg);
@ -113,7 +109,6 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
log.error(msg); log.error(msg);
return Response.status(Response.Status.UNAUTHORIZED).entity(msg).build(); return Response.status(Response.Status.UNAUTHORIZED).entity(msg).build();
} }
} else { } else {
return Response.ok().entity(operationReply.generateReply(syncmlDocument, null)).build(); return Response.ok().entity(operationReply.generateReply(syncmlDocument, null)).build();
} }
@ -121,7 +116,6 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
if (DeviceUtil.getTokenEntryFromDeviceId(deviceIdentifier.getId()) == null) { if (DeviceUtil.getTokenEntryFromDeviceId(deviceIdentifier.getId()) == null) {
if (syncmlHeader.getCredential() != null) { if (syncmlHeader.getCredential() != null) {
token = syncmlHeader.getCredential().getData(); token = syncmlHeader.getCredential().getData();
MobileCacheEntry cacheToken = DeviceUtil.getTokenEntry(token); MobileCacheEntry cacheToken = DeviceUtil.getTokenEntry(token);
DeviceUtil.persistChallengeToken(token, deviceIdentifier.getId(), user); DeviceUtil.persistChallengeToken(token, deviceIdentifier.getId(), user);
PrivilegedCarbonContext carbonCtx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); PrivilegedCarbonContext carbonCtx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
@ -193,7 +187,6 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
boolean status = false; boolean status = false;
String user; String user;
SyncmlDocument syncmlDocument; SyncmlDocument syncmlDocument;
try { try {
syncmlDocument = SyncmlParser.parseSyncmlPayload(request); syncmlDocument = SyncmlParser.parseSyncmlPayload(request);
ReplaceTag replace = syncmlDocument.getBody().getReplace(); ReplaceTag replace = syncmlDocument.getBody().getReplace();

Loading…
Cancel
Save