mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
fixing windows plugin relalted slf4j issue
This commit is contained in:
parent
97eac5064e
commit
86056df434
@ -260,6 +260,17 @@
|
|||||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.webapp.authenticator.framework</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.wso2.carbon.identity</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.identity.base</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.wso2.carbon.identity</groupId>
|
<groupId>org.wso2.carbon.identity</groupId>
|
||||||
<artifactId>org.wso2.carbon.identity.oauth.stub</artifactId>
|
<artifactId>org.wso2.carbon.identity.oauth.stub</artifactId>
|
||||||
@ -281,6 +292,12 @@
|
|||||||
<artifactId>cache-api</artifactId>
|
<artifactId>cache-api</artifactId>
|
||||||
<version>0.5</version>
|
<version>0.5</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
@ -318,6 +335,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.swagger</groupId>
|
<groupId>io.swagger</groupId>
|
||||||
<artifactId>swagger-annotations</artifactId>
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
@ -28,11 +28,9 @@ public final class PluginConstants {
|
|||||||
public static final String DISCOVERY_SERVICE_ENDPOINT =
|
public static final String DISCOVERY_SERVICE_ENDPOINT =
|
||||||
"org.wso2.carbon.mdm.mobileservices.windows.services.discovery.DiscoveryService";
|
"org.wso2.carbon.mdm.mobileservices.windows.services.discovery.DiscoveryService";
|
||||||
public static final String CERTIFICATE_ENROLLMENT_SERVICE_ENDPOINT =
|
public static final String CERTIFICATE_ENROLLMENT_SERVICE_ENDPOINT =
|
||||||
"org.wso2.carbon.mdm.mobileservices.windows.services.wstep" +
|
"org.wso2.carbon.mdm.mobileservices.windows.services.wstep.CertificateEnrollmentService";
|
||||||
".CertificateEnrollmentService";
|
|
||||||
public static final String CERTIFICATE_ENROLLMENT_POLICY_SERVICE_ENDPOINT =
|
public static final String CERTIFICATE_ENROLLMENT_POLICY_SERVICE_ENDPOINT =
|
||||||
"org.wso2.carbon.mdm.mobileservices.windows.services.xcep" +
|
"org.wso2.carbon.mdm.mobileservices.windows.services.xcep.CertificateEnrollmentPolicyService";
|
||||||
".CertificateEnrollmentPolicyService";
|
|
||||||
|
|
||||||
//Services' target namespaces
|
//Services' target namespaces
|
||||||
public static final String DISCOVERY_SERVICE_TARGET_NAMESPACE =
|
public static final String DISCOVERY_SERVICE_TARGET_NAMESPACE =
|
||||||
@ -60,11 +58,11 @@ public final class PluginConstants {
|
|||||||
|
|
||||||
//Servlet Context attributes names
|
//Servlet Context attributes names
|
||||||
public static final String CONTEXT_WAP_PROVISIONING_FILE = "WAP_PROVISIONING_FILE";
|
public static final String CONTEXT_WAP_PROVISIONING_FILE = "WAP_PROVISIONING_FILE";
|
||||||
public static final String WINDOWS_PLUGIN_PROPERTIES = "WINDOWS_PLUGIN_PROPERTIES";
|
|
||||||
|
|
||||||
//Message handler constants
|
//Message handler constants
|
||||||
public static final String CONTENT_LENGTH = "Content-Length";
|
public static final String CONTENT_LENGTH = "Content-Length";
|
||||||
public static final String SECURITY = "Security";
|
public static final String SECURITY = "Security";
|
||||||
|
public static final String TO = "To";
|
||||||
public static final String CXF_REQUEST_URI = "org.apache.cxf.request.uri";
|
public static final String CXF_REQUEST_URI = "org.apache.cxf.request.uri";
|
||||||
|
|
||||||
//Web services media types
|
//Web services media types
|
||||||
@ -78,20 +76,16 @@ public final class PluginConstants {
|
|||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String ENROLL_SUBDOMAIN = "https://EnterpriseEnrollment.";
|
public static final String DEVICE_ENROLLMENT_SUBDOMAIN = "https://EnterpriseEnrollment.";
|
||||||
public static final String CERTIFICATE_ENROLLMENT_POLICY_SERVICE_URL =
|
public static final String CERTIFICATE_ENROLLMENT_POLICY_SERVICE_URL =
|
||||||
"/ENROLLMENTSERVER/PolicyEnrollmentWebservice" +
|
"/ENROLLMENTSERVER/PolicyEnrollmentWebservice.svc";
|
||||||
".svc";
|
|
||||||
public static final String CERTIFICATE_ENROLLMENT_SERVICE_URL =
|
public static final String CERTIFICATE_ENROLLMENT_SERVICE_URL =
|
||||||
"/ENROLLMENTSERVER/DeviceEnrollmentWebservice" +
|
"/ENROLLMENTSERVER/DeviceEnrollmentWebservice.svc";
|
||||||
".svc";
|
|
||||||
public static final String ONPREMISE_CERTIFICATE_ENROLLMENT_POLICY =
|
public static final String ONPREMISE_CERTIFICATE_ENROLLMENT_POLICY =
|
||||||
"/ENROLLMENTSERVER/ONPREMISE/" +
|
"/ENROLLMENTSERVER/ONPREMISE/PolicyEnrollmentWebservice.svc";
|
||||||
"PolicyEnrollmentWebservice.svc";
|
|
||||||
public static final String ONPREMISE_CERTIFICATE_ENROLLMENT_SERVICE_URL =
|
public static final String ONPREMISE_CERTIFICATE_ENROLLMENT_SERVICE_URL =
|
||||||
"/ENROLLMENTSERVER/ONPREMISE/DeviceEnrollmentWebservice.svc";
|
"/ENROLLMENTSERVER/ONPREMISE/DeviceEnrollmentWebservice.svc";
|
||||||
public static final String WAB_URL = "/mdm/enrollments/windows/login-agent";
|
public static final String WAB_URL = "/emm-web-agent/enrollments/windows/login-agent";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,7 +107,7 @@ public final class PluginConstants {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Certificate enrollment Service related constants
|
* Certificate enrollment Service related constants.
|
||||||
*/
|
*/
|
||||||
public final class CertificateEnrolment {
|
public final class CertificateEnrolment {
|
||||||
private CertificateEnrolment() {
|
private CertificateEnrolment() {
|
||||||
@ -121,17 +115,14 @@ public final class PluginConstants {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final String TOKEN_TYPE =
|
public static final String TOKEN_TYPE =
|
||||||
"http://schemas.microsoft.com/5.0.0" +
|
"http://schemas.microsoft.com/5.0.0.0/ConfigurationManager/Enrollment/DeviceEnrollmentToken";
|
||||||
".0/ConfigurationManager/Enrollment/DeviceEnrollmentToken";
|
|
||||||
public static final String PARM = "parm";
|
public static final String PARM = "parm";
|
||||||
public static final String TYPE = "type";
|
public static final String TYPE = "type";
|
||||||
public static final String VALUE = "value";
|
public static final String VALUE = "value";
|
||||||
public static final String VALUE_TYPE =
|
public static final String VALUE_TYPE =
|
||||||
"http://schemas.microsoft.com/5.0.0" +
|
"http://schemas.microsoft.com/5.0.0.0/ConfigurationManager/Enrollment/DeviceEnrollmentProvisionDoc";
|
||||||
".0/ConfigurationManager/Enrollment/DeviceEnrollmentProvisionDoc";
|
|
||||||
public static final String ENCODING_TYPE =
|
public static final String ENCODING_TYPE =
|
||||||
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0" +
|
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd#base64binary";
|
||||||
".xsd#base64binary";
|
|
||||||
public static final String CA_CERT = "cacert";
|
public static final String CA_CERT = "cacert";
|
||||||
public static final String X_509 = "X.509";
|
public static final String X_509 = "X.509";
|
||||||
public static final String PROPERTIES_XML = "properties.xml";
|
public static final String PROPERTIES_XML = "properties.xml";
|
||||||
@ -141,8 +132,7 @@ public final class PluginConstants {
|
|||||||
public static final String JKS = "JKS";
|
public static final String JKS = "JKS";
|
||||||
public static final String SECURITY = "Security";
|
public static final String SECURITY = "Security";
|
||||||
public static final String WSS_SECURITY_UTILITY =
|
public static final String WSS_SECURITY_UTILITY =
|
||||||
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0" +
|
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
|
||||||
".xsd";
|
|
||||||
public static final String TIMESTAMP_ID = "Id";
|
public static final String TIMESTAMP_ID = "Id";
|
||||||
public static final String TIMESTAMP_U = "u";
|
public static final String TIMESTAMP_U = "u";
|
||||||
public static final String TIMESTAMP = "Timestamp";
|
public static final String TIMESTAMP = "Timestamp";
|
||||||
@ -150,10 +140,23 @@ public final class PluginConstants {
|
|||||||
public static final String CREATED = "Created";
|
public static final String CREATED = "Created";
|
||||||
public static final String EXPIRES = "Expires";
|
public static final String EXPIRES = "Expires";
|
||||||
public static final String UTF_8 = "utf-8";
|
public static final String UTF_8 = "utf-8";
|
||||||
|
|
||||||
|
public static final int DOMAIN_SEGMENT = 1;
|
||||||
|
public static final int EMAIL_SEGMENT = 0;
|
||||||
|
public static final int REQUEST_ID = 0;
|
||||||
|
public static final int CA_CERTIFICATE_POSITION = 0;
|
||||||
|
public static final int SIGNED_CERTIFICATE_POSITION = 1;
|
||||||
|
public static final int APPAUTH_USERNAME_POSITION = 21;
|
||||||
|
public static final int APPAUTH_PASSWORD_POSITION = 22;
|
||||||
|
public static final int POLLING_FREQUENCY_POSITION = 24;
|
||||||
|
public static final int SYNCML_PROVISIONING_ADDR_POSITION = 8;
|
||||||
|
public static final int DOMAIN_POSITION = 7;
|
||||||
|
public static final String ENROLL_SUBDOMAIN = "https://EnterpriseEnrollment.";
|
||||||
|
public static final String SYNCML_PROVISIONING_SERVICE_URL = "/Syncml/initialquery";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SynclML service related constants
|
* SynclML service related constants.
|
||||||
*/
|
*/
|
||||||
public final class SyncML {
|
public final class SyncML {
|
||||||
private SyncML() {
|
private SyncML() {
|
||||||
@ -182,9 +185,9 @@ public final class PluginConstants {
|
|||||||
public static final int DEVICE_LANG_POSITION = 4;
|
public static final int DEVICE_LANG_POSITION = 4;
|
||||||
public static final int IMSI_POSITION = 1;
|
public static final int IMSI_POSITION = 1;
|
||||||
public static final int IMEI_POSITION = 2;
|
public static final int IMEI_POSITION = 2;
|
||||||
public static final int VENDER_POSITION = 4;
|
public static final int VENDOR_POSITION = 4;
|
||||||
public static final int MODEL_POSITION = 5;
|
public static final int MODEL_POSITION = 5;
|
||||||
public static final int MACADDRESS_POSITION = 7;
|
public static final int MAC_ADDRESS_POSITION = 7;
|
||||||
public static final int RESOLUTION_POSITION = 8;
|
public static final int RESOLUTION_POSITION = 8;
|
||||||
public static final int DEVICE_NAME_POSITION = 9;
|
public static final int DEVICE_NAME_POSITION = 9;
|
||||||
public static final String SYNCML_DATA_ONE = "1";
|
public static final String SYNCML_DATA_ONE = "1";
|
||||||
@ -275,7 +278,8 @@ public final class PluginConstants {
|
|||||||
public static final String CONTENT_TYPE_TEXT = "text";
|
public static final String CONTENT_TYPE_TEXT = "text";
|
||||||
public static final String NOTIFIER_FREQUENCY = "notifierFrequency";
|
public static final String NOTIFIER_FREQUENCY = "notifierFrequency";
|
||||||
public static final String DEFAULT_FREQUENCY = "8";
|
public static final String DEFAULT_FREQUENCY = "8";
|
||||||
|
public static final String AUTH_POLICY = "authPolicy";
|
||||||
|
public static final String DEFAULT_AUTH_POLICY = "Federated";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -290,4 +294,13 @@ public final class PluginConstants {
|
|||||||
public static final String ENCRYPTED_ENABLE = "encrypted";
|
public static final String ENCRYPTED_ENABLE = "encrypted";
|
||||||
public static final String ENABLE_PASSWORD = "enablePassword";
|
public static final String ENABLE_PASSWORD = "enablePassword";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Authentication related constants.
|
||||||
|
*/
|
||||||
|
public final class AuthenticatorProperties {
|
||||||
|
private AuthenticatorProperties() { throw new AssertionError(); }
|
||||||
|
public static final String MAX_CONNECTION_PER_HOST = "MaxConnectionsPerHost";
|
||||||
|
public static final String MAX_TOTAL_CONNECTIONS = "MaxTotalConnections";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* you may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.mdm.mobileservices.windows.common.authenticator;
|
||||||
|
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.OAuthTokenValidationException;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.util.OAuthValidationResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Declares the contract for OAuth2TokenValidator implementations.
|
||||||
|
*/
|
||||||
|
public interface OAuth2TokenValidator {
|
||||||
|
/**
|
||||||
|
* This method gets a string accessToken and validates it and generate the OAuthValidationResponse
|
||||||
|
* containing the validity and user details if valid.
|
||||||
|
*
|
||||||
|
* @param accessToken which need to be validated.
|
||||||
|
* @param resource which need to be validated.
|
||||||
|
* @return OAuthValidationResponse with the validated results.
|
||||||
|
*/
|
||||||
|
OAuthValidationResponse validateToken(String accessToken, String resource) throws OAuthTokenValidationException;
|
||||||
|
}
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.mdm.mobileservices.windows.common.authenticator;
|
||||||
|
|
||||||
|
import org.wso2.carbon.utils.CarbonUtils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines constants to be used inside oauth validators.
|
||||||
|
*/
|
||||||
|
public class OAuthConstants {
|
||||||
|
|
||||||
|
public static final String AUTHORIZATION_HEADER_PREFIX_BEARER = "Bearer";
|
||||||
|
public static final String AUTHORIZATION_HEADER_PREFIX_BASIC = "Basic";
|
||||||
|
public static final String BEARER_TOKEN_TYPE = "bearer";
|
||||||
|
public static final String BEARER_TOKEN_IDENTIFIER = "token";
|
||||||
|
public static final String AUTHENTICATOR_NAME = "OAuthAuthenticator";
|
||||||
|
public static final String RESOURCE_KEY = "resource";
|
||||||
|
public static final String AUTHENTICATOR_CONFIG_PATH = CarbonUtils.getEtcCarbonConfigDirPath() +
|
||||||
|
File.separator + "webapp-authenticator-config.xml";
|
||||||
|
private static final String AUTHENTICATOR_CONFIG_SCHEMA_PATH =
|
||||||
|
"resources/config/schema/webapp-authenticator-config-schema.xsd";
|
||||||
|
}
|
||||||
@ -0,0 +1,214 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.mdm.mobileservices.windows.common.authenticator;
|
||||||
|
|
||||||
|
import org.apache.axis2.AxisFault;
|
||||||
|
import org.apache.axis2.client.Options;
|
||||||
|
import org.apache.axis2.client.ServiceClient;
|
||||||
|
import org.apache.axis2.transport.http.HTTPConstants;
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
import org.apache.commons.httpclient.Header;
|
||||||
|
import org.apache.commons.httpclient.HttpClient;
|
||||||
|
import org.apache.commons.httpclient.HttpConnectionManager;
|
||||||
|
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
|
||||||
|
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.apache.commons.pool.PoolableObjectFactory;
|
||||||
|
import org.apache.http.conn.HttpClientConnectionManager;
|
||||||
|
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||||
|
import org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.OAuthTokenValidationException;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
public class OAuthTokenValidationStubFactory implements PoolableObjectFactory {
|
||||||
|
private String url;
|
||||||
|
private String basicAuthHeader;
|
||||||
|
private HttpClient httpClient;
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(OAuthTokenValidationStubFactory.class);
|
||||||
|
|
||||||
|
public OAuthTokenValidationStubFactory(String url, String adminUsername, String adminPassword,
|
||||||
|
Properties properties) {
|
||||||
|
this.validateUrl(url);
|
||||||
|
this.url = url;
|
||||||
|
|
||||||
|
this.validateCredentials(adminUsername, adminPassword);
|
||||||
|
this.basicAuthHeader = new String(Base64.encodeBase64((adminUsername + ":" + adminPassword).getBytes()));
|
||||||
|
|
||||||
|
HttpConnectionManager connectionManager = this.createConnectionManager(properties);
|
||||||
|
this.httpClient = new HttpClient(connectionManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance of MultiThreadedHttpConnectionManager using HttpClient 3.x APIs
|
||||||
|
*
|
||||||
|
* @param properties Properties to configure MultiThreadedHttpConnectionManager
|
||||||
|
* @return An instance of properly configured MultiThreadedHttpConnectionManager
|
||||||
|
*/
|
||||||
|
private HttpConnectionManager createConnectionManager(Properties properties) {
|
||||||
|
HttpConnectionManagerParams params = new HttpConnectionManagerParams();
|
||||||
|
if (properties == null || properties.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("Parameters required to initialize HttpClient instances " +
|
||||||
|
"associated with OAuth token validation service stub are not provided");
|
||||||
|
}
|
||||||
|
String maxConnectionsPerHostParam = properties.getProperty(PluginConstants.
|
||||||
|
AuthenticatorProperties.MAX_CONNECTION_PER_HOST);
|
||||||
|
if (maxConnectionsPerHostParam == null || maxConnectionsPerHostParam.isEmpty()) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("MaxConnectionsPerHost parameter is not explicitly defined. Therefore, the default, " +
|
||||||
|
"which is 2, will be used");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
params.setDefaultMaxConnectionsPerHost(Integer.parseInt(maxConnectionsPerHostParam));
|
||||||
|
}
|
||||||
|
|
||||||
|
String maxTotalConnectionsParam = properties.getProperty(PluginConstants.
|
||||||
|
AuthenticatorProperties.MAX_TOTAL_CONNECTIONS);
|
||||||
|
if (maxTotalConnectionsParam == null || maxTotalConnectionsParam.isEmpty()) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("MaxTotalConnections parameter is not explicitly defined. Therefore, the default, " +
|
||||||
|
"which is 10, will be used");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
params.setMaxTotalConnections(Integer.parseInt(maxTotalConnectionsParam));
|
||||||
|
}
|
||||||
|
HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
|
||||||
|
connectionManager.setParams(params);
|
||||||
|
return connectionManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance of PoolingHttpClientConnectionManager using HttpClient 4.x APIs
|
||||||
|
*
|
||||||
|
* @param properties Properties to configure PoolingHttpClientConnectionManager
|
||||||
|
* @return An instance of properly configured PoolingHttpClientConnectionManager
|
||||||
|
*/
|
||||||
|
private HttpClientConnectionManager createClientConnectionManager(Properties properties) {
|
||||||
|
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
|
||||||
|
if (properties != null) {
|
||||||
|
String maxConnectionsPerHostParam = properties.getProperty(PluginConstants.
|
||||||
|
AuthenticatorProperties.MAX_CONNECTION_PER_HOST);
|
||||||
|
if (maxConnectionsPerHostParam == null || maxConnectionsPerHostParam.isEmpty()) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("MaxConnectionsPerHost parameter is not explicitly defined. Therefore, the default, " +
|
||||||
|
"which is 2, will be used");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
connectionManager.setDefaultMaxPerRoute(Integer.parseInt(maxConnectionsPerHostParam));
|
||||||
|
}
|
||||||
|
|
||||||
|
String maxTotalConnectionsParam = properties.getProperty(PluginConstants.
|
||||||
|
AuthenticatorProperties.MAX_TOTAL_CONNECTIONS);
|
||||||
|
if (maxTotalConnectionsParam == null || maxTotalConnectionsParam.isEmpty()) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("MaxTotalConnections parameter is not explicitly defined. Therefore, the default, " +
|
||||||
|
"which is 10, will be used");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
connectionManager.setMaxTotal(Integer.parseInt(maxTotalConnectionsParam));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Properties, i.e. MaxTotalConnections/MaxConnectionsPerHost, required to tune the " +
|
||||||
|
"HttpClient used in OAuth token validation service stub instances are not provided. " +
|
||||||
|
"Therefore, the defaults, 2/10 respectively, will be used");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return connectionManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object makeObject() throws Exception {
|
||||||
|
return this.createStub();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroyObject(Object o) throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean validateObject(Object o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void activateObject(Object o) throws Exception {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("OAuth token validate stub instance is activated");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void passivateObject(Object o) throws Exception {
|
||||||
|
if (o instanceof OAuth2TokenValidationServiceStub) {
|
||||||
|
OAuth2TokenValidationServiceStub stub = (OAuth2TokenValidationServiceStub) o;
|
||||||
|
stub._getServiceClient().cleanupTransport();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private OAuth2TokenValidationServiceStub createStub() throws OAuthTokenValidationException {
|
||||||
|
OAuth2TokenValidationServiceStub stub;
|
||||||
|
try {
|
||||||
|
stub = new OAuth2TokenValidationServiceStub(url);
|
||||||
|
ServiceClient client = stub._getServiceClient();
|
||||||
|
client.getServiceContext().getConfigurationContext().setProperty(
|
||||||
|
HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
|
||||||
|
|
||||||
|
List<Header> headerList = new ArrayList<>();
|
||||||
|
Header header = new Header();
|
||||||
|
header.setName(HTTPConstants.HEADER_AUTHORIZATION);
|
||||||
|
header.setValue(OAuthConstants.AUTHORIZATION_HEADER_PREFIX_BASIC + " " + basicAuthHeader);
|
||||||
|
headerList.add(header);
|
||||||
|
|
||||||
|
Options options = client.getOptions();
|
||||||
|
options.setProperty(HTTPConstants.HTTP_HEADERS, headerList);
|
||||||
|
options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, "true");
|
||||||
|
client.setOptions(options);
|
||||||
|
} catch (AxisFault axisFault) {
|
||||||
|
throw new OAuthTokenValidationException("Error occurred while creating the " +
|
||||||
|
"OAuth2TokenValidationServiceStub.", axisFault);
|
||||||
|
}
|
||||||
|
return stub;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateUrl(String url) {
|
||||||
|
if (url == null || url.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("Url provided as the endpoint of the OAuth token validation service " +
|
||||||
|
"is null");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateCredentials(String adminUsername, String adminPassword) {
|
||||||
|
if (adminUsername == null || adminUsername.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("An appropriate username required to initialize OAuth token " +
|
||||||
|
"validation service stub factory hasn't been provided");
|
||||||
|
}
|
||||||
|
if (adminPassword == null || adminPassword.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("An appropriate password required to initialize OAuth token " +
|
||||||
|
"validation service stub factory hasn't been provided");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.mdm.mobileservices.windows.common.authenticator;
|
||||||
|
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.authenticator.impl.LocalOAuthValidator;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.authenticator.impl.RemoteOAuthValidator;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils;
|
||||||
|
import org.wso2.carbon.webapp.authenticator.framework.config.AuthenticatorConfig;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The class validate the configurations and provide the most suitable implementation according to the configuration.
|
||||||
|
* Factory class for OAuthValidator.
|
||||||
|
*/
|
||||||
|
public class OAuthValidatorFactory {
|
||||||
|
|
||||||
|
private static Properties authenticatorProperties;
|
||||||
|
|
||||||
|
public static OAuth2TokenValidator getValidator() {
|
||||||
|
Properties authenticatorProperties = getAuthenticatorProperties();
|
||||||
|
boolean isRemote = Boolean.parseBoolean(authenticatorProperties.getProperty("IsRemote"));
|
||||||
|
if (isRemote) {
|
||||||
|
String url = authenticatorProperties.getProperty("TokenValidationEndpointUrl");
|
||||||
|
if ((url == null) || (url.isEmpty())) {
|
||||||
|
throw new IllegalStateException("OAuth token validation endpoint url is not provided");
|
||||||
|
}
|
||||||
|
String adminUsername = authenticatorProperties.getProperty("Username");
|
||||||
|
if (adminUsername == null) {
|
||||||
|
throw new IllegalStateException("Username to connect to the OAuth token validation endpoint " +
|
||||||
|
"is not provided");
|
||||||
|
}
|
||||||
|
|
||||||
|
String adminPassword = authenticatorProperties.getProperty("Password");
|
||||||
|
if (adminPassword == null) {
|
||||||
|
throw new IllegalStateException("Password to connect to the OAuth token validation endpoint " +
|
||||||
|
"is not provided");
|
||||||
|
}
|
||||||
|
|
||||||
|
Properties validatorProperties = new Properties();
|
||||||
|
validatorProperties.setProperty("MaxTotalConnections", authenticatorProperties.getProperty("MaxTotalConnections"));
|
||||||
|
validatorProperties.setProperty("MaxConnectionsPerHost", authenticatorProperties.getProperty("MaxConnectionsPerHost"));
|
||||||
|
if ((url != null) && (!url.trim().isEmpty())) {
|
||||||
|
url = url + "/services/OAuth2TokenValidationService.OAuth2TokenValidationServiceHttpsSoap12Endpoint/";
|
||||||
|
return new RemoteOAuthValidator(url, adminUsername, adminPassword, validatorProperties);
|
||||||
|
}
|
||||||
|
throw new IllegalStateException("Remote server host can't be empty in OAuthAuthenticator configuration.");
|
||||||
|
}
|
||||||
|
return new LocalOAuthValidator();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Properties getAuthenticatorProperties() {
|
||||||
|
if (authenticatorProperties == null) {
|
||||||
|
AuthenticatorConfig config = WindowsAPIUtils.getBSTAuthenticatorConfig();
|
||||||
|
if ((config.getParams() != null) && (!config.getParams().isEmpty())) {
|
||||||
|
Properties properties = new Properties();
|
||||||
|
for (AuthenticatorConfig.Parameter param : config.getParams()) {
|
||||||
|
properties.setProperty(param.getName(), param.getValue());
|
||||||
|
}
|
||||||
|
authenticatorProperties = properties;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return authenticatorProperties;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.mdm.mobileservices.windows.common.authenticator.impl;
|
||||||
|
|
||||||
|
import org.wso2.carbon.identity.oauth2.dto.OAuth2TokenValidationRequestDTO;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.authenticator.OAuth2TokenValidator;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.authenticator.OAuthConstants;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.OAuthTokenValidationException;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.util.OAuthValidationResponse;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils;
|
||||||
|
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the OAuth2 token validation from the same server using OSGi services.
|
||||||
|
*/
|
||||||
|
public class LocalOAuthValidator implements OAuth2TokenValidator {
|
||||||
|
@Override
|
||||||
|
public OAuthValidationResponse validateToken(String accessToken, String resource)
|
||||||
|
throws OAuthTokenValidationException {
|
||||||
|
|
||||||
|
OAuth2TokenValidationRequestDTO validationRequest = new OAuth2TokenValidationRequestDTO();
|
||||||
|
OAuth2TokenValidationRequestDTO.OAuth2AccessToken oauthToken =
|
||||||
|
validationRequest.new OAuth2AccessToken();
|
||||||
|
oauthToken.setTokenType(OAuthConstants.BEARER_TOKEN_TYPE);
|
||||||
|
oauthToken.setIdentifier(accessToken);
|
||||||
|
validationRequest.setAccessToken(oauthToken);
|
||||||
|
|
||||||
|
//Set the resource context param. This will be used in scope validation.
|
||||||
|
OAuth2TokenValidationRequestDTO.TokenValidationContextParam
|
||||||
|
resourceContextParam = validationRequest.new TokenValidationContextParam();
|
||||||
|
resourceContextParam.setKey(OAuthConstants.RESOURCE_KEY);
|
||||||
|
resourceContextParam.setValue(resource);
|
||||||
|
|
||||||
|
OAuth2TokenValidationRequestDTO.TokenValidationContextParam[]
|
||||||
|
tokenValidationContextParams =
|
||||||
|
new OAuth2TokenValidationRequestDTO.TokenValidationContextParam[1];
|
||||||
|
tokenValidationContextParams[0] = resourceContextParam;
|
||||||
|
validationRequest.setContext(tokenValidationContextParams);
|
||||||
|
|
||||||
|
org.wso2.carbon.identity.oauth2.dto.OAuth2TokenValidationResponseDTO tokenValidationResponse =
|
||||||
|
WindowsAPIUtils.getOAuth2TokenValidationService().findOAuthConsumerIfTokenIsValid(
|
||||||
|
validationRequest).getAccessTokenValidationResponse();
|
||||||
|
boolean isValid = tokenValidationResponse.isValid();
|
||||||
|
String username;
|
||||||
|
String tenantDomain;
|
||||||
|
if (isValid) {
|
||||||
|
username = MultitenantUtils.getTenantAwareUsername(
|
||||||
|
tokenValidationResponse.getAuthorizedUser());
|
||||||
|
tenantDomain =
|
||||||
|
MultitenantUtils.getTenantDomain(tokenValidationResponse.getAuthorizedUser());
|
||||||
|
} else {
|
||||||
|
OAuthValidationResponse oAuthValidationResponse = new OAuthValidationResponse();
|
||||||
|
oAuthValidationResponse.setErrorMsg(tokenValidationResponse.getErrorMsg());
|
||||||
|
return oAuthValidationResponse;
|
||||||
|
}
|
||||||
|
return new OAuthValidationResponse(username, tenantDomain, isValid);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,121 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.mdm.mobileservices.windows.common.authenticator.impl;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.apache.commons.pool.impl.GenericObjectPool;
|
||||||
|
import org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub;
|
||||||
|
import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO;
|
||||||
|
import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO_OAuth2AccessToken;
|
||||||
|
import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO_TokenValidationContextParam;
|
||||||
|
import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationResponseDTO;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.authenticator.OAuth2TokenValidator;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.authenticator.OAuthTokenValidationStubFactory;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.OAuthTokenValidationException;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.util.OAuthValidationResponse;
|
||||||
|
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
|
||||||
|
|
||||||
|
import java.rmi.RemoteException;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the OAuth2 token validation from remote IS servers using remote OAuthValidation service-stub.
|
||||||
|
*/
|
||||||
|
public class RemoteOAuthValidator implements OAuth2TokenValidator {
|
||||||
|
|
||||||
|
private GenericObjectPool stubs;
|
||||||
|
private static final Log log = LogFactory.getLog(RemoteOAuthValidator.class);
|
||||||
|
|
||||||
|
public RemoteOAuthValidator(String hostURL, String adminUsername, String adminPassword, Properties properties) {
|
||||||
|
this.stubs =
|
||||||
|
new GenericObjectPool(new OAuthTokenValidationStubFactory(
|
||||||
|
hostURL, adminUsername, adminPassword, properties));
|
||||||
|
}
|
||||||
|
|
||||||
|
public OAuthValidationResponse validateToken(String accessToken,
|
||||||
|
String resource) throws OAuthTokenValidationException {
|
||||||
|
OAuth2TokenValidationServiceStub stub = null;
|
||||||
|
OAuth2TokenValidationResponseDTO validationResponse;
|
||||||
|
try {
|
||||||
|
OAuth2TokenValidationRequestDTO validationRequest = createValidationRequest(accessToken, resource);
|
||||||
|
stub = (OAuth2TokenValidationServiceStub) this.stubs.borrowObject();
|
||||||
|
validationResponse =
|
||||||
|
stub.findOAuthConsumerIfTokenIsValid(validationRequest).getAccessTokenValidationResponse();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
throw new OAuthTokenValidationException("Remote Exception occurred while invoking the Remote " +
|
||||||
|
"IS server for OAuth2 token validation.", e);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new OAuthTokenValidationException("Error occurred while borrowing an oauth token validation " +
|
||||||
|
"service stub from the pool", e);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
this.stubs.returnObject(stub);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("Error occurred while returning the object back to the oauth token validation service " +
|
||||||
|
"stub pool", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (validationResponse == null) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Response returned by the OAuth token validation service is null");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isValid = validationResponse.getValid();
|
||||||
|
String tenantDomain;
|
||||||
|
String username;
|
||||||
|
if (isValid) {
|
||||||
|
username = MultitenantUtils.getTenantAwareUsername(validationResponse.getAuthorizedUser());
|
||||||
|
tenantDomain = MultitenantUtils.getTenantDomain(validationResponse.getAuthorizedUser());
|
||||||
|
} else {
|
||||||
|
OAuthValidationResponse oAuthValidationResponse = new OAuthValidationResponse();
|
||||||
|
oAuthValidationResponse.setErrorMsg(validationResponse.getErrorMsg());
|
||||||
|
return oAuthValidationResponse;
|
||||||
|
}
|
||||||
|
return new OAuthValidationResponse(username, tenantDomain, isValid);
|
||||||
|
}
|
||||||
|
|
||||||
|
private OAuth2TokenValidationRequestDTO createValidationRequest(String accessToken, String resource) {
|
||||||
|
OAuth2TokenValidationRequestDTO validationRequest = new OAuth2TokenValidationRequestDTO();
|
||||||
|
OAuth2TokenValidationRequestDTO_OAuth2AccessToken oauthToken =
|
||||||
|
new OAuth2TokenValidationRequestDTO_OAuth2AccessToken();
|
||||||
|
|
||||||
|
oauthToken.setTokenType("bearer");
|
||||||
|
oauthToken.setIdentifier(accessToken);
|
||||||
|
validationRequest.setAccessToken(oauthToken);
|
||||||
|
|
||||||
|
OAuth2TokenValidationRequestDTO_TokenValidationContextParam resourceContextParam =
|
||||||
|
new OAuth2TokenValidationRequestDTO_TokenValidationContextParam();
|
||||||
|
|
||||||
|
resourceContextParam.setKey("resource");
|
||||||
|
resourceContextParam.setValue(resource);
|
||||||
|
|
||||||
|
OAuth2TokenValidationRequestDTO_TokenValidationContextParam[] tokenValidationContextParams =
|
||||||
|
new OAuth2TokenValidationRequestDTO_TokenValidationContextParam[1];
|
||||||
|
|
||||||
|
tokenValidationContextParams[0] = resourceContextParam;
|
||||||
|
validationRequest.setContext(tokenValidationContextParams);
|
||||||
|
|
||||||
|
return validationRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,40 +1,35 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.common.beans;
|
package org.wso2.carbon.mdm.mobileservices.windows.common.beans;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import java.io.Serializable;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for java CacheEntry
|
* Class for java CacheEntry
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "CacheEntry",
|
public class CacheEntry implements Serializable {
|
||||||
description = "This class carries all information related to token cache")
|
|
||||||
public class CacheEntry {
|
|
||||||
|
|
||||||
@ApiModelProperty(name = "deviceID", value = "Windows deviceIdentifier", required = true)
|
|
||||||
private String deviceID;
|
private String deviceID;
|
||||||
@ApiModelProperty(name = "username", value = "Enrolled User", required = true)
|
|
||||||
private String username;
|
private String username;
|
||||||
@ApiModelProperty(name = "ownership", value = "Enrollment ownership(BYOD/COPE)", required = true)
|
|
||||||
private String ownership;
|
private String ownership;
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 19981017L;
|
||||||
|
|
||||||
public String getOwnership() {
|
public String getOwnership() {
|
||||||
return ownership;
|
return ownership;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,34 +1,27 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.common.beans;
|
package org.wso2.carbon.mdm.mobileservices.windows.common.beans;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for challenge token
|
* Class for challenge token
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "Token", description = "Details related device encryption.")
|
|
||||||
public class Token {
|
public class Token {
|
||||||
|
|
||||||
@ApiModelProperty(name = "challengeToken",
|
|
||||||
value = "Enrollment Binary security token", required = true)
|
|
||||||
private String challengeToken;
|
private String challengeToken;
|
||||||
|
|
||||||
public String getChallengeToken() {
|
public String getChallengeToken() {
|
||||||
|
|||||||
@ -1,103 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
|
||||||
*
|
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
|
||||||
* in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.common.beans;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bean class for storing Windows plugin properties after reading the property file.
|
|
||||||
*/
|
|
||||||
@ApiModel(value = "WindowsPluginProperties", description = "Windows plugin related properties.")
|
|
||||||
public class WindowsPluginProperties {
|
|
||||||
|
|
||||||
@ApiModelProperty(name = "keyStorePassword", value = "Password of the keyStore.", required = true)
|
|
||||||
private String keyStorePassword;
|
|
||||||
@ApiModelProperty(name = "privateKeyPassword", value = "password of the privateKey.", required = true)
|
|
||||||
private String privateKeyPassword;
|
|
||||||
@ApiModelProperty(name = "commonName", value = "Common Name of the certificate.", required = true)
|
|
||||||
private String commonName;
|
|
||||||
@ApiModelProperty(name = "authPolicy", value = "Windows enrollment authentication policy(Federated/on-premise).", required = true)
|
|
||||||
private String authPolicy;
|
|
||||||
@ApiModelProperty(name = "domain", value = "Domain of the given Email.", required = true)
|
|
||||||
private String domain;
|
|
||||||
@ApiModelProperty(name = "notBeforeDays", value = "Number of days to before the certificate expire.", required = true)
|
|
||||||
private int notBeforeDays;
|
|
||||||
@ApiModelProperty(name = "notAfterDays", value = "Number of days to after the certificate has been expired.", required = true)
|
|
||||||
private int notAfterDays;
|
|
||||||
|
|
||||||
public String getKeyStorePassword() {
|
|
||||||
return keyStorePassword;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPrivateKeyPassword() {
|
|
||||||
return privateKeyPassword;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCommonName() {
|
|
||||||
return commonName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNotBeforeDays() {
|
|
||||||
return notBeforeDays;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNotAfterDays() {
|
|
||||||
return notAfterDays;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKeyStorePassword(String keyStorePassword) {
|
|
||||||
this.keyStorePassword = keyStorePassword;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPrivateKeyPassword(String privateKeyPassword) {
|
|
||||||
this.privateKeyPassword = privateKeyPassword;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCommonName(String commonName) {
|
|
||||||
this.commonName = commonName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNotBeforeDays(int notBeforeDays) {
|
|
||||||
this.notBeforeDays = notBeforeDays;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNotAfterDays(int notAfterDays) {
|
|
||||||
this.notAfterDays = notAfterDays;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAuthPolicy() {
|
|
||||||
return authPolicy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAuthPolicy(String authPolicy) {
|
|
||||||
this.authPolicy = authPolicy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDomain() {
|
|
||||||
return domain;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDomain(String domain) {
|
|
||||||
this.domain = domain;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
@ -30,7 +30,7 @@ import javax.ws.rs.core.Response;
|
|||||||
public class BadRequestException extends WebApplicationException {
|
public class BadRequestException extends WebApplicationException {
|
||||||
|
|
||||||
public BadRequestException(Message message, MediaType mediaType) {
|
public BadRequestException(Message message, MediaType mediaType) {
|
||||||
super(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).
|
super(Response.status(Response.Status.BAD_REQUEST).entity(message).
|
||||||
type(mediaType).build());
|
type(mediaType).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
@ -19,7 +19,7 @@
|
|||||||
package org.wso2.carbon.mdm.mobileservices.windows.common.exceptions;
|
package org.wso2.carbon.mdm.mobileservices.windows.common.exceptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MDMAPIUtils class provides utility function used by CDM REST-API classes.
|
* MDMAPIUtils class provides utility function which are used by CDM REST-API classes.
|
||||||
*/
|
*/
|
||||||
public class MDMAPIException extends Exception {
|
public class MDMAPIException extends Exception {
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* you may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.mdm.mobileservices.windows.common.exceptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom exception to be thrown inside OAuthTokenValidation related functionality.
|
||||||
|
*/
|
||||||
|
public class OAuthTokenValidationException extends Exception {
|
||||||
|
private static final long serialVersionUID = -3151279311929070297L;
|
||||||
|
|
||||||
|
private String errorMessage;
|
||||||
|
|
||||||
|
public String getErrorMessage() {
|
||||||
|
return errorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrorMessage(String errorMessage) {
|
||||||
|
this.errorMessage = errorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OAuthTokenValidationException(String msg, Exception nestedEx) {
|
||||||
|
super(msg, nestedEx);
|
||||||
|
setErrorMessage(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OAuthTokenValidationException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
setErrorMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OAuthTokenValidationException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
setErrorMessage(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OAuthTokenValidationException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public OAuthTokenValidationException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
@ -19,7 +19,7 @@
|
|||||||
package org.wso2.carbon.mdm.mobileservices.windows.common.exceptions;
|
package org.wso2.carbon.mdm.mobileservices.windows.common.exceptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom class for windows API configurations.
|
* Custom class for windows device configurations.
|
||||||
*/
|
*/
|
||||||
public class WindowsConfigurationException extends Exception {
|
public class WindowsConfigurationException extends Exception {
|
||||||
|
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* you may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,40 +1,30 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* you may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.common.util;
|
package org.wso2.carbon.mdm.mobileservices.windows.common.util;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DTO class to hold the information of authenticated user.
|
* DTO class to hold the information of authenticated user.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "ApplicationInstallation",
|
|
||||||
description = "This class carries all information related to install application")
|
|
||||||
|
|
||||||
public class AuthenticationInfo {
|
public class AuthenticationInfo {
|
||||||
@ApiModelProperty(name = "message", value = "Authentication info message.", required = true)
|
|
||||||
private String message;
|
private String message;
|
||||||
@ApiModelProperty(name = "username", value = "Username of the enrolled user.", required = true)
|
|
||||||
private String username;
|
private String username;
|
||||||
@ApiModelProperty(name = "tenantDomain", value = "Enrolled user's tenant domain.", required = true)
|
|
||||||
private String tenantDomain;
|
private String tenantDomain;
|
||||||
@ApiModelProperty(name = "tenantId", value = "Enrolled user's tenant ID)", required = true)
|
|
||||||
private int tenantId = -1;
|
private int tenantId = -1;
|
||||||
|
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* you may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
@ -19,8 +19,6 @@
|
|||||||
package org.wso2.carbon.mdm.mobileservices.windows.common.util;
|
package org.wso2.carbon.mdm.mobileservices.windows.common.util;
|
||||||
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.apache.ws.security.WSSecurityException;
|
import org.apache.ws.security.WSSecurityException;
|
||||||
import org.apache.ws.security.handler.RequestData;
|
import org.apache.ws.security.handler.RequestData;
|
||||||
import org.apache.ws.security.message.token.BinarySecurity;
|
import org.apache.ws.security.message.token.BinarySecurity;
|
||||||
@ -28,13 +26,12 @@ import org.apache.ws.security.validate.Credential;
|
|||||||
import org.apache.ws.security.validate.Validator;
|
import org.apache.ws.security.validate.Validator;
|
||||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
import org.wso2.carbon.identity.oauth2.dto.OAuth2TokenValidationRequestDTO;
|
|
||||||
import org.wso2.carbon.identity.oauth2.dto.OAuth2TokenValidationResponseDTO;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.authenticator.OAuthValidatorFactory;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.beans.CacheEntry;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.beans.CacheEntry;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.AuthenticationException;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.AuthenticationException;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.OAuthTokenValidationException;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException;
|
||||||
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@ -43,119 +40,98 @@ import java.util.HashMap;
|
|||||||
*/
|
*/
|
||||||
public class BSTValidator implements Validator {
|
public class BSTValidator implements Validator {
|
||||||
|
|
||||||
private static Log log = LogFactory.getLog(BSTValidator.class);
|
|
||||||
private static final String BEARER_TOKEN_TYPE = "bearer";
|
|
||||||
private static final String RESOURCE_KEY = "resource";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method validates the binary security token in SOAP message coming from the device.
|
* This method validates the binary security token in SOAP message coming from the device.
|
||||||
*
|
*
|
||||||
* @param credential - binary security token credential object
|
* @param credential - binary security token credential object.
|
||||||
* @param requestData - Request data associated with the request
|
* @param requestData - Request data associated with the request.
|
||||||
* @return - Credential object if authentication is success, or null if not success
|
* @return - Credential object if authentication is success, or null if not success.
|
||||||
* @throws WSSecurityException
|
* @throws WSSecurityException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Credential validate(Credential credential, RequestData requestData) throws WSSecurityException {
|
public Credential validate(Credential credential, RequestData requestData) throws WSSecurityException {
|
||||||
String encodedBinarySecurityToken;
|
String bearerToken;
|
||||||
String requestedUri;
|
String requestedUri;
|
||||||
Credential returnCredentials = null;
|
Credential userCredentials;
|
||||||
|
|
||||||
HashMap msgContext = (HashMap) requestData.getMsgContext();
|
HashMap msgContext = (HashMap) requestData.getMsgContext();
|
||||||
requestedUri = msgContext.get(PluginConstants.CXF_REQUEST_URI).toString();
|
requestedUri = msgContext.get(PluginConstants.CXF_REQUEST_URI).toString();
|
||||||
BinarySecurity binarySecurityTokenObject = credential.getBinarySecurityToken();
|
BinarySecurity binarySecurityTokenObject = credential.getBinarySecurityToken();
|
||||||
String binarySecurityToken = binarySecurityTokenObject.getElement().getFirstChild().getTextContent();
|
String binarySecurityToken = binarySecurityTokenObject.getElement().getFirstChild().getTextContent();
|
||||||
Base64 base64 = new Base64();
|
Base64 base64 = new Base64();
|
||||||
encodedBinarySecurityToken = new String(base64.decode(binarySecurityToken));
|
bearerToken = new String(base64.decode(binarySecurityToken));
|
||||||
AuthenticationInfo authenticationInfo;
|
AuthenticationInfo authenticationInfo;
|
||||||
try {
|
try {
|
||||||
authenticationInfo = validateRequest(requestedUri, encodedBinarySecurityToken);
|
authenticationInfo = validateRequest(requestedUri, bearerToken);
|
||||||
PrivilegedCarbonContext.startTenantFlow();
|
WindowsAPIUtils.startTenantFlow(authenticationInfo);
|
||||||
PrivilegedCarbonContext privilegedCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
||||||
privilegedCarbonContext.setTenantId(authenticationInfo.getTenantId());
|
|
||||||
privilegedCarbonContext.setTenantDomain(authenticationInfo.getTenantDomain());
|
|
||||||
privilegedCarbonContext.setUsername(authenticationInfo.getUsername());
|
|
||||||
|
|
||||||
if (authenticate(binarySecurityToken)) {
|
if (authenticate(binarySecurityToken, authenticationInfo)) {
|
||||||
returnCredentials = credential;
|
userCredentials = credential;
|
||||||
} else {
|
} else {
|
||||||
String msg = "Authentication failure due to invalid binary security token.";
|
throw new WindowsDeviceEnrolmentException(
|
||||||
log.error(msg);
|
"Authentication failure due to invalid binary security token.");
|
||||||
throw new WindowsDeviceEnrolmentException(msg);
|
|
||||||
}
|
}
|
||||||
} catch (AuthenticationException e) {
|
} catch (AuthenticationException e) {
|
||||||
String msg = "Failure occurred in the BST validator.";
|
throw new WSSecurityException("Failure occurred in the BST validator.", e);
|
||||||
log.error(msg, e);
|
|
||||||
throw new WSSecurityException(msg, e);
|
|
||||||
} catch (WindowsDeviceEnrolmentException e) {
|
} catch (WindowsDeviceEnrolmentException e) {
|
||||||
String msg = "Authentication Failure occurred due to binary security token.";
|
throw new WSSecurityException("Authentication failure occurred due to binary security token.", e);
|
||||||
log.error(msg, e);
|
} catch (OAuthTokenValidationException e) {
|
||||||
throw new WSSecurityException(msg, e);
|
throw new WSSecurityException(
|
||||||
|
"Failed to authenticate the incoming request due to oauth token validation error.", e);
|
||||||
|
} finally {
|
||||||
|
PrivilegedCarbonContext.endTenantFlow();
|
||||||
}
|
}
|
||||||
return returnCredentials;
|
return userCredentials;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method authenticates the user checking the binary security token in the user store.
|
* This method authenticates the client who comes with binary security token.
|
||||||
*
|
*
|
||||||
* @param binarySecurityToken - Binary security token received in the SOAP message header
|
* @param binarySecurityToken - Binary security token received in the SOAP message header.
|
||||||
* @return - Authentication status
|
* @return - Authentication status.
|
||||||
* @throws AuthenticationException
|
* @throws AuthenticationException
|
||||||
*/
|
*/
|
||||||
public boolean authenticate(String binarySecurityToken) throws
|
private boolean authenticate(String binarySecurityToken, AuthenticationInfo authenticationInfo) throws
|
||||||
AuthenticationException {
|
AuthenticationException {
|
||||||
|
WindowsAPIUtils.startTenantFlow(authenticationInfo);
|
||||||
CacheEntry cacheentry = (CacheEntry) DeviceUtil.getCacheEntry(binarySecurityToken);
|
if (DeviceUtil.getCacheEntry(binarySecurityToken) != null) {
|
||||||
String username = cacheentry.getUsername();
|
CacheEntry cacheentry = (CacheEntry) DeviceUtil.getCacheEntry(binarySecurityToken);
|
||||||
return username != null;
|
String username = cacheentry.getUsername();
|
||||||
|
return username != null;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate SOAP request token.
|
* Validate SOAP request token.
|
||||||
*
|
*
|
||||||
* @param requestedUri- Requested endpoint URI.
|
* @param requestedUri -Requested endpoint URI.
|
||||||
* @param encodedBinarySecurityToken-Binary security token comes from the soap request message.
|
* @param binarySecurityToken -Binary security token comes from the soap request message.
|
||||||
* @return returns authorized user information.
|
* @return returns authorized user information.
|
||||||
* @throws WindowsDeviceEnrolmentException
|
* @throws WindowsDeviceEnrolmentException
|
||||||
*/
|
*/
|
||||||
public AuthenticationInfo validateRequest(String requestedUri, String encodedBinarySecurityToken)
|
private AuthenticationInfo validateRequest(String requestedUri, String binarySecurityToken)
|
||||||
throws WindowsDeviceEnrolmentException {
|
throws WindowsDeviceEnrolmentException, OAuthTokenValidationException {
|
||||||
|
|
||||||
AuthenticationInfo authenticationInfo = new AuthenticationInfo();
|
AuthenticationInfo authenticationInfo = new AuthenticationInfo();
|
||||||
// Create a OAuth2TokenValidationRequestDTO object for validating access token
|
String resource = requestedUri + ":POST";
|
||||||
OAuth2TokenValidationRequestDTO dto = new OAuth2TokenValidationRequestDTO();
|
OAuthValidationResponse oAuthValidationResponse = OAuthValidatorFactory.getValidator().
|
||||||
//Set the access token info
|
validateToken(binarySecurityToken, resource);
|
||||||
OAuth2TokenValidationRequestDTO.OAuth2AccessToken oAuth2AccessToken = dto.new OAuth2AccessToken();
|
|
||||||
oAuth2AccessToken.setTokenType(BSTValidator.BEARER_TOKEN_TYPE);
|
|
||||||
oAuth2AccessToken.setIdentifier(encodedBinarySecurityToken);
|
|
||||||
dto.setAccessToken(oAuth2AccessToken);
|
|
||||||
|
|
||||||
//Set the resource context param. This will be used in scope validation.
|
|
||||||
OAuth2TokenValidationRequestDTO.TokenValidationContextParam
|
|
||||||
resourceContextParam = dto.new TokenValidationContextParam();
|
|
||||||
resourceContextParam.setKey(BSTValidator.RESOURCE_KEY);
|
|
||||||
resourceContextParam.setValue(requestedUri + ":POST");
|
|
||||||
|
|
||||||
OAuth2TokenValidationRequestDTO.TokenValidationContextParam[]
|
|
||||||
tokenValidationContextParams =
|
|
||||||
new OAuth2TokenValidationRequestDTO.TokenValidationContextParam[1];
|
|
||||||
tokenValidationContextParams[0] = resourceContextParam;
|
|
||||||
dto.setContext(tokenValidationContextParams);
|
|
||||||
try {
|
try {
|
||||||
OAuth2TokenValidationResponseDTO oAuth2TokenValidationResponseDTO =
|
if (oAuthValidationResponse.isValid()) {
|
||||||
WindowsAPIUtils.getOAuth2TokenValidationService().validate(dto);
|
String username = oAuthValidationResponse.getUserName();
|
||||||
if (oAuth2TokenValidationResponseDTO.isValid()) {
|
String tenantDomain = oAuthValidationResponse.getTenantDomain();
|
||||||
String username = oAuth2TokenValidationResponseDTO.getAuthorizedUser();
|
|
||||||
authenticationInfo.setUsername(username);
|
authenticationInfo.setUsername(username);
|
||||||
authenticationInfo.setTenantDomain(MultitenantUtils.getTenantDomain(username));
|
authenticationInfo.setTenantDomain(tenantDomain);
|
||||||
authenticationInfo.setTenantId(WindowsAPIUtils.getTenantIdOFUser(username));
|
authenticationInfo.setTenantId(WindowsAPIUtils.getTenantIdOFUser(username + "@" + tenantDomain));
|
||||||
} else {
|
} else {
|
||||||
authenticationInfo.setMessage(oAuth2TokenValidationResponseDTO.getErrorMsg());
|
authenticationInfo.setMessage(oAuthValidationResponse.getErrorMsg());
|
||||||
}
|
}
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
String msg = "Authentication failure due to invalid binary security token.";
|
throw new WindowsDeviceEnrolmentException(
|
||||||
log.error(msg, e);
|
"Authentication failure due to invalid binary security token.", e);
|
||||||
throw new WindowsDeviceEnrolmentException(msg, e);
|
|
||||||
}
|
}
|
||||||
return authenticationInfo;
|
return authenticationInfo;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,138 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
|
||||||
*
|
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
|
||||||
* in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.common.util;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.beans.WindowsPluginProperties;
|
|
||||||
import org.xml.sax.SAXException;
|
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
|
||||||
import javax.servlet.ServletContextEvent;
|
|
||||||
import javax.servlet.ServletContextListener;
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class performs one time operations.
|
|
||||||
*/
|
|
||||||
public class ConfigInitializerContextListener implements ServletContextListener {
|
|
||||||
|
|
||||||
public static final int INITIAL_VALUE = 0;
|
|
||||||
private static Log log = LogFactory.getLog(ConfigInitializerContextListener.class);
|
|
||||||
|
|
||||||
private enum PropertyName {
|
|
||||||
PROPERTY_SIGNED_CERT_CN("SignedCertCN"),
|
|
||||||
PROPERTY_SIGNED_CERT_NOT_BEFORE("SignedCertNotBefore"),
|
|
||||||
PROPERTY_SIGNED_CERT_NOT_AFTER("SignedCertNotAfter"),
|
|
||||||
PROPERTY_PASSWORD("Password"),
|
|
||||||
PROPERTY_PRIVATE_KEY_PASSWORD("PrivateKeyPassword"),
|
|
||||||
AUTH_POLICY("AuthPolicy"),
|
|
||||||
DOMAIN("domain");
|
|
||||||
|
|
||||||
private final String propertyName;
|
|
||||||
|
|
||||||
PropertyName(final String propertyName) {
|
|
||||||
this.propertyName = propertyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue() {
|
|
||||||
return this.propertyName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method loads wap-provisioning file / property file, sets wap-provisioning file and
|
|
||||||
* extracted properties as attributes in servlet context.
|
|
||||||
*
|
|
||||||
* @param servletContextEvent - Uses when servlet communicating with servlet container.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void contextInitialized(ServletContextEvent servletContextEvent) {
|
|
||||||
|
|
||||||
ServletContext servletContext = servletContextEvent.getServletContext();
|
|
||||||
File propertyFile = new File(getClass().getClassLoader().getResource(
|
|
||||||
PluginConstants.CertificateEnrolment.PROPERTIES_XML).getFile());
|
|
||||||
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
|
|
||||||
DocumentBuilder docBuilder;
|
|
||||||
Document document = null;
|
|
||||||
try {
|
|
||||||
docBuilder = docBuilderFactory.newDocumentBuilder();
|
|
||||||
if (docBuilder != null) {
|
|
||||||
document = docBuilder.parse(propertyFile);
|
|
||||||
}
|
|
||||||
} catch (ParserConfigurationException e) {
|
|
||||||
log.error("Parser configuration failure while reading properties.xml.");
|
|
||||||
} catch (SAXException e) {
|
|
||||||
log.error("Parsing error occurred while reading properties.xml.");
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error("File reading error occurred while accessing properties.xml.");
|
|
||||||
}
|
|
||||||
|
|
||||||
String password = null;
|
|
||||||
String privateKeyPassword = null;
|
|
||||||
String signedCertCommonName = null;
|
|
||||||
String authPolicy = null;
|
|
||||||
String domain = null;
|
|
||||||
int signedCertNotBeforeDate = INITIAL_VALUE;
|
|
||||||
int signedCertNotAfterDate = INITIAL_VALUE;
|
|
||||||
|
|
||||||
if (document != null) {
|
|
||||||
password = document.getElementsByTagName(PropertyName.PROPERTY_PASSWORD.getValue()).item(0).
|
|
||||||
getTextContent();
|
|
||||||
privateKeyPassword = document.getElementsByTagName(PropertyName.PROPERTY_PRIVATE_KEY_PASSWORD.getValue()).
|
|
||||||
item(0).getTextContent();
|
|
||||||
signedCertCommonName =
|
|
||||||
document.getElementsByTagName(PropertyName.PROPERTY_SIGNED_CERT_CN.getValue()).item(0).
|
|
||||||
getTextContent();
|
|
||||||
authPolicy = document.getElementsByTagName(PropertyName.AUTH_POLICY.getValue()).item(0).
|
|
||||||
getTextContent();
|
|
||||||
signedCertNotBeforeDate = Integer.valueOf(document.getElementsByTagName(
|
|
||||||
PropertyName.PROPERTY_SIGNED_CERT_NOT_BEFORE.getValue()).item(0).getTextContent());
|
|
||||||
signedCertNotAfterDate = Integer.valueOf(document.getElementsByTagName(
|
|
||||||
PropertyName.PROPERTY_SIGNED_CERT_NOT_AFTER.getValue()).item(0).getTextContent());
|
|
||||||
domain = document.getElementsByTagName(PropertyName.DOMAIN.getValue()).item(0).getTextContent();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
WindowsPluginProperties properties = new WindowsPluginProperties();
|
|
||||||
properties.setKeyStorePassword(password);
|
|
||||||
properties.setPrivateKeyPassword(privateKeyPassword);
|
|
||||||
properties.setCommonName(signedCertCommonName);
|
|
||||||
properties.setNotBeforeDays(signedCertNotBeforeDate);
|
|
||||||
properties.setNotAfterDays(signedCertNotAfterDate);
|
|
||||||
properties.setAuthPolicy(authPolicy);
|
|
||||||
properties.setDomain(domain);
|
|
||||||
servletContext.setAttribute(PluginConstants.WINDOWS_PLUGIN_PROPERTIES, properties);
|
|
||||||
|
|
||||||
File wapProvisioningFile = new File(getClass().getClassLoader().getResource(
|
|
||||||
PluginConstants.CertificateEnrolment.WAP_PROVISIONING_XML).getFile());
|
|
||||||
servletContext.setAttribute(PluginConstants.CONTEXT_WAP_PROVISIONING_FILE, wapProvisioningFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void contextDestroyed(ServletContextEvent servletContextEvent) {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.mdm.mobileservices.windows.common.util;
|
||||||
|
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants;
|
||||||
|
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
|
import javax.servlet.ServletContextEvent;
|
||||||
|
import javax.servlet.ServletContextListener;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class performs one time operations.
|
||||||
|
*/
|
||||||
|
public class ContextInitializer implements ServletContextListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method loads wap-provisioning file and sets wap-provisioning file as attribute in servlet context.
|
||||||
|
*
|
||||||
|
* @param servletContextEvent - Uses when servlet communicating with servlet container.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void contextInitialized(ServletContextEvent servletContextEvent) {
|
||||||
|
ServletContext servletContext = servletContextEvent.getServletContext();
|
||||||
|
|
||||||
|
File wapProvisioningFile = new File(getClass().getClassLoader().getResource(
|
||||||
|
PluginConstants.CertificateEnrolment.WAP_PROVISIONING_XML).getFile());
|
||||||
|
servletContext.setAttribute(PluginConstants.CONTEXT_WAP_PROVISIONING_FILE, wapProvisioningFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void contextDestroyed(ServletContextEvent servletContextEvent) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,46 +1,41 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* you may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.common.util;
|
package org.wso2.carbon.mdm.mobileservices.windows.common.util;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for holding device ids.
|
* Class for holding valid and invalid devices.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "DeviceIDHolder", description = "This class carries all information related to DeviceIDs")
|
|
||||||
public class DeviceIDHolder {
|
public class DeviceIDHolder {
|
||||||
|
|
||||||
@ApiModelProperty(name = "errorDeviceIdList", value = "Error occurred DeviceIds.)", required = true)
|
private List<String> invalidDeviceIdList;
|
||||||
private List<String> errorDeviceIdList;
|
|
||||||
@ApiModelProperty(name = "validDeviceIDList", value = "Valid DeviceIDs.)", required = true)
|
|
||||||
private List<DeviceIdentifier> validDeviceIDList;
|
private List<DeviceIdentifier> validDeviceIDList;
|
||||||
|
|
||||||
public List<String> getErrorDeviceIdList() {
|
public List<String> getInvalidDeviceIdList() {
|
||||||
return errorDeviceIdList;
|
return invalidDeviceIdList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setErrorDeviceIdList(List<String> errorDeviceIdList) {
|
public void setInvalidDeviceIdList(List<String> invalidDeviceIdList) {
|
||||||
this.errorDeviceIdList = errorDeviceIdList;
|
this.invalidDeviceIdList = invalidDeviceIdList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DeviceIdentifier> getValidDeviceIDList() {
|
public List<DeviceIdentifier> getValidDeviceIDList() {
|
||||||
|
|||||||
@ -1,24 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.common.util;
|
package org.wso2.carbon.mdm.mobileservices.windows.common.util;
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.beans.CacheEntry;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.beans.CacheEntry;
|
||||||
|
|
||||||
import javax.cache.Cache;
|
import javax.cache.Cache;
|
||||||
@ -29,7 +28,7 @@ import java.util.UUID;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for generate random token for XCEP and WSTEP
|
* Class for generate random token for XCEP and WSTEP.
|
||||||
*/
|
*/
|
||||||
public class DeviceUtil {
|
public class DeviceUtil {
|
||||||
|
|
||||||
@ -42,7 +41,7 @@ public class DeviceUtil {
|
|||||||
return String.valueOf(UUID.randomUUID());
|
return String.valueOf(UUID.randomUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void persistChallengeToken(String token, String deviceID, String username) throws DeviceManagementException {
|
public static void persistChallengeToken(String token, String deviceID, String username) {
|
||||||
|
|
||||||
Object objCacheEntry = getCacheEntry(token);
|
Object objCacheEntry = getCacheEntry(token);
|
||||||
CacheEntry cacheEntry;
|
CacheEntry cacheEntry;
|
||||||
@ -70,12 +69,12 @@ public class DeviceUtil {
|
|||||||
CacheManager contextCacheManager = Caching.getCacheManager(TOKEN_CACHE_MANAGER).
|
CacheManager contextCacheManager = Caching.getCacheManager(TOKEN_CACHE_MANAGER).
|
||||||
getCache(TOKEN_CACHE).getCacheManager();
|
getCache(TOKEN_CACHE).getCacheManager();
|
||||||
if (!isContextCacheInitialized) {
|
if (!isContextCacheInitialized) {
|
||||||
|
return Caching.getCacheManager(TOKEN_CACHE_MANAGER).getCache(TOKEN_CACHE);
|
||||||
|
} else {
|
||||||
isContextCacheInitialized = true;
|
isContextCacheInitialized = true;
|
||||||
return contextCacheManager.createCacheBuilder(TOKEN_CACHE_MANAGER).setExpiry(
|
return contextCacheManager.createCacheBuilder(TOKEN_CACHE_MANAGER).setExpiry(
|
||||||
CacheConfiguration.ExpiryType.MODIFIED,
|
CacheConfiguration.ExpiryType.MODIFIED,
|
||||||
new CacheConfiguration.Duration(TimeUnit.MINUTES, CACHE_DURATION)).setStoreByValue(false).build();
|
new CacheConfiguration.Duration(TimeUnit.MINUTES, CACHE_DURATION)).setStoreByValue(false).build();
|
||||||
} else {
|
|
||||||
return Caching.getCacheManager(TOKEN_CACHE_MANAGER).getCache(TOKEN_CACHE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,20 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate Error Messages for responses.
|
* Generate Error Messages for responses.
|
||||||
*/
|
*/
|
||||||
@ -23,7 +24,6 @@ package org.wso2.carbon.mdm.mobileservices.windows.common.util;
|
|||||||
public class ErrorMessage {
|
public class ErrorMessage {
|
||||||
|
|
||||||
private String errorMessage;
|
private String errorMessage;
|
||||||
private String errorCode;
|
|
||||||
|
|
||||||
public String getErrorMessage() {
|
public String getErrorMessage() {
|
||||||
return errorMessage;
|
return errorMessage;
|
||||||
@ -33,7 +33,5 @@ public class ErrorMessage {
|
|||||||
this.errorMessage = errorMessage;
|
this.errorMessage = errorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getErrorCode() {
|
|
||||||
return errorCode;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
@ -60,9 +60,7 @@ public class GsonMessageBodyHandler implements MessageBodyWriter<Object>, Messag
|
|||||||
public Object readFrom(Class<Object> objectClass, Type type, Annotation[] annotations, MediaType mediaType,
|
public Object readFrom(Class<Object> objectClass, Type type, Annotation[] annotations, MediaType mediaType,
|
||||||
MultivaluedMap<String, String> stringStringMultivaluedMap, InputStream entityStream)
|
MultivaluedMap<String, String> stringStringMultivaluedMap, InputStream entityStream)
|
||||||
throws IOException, WebApplicationException {
|
throws IOException, WebApplicationException {
|
||||||
|
InputStreamReader reader = new InputStreamReader(entityStream, UTF_8);
|
||||||
InputStreamReader reader = new InputStreamReader(entityStream, "UTF-8");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return getGson().fromJson(reader, type);
|
return getGson().fromJson(reader, type);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.mdm.mobileservices.windows.common.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class for OAuthValidation Response.
|
||||||
|
*/
|
||||||
|
public class OAuthValidationResponse {
|
||||||
|
|
||||||
|
private String userName;
|
||||||
|
private String tenantDomain;
|
||||||
|
private boolean isValid;
|
||||||
|
private String errorMsg;
|
||||||
|
|
||||||
|
public OAuthValidationResponse() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public OAuthValidationResponse(String userName, String tenantDomain, boolean isValid) {
|
||||||
|
this.userName = userName;
|
||||||
|
this.tenantDomain = tenantDomain;
|
||||||
|
this.isValid = isValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserName() {
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserName(String userName) {
|
||||||
|
this.userName = userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTenantDomain() {
|
||||||
|
return tenantDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTenantDomain(String tenantDomain) {
|
||||||
|
this.tenantDomain = tenantDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isValid() {
|
||||||
|
return isValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsValid(boolean isValid) {
|
||||||
|
this.isValid = isValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getErrorMsg() {
|
||||||
|
return errorMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrorMsg(String errorMsg) {
|
||||||
|
this.errorMsg = errorMsg;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,25 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.common.util;
|
package org.wso2.carbon.mdm.mobileservices.windows.common.util;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.apache.ws.security.WSSecurityException;
|
import org.apache.ws.security.WSSecurityException;
|
||||||
import org.apache.ws.security.handler.RequestData;
|
import org.apache.ws.security.handler.RequestData;
|
||||||
import org.apache.ws.security.validate.Credential;
|
import org.apache.ws.security.validate.Credential;
|
||||||
@ -40,7 +38,6 @@ public class UsernameTokenValidator implements Validator {
|
|||||||
private static final int USER_SEGMENT = 0;
|
private static final int USER_SEGMENT = 0;
|
||||||
private static final int DOMAIN_SEGMENT = 1;
|
private static final int DOMAIN_SEGMENT = 1;
|
||||||
private static final String DELIMITER = "@";
|
private static final String DELIMITER = "@";
|
||||||
private static Log log = LogFactory.getLog(UsernameTokenValidator.class);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method validates the username token in SOAP message coming from the device.
|
* This method validates the username token in SOAP message coming from the device.
|
||||||
@ -65,20 +62,12 @@ public class UsernameTokenValidator implements Validator {
|
|||||||
if (authenticate(user, password, domain)) {
|
if (authenticate(user, password, domain)) {
|
||||||
returnCredentials = credential;
|
returnCredentials = credential;
|
||||||
} else {
|
} else {
|
||||||
String msg = "Authentication failure due to incorrect credentials.";
|
throw new WindowsDeviceEnrolmentException("Authentication failure due to incorrect credentials.");
|
||||||
log.error(msg);
|
|
||||||
throw new WindowsDeviceEnrolmentException(msg);
|
|
||||||
}
|
}
|
||||||
//Generic exception is caught here as there is no need of taking different actions for
|
|
||||||
//different exceptions.
|
|
||||||
} catch (AuthenticationException e) {
|
} catch (AuthenticationException e) {
|
||||||
String msg = "Failure occurred in the BST validator.";
|
throw new WSSecurityException("Failure occurred in the BST validator.", e);
|
||||||
log.error(msg, e);
|
|
||||||
throw new WSSecurityException(msg, e);
|
|
||||||
} catch (WindowsDeviceEnrolmentException e) {
|
} catch (WindowsDeviceEnrolmentException e) {
|
||||||
String msg = "Authentication Failure occurred due to binary security token.";
|
throw new WSSecurityException("Authentication Failure occurred due to binary security token.", e);
|
||||||
log.error(msg, e);
|
|
||||||
throw new WSSecurityException(msg, e);
|
|
||||||
}
|
}
|
||||||
return returnCredentials;
|
return returnCredentials;
|
||||||
}
|
}
|
||||||
@ -103,30 +92,21 @@ public class UsernameTokenValidator implements Validator {
|
|||||||
RealmService realmService = (RealmService) ctx.getOSGiService(RealmService.class, null);
|
RealmService realmService = (RealmService) ctx.getOSGiService(RealmService.class, null);
|
||||||
|
|
||||||
if (realmService == null) {
|
if (realmService == null) {
|
||||||
String msg = "RealmService not initialized.";
|
throw new AuthenticationException("RealmService not initialized.");
|
||||||
log.error(msg);
|
|
||||||
throw new AuthenticationException(msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int tenantId;
|
int tenantId;
|
||||||
if (tenantDomain == null || tenantDomain.trim().isEmpty()) {
|
if (tenantDomain == null || tenantDomain.trim().isEmpty()) {
|
||||||
tenantId = MultitenantConstants.SUPER_TENANT_ID;
|
tenantId = MultitenantConstants.SUPER_TENANT_ID;
|
||||||
} else {
|
} else {
|
||||||
tenantId = realmService.getTenantManager().getTenantId(tenantDomain);
|
tenantId = realmService.getTenantManager().getTenantId(tenantDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tenantId == MultitenantConstants.INVALID_TENANT_ID) {
|
if (tenantId == MultitenantConstants.INVALID_TENANT_ID) {
|
||||||
String msg = "Invalid tenant domain " + tenantDomain;
|
throw new AuthenticationException("Invalid tenant domain " + tenantDomain);
|
||||||
log.error(msg);
|
|
||||||
throw new AuthenticationException(msg);
|
|
||||||
}
|
}
|
||||||
UserRealm userRealm = realmService.getTenantUserRealm(tenantId);
|
UserRealm userRealm = realmService.getTenantUserRealm(tenantId);
|
||||||
|
|
||||||
return userRealm.getUserStoreManager().authenticate(username, password);
|
return userRealm.getUserStoreManager().authenticate(username, password);
|
||||||
} catch (UserStoreException e) {
|
} catch (UserStoreException e) {
|
||||||
String msg = "User store is not initialized.";
|
throw new AuthenticationException("User store is not initialized.", e);
|
||||||
log.error(msg, e);
|
|
||||||
throw new AuthenticationException(msg, e);
|
|
||||||
} finally {
|
} finally {
|
||||||
PrivilegedCarbonContext.endTenantFlow();
|
PrivilegedCarbonContext.endTenantFlow();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,32 +1,29 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.common.util;
|
package org.wso2.carbon.mdm.mobileservices.windows.common.util;
|
||||||
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.wso2.carbon.base.MultitenantConstants;
|
import org.wso2.carbon.base.MultitenantConstants;
|
||||||
import org.wso2.carbon.certificate.mgt.core.service.CertificateManagementService;
|
|
||||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
|
||||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
||||||
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService;
|
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
@ -35,13 +32,13 @@ import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
|||||||
import org.wso2.carbon.identity.core.util.IdentityTenantUtil;
|
import org.wso2.carbon.identity.core.util.IdentityTenantUtil;
|
||||||
import org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService;
|
import org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.MDMAPIException;
|
|
||||||
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
||||||
import org.wso2.carbon.user.api.TenantManager;
|
import org.wso2.carbon.user.api.TenantManager;
|
||||||
import org.wso2.carbon.user.api.UserStoreException;
|
import org.wso2.carbon.user.api.UserStoreException;
|
||||||
import org.wso2.carbon.user.api.UserStoreManager;
|
|
||||||
import org.wso2.carbon.user.core.service.RealmService;
|
import org.wso2.carbon.user.core.service.RealmService;
|
||||||
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
|
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
|
||||||
|
import org.wso2.carbon.webapp.authenticator.framework.config.AuthenticatorConfig;
|
||||||
|
import org.wso2.carbon.webapp.authenticator.framework.config.AuthenticatorConfigService;
|
||||||
|
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
@ -52,8 +49,6 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class WindowsAPIUtils {
|
public class WindowsAPIUtils {
|
||||||
|
|
||||||
private static Log log = LogFactory.getLog(WindowsAPIUtils.class);
|
|
||||||
|
|
||||||
public static DeviceIdentifier convertToDeviceIdentifierObject(String deviceId) {
|
public static DeviceIdentifier convertToDeviceIdentifierObject(String deviceId) {
|
||||||
DeviceIdentifier identifier = new DeviceIdentifier();
|
DeviceIdentifier identifier = new DeviceIdentifier();
|
||||||
identifier.setId(deviceId);
|
identifier.setId(deviceId);
|
||||||
@ -61,59 +56,23 @@ public class WindowsAPIUtils {
|
|||||||
return identifier;
|
return identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CertificateManagementService getCertificateManagementService() {
|
|
||||||
CertificateManagementService cmService;
|
|
||||||
PrivilegedCarbonContext.startTenantFlow();
|
|
||||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
||||||
ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
|
|
||||||
ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
|
|
||||||
cmService =
|
|
||||||
(CertificateManagementService)ctx.getOSGiService(DeviceManagementProviderService.class, null);
|
|
||||||
PrivilegedCarbonContext.endTenantFlow();
|
|
||||||
return cmService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DeviceManagementProviderService getDeviceManagementService() {
|
public static DeviceManagementProviderService getDeviceManagementService() {
|
||||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||||
DeviceManagementProviderService deviceManagementProviderService =
|
DeviceManagementProviderService deviceManagementProviderService =
|
||||||
(DeviceManagementProviderService) ctx.getOSGiService(DeviceManagementProviderService.class, null);
|
(DeviceManagementProviderService) ctx.getOSGiService(DeviceManagementProviderService.class, null);
|
||||||
if (deviceManagementProviderService == null) {
|
if (deviceManagementProviderService == null) {
|
||||||
String msg = "Device Management service has not initialized.";
|
throw new IllegalStateException("Device Management service has not initialized.");
|
||||||
log.error(msg);
|
|
||||||
throw new IllegalStateException(msg);
|
|
||||||
}
|
}
|
||||||
return deviceManagementProviderService;
|
return deviceManagementProviderService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static UserStoreManager getUserStoreManager() throws MDMAPIException {
|
|
||||||
RealmService realmService;
|
|
||||||
UserStoreManager userStoreManager;
|
|
||||||
try {
|
|
||||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
||||||
realmService = (RealmService) ctx.getOSGiService(RealmService.class, null);
|
|
||||||
if (realmService == null) {
|
|
||||||
String msg = "Realm service has not initialized.";
|
|
||||||
throw new IllegalStateException(msg);
|
|
||||||
}
|
|
||||||
int tenantId = ctx.getTenantId();
|
|
||||||
userStoreManager = realmService.getTenantUserRealm(tenantId).getUserStoreManager();
|
|
||||||
} catch (UserStoreException e) {
|
|
||||||
String msg = "Error occurred while retrieving current user store manager";
|
|
||||||
throw new MDMAPIException(msg, e);
|
|
||||||
}
|
|
||||||
return userStoreManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static NotificationManagementService getNotificationManagementService() {
|
public static NotificationManagementService getNotificationManagementService() {
|
||||||
NotificationManagementService notificationManagementService;
|
NotificationManagementService notificationManagementService;
|
||||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||||
notificationManagementService = (NotificationManagementService) ctx.getOSGiService(
|
notificationManagementService =
|
||||||
NotificationManagementService.class, null);
|
(NotificationManagementService) ctx.getOSGiService(NotificationManagementService.class, null);
|
||||||
if (notificationManagementService == null) {
|
if (notificationManagementService == null) {
|
||||||
String msg = "Notification Management service not initialized.";
|
throw new IllegalStateException("Notification Management service not initialized.");
|
||||||
log.error(msg);
|
|
||||||
throw new IllegalStateException(msg);
|
|
||||||
}
|
}
|
||||||
return notificationManagementService;
|
return notificationManagementService;
|
||||||
}
|
}
|
||||||
@ -134,25 +93,23 @@ public class WindowsAPIUtils {
|
|||||||
WindowsDeviceUtils deviceUtils = new WindowsDeviceUtils();
|
WindowsDeviceUtils deviceUtils = new WindowsDeviceUtils();
|
||||||
DeviceIDHolder deviceIDHolder = deviceUtils.validateDeviceIdentifiers(deviceIDs,
|
DeviceIDHolder deviceIDHolder = deviceUtils.validateDeviceIdentifiers(deviceIDs,
|
||||||
message, responseMediaType);
|
message, responseMediaType);
|
||||||
getDeviceManagementService().addOperation("windows", operation, deviceIDHolder.getValidDeviceIDList());
|
// getDeviceManagementService().addOperation(operation, deviceIDHolder.getValidDeviceIDList());
|
||||||
if (!deviceIDHolder.getErrorDeviceIdList().isEmpty()) {
|
if (!deviceIDHolder.getInvalidDeviceIdList().isEmpty()) {
|
||||||
return javax.ws.rs.core.Response.status(PluginConstants.StatusCodes.
|
return Response.status(PluginConstants.StatusCodes.
|
||||||
MULTI_STATUS_HTTP_CODE).type(
|
MULTI_STATUS_HTTP_CODE).type(
|
||||||
responseMediaType).entity(deviceUtils.
|
responseMediaType).entity(deviceUtils.
|
||||||
convertErrorMapIntoErrorMessage(deviceIDHolder.getErrorDeviceIdList())).build();
|
convertErrorMapIntoErrorMessage(deviceIDHolder.getInvalidDeviceIdList())).build();
|
||||||
}
|
}
|
||||||
return javax.ws.rs.core.Response.status(javax.ws.rs.core.Response.Status.CREATED).
|
return Response.status(Response.Status.CREATED).
|
||||||
type(responseMediaType).build();
|
type(responseMediaType).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PolicyManagerService getPolicyManagerService() {
|
public static PolicyManagerService getPolicyManagerService() {
|
||||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||||
PolicyManagerService policyManagerService = (PolicyManagerService) ctx.getOSGiService(
|
PolicyManagerService policyManagerService =
|
||||||
PolicyManagerService.class, null);
|
(PolicyManagerService) ctx.getOSGiService(PolicyManagerService.class, null);
|
||||||
if (policyManagerService == null) {
|
if (policyManagerService == null) {
|
||||||
String msg = "Policy Manager service has not initialized";
|
throw new IllegalStateException("Policy Manager service has not initialized");
|
||||||
log.error(msg);
|
|
||||||
throw new IllegalStateException(msg);
|
|
||||||
}
|
}
|
||||||
return policyManagerService;
|
return policyManagerService;
|
||||||
}
|
}
|
||||||
@ -165,6 +122,14 @@ public class WindowsAPIUtils {
|
|||||||
getDeviceManagementService().updateOperation(deviceIdentifier, operation);
|
getDeviceManagementService().updateOperation(deviceIdentifier, operation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<? extends Operation> getPendingOperations(DeviceIdentifier deviceIdentifier)
|
||||||
|
throws OperationManagementException, DeviceManagementException {
|
||||||
|
List<? extends Operation> pendingDataOperations;
|
||||||
|
pendingDataOperations = WindowsAPIUtils.getDeviceManagementService().getOperationsByDeviceAndStatus(
|
||||||
|
deviceIdentifier, Operation.Status.PENDING);
|
||||||
|
return pendingDataOperations;
|
||||||
|
}
|
||||||
|
|
||||||
public static PlatformConfiguration getTenantConfiguration() throws DeviceManagementException {
|
public static PlatformConfiguration getTenantConfiguration() throws DeviceManagementException {
|
||||||
return getDeviceManagementService().getConfiguration(
|
return getDeviceManagementService().getConfiguration(
|
||||||
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
|
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
|
||||||
@ -172,16 +137,20 @@ public class WindowsAPIUtils {
|
|||||||
|
|
||||||
public static int getTenantIdOFUser(String username) throws DeviceManagementException {
|
public static int getTenantIdOFUser(String username) throws DeviceManagementException {
|
||||||
int tenantId = 0;
|
int tenantId = 0;
|
||||||
|
RealmService realmService;
|
||||||
String domainName = MultitenantUtils.getTenantDomain(username);
|
String domainName = MultitenantUtils.getTenantDomain(username);
|
||||||
if (domainName != null) {
|
if (domainName != null) {
|
||||||
try {
|
try {
|
||||||
TenantManager tenantManager = IdentityTenantUtil.getRealmService().getTenantManager();
|
if ((realmService = IdentityTenantUtil.getRealmService()) != null) {
|
||||||
tenantId = tenantManager.getTenantId(domainName);
|
TenantManager tenantManager = realmService.getTenantManager();
|
||||||
|
tenantId = tenantManager.getTenantId(domainName);
|
||||||
|
}
|
||||||
|
if (realmService == null) {
|
||||||
|
throw new IllegalStateException("Realm service has not initialized.");
|
||||||
|
}
|
||||||
} catch (UserStoreException e) {
|
} catch (UserStoreException e) {
|
||||||
String errorMsg = "Error when getting the tenant id from the tenant domain : " +
|
throw new DeviceManagementException("Error when getting the tenant id from the tenant domain : "
|
||||||
domainName;
|
+ domainName, e);
|
||||||
log.error(errorMsg, e);
|
|
||||||
throw new DeviceManagementException(errorMsg, e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tenantId;
|
return tenantId;
|
||||||
@ -192,19 +161,50 @@ public class WindowsAPIUtils {
|
|||||||
OAuth2TokenValidationService oAuth2TokenValidationService =
|
OAuth2TokenValidationService oAuth2TokenValidationService =
|
||||||
(OAuth2TokenValidationService) ctx.getOSGiService(OAuth2TokenValidationService.class, null);
|
(OAuth2TokenValidationService) ctx.getOSGiService(OAuth2TokenValidationService.class, null);
|
||||||
if (oAuth2TokenValidationService == null) {
|
if (oAuth2TokenValidationService == null) {
|
||||||
String msg = "OAuth2TokenValidation service has not initialized.";
|
throw new IllegalStateException("OAuth2TokenValidation service has not initialized.");
|
||||||
log.error(msg);
|
|
||||||
throw new IllegalStateException(msg);
|
|
||||||
}
|
}
|
||||||
return oAuth2TokenValidationService;
|
return oAuth2TokenValidationService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void startTenantFlow(String userName) {
|
public static AuthenticatorConfig getBSTAuthenticatorConfig() {
|
||||||
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||||
|
AuthenticatorConfigService authenticatorConfigService =
|
||||||
|
(AuthenticatorConfigService) ctx.getOSGiService(AuthenticatorConfigService.class, null);
|
||||||
|
AuthenticatorConfig authenticatorConfig = authenticatorConfigService.getAuthenticatorConfig("BST");
|
||||||
|
if (authenticatorConfigService == null) {
|
||||||
|
throw new IllegalStateException("AuthenticatorConfiguration service has not initialized.");
|
||||||
|
}
|
||||||
|
if (authenticatorConfig == null) {
|
||||||
|
throw new IllegalStateException("BST authenticatorConfig has not initialized.");
|
||||||
|
}
|
||||||
|
return authenticatorConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void startTenantFlow(AuthenticationInfo authenticationInfo) {
|
||||||
PrivilegedCarbonContext.startTenantFlow();
|
PrivilegedCarbonContext.startTenantFlow();
|
||||||
PrivilegedCarbonContext privilegedCarbonContext = PrivilegedCarbonContext.
|
PrivilegedCarbonContext privilegedCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||||
getThreadLocalCarbonContext();
|
if (authenticationInfo.getTenantDomain() == null) {
|
||||||
privilegedCarbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
|
privilegedCarbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
|
||||||
privilegedCarbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
|
privilegedCarbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
|
||||||
privilegedCarbonContext.setUsername(userName);
|
} else {
|
||||||
|
privilegedCarbonContext.setTenantId(authenticationInfo.getTenantId());
|
||||||
|
privilegedCarbonContext.setTenantDomain(authenticationInfo.getTenantDomain());
|
||||||
|
}
|
||||||
|
privilegedCarbonContext.setUsername(authenticationInfo.getUsername());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used to get tenant configurations.
|
||||||
|
*
|
||||||
|
* @return List of Configurations entries.
|
||||||
|
* @throws DeviceManagementException
|
||||||
|
*/
|
||||||
|
public static List<ConfigurationEntry> getTenantConfigurationData() throws DeviceManagementException {
|
||||||
|
PlatformConfiguration tenantConfiguration;
|
||||||
|
if ((tenantConfiguration = WindowsAPIUtils.getTenantConfiguration()) != null) {
|
||||||
|
return tenantConfiguration.getConfiguration();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
@ -43,8 +43,8 @@ public class WindowsDeviceUtils {
|
|||||||
message.setResponseMessage("Device identifier list is empty");
|
message.setResponseMessage("Device identifier list is empty");
|
||||||
throw new BadRequestException(message, responseMediaType);
|
throw new BadRequestException(message, responseMediaType);
|
||||||
}
|
}
|
||||||
List<String> errorDeviceIdList = new ArrayList<String>();
|
List<String> errorDeviceIdList = new ArrayList<>();
|
||||||
List<DeviceIdentifier> validDeviceIDList = new ArrayList<DeviceIdentifier>();
|
List<DeviceIdentifier> validDeviceIDList = new ArrayList<>();
|
||||||
int deviceIDCounter = 0;
|
int deviceIDCounter = 0;
|
||||||
|
|
||||||
for (String deviceID : deviceIDs) {
|
for (String deviceID : deviceIDs) {
|
||||||
@ -75,11 +75,12 @@ public class WindowsDeviceUtils {
|
|||||||
}
|
}
|
||||||
DeviceIDHolder deviceIDHolder = new DeviceIDHolder();
|
DeviceIDHolder deviceIDHolder = new DeviceIDHolder();
|
||||||
deviceIDHolder.setValidDeviceIDList(validDeviceIDList);
|
deviceIDHolder.setValidDeviceIDList(validDeviceIDList);
|
||||||
deviceIDHolder.setErrorDeviceIdList(errorDeviceIdList);
|
deviceIDHolder.setInvalidDeviceIdList(errorDeviceIdList);
|
||||||
return deviceIDHolder;
|
return deviceIDHolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String convertErrorMapIntoErrorMessage(List<String> errorDeviceIdList) {
|
public String convertErrorMapIntoErrorMessage(List<String> errorDeviceIdList) {
|
||||||
return StringUtils.join(errorDeviceIdList.iterator(), COMMA_SEPARATION_PATTERN);
|
return StringUtils.join(errorDeviceIdList.iterator(), COMMA_SEPARATION_PATTERN);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,25 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
||||||
@ -30,12 +28,9 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* Configurations that needs to be added on the device.
|
* Configurations that needs to be added on the device.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "AddTag", description = "This class carries all information related to Syncml AddTag.")
|
|
||||||
public class AddTag {
|
public class AddTag {
|
||||||
@ApiModelProperty(name = "commandId", value = "CommandID of the AddTag.", required = true)
|
|
||||||
int commandId = -1;
|
int commandId = -1;
|
||||||
@ApiModelProperty(name = "items", value = "List of items of the AddTag.", required = true)
|
List<ItemTag> items;
|
||||||
List<Item> items;
|
|
||||||
|
|
||||||
public int getCommandId() {
|
public int getCommandId() {
|
||||||
return commandId;
|
return commandId;
|
||||||
@ -45,11 +40,11 @@ public class AddTag {
|
|||||||
this.commandId = commandId;
|
this.commandId = commandId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Item> getItems() {
|
public List<ItemTag> getItems() {
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItems(List<Item> items) {
|
public void setItems(List<ItemTag> items) {
|
||||||
this.items = items;
|
this.items = items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,8 +57,8 @@ public class AddTag {
|
|||||||
commandId.appendChild(doc.createTextNode(String.valueOf(getCommandId())));
|
commandId.appendChild(doc.createTextNode(String.valueOf(getCommandId())));
|
||||||
add.appendChild(commandId);
|
add.appendChild(commandId);
|
||||||
}
|
}
|
||||||
for (Iterator<Item> itemIterator = getItems().iterator(); itemIterator.hasNext(); ) {
|
for (Iterator<ItemTag> itemIterator = getItems().iterator(); itemIterator.hasNext();) {
|
||||||
Item item = itemIterator.next();
|
ItemTag item = itemIterator.next();
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
item.buildItemElement(doc, add);
|
item.buildItemElement(doc, add);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,25 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
||||||
@ -27,12 +25,9 @@ import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
|||||||
/**
|
/**
|
||||||
* Inform an event occurred from device to server.
|
* Inform an event occurred from device to server.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "Alert",
|
public class AlertTag {
|
||||||
description = "This class carries all information related to Syncml alert.")
|
|
||||||
public class Alert {
|
|
||||||
@ApiModelProperty(name = "commandId", value = "CommandId of The Syncml Alert.", required = true)
|
|
||||||
int commandId = -1;
|
int commandId = -1;
|
||||||
@ApiModelProperty(name = "data", value = "Data of the AlertTag.", required = true)
|
|
||||||
String data;
|
String data;
|
||||||
|
|
||||||
public int getCommandId() {
|
public int getCommandId() {
|
||||||
@ -1,25 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
||||||
@ -30,20 +28,16 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* Wrapper for other SyncML elements.
|
* Wrapper for other SyncML elements.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "AtomicTag", description = "This class carries all information related to syncml Engine Atomic tag")
|
|
||||||
public class AtomicTag {
|
public class AtomicTag {
|
||||||
@ApiModelProperty(name = "commandId", value = "Syncml Atomic tag CommandId", required = true)
|
|
||||||
int commandId = -1;
|
int commandId = -1;
|
||||||
@ApiModelProperty(name = "adds", value = "List of addtags", required = true)
|
|
||||||
List<AddTag> adds;
|
List<AddTag> adds;
|
||||||
@ApiModelProperty(name = "replaces", value = "List of replace tags", required = true)
|
List<ReplaceTag> replaces;
|
||||||
List<Replace> replaces;
|
|
||||||
|
|
||||||
public List<Replace> getReplaces() {
|
public List<ReplaceTag> getReplaces() {
|
||||||
return replaces;
|
return replaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReplaces(List<Replace> replaces) {
|
public void setReplaces(List<ReplaceTag> replaces) {
|
||||||
this.replaces = replaces;
|
this.replaces = replaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,8 +74,8 @@ public class AtomicTag {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getReplaces() != null) {
|
if (getReplaces() != null) {
|
||||||
for (Iterator<Replace> replaceIterator = getReplaces().iterator(); replaceIterator.hasNext(); ) {
|
for (Iterator<ReplaceTag> replaceIterator = getReplaces().iterator(); replaceIterator.hasNext(); ) {
|
||||||
Replace add = replaceIterator.next();
|
ReplaceTag add = replaceIterator.next();
|
||||||
if (add != null) {
|
if (add != null) {
|
||||||
add.buildReplaceElement(doc, atomic);
|
add.buildReplaceElement(doc, atomic);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,25 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
||||||
@ -27,10 +25,7 @@ import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
|||||||
/**
|
/**
|
||||||
* Challenge data pass through the device and Device Management server for the security purpose.
|
* Challenge data pass through the device and Device Management server for the security purpose.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "ChallengeTag",
|
|
||||||
description = "This class carries all information related to install application")
|
|
||||||
public class ChallengeTag {
|
public class ChallengeTag {
|
||||||
@ApiModelProperty(name = "meta", value = "Syncml MetaTag", required = true)
|
|
||||||
MetaTag meta;
|
MetaTag meta;
|
||||||
|
|
||||||
public MetaTag getMeta() {
|
public MetaTag getMeta() {
|
||||||
@ -41,11 +36,11 @@ public class ChallengeTag {
|
|||||||
this.meta = meta;
|
this.meta = meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buildChallElement(Document doc, Element rootElement) {
|
public void buildChallengeElement(Document doc, Element rootElement) {
|
||||||
Element chal = doc.createElement(Constants.CHALLENGE);
|
Element challenge = doc.createElement(Constants.CHALLENGE);
|
||||||
rootElement.appendChild(chal);
|
rootElement.appendChild(challenge);
|
||||||
if (getMeta() != null) {
|
if (getMeta() != null) {
|
||||||
getMeta().buildMetaElement(doc, chal);
|
getMeta().buildMetaElement(doc, challenge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,25 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
||||||
@ -27,12 +25,8 @@ import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
|||||||
/**
|
/**
|
||||||
* Credentials passed between the device and the server for security purposes.
|
* Credentials passed between the device and the server for security purposes.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "Credential",
|
public class CredentialTag {
|
||||||
description = "This class carries all information related to syncml credentials")
|
|
||||||
public class Credential {
|
|
||||||
@ApiModelProperty(name = "meta", value = "Syncml credential's MetaTag reference.)", required = true)
|
|
||||||
MetaTag meta;
|
MetaTag meta;
|
||||||
@ApiModelProperty(name = "data", value = "Data of the Credential Tag.)", required = true)
|
|
||||||
String data;
|
String data;
|
||||||
|
|
||||||
public MetaTag getMeta() {
|
public MetaTag getMeta() {
|
||||||
@ -1,25 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
||||||
@ -30,13 +28,9 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* Configurations that need to be delete on Device.
|
* Configurations that need to be delete on Device.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "DeleteTag",
|
|
||||||
description = "This class carries all information related to Syncml DeleteTag.")
|
|
||||||
public class DeleteTag {
|
public class DeleteTag {
|
||||||
@ApiModelProperty(name = "commandId", value = "CommandId of the Syncl DeleteTag.", required = true)
|
|
||||||
int commandId = -1;
|
int commandId = -1;
|
||||||
@ApiModelProperty(name = "items", value = "List of items of the syncml DeleteTag. ", required = true)
|
List<ItemTag> items;
|
||||||
List<Item> items;
|
|
||||||
|
|
||||||
public int getCommandId() {
|
public int getCommandId() {
|
||||||
return commandId;
|
return commandId;
|
||||||
@ -46,11 +40,11 @@ public class DeleteTag {
|
|||||||
this.commandId = commandId;
|
this.commandId = commandId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Item> getItems() {
|
public List<ItemTag> getItems() {
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItems(List<Item> items) {
|
public void setItems(List<ItemTag> items) {
|
||||||
this.items = items;
|
this.items = items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,8 +57,8 @@ public class DeleteTag {
|
|||||||
commandId.appendChild(doc.createTextNode(String.valueOf(getCommandId())));
|
commandId.appendChild(doc.createTextNode(String.valueOf(getCommandId())));
|
||||||
delete.appendChild(commandId);
|
delete.appendChild(commandId);
|
||||||
}
|
}
|
||||||
for (Iterator<Item> itemIterator = getItems().iterator(); itemIterator.hasNext(); ) {
|
for (Iterator<ItemTag> itemIterator = getItems().iterator(); itemIterator.hasNext(); ) {
|
||||||
Item item = itemIterator.next();
|
ItemTag item = itemIterator.next();
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
item.buildItemElement(doc, delete);
|
item.buildItemElement(doc, delete);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,25 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
||||||
@ -30,13 +28,9 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* Commands that needs to be executed on the device.
|
* Commands that needs to be executed on the device.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "ExecuteTag",
|
|
||||||
description = "This class carries all information related to Syncml ExecuteTag.")
|
|
||||||
public class ExecuteTag {
|
public class ExecuteTag {
|
||||||
@ApiModelProperty(name = "type", value = "CommandId of the syncml ExecuteTag.", required = true)
|
|
||||||
int commandId = -1;
|
int commandId = -1;
|
||||||
@ApiModelProperty(name = "type", value = "List of items of the Syncml ExecuteTag.", required = true)
|
List<ItemTag> items;
|
||||||
List<Item> items;
|
|
||||||
|
|
||||||
public int getCommandId() {
|
public int getCommandId() {
|
||||||
return commandId;
|
return commandId;
|
||||||
@ -46,11 +40,11 @@ public class ExecuteTag {
|
|||||||
this.commandId = commandId;
|
this.commandId = commandId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Item> getItems() {
|
public List<ItemTag> getItems() {
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItems(List<Item> items) {
|
public void setItems(List<ItemTag> items) {
|
||||||
this.items = items;
|
this.items = items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,8 +57,8 @@ public class ExecuteTag {
|
|||||||
commandId.appendChild(doc.createTextNode(String.valueOf(getCommandId())));
|
commandId.appendChild(doc.createTextNode(String.valueOf(getCommandId())));
|
||||||
exec.appendChild(commandId);
|
exec.appendChild(commandId);
|
||||||
}
|
}
|
||||||
for (Iterator<Item> itemIterator = getItems().iterator(); itemIterator.hasNext(); ) {
|
for (Iterator<ItemTag> itemIterator = getItems().iterator(); itemIterator.hasNext(); ) {
|
||||||
Item item = itemIterator.next();
|
ItemTag item = itemIterator.next();
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
item.buildItemElement(doc, exec);
|
item.buildItemElement(doc, exec);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,25 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
||||||
@ -30,13 +28,9 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* Data that needs to be retrieved from the device.
|
* Data that needs to be retrieved from the device.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "Get",
|
public class GetTag {
|
||||||
description = "This class carries all information related to syncml GetTag.")
|
|
||||||
public class Get {
|
|
||||||
@ApiModelProperty(name = "commandId", value = "CommandId of the syncml GetTag.", required = true)
|
|
||||||
int commandId = -1;
|
int commandId = -1;
|
||||||
@ApiModelProperty(name = "items", value = "List of items of the Syncml GetTag.", required = true)
|
List<ItemTag> items;
|
||||||
List<Item> items;
|
|
||||||
|
|
||||||
public int getCommandId() {
|
public int getCommandId() {
|
||||||
return commandId;
|
return commandId;
|
||||||
@ -46,11 +40,11 @@ public class Get {
|
|||||||
this.commandId = commandId;
|
this.commandId = commandId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Item> getItems() {
|
public List<ItemTag> getItems() {
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItems(List<Item> items) {
|
public void setItems(List<ItemTag> items) {
|
||||||
this.items = items;
|
this.items = items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,8 +58,8 @@ public class Get {
|
|||||||
get.appendChild(commandId);
|
get.appendChild(commandId);
|
||||||
}
|
}
|
||||||
if (getItems() != null) {
|
if (getItems() != null) {
|
||||||
for (Iterator<Item> itemIterator = getItems().iterator(); itemIterator.hasNext(); ) {
|
for (Iterator<ItemTag> itemIterator = getItems().iterator(); itemIterator.hasNext(); ) {
|
||||||
Item item = itemIterator.next();
|
ItemTag item = itemIterator.next();
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
item.buildItemElement(doc, get);
|
item.buildItemElement(doc, get);
|
||||||
}
|
}
|
||||||
@ -1,25 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
||||||
@ -27,16 +25,11 @@ import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
|||||||
/**
|
/**
|
||||||
* Represents an items that should be retrieved from the device or a command.
|
* Represents an items that should be retrieved from the device or a command.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "Item",
|
public class ItemTag {
|
||||||
description = "This class carries all information related to Syncml Item.")
|
|
||||||
public class Item {
|
TargetTag target;
|
||||||
@ApiModelProperty(name = "target", value = "Target reference value of the Syncml Message(ex:Device).", required = true)
|
SourceTag source;
|
||||||
Target target;
|
|
||||||
@ApiModelProperty(name = "source", value = "Source reference of the syncml message.(Ex:EMM Server).", required = true)
|
|
||||||
Source source;
|
|
||||||
@ApiModelProperty(name = "data", value = "Content of the syncml message.", required = true)
|
|
||||||
String data;
|
String data;
|
||||||
@ApiModelProperty(name = "meta", value = "Meta data of the syncml messsage.", required = true)
|
|
||||||
MetaTag meta;
|
MetaTag meta;
|
||||||
|
|
||||||
public MetaTag getMeta() {
|
public MetaTag getMeta() {
|
||||||
@ -55,19 +48,19 @@ public class Item {
|
|||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Source getSource() {
|
public SourceTag getSource() {
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSource(Source source) {
|
public void setSource(SourceTag source) {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Target getTarget() {
|
public TargetTag getTarget() {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTarget(Target target) {
|
public void setTarget(TargetTag target) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1,25 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.w3c.dom.Attr;
|
import org.w3c.dom.Attr;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
@ -28,13 +26,10 @@ import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
|||||||
/**
|
/**
|
||||||
* MetaTag data related to credentials.
|
* MetaTag data related to credentials.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "MetaTag", description = "This class carries all information related to MetaTag")
|
|
||||||
public class MetaTag {
|
public class MetaTag {
|
||||||
@ApiModelProperty(name = "format", value = "MetaTag format.)", required = true)
|
|
||||||
String format;
|
String format;
|
||||||
@ApiModelProperty(name = "type", value = "MetaTag type)", required = true)
|
|
||||||
String type;
|
String type;
|
||||||
@ApiModelProperty(name = "nextNonce", value = "Syncml Nextnonce)", required = true)
|
|
||||||
String nextNonce;
|
String nextNonce;
|
||||||
|
|
||||||
public String getNextNonce() {
|
public String getNextNonce() {
|
||||||
|
|||||||
@ -1,25 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
||||||
@ -30,13 +28,9 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* Commands sent from the device.
|
* Commands sent from the device.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "Replace",
|
public class ReplaceTag {
|
||||||
description = "This class carries all information related to Syncml ReplaceTag.")
|
|
||||||
public class Replace {
|
|
||||||
@ApiModelProperty(name = "commandId", value = "CommandId of the syncml ReplaceTag.", required = true)
|
|
||||||
int commandId = -1;
|
int commandId = -1;
|
||||||
@ApiModelProperty(name = "items", value = "List of items of the syncml ReplaceTag.", required = true)
|
List<ItemTag> items;
|
||||||
List<Item> items;
|
|
||||||
|
|
||||||
public int getCommandId() {
|
public int getCommandId() {
|
||||||
return commandId;
|
return commandId;
|
||||||
@ -46,11 +40,11 @@ public class Replace {
|
|||||||
this.commandId = commandId;
|
this.commandId = commandId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Item> getItems() {
|
public List<ItemTag> getItems() {
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItems(List<Item> items) {
|
public void setItems(List<ItemTag> items) {
|
||||||
this.items = items;
|
this.items = items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,8 +58,8 @@ public class Replace {
|
|||||||
replace.appendChild(commandId);
|
replace.appendChild(commandId);
|
||||||
}
|
}
|
||||||
if (getItems() != null) {
|
if (getItems() != null) {
|
||||||
for (Iterator<Item> itemIterator = getItems().iterator(); itemIterator.hasNext(); ) {
|
for (Iterator<ItemTag> itemIterator = getItems().iterator(); itemIterator.hasNext(); ) {
|
||||||
Item item = itemIterator.next();
|
ItemTag item = itemIterator.next();
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
item.buildItemElement(doc, replace);
|
item.buildItemElement(doc, replace);
|
||||||
}
|
}
|
||||||
@ -1,25 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
||||||
@ -30,17 +28,11 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* Results sent for the requests made to the device.
|
* Results sent for the requests made to the device.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "Results",
|
public class ResultsTag {
|
||||||
description = "This class carries all information related to Syncml Item.")
|
|
||||||
public class Results {
|
|
||||||
@ApiModelProperty(name = "commandId", value = "CommandID of the Syncml Results Tag.", required = true)
|
|
||||||
int commandId = -1;
|
int commandId = -1;
|
||||||
@ApiModelProperty(name = "messageReference", value = "MessageReference of the Syncml Results Tag.", required = true)
|
|
||||||
int messageReference = -1;
|
int messageReference = -1;
|
||||||
@ApiModelProperty(name = "commandReference", value = "CommandReference of the Syncml Results Tag.", required = true)
|
|
||||||
int commandReference = -1;
|
int commandReference = -1;
|
||||||
@ApiModelProperty(name = "item", value = "List of Items in Syncml ResultTag.", required = true)
|
List<ItemTag> item;
|
||||||
List<Item> item;
|
|
||||||
|
|
||||||
public int getCommandId() {
|
public int getCommandId() {
|
||||||
return commandId;
|
return commandId;
|
||||||
@ -66,11 +58,11 @@ public class Results {
|
|||||||
this.commandReference = commandReference;
|
this.commandReference = commandReference;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Item> getItem() {
|
public List<ItemTag> getItem() {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItem(List<Item> item) {
|
public void setItem(List<ItemTag> item) {
|
||||||
this.item = item;
|
this.item = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,8 +85,8 @@ public class Results {
|
|||||||
results.appendChild(messageReference);
|
results.appendChild(messageReference);
|
||||||
}
|
}
|
||||||
if (getItem() != null) {
|
if (getItem() != null) {
|
||||||
for (Iterator<Item> itemIterator = getItem().iterator(); itemIterator.hasNext(); ) {
|
for (Iterator<ItemTag> itemIterator = getItem().iterator(); itemIterator.hasNext(); ) {
|
||||||
Item item = itemIterator.next();
|
ItemTag item = itemIterator.next();
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
item.buildItemElement(doc, results);
|
item.buildItemElement(doc, results);
|
||||||
}
|
}
|
||||||
@ -1,25 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
||||||
@ -28,23 +26,16 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sequence data that use to execute tag list
|
* Class used to build syncml SequenceTag.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "SequenceTag",
|
|
||||||
description = "This class carries all information related to Syncml SequenceTag.")
|
|
||||||
public class SequenceTag {
|
public class SequenceTag {
|
||||||
@ApiModelProperty(name = "commandId", value = "CommandId of the Syncml SequenceTag", required = true)
|
|
||||||
int commandId;
|
int commandId;
|
||||||
@ApiModelProperty(name = "exec", value = "ExcecuteTag sequence of the Syncml SequenceTag", required = true)
|
|
||||||
ExecuteTag exec;
|
ExecuteTag exec;
|
||||||
@ApiModelProperty(name = "get", value = "GetTag of the syncml SequenceTag.", required = true)
|
GetTag get;
|
||||||
Get get;
|
|
||||||
@ApiModelProperty(name = "deleteTag", value = "DeleteTag of the syncml SequenceTag.", required = true)
|
|
||||||
DeleteTag deleteTag;
|
DeleteTag deleteTag;
|
||||||
@ApiModelProperty(name = "atomicTag", value = "AtomicTag sequence of the syncml SequenceTag.", required = true)
|
|
||||||
AtomicTag atomicTag;
|
AtomicTag atomicTag;
|
||||||
@ApiModelProperty(name = "replaces", value = "ReplaceTag of the syncml SequenceTag.", required = true)
|
List<ReplaceTag> replaces;
|
||||||
List<Replace> replaces;
|
|
||||||
|
|
||||||
public DeleteTag getDeleteTag() {
|
public DeleteTag getDeleteTag() {
|
||||||
return deleteTag;
|
return deleteTag;
|
||||||
@ -54,11 +45,11 @@ public class SequenceTag {
|
|||||||
this.deleteTag = deleteTag;
|
this.deleteTag = deleteTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Replace> getReplaces() {
|
public List<ReplaceTag> getReplaces() {
|
||||||
return replaces;
|
return replaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReplaces(List<Replace> replaces) {
|
public void setReplaces(List<ReplaceTag> replaces) {
|
||||||
this.replaces = replaces;
|
this.replaces = replaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,11 +77,11 @@ public class SequenceTag {
|
|||||||
this.commandId = commandId;
|
this.commandId = commandId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Get getGet() {
|
public GetTag getGet() {
|
||||||
return get;
|
return get;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGet(Get get) {
|
public void setGet(GetTag get) {
|
||||||
this.get = get;
|
this.get = get;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,18 +100,19 @@ public class SequenceTag {
|
|||||||
getGet().buildGetElement(doc, sequence);
|
getGet().buildGetElement(doc, sequence);
|
||||||
}
|
}
|
||||||
if (getReplaces() != null) {
|
if (getReplaces() != null) {
|
||||||
for (Iterator<Replace> replaceIterator = getReplaces().iterator(); replaceIterator.hasNext(); ) {
|
for (Iterator<ReplaceTag> replaceIterator = getReplaces().iterator(); replaceIterator.hasNext(); ) {
|
||||||
Replace replace = replaceIterator.next();
|
ReplaceTag replace = replaceIterator.next();
|
||||||
if (replace != null) {
|
if (replace != null) {
|
||||||
replace.buildReplaceElement(doc, sequence);
|
replace.buildReplaceElement(doc, sequence);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getAtomicTag() != null) {
|
|
||||||
getAtomicTag().buildAtomicElement(doc, sequence);
|
|
||||||
}
|
|
||||||
if (getDeleteTag() != null) {
|
if (getDeleteTag() != null) {
|
||||||
getDeleteTag().buildDeleteElement(doc, sequence);
|
getDeleteTag().buildDeleteElement(doc, sequence);
|
||||||
}
|
}
|
||||||
|
if (getAtomicTag() != null) {
|
||||||
|
getAtomicTag().buildAtomicElement(doc, sequence);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,25 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
||||||
@ -27,28 +25,25 @@ import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
|||||||
/**
|
/**
|
||||||
* Source details of syncml header's.
|
* Source details of syncml header's.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "Source",
|
public class SourceTag {
|
||||||
description = "This class carries all information related to Syncml source.")
|
|
||||||
public class Source {
|
private String locURI;
|
||||||
@ApiModelProperty(name = "LocURI", value = "Location URI.(Source Location:Device)", required = true)
|
private String locName;
|
||||||
private String LocURI;
|
|
||||||
@ApiModelProperty(name = "LocName", value = "Name of the location", required = true)
|
|
||||||
private String LocName;
|
|
||||||
|
|
||||||
public String getLocURI() {
|
public String getLocURI() {
|
||||||
return LocURI;
|
return locURI;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocURI(String locURI) {
|
public void setLocURI(String locURI) {
|
||||||
LocURI = locURI;
|
this.locURI = locURI;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLocName() {
|
public String getLocName() {
|
||||||
return LocName;
|
return locName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocName(String locName) {
|
public void setLocName(String locName) {
|
||||||
LocName = locName;
|
this.locName = locName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buildSourceElement(Document doc, Element rootElement) {
|
public void buildSourceElement(Document doc, Element rootElement) {
|
||||||
@ -1,25 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
||||||
@ -27,26 +25,17 @@ import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
|||||||
/**
|
/**
|
||||||
* Status of a previously sent message to device;
|
* Status of a previously sent message to device;
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "Status",
|
public class StatusTag {
|
||||||
description = "This class carries all information related to Syncml Device statuses.")
|
|
||||||
public class Status {
|
|
||||||
@ApiModelProperty(name = "commandId", value = "CommandId of the Syncml StatusTag.", required = true)
|
|
||||||
int commandId = -1;
|
int commandId = -1;
|
||||||
@ApiModelProperty(name = "messageReference", value = "Message referenceId.", required = true)
|
|
||||||
int messageReference = -1;
|
int messageReference = -1;
|
||||||
@ApiModelProperty(name = "commandReference", value = "Command referenceId.", required = true)
|
|
||||||
int commandReference = -1;
|
int commandReference = -1;
|
||||||
@ApiModelProperty(name = "command", value = "Command String.", required = true)
|
|
||||||
String command;
|
String command;
|
||||||
@ApiModelProperty(name = "targetReference", value = "Target reference of the status message.", required = true)
|
|
||||||
String targetReference;
|
String targetReference;
|
||||||
@ApiModelProperty(name = "data", value = "Status data of the message.(ex:200,404,500...)", required = true)
|
|
||||||
String data;
|
String data;
|
||||||
@ApiModelProperty(name = "challenge", value = "Challenge value.", required = true)
|
|
||||||
ChallengeTag challenge;
|
ChallengeTag challenge;
|
||||||
|
|
||||||
public Status(int commandId, int messageReference, int commandReference, String command,
|
public StatusTag(int commandId, int messageReference, int commandReference, String command,
|
||||||
String targetReference, String data) {
|
String targetReference, String data) {
|
||||||
this.commandId = commandId;
|
this.commandId = commandId;
|
||||||
this.messageReference = messageReference;
|
this.messageReference = messageReference;
|
||||||
this.commandReference = commandReference;
|
this.commandReference = commandReference;
|
||||||
@ -55,7 +44,7 @@ public class Status {
|
|||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Status() {
|
public StatusTag() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChallengeTag getChallenge() {
|
public ChallengeTag getChallenge() {
|
||||||
@ -143,7 +132,7 @@ public class Status {
|
|||||||
status.appendChild(targetReference);
|
status.appendChild(targetReference);
|
||||||
}
|
}
|
||||||
if (getChallenge() != null) {
|
if (getChallenge() != null) {
|
||||||
getChallenge().buildChallElement(doc, status);
|
getChallenge().buildChallengeElement(doc, status);
|
||||||
}
|
}
|
||||||
if (getData() != null) {
|
if (getData() != null) {
|
||||||
Element data = doc.createElement(Constants.DATA);
|
Element data = doc.createElement(Constants.DATA);
|
||||||
@ -1,25 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
||||||
@ -30,23 +28,14 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* Represents the body details of a syncml.
|
* Represents the body details of a syncml.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "SyncmlBody", description = "This class carries all information related to SyncmlBody.")
|
|
||||||
public class SyncmlBody {
|
public class SyncmlBody {
|
||||||
@ApiModelProperty(name = "getCommands", value = "Get value of the syncmlBody.", required = true)
|
GetTag getCommands;
|
||||||
Get getCommands;
|
|
||||||
@ApiModelProperty(name = "exec", value = "List of executeTags in syncmlBody.", required = true)
|
|
||||||
List<ExecuteTag> exec;
|
List<ExecuteTag> exec;
|
||||||
@ApiModelProperty(name = "status", value = "List of statusTags in syncmlBody.", required = true)
|
List<StatusTag> status;
|
||||||
List<Status> status;
|
AlertTag alert;
|
||||||
@ApiModelProperty(name = "alert", value = "Alert tag in syncmlBody.", required = true)
|
ReplaceTag replace;
|
||||||
Alert alert;
|
ResultsTag results;
|
||||||
@ApiModelProperty(name = "replace", value = "replace tag in syncmlBody.", required = true)
|
|
||||||
Replace replace;
|
|
||||||
@ApiModelProperty(name = "results", value = "Results tag in syncmlBody.", required = true)
|
|
||||||
Results results;
|
|
||||||
@ApiModelProperty(name = "sequence", value = "Sequence tag in syncmlBody.", required = true)
|
|
||||||
SequenceTag sequence;
|
SequenceTag sequence;
|
||||||
@ApiModelProperty(name = "atomicTag", value = "Atomic tag in syncmlBody.", required = true)
|
|
||||||
AtomicTag atomicTag;
|
AtomicTag atomicTag;
|
||||||
|
|
||||||
public AtomicTag getAtomicTag() {
|
public AtomicTag getAtomicTag() {
|
||||||
@ -73,43 +62,43 @@ public class SyncmlBody {
|
|||||||
this.exec = exec;
|
this.exec = exec;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Results getResults() {
|
public ResultsTag getResults() {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResults(Results results) {
|
public void setResults(ResultsTag results) {
|
||||||
this.results = results;
|
this.results = results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Replace getReplace() {
|
public ReplaceTag getReplace() {
|
||||||
return replace;
|
return replace;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReplace(Replace replace) {
|
public void setReplace(ReplaceTag replace) {
|
||||||
this.replace = replace;
|
this.replace = replace;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Status> getStatus() {
|
public List<StatusTag> getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStatus(List<Status> status) {
|
public void setStatus(List<StatusTag> status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Alert getAlert() {
|
public AlertTag getAlert() {
|
||||||
return alert;
|
return alert;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAlert(Alert alert) {
|
public void setAlert(AlertTag alert) {
|
||||||
this.alert = alert;
|
this.alert = alert;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Get getGet() {
|
public GetTag getGet() {
|
||||||
return getCommands;
|
return getCommands;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGet(Get get) {
|
public void setGet(GetTag get) {
|
||||||
this.getCommands = get;
|
this.getCommands = get;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,36 +1,31 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a base format of a syncml document
|
* Represents a base format of a syncml document
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "SyncmlDocument", description = "This class carries all information related to SyncmlDocument.")
|
|
||||||
public class SyncmlDocument {
|
public class SyncmlDocument {
|
||||||
@ApiModelProperty(name = "header", value = "Header of the syncmlDocument.", required = true)
|
|
||||||
SyncmlHeader header;
|
SyncmlHeader header;
|
||||||
@ApiModelProperty(name = "body", value = "Body of the SyncmlDocument.", required = true)
|
|
||||||
SyncmlBody body;
|
SyncmlBody body;
|
||||||
|
|
||||||
public SyncmlHeader getHeader() {
|
public SyncmlHeader getHeader() {
|
||||||
|
|||||||
@ -1,25 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
||||||
@ -27,19 +25,12 @@ import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
|||||||
/**
|
/**
|
||||||
* Represents the header details of a syncml.
|
* Represents the header details of a syncml.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "SyncmlHeader", description = "This class carries all information related to SyncmlHeader.")
|
|
||||||
public class SyncmlHeader {
|
public class SyncmlHeader {
|
||||||
@ApiModelProperty(name = "sessionId", value = "SessionId of the syncml Message.", required = true)
|
|
||||||
private int sessionId = -1;
|
private int sessionId = -1;
|
||||||
@ApiModelProperty(name = "MsgID", value = "MessageId of the syncml Session.", required = true)
|
|
||||||
private int MsgID = -1;
|
private int MsgID = -1;
|
||||||
@ApiModelProperty(name = "target", value = "Target of the syncml Message.(Ex:Device/Server.)", required = true)
|
private TargetTag target;
|
||||||
private Target target;
|
private SourceTag source;
|
||||||
@ApiModelProperty(name = "source", value = "Source of the Syncml Message.(Ex:Server/Device.)", required = true)
|
private CredentialTag credential;
|
||||||
private Source source;
|
|
||||||
@ApiModelProperty(name = "credential", value = "Credentials of the Syncml header.", required = true)
|
|
||||||
private Credential credential;
|
|
||||||
@ApiModelProperty(name = "hexadecimalSessionId", value = "HexaDecimal SessionId of the syncmlHeader.", required = true)
|
|
||||||
private String hexadecimalSessionId;
|
private String hexadecimalSessionId;
|
||||||
|
|
||||||
public String getHexadecimalSessionId() {
|
public String getHexadecimalSessionId() {
|
||||||
@ -50,11 +41,11 @@ public class SyncmlHeader {
|
|||||||
this.hexadecimalSessionId = hexSessionId;
|
this.hexadecimalSessionId = hexSessionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Credential getCredential() {
|
public CredentialTag getCredential() {
|
||||||
return credential;
|
return credential;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCredential(Credential credential) {
|
public void setCredential(CredentialTag credential) {
|
||||||
this.credential = credential;
|
this.credential = credential;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,19 +65,19 @@ public class SyncmlHeader {
|
|||||||
this.MsgID = msgID;
|
this.MsgID = msgID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Target getTarget() {
|
public TargetTag getTarget() {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTarget(Target target) {
|
public void setTarget(TargetTag target) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Source getSource() {
|
public SourceTag getSource() {
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSource(Source source) {
|
public void setSource(SourceTag source) {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,25 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
package org.wso2.carbon.mdm.mobileservices.windows.operations;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
||||||
@ -27,11 +25,9 @@ import org.wso2.carbon.mdm.mobileservices.windows.operations.util.Constants;
|
|||||||
/**
|
/**
|
||||||
* Target details of syncml header's.
|
* Target details of syncml header's.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "Target", description = "This class carries all information related to Syncml Target.")
|
public class TargetTag {
|
||||||
public class Target {
|
|
||||||
@ApiModelProperty(name = "LocURI", value = "Location URI of the target.", required = true)
|
|
||||||
private String LocURI;
|
private String LocURI;
|
||||||
@ApiModelProperty(name = "LocName", value = "Location Name of the target.", required = true)
|
|
||||||
private String LocName;
|
private String LocName;
|
||||||
|
|
||||||
public String getLocURI() {
|
public String getLocURI() {
|
||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
@ -22,7 +22,6 @@ package org.wso2.carbon.mdm.mobileservices.windows.operations.util;
|
|||||||
* Constant values used in syncml generator.
|
* Constant values used in syncml generator.
|
||||||
*/
|
*/
|
||||||
public class Constants {
|
public class Constants {
|
||||||
|
|
||||||
public static final String PROVIDER_ID = "MobiCDMServer";
|
public static final String PROVIDER_ID = "MobiCDMServer";
|
||||||
public static final String SERVER_SECRET = "dummy";
|
public static final String SERVER_SECRET = "dummy";
|
||||||
public static final String INITIAL_NONCE = "ZHVtbXk=";
|
public static final String INITIAL_NONCE = "ZHVtbXk=";
|
||||||
@ -35,8 +34,6 @@ public class Constants {
|
|||||||
public static final String UTF_8 = "UTF-8";
|
public static final String UTF_8 = "UTF-8";
|
||||||
public static final String MD5 = "MD5";
|
public static final String MD5 = "MD5";
|
||||||
public static final String YES = "yes";
|
public static final String YES = "yes";
|
||||||
public static final String ERROR = "Error";
|
|
||||||
public static final String INFORMATION = "information";
|
|
||||||
|
|
||||||
public static final String EXECUTE = "Exec";
|
public static final String EXECUTE = "Exec";
|
||||||
public static final String ATOMIC = "Atomic";
|
public static final String ATOMIC = "Atomic";
|
||||||
@ -82,17 +79,26 @@ public class Constants {
|
|||||||
public static final String META_FORMAT_CHARACTER = "chr";
|
public static final String META_FORMAT_CHARACTER = "chr";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SynclML service related constants
|
* SynclML service related constants.
|
||||||
*/
|
*/
|
||||||
public final class SyncMLResponseCodes {
|
public final class SyncMLResponseCodes {
|
||||||
public static final String AUTHENTICATION_ACCEPTED = "212";
|
public static final String AUTHENTICATION_ACCEPTED = "212";
|
||||||
public static final String ACCEPTED = "200";
|
public static final String ACCEPTED = "200";
|
||||||
public static final String ACCEPTED_FOR_PROCESSING = "202";
|
public static final String ACCEPTED_FOR_PROCESSING = "202";
|
||||||
public static final String PIN_NOTFOUND = "405";
|
public static final String PIN_NOTFOUND = "405";
|
||||||
public static final String CREDENTIALS_MISSING = "407";
|
public static final String LOCK_RESET_NOTIFICATION = "Error occurred in Device Lock Operation. " +
|
||||||
public static final String INVALID_CREDENTIALS = "401";
|
|
||||||
public static final String LOCKRESET_NOTIFICATION = "Error occurred in Device Lock Operation. " +
|
|
||||||
"Please trigger lock-reset operation.";
|
"Please trigger lock-reset operation.";
|
||||||
|
public static final String POSITIVE_CSP_DATA = "1";
|
||||||
|
public static final String NEGATIVE_CSP_DATA = "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SyncmML message related constants.
|
||||||
|
*/
|
||||||
|
public final class SyncmlMessageCodes {
|
||||||
|
public static final int replaceCommandId = 300;
|
||||||
|
public static final int elementCommandId = 75;
|
||||||
|
public static final int atomicCommandId = 400;
|
||||||
|
public static final int addCommandId = 90;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
@ -31,7 +31,7 @@ public class OperationCode {
|
|||||||
IMSI("./Vendor/MSFT/DeviceInstanceService/Identity/Identity1/IMSI"),
|
IMSI("./Vendor/MSFT/DeviceInstanceService/Identity/Identity1/IMSI"),
|
||||||
IMEI("./Vendor/MSFT/DeviceInstanceService/Identity/Identity1/IMEI"),
|
IMEI("./Vendor/MSFT/DeviceInstanceService/Identity/Identity1/IMEI"),
|
||||||
SOFTWARE_VERSION("./DevDetail/SwV"),
|
SOFTWARE_VERSION("./DevDetail/SwV"),
|
||||||
VENDER("./DevDetail/OEM"),
|
VENDOR("./DevDetail/OEM"),
|
||||||
MAC_ADDRESS("./DevDetail/Ext/WLANMACAddress"),
|
MAC_ADDRESS("./DevDetail/Ext/WLANMACAddress"),
|
||||||
RESOLUTION("./DevDetail/Ext/Microsoft/Resolution"),
|
RESOLUTION("./DevDetail/Ext/Microsoft/Resolution"),
|
||||||
DEVICE_NAME("./DevDetail/Ext/Microsoft/DeviceName"),
|
DEVICE_NAME("./DevDetail/Ext/Microsoft/DeviceName"),
|
||||||
@ -68,7 +68,8 @@ public class OperationCode {
|
|||||||
ENCRYPT_STORAGE("./Vendor/MSFT/PolicyManager/My/Security/RequireDeviceEncryption"),
|
ENCRYPT_STORAGE("./Vendor/MSFT/PolicyManager/My/Security/RequireDeviceEncryption"),
|
||||||
CAMERA_STATUS("./Vendor/MSFT/PolicyManager/Device/Camera/AllowCamera"),
|
CAMERA_STATUS("./Vendor/MSFT/PolicyManager/Device/Camera/AllowCamera"),
|
||||||
ENCRYPT_STORAGE_STATUS("./Vendor/MSFT/PolicyManager/Device/Security/RequireDeviceEncryption"),
|
ENCRYPT_STORAGE_STATUS("./Vendor/MSFT/PolicyManager/Device/Security/RequireDeviceEncryption"),
|
||||||
DEVICE_PASSWORD_ENABLE("./Vendor/MSFT/PolicyManager/My/DeviceLock/DevicePasswordEnabled");
|
DEVICE_PASSWORD_ENABLE("./Vendor/MSFT/PolicyManager/My/DeviceLock/DevicePasswordEnabled"),
|
||||||
|
DEVICE_PASSCODE_DELETE("./Vendor/MSFT/PolicyManager/My/DeviceLock");
|
||||||
|
|
||||||
private final String code;
|
private final String code;
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,490 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.mdm.mobileservices.windows.operations.util;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.notification.mgt.Notification;
|
||||||
|
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService;
|
||||||
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.operations.*;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.services.syncml.beans.Profile;
|
||||||
|
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
||||||
|
import org.wso2.carbon.policy.mgt.common.ProfileFeature;
|
||||||
|
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature;
|
||||||
|
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils.convertToDeviceIdentifierObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is used to handle pending operations of the device.
|
||||||
|
*/
|
||||||
|
public class OperationHandler {
|
||||||
|
private static Log log = LogFactory.getLog(OperationHandler.class);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the operations using device status payload.
|
||||||
|
*
|
||||||
|
* @param status Client side status for the specific operations.
|
||||||
|
* @param syncmlDocument syncml payload for operation status which parse through the syncml engine.
|
||||||
|
* @param deviceIdentifier specific device identifier for each device.
|
||||||
|
* @throws OperationManagementException
|
||||||
|
*/
|
||||||
|
public void updateDeviceOperations(StatusTag status, SyncmlDocument syncmlDocument,
|
||||||
|
DeviceIdentifier deviceIdentifier) throws OperationManagementException {
|
||||||
|
List<? extends Operation> pendingDataOperations;
|
||||||
|
try {
|
||||||
|
pendingDataOperations = WindowsAPIUtils.getPendingOperations(deviceIdentifier);
|
||||||
|
|
||||||
|
if (Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData()) ||
|
||||||
|
(Constants.SyncMLResponseCodes.ACCEPTED_FOR_PROCESSING.equals(status.getData()))) {
|
||||||
|
for (Operation operation : pendingDataOperations) {
|
||||||
|
if (operation.getId() == status.getCommandReference()) {
|
||||||
|
operation.setStatus(Operation.Status.COMPLETED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (syncmlDocument.getHeader().getSource().getLocURI() != null) {
|
||||||
|
updateStatus(syncmlDocument.getHeader().getSource().getLocURI(), pendingDataOperations);
|
||||||
|
}
|
||||||
|
} else if (Constants.SyncMLResponseCodes.PIN_NOTFOUND.equals(status.getData())) {
|
||||||
|
for (Operation operation : pendingDataOperations) {
|
||||||
|
if (operation.getId() == status.getCommandReference() && (OperationCode.Command.DEVICE_LOCK.equals(
|
||||||
|
operation.getCode()))) {
|
||||||
|
operation.setStatus(Operation.Status.ERROR);
|
||||||
|
if (syncmlDocument.getHeader().getSource().getLocURI() != null) {
|
||||||
|
updateStatus(syncmlDocument.getHeader().getSource().getLocURI(), pendingDataOperations);
|
||||||
|
}
|
||||||
|
NotificationManagementService nmService = WindowsAPIUtils.getNotificationManagementService();
|
||||||
|
Notification lockResetNotification = new Notification();
|
||||||
|
lockResetNotification.setOperationId(status.getCommandReference());
|
||||||
|
lockResetNotification.setStatus(String.valueOf(Notification.Status.NEW));
|
||||||
|
// lockResetNotification.setDeviceIdentifier(deviceIdentifier);
|
||||||
|
lockResetNotification.setDescription(
|
||||||
|
Constants.SyncMLResponseCodes.LOCK_RESET_NOTIFICATION);
|
||||||
|
nmService.addNotification(deviceIdentifier, lockResetNotification);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
throw new OperationManagementException("Error occurred in getting pending operations.");
|
||||||
|
} catch (NotificationManagementException e) {
|
||||||
|
throw new OperationManagementException("Error occurred while adding notification", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update operation statuses.
|
||||||
|
*
|
||||||
|
* @param deviceId specific device Id.
|
||||||
|
* @param operations operation list to be update.
|
||||||
|
* @throws OperationManagementException
|
||||||
|
*/
|
||||||
|
public static void updateStatus(String deviceId, List<? extends Operation> operations)
|
||||||
|
throws OperationManagementException {
|
||||||
|
for (Operation operation : operations) {
|
||||||
|
WindowsAPIUtils.updateOperation(deviceId, operation);
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Updating operation '" + operation.toString() + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Status of the lock operation.
|
||||||
|
*
|
||||||
|
* @param status Status of the operation.
|
||||||
|
* @param syncmlDocument parsed syncml payload.
|
||||||
|
* @param deviceIdentifier Device Id.
|
||||||
|
* @throws OperationManagementException
|
||||||
|
*/
|
||||||
|
public void updateLockOperation(StatusTag status, SyncmlDocument syncmlDocument, DeviceIdentifier deviceIdentifier)
|
||||||
|
throws OperationManagementException {
|
||||||
|
List<? extends Operation> pendingDataOperations;
|
||||||
|
try {
|
||||||
|
pendingDataOperations = WindowsAPIUtils.getPendingOperations(deviceIdentifier);
|
||||||
|
if (Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData())) {
|
||||||
|
for (Operation operation : pendingDataOperations) {
|
||||||
|
if ((OperationCode.Command.DEVICE_LOCK.getCode().equals(operation.getCode()))
|
||||||
|
&& operation.getId() == status.getCommandReference()) {
|
||||||
|
operation.setStatus(Operation.Status.COMPLETED);
|
||||||
|
updateStatus(syncmlDocument.getHeader().getSource().getLocURI(), pendingDataOperations);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Constants.SyncMLResponseCodes.PIN_NOTFOUND.equals(status.getData())) {
|
||||||
|
for (Operation operation : pendingDataOperations) {
|
||||||
|
|
||||||
|
if ((OperationCode.Command.DEVICE_LOCK.getCode().equals(operation.getCode()) &&
|
||||||
|
operation.getId() == status.getCommandReference())) {
|
||||||
|
operation.setStatus(Operation.Status.ERROR);
|
||||||
|
updateStatus(syncmlDocument.getHeader().getSource().getLocURI(), pendingDataOperations);
|
||||||
|
|
||||||
|
NotificationManagementService nmService = WindowsAPIUtils.getNotificationManagementService();
|
||||||
|
Notification lockResetNotification = new Notification();
|
||||||
|
lockResetNotification.setOperationId(status.getCommandReference());
|
||||||
|
lockResetNotification.setStatus(String.valueOf(Notification.Status.NEW));
|
||||||
|
// lockResetNotification.setDeviceIdentifier(deviceIdentifier);
|
||||||
|
lockResetNotification.setDescription(Constants.SyncMLResponseCodes.LOCK_RESET_NOTIFICATION);
|
||||||
|
|
||||||
|
nmService.addNotification(deviceIdentifier, lockResetNotification);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
throw new OperationManagementException("Error occurred in getting pending operations.");
|
||||||
|
} catch (NotificationManagementException e) {
|
||||||
|
throw new OperationManagementException("Error occurred in adding notifications.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* Update status of the ring operation.
|
||||||
|
*
|
||||||
|
* @param status Ring status of the device.
|
||||||
|
* @param syncmlDocument Parsed syncml payload from the syncml engine.
|
||||||
|
* @param deviceIdentifier specific device id to be update.
|
||||||
|
* @throws OperationManagementException
|
||||||
|
*/
|
||||||
|
public void ring(StatusTag status, SyncmlDocument syncmlDocument, DeviceIdentifier deviceIdentifier)
|
||||||
|
throws OperationManagementException {
|
||||||
|
List<? extends Operation> pendingDataOperations;
|
||||||
|
try {
|
||||||
|
if ((Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData()))) {
|
||||||
|
pendingDataOperations = WindowsAPIUtils.getPendingOperations(deviceIdentifier);
|
||||||
|
for (Operation operation : pendingDataOperations) {
|
||||||
|
if ((OperationCode.Command.DEVICE_RING.equals(operation.getCode())) &&
|
||||||
|
(operation.getId() == status.getCommandReference())) {
|
||||||
|
operation.setStatus(Operation.Status.COMPLETED);
|
||||||
|
updateStatus(syncmlDocument.getHeader().getSource().getLocURI(),
|
||||||
|
pendingDataOperations);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
throw new OperationManagementException("Error occurred in getting pending operation.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* Update the status of the DataWipe operation.
|
||||||
|
*
|
||||||
|
* @param status Status of the data wipe.
|
||||||
|
* @param syncmlDocument Parsed syncml payload from the syncml engine.
|
||||||
|
* @param deviceIdentifier specific device id to be wiped.
|
||||||
|
* @throws OperationManagementException
|
||||||
|
*/
|
||||||
|
public void dataWipe(StatusTag status, SyncmlDocument syncmlDocument, DeviceIdentifier deviceIdentifier)
|
||||||
|
throws OperationManagementException {
|
||||||
|
List<? extends Operation> pendingDataOperations;
|
||||||
|
if ((Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData()))) {
|
||||||
|
try {
|
||||||
|
pendingDataOperations = WindowsAPIUtils.getPendingOperations(deviceIdentifier);
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
throw new OperationManagementException("Error occurred in getting pending operation.");
|
||||||
|
}
|
||||||
|
for (Operation operation : pendingDataOperations) {
|
||||||
|
|
||||||
|
if ((OperationCode.Command.WIPE_DATA.equals(operation.getCode())) &&
|
||||||
|
(operation.getId() == status.getCommandReference())) {
|
||||||
|
operation.setStatus(Operation.Status.COMPLETED);
|
||||||
|
updateStatus(syncmlDocument.getHeader().getSource().getLocURI(),
|
||||||
|
pendingDataOperations);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get pending operations.
|
||||||
|
*
|
||||||
|
* @param syncmlDocument SyncmlDocument object which creates from the syncml engine using syncml payload
|
||||||
|
* @return Return list of pending operations.
|
||||||
|
* @throws OperationManagementException
|
||||||
|
*/
|
||||||
|
public List<? extends Operation> getPendingOperations(SyncmlDocument syncmlDocument)
|
||||||
|
throws OperationManagementException, WindowsOperationException {
|
||||||
|
|
||||||
|
List<? extends Operation> pendingOperations;
|
||||||
|
DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(
|
||||||
|
syncmlDocument.getHeader().getSource().getLocURI());
|
||||||
|
UpdateUriOperations(syncmlDocument);
|
||||||
|
generateComplianceFeatureStatus(syncmlDocument);
|
||||||
|
|
||||||
|
pendingOperations = WindowsAPIUtils.getDeviceManagementService().getPendingOperations(deviceIdentifier);
|
||||||
|
return pendingOperations;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set compliance of the feature according to the device status for the specific feature.
|
||||||
|
*
|
||||||
|
* @param activeFeature Features to be applied on the device.
|
||||||
|
* @param deviceFeature Actual features applied on the device.
|
||||||
|
* @return Returns setting up compliance feature.
|
||||||
|
*/
|
||||||
|
public ComplianceFeature setComplianceFeatures(ProfileFeature activeFeature, Profile deviceFeature) {
|
||||||
|
ComplianceFeature complianceFeature = new ComplianceFeature();
|
||||||
|
complianceFeature.setFeature(activeFeature);
|
||||||
|
complianceFeature.setFeatureCode(activeFeature.getFeatureCode());
|
||||||
|
complianceFeature.setCompliance(deviceFeature.isCompliance());
|
||||||
|
return complianceFeature;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the completed/Error status of the operation which have the URI of the operation code in the syncml payload.
|
||||||
|
*
|
||||||
|
* @param syncmlDocument SyncmlDocument object generated from the the syncml engine.
|
||||||
|
* @throws OperationManagementException
|
||||||
|
*/
|
||||||
|
public void UpdateUriOperations(SyncmlDocument syncmlDocument) throws OperationManagementException,
|
||||||
|
WindowsOperationException {
|
||||||
|
List<? extends Operation> pendingDataOperations;
|
||||||
|
DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(
|
||||||
|
syncmlDocument.getHeader().getSource().getLocURI());
|
||||||
|
|
||||||
|
List<StatusTag> statuses = syncmlDocument.getBody().getStatus();
|
||||||
|
try {
|
||||||
|
pendingDataOperations = WindowsAPIUtils.getPendingOperations(deviceIdentifier);
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
throw new OperationManagementException("Error occurred in getting pending operation.");
|
||||||
|
}
|
||||||
|
for (StatusTag status : statuses) {
|
||||||
|
|
||||||
|
if ((Constants.EXECUTE.equals(status.getCommand()))) {
|
||||||
|
if (status.getTargetReference() == null) {
|
||||||
|
updateDeviceOperations(status, syncmlDocument, deviceIdentifier);
|
||||||
|
} else {
|
||||||
|
if ((OperationCode.Command.DEVICE_LOCK.equals(status.getTargetReference()))) {
|
||||||
|
updateLockOperation(status, syncmlDocument, deviceIdentifier);
|
||||||
|
}
|
||||||
|
if ((OperationCode.Command.DEVICE_RING.equals(status.getTargetReference()))) {
|
||||||
|
ring(status, syncmlDocument, deviceIdentifier);
|
||||||
|
}
|
||||||
|
if (equals(OperationCode.Command.WIPE_DATA.equals(status.getTargetReference()))) {
|
||||||
|
dataWipe(status, syncmlDocument, deviceIdentifier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((Constants.SEQUENCE.equals(status.getCommand()))) {
|
||||||
|
if ((Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData()))) {
|
||||||
|
for (Operation operation : pendingDataOperations) {
|
||||||
|
if ((PluginConstants.OperationCodes.POLICY_BUNDLE.equals(operation.getCode())) &&
|
||||||
|
operation.getId() == status.getCommandReference()) {
|
||||||
|
operation.setStatus(Operation.Status.COMPLETED);
|
||||||
|
}
|
||||||
|
if ((PluginConstants.OperationCodes.MONITOR.equals(operation.getCode())) &&
|
||||||
|
operation.getId() == status.getCommandReference()) {
|
||||||
|
operation.setStatus(Operation.Status.COMPLETED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateStatus(syncmlDocument.getHeader().getSource().getLocURI(),
|
||||||
|
pendingDataOperations);
|
||||||
|
} else {
|
||||||
|
for (Operation operation : pendingDataOperations) {
|
||||||
|
|
||||||
|
if ((PluginConstants.OperationCodes.POLICY_BUNDLE.equals(operation.getCode())) &&
|
||||||
|
operation.getId() == status.getCommandReference()) {
|
||||||
|
operation.setStatus(Operation.Status.ERROR);
|
||||||
|
}
|
||||||
|
if ((PluginConstants.OperationCodes.MONITOR.equals(operation.getCode())) &&
|
||||||
|
operation.getId() == status.getCommandReference()) {
|
||||||
|
operation.setStatus(Operation.Status.ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateStatus(syncmlDocument.getHeader().getSource().getLocURI(),
|
||||||
|
pendingDataOperations);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate status of the features that have been activated on the device.
|
||||||
|
*
|
||||||
|
* @param syncmlDocument syncmlDocument object pasrsed from the syncml engine.
|
||||||
|
* @return device statuses for the activated features
|
||||||
|
* @throws WindowsOperationException
|
||||||
|
*/
|
||||||
|
public List<Profile> generateDeviceOperationStatusObject(SyncmlDocument syncmlDocument) throws
|
||||||
|
WindowsOperationException {
|
||||||
|
|
||||||
|
DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(
|
||||||
|
syncmlDocument.getHeader().getSource().getLocURI());
|
||||||
|
String lockUri = null;
|
||||||
|
ResultsTag result = syncmlDocument.getBody().getResults();
|
||||||
|
|
||||||
|
List<Profile> profiles = new ArrayList<>();
|
||||||
|
if (result != null) {
|
||||||
|
List<ItemTag> results = result.getItem();
|
||||||
|
for (OperationCode.Info info : OperationCode.Info.values()) {
|
||||||
|
if (PluginConstants.OperationCodes.PIN_CODE.equals(info
|
||||||
|
.name())) {
|
||||||
|
lockUri = info.getCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (ItemTag item : results) {
|
||||||
|
for (OperationCode.Info info : OperationCode.Info.values()) {
|
||||||
|
if (item.getSource().getLocURI().equals(info.getCode()) &&
|
||||||
|
PluginConstants.OperationCodes.CAMERA_STATUS.equals(info.name())) {
|
||||||
|
Profile cameraProfile = new Profile();
|
||||||
|
cameraProfile.setFeatureCode(PluginConstants.OperationCodes.CAMERA);
|
||||||
|
cameraProfile.setData(item.getData());
|
||||||
|
if ((PluginConstants.SyncML.SYNCML_DATA_ONE.equals(item.getData()))) {
|
||||||
|
cameraProfile.setEnable(true);
|
||||||
|
} else {
|
||||||
|
cameraProfile.setEnable(false);
|
||||||
|
}
|
||||||
|
profiles.add(cameraProfile);
|
||||||
|
}
|
||||||
|
if (item.getSource().getLocURI().equals(info.getCode()) &&
|
||||||
|
PluginConstants.OperationCodes.ENCRYPT_STORAGE_STATUS.equals(info.name())) {
|
||||||
|
Profile encryptStorage = new Profile();
|
||||||
|
encryptStorage.setFeatureCode(PluginConstants.OperationCodes.ENCRYPT_STORAGE);
|
||||||
|
encryptStorage.setData(item.getData());
|
||||||
|
if ((PluginConstants.SyncML.SYNCML_DATA_ONE.equals(item.getData()))) {
|
||||||
|
encryptStorage.setEnable(true);
|
||||||
|
} else {
|
||||||
|
encryptStorage.setEnable(false);
|
||||||
|
}
|
||||||
|
profiles.add(encryptStorage);
|
||||||
|
}
|
||||||
|
if (item.getSource().getLocURI().equals(info.getCode()) &&
|
||||||
|
PluginConstants.OperationCodes.DEVICE_PASSWORD_STATUS.equals(info.name())) {
|
||||||
|
Profile encryptStorage = new Profile();
|
||||||
|
encryptStorage.setFeatureCode(PluginConstants.OperationCodes.PASSCODE_POLICY);
|
||||||
|
encryptStorage.setData(item.getData());
|
||||||
|
if ((PluginConstants.SyncML.SYNCML_DATA_ZERO.equals(item.getData()))) {
|
||||||
|
encryptStorage.setEnable(true);
|
||||||
|
} else {
|
||||||
|
encryptStorage.setEnable(false);
|
||||||
|
}
|
||||||
|
profiles.add(encryptStorage);
|
||||||
|
}
|
||||||
|
if (!item.getData().isEmpty() && item.getSource().getLocURI().equals(lockUri)) {
|
||||||
|
String pinValue = item.getData();
|
||||||
|
NotificationManagementService nmService = WindowsAPIUtils.getNotificationManagementService();
|
||||||
|
Notification notification = new Notification();
|
||||||
|
notification.setDescription("Auto generated DevicePin : " + pinValue);
|
||||||
|
notification.setOperationId(result.getCommandReference());
|
||||||
|
// notification.setDeviceIdentifier(deviceIdentifier);
|
||||||
|
notification.setStatus(String.valueOf(Notification.Status.NEW));
|
||||||
|
try {
|
||||||
|
nmService.addNotification(deviceIdentifier, notification);
|
||||||
|
} catch (NotificationManagementException e) {
|
||||||
|
throw new WindowsOperationException("Failure Occurred while getting notification" +
|
||||||
|
" service.", e);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return profiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate Compliance Features.
|
||||||
|
*
|
||||||
|
* @param syncmlDocument syncmlDocument object parsed from the syncml engine.
|
||||||
|
* @throws WindowsOperationException
|
||||||
|
*/
|
||||||
|
public void generateComplianceFeatureStatus(SyncmlDocument syncmlDocument) throws WindowsOperationException {
|
||||||
|
List<Profile> profiles = generateDeviceOperationStatusObject(syncmlDocument);
|
||||||
|
DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(
|
||||||
|
syncmlDocument.getHeader().getSource().getLocURI());
|
||||||
|
boolean isCompliance = false;
|
||||||
|
if (profiles.size() != Constants.EMPTY) {
|
||||||
|
try {
|
||||||
|
if (WindowsAPIUtils.getPolicyManagerService().getAppliedPolicyToDevice(deviceIdentifier).getProfile().
|
||||||
|
getProfileFeaturesList() != null) {
|
||||||
|
List<ProfileFeature> profileFeatures = WindowsAPIUtils.getPolicyManagerService().
|
||||||
|
getAppliedPolicyToDevice(deviceIdentifier).getProfile().getProfileFeaturesList();
|
||||||
|
List<ComplianceFeature> complianceFeatures = new ArrayList<>();
|
||||||
|
for (ProfileFeature activeFeature : profileFeatures) {
|
||||||
|
JSONObject policyContent = new JSONObject(activeFeature.getContent().toString());
|
||||||
|
|
||||||
|
for (Profile deviceFeature : profiles) {
|
||||||
|
if (deviceFeature.getFeatureCode().equals(activeFeature.getFeatureCode()) &&
|
||||||
|
(PluginConstants.OperationCodes.CAMERA.equals(deviceFeature.getFeatureCode()))) {
|
||||||
|
if (policyContent.getBoolean(PluginConstants.PolicyConfigProperties.
|
||||||
|
POLICY_ENABLE) == (deviceFeature.isEnable())) {
|
||||||
|
isCompliance = true;
|
||||||
|
deviceFeature.setCompliance(isCompliance);
|
||||||
|
} else {
|
||||||
|
deviceFeature.setCompliance(isCompliance);
|
||||||
|
}
|
||||||
|
ComplianceFeature complianceFeature = setComplianceFeatures(activeFeature,
|
||||||
|
deviceFeature);
|
||||||
|
complianceFeatures.add(complianceFeature);
|
||||||
|
}
|
||||||
|
if (deviceFeature.getFeatureCode().equals(activeFeature.getFeatureCode()) &&
|
||||||
|
(PluginConstants.OperationCodes.
|
||||||
|
ENCRYPT_STORAGE.equals(deviceFeature.getFeatureCode()))) {
|
||||||
|
if (policyContent.getBoolean(PluginConstants.PolicyConfigProperties.
|
||||||
|
ENCRYPTED_ENABLE) == (deviceFeature.isEnable())) {
|
||||||
|
isCompliance = true;
|
||||||
|
deviceFeature.setCompliance(isCompliance);
|
||||||
|
} else {
|
||||||
|
deviceFeature.setCompliance(isCompliance);
|
||||||
|
}
|
||||||
|
ComplianceFeature complianceFeature = setComplianceFeatures(activeFeature,
|
||||||
|
deviceFeature);
|
||||||
|
complianceFeatures.add(complianceFeature);
|
||||||
|
}
|
||||||
|
if (deviceFeature.getFeatureCode().equals(activeFeature.getFeatureCode()) &&
|
||||||
|
(PluginConstants.OperationCodes.
|
||||||
|
PASSCODE_POLICY.equals(deviceFeature.getFeatureCode()))) {
|
||||||
|
if (policyContent.getBoolean(PluginConstants.PolicyConfigProperties.
|
||||||
|
ENABLE_PASSWORD) == (deviceFeature.isEnable())) {
|
||||||
|
isCompliance = true;
|
||||||
|
deviceFeature.setCompliance(isCompliance);
|
||||||
|
} else {
|
||||||
|
deviceFeature.setCompliance(isCompliance);
|
||||||
|
}
|
||||||
|
ComplianceFeature complianceFeature = setComplianceFeatures(activeFeature,
|
||||||
|
deviceFeature);
|
||||||
|
complianceFeatures.add(complianceFeature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WindowsAPIUtils.getPolicyManagerService().checkPolicyCompliance(deviceIdentifier,
|
||||||
|
complianceFeatures);
|
||||||
|
}
|
||||||
|
} catch (JSONException e) {
|
||||||
|
throw new WindowsOperationException("Error occurred while parsing json object.", e);
|
||||||
|
} catch (PolicyComplianceException e) {
|
||||||
|
throw new WindowsOperationException("Error occurred while setting up policy compliance.", e);
|
||||||
|
} catch (PolicyManagementException e) {
|
||||||
|
throw new WindowsOperationException("Error occurred while getting effective policy.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
@ -77,20 +77,20 @@ public class OperationReply {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void generateHeader() throws SyncmlMessageFormatException {
|
private void generateHeader() throws SyncmlMessageFormatException {
|
||||||
String nextnonceValue = Constants.INITIAL_NONCE;
|
String nextNonceValue = Constants.INITIAL_NONCE;
|
||||||
SyncmlHeader sourceHeader = syncmlDocument.getHeader();
|
SyncmlHeader sourceHeader = syncmlDocument.getHeader();
|
||||||
SyncmlHeader header = new SyncmlHeader();
|
SyncmlHeader header = new SyncmlHeader();
|
||||||
header.setMsgID(sourceHeader.getMsgID());
|
header.setMsgID(sourceHeader.getMsgID());
|
||||||
header.setHexadecimalSessionId(Integer.toHexString(sourceHeader.getSessionId()));
|
header.setHexadecimalSessionId(Integer.toHexString(sourceHeader.getSessionId()));
|
||||||
Target target = new Target();
|
TargetTag target = new TargetTag();
|
||||||
target.setLocURI(sourceHeader.getSource().getLocURI());
|
target.setLocURI(sourceHeader.getSource().getLocURI());
|
||||||
header.setTarget(target);
|
header.setTarget(target);
|
||||||
|
|
||||||
Source source = new Source();
|
SourceTag source = new SourceTag();
|
||||||
source.setLocURI(sourceHeader.getTarget().getLocURI());
|
source.setLocURI(sourceHeader.getTarget().getLocURI());
|
||||||
header.setSource(source);
|
header.setSource(source);
|
||||||
|
|
||||||
Credential cred = new Credential();
|
CredentialTag cred = new CredentialTag();
|
||||||
if (sourceHeader.getCredential() == null) {
|
if (sourceHeader.getCredential() == null) {
|
||||||
MetaTag meta = new MetaTag();
|
MetaTag meta = new MetaTag();
|
||||||
meta.setFormat(Constants.CRED_FORMAT);
|
meta.setFormat(Constants.CRED_FORMAT);
|
||||||
@ -100,15 +100,15 @@ public class OperationReply {
|
|||||||
cred.setMeta(sourceHeader.getCredential().getMeta());
|
cred.setMeta(sourceHeader.getCredential().getMeta());
|
||||||
}
|
}
|
||||||
SyncmlBody sourcebody = syncmlDocument.getBody();
|
SyncmlBody sourcebody = syncmlDocument.getBody();
|
||||||
List<Status> statuses = sourcebody.getStatus();
|
List<StatusTag> statuses = sourcebody.getStatus();
|
||||||
|
|
||||||
for (Status status : statuses) {
|
for (StatusTag status : statuses) {
|
||||||
if (HEADER_COMMAND_TEXT.equals(status.getCommand()) &&
|
if (HEADER_COMMAND_TEXT.equals(status.getCommand()) &&
|
||||||
status.getChallenge() != null) {
|
status.getChallenge() != null) {
|
||||||
nextnonceValue = status.getChallenge().getMeta().getNextNonce();
|
nextNonceValue = status.getChallenge().getMeta().getNextNonce();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cred.setData(new SyncmlCredentials().generateCredData(nextnonceValue));
|
cred.setData(SyncmlCredentialUtil.generateCredData(nextNonceValue));
|
||||||
header.setCredential(cred);
|
header.setCredential(cred);
|
||||||
|
|
||||||
replySyncmlDocument.setHeader(header);
|
replySyncmlDocument.setHeader(header);
|
||||||
@ -131,22 +131,22 @@ 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();
|
||||||
Status headerStatus;
|
StatusTag headerStatus;
|
||||||
SyncmlBody syncmlBodyReply = new SyncmlBody();
|
SyncmlBody syncmlBodyReply = new SyncmlBody();
|
||||||
List<Status> statuses = new ArrayList<>();
|
List<StatusTag> statuses = new ArrayList<>();
|
||||||
List<Status> sourceStatuses = sourceSyncmlBody.getStatus();
|
List<StatusTag> sourceStatuses = sourceSyncmlBody.getStatus();
|
||||||
if (sourceStatuses.isEmpty()) {
|
if (sourceStatuses.isEmpty()) {
|
||||||
headerStatus =
|
headerStatus =
|
||||||
new Status(headerCommandId, sourceHeader.getMsgID(), HEADER_STATUS_ID,
|
new StatusTag(headerCommandId, sourceHeader.getMsgID(), HEADER_STATUS_ID,
|
||||||
HEADER_COMMAND_TEXT, sourceHeader.getSource().getLocURI(),
|
HEADER_COMMAND_TEXT, sourceHeader.getSource().getLocURI(),
|
||||||
String.valueOf(Constants.SyncMLResponseCodes.AUTHENTICATION_ACCEPTED));
|
String.valueOf(Constants.SyncMLResponseCodes.AUTHENTICATION_ACCEPTED));
|
||||||
statuses.add(headerStatus);
|
statuses.add(headerStatus);
|
||||||
} else {
|
} else {
|
||||||
for (Status 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 Status(headerCommandId, sourceHeader.getMsgID(), HEADER_STATUS_ID,
|
new StatusTag(headerCommandId, sourceHeader.getMsgID(), HEADER_STATUS_ID,
|
||||||
HEADER_COMMAND_TEXT, sourceHeader.getSource().getLocURI(),
|
HEADER_COMMAND_TEXT, sourceHeader.getSource().getLocURI(),
|
||||||
String.valueOf(Constants.SyncMLResponseCodes.AUTHENTICATION_ACCEPTED));
|
String.valueOf(Constants.SyncMLResponseCodes.AUTHENTICATION_ACCEPTED));
|
||||||
statuses.add(headerStatus);
|
statuses.add(headerStatus);
|
||||||
@ -155,14 +155,14 @@ public class OperationReply {
|
|||||||
}
|
}
|
||||||
if (sourceSyncmlBody.getResults() != null) {
|
if (sourceSyncmlBody.getResults() != null) {
|
||||||
int ResultCommandId = ++headerCommandId;
|
int ResultCommandId = ++headerCommandId;
|
||||||
Status resultStatus = new Status(ResultCommandId, sourceHeader.getMsgID(),
|
StatusTag resultStatus = new StatusTag(ResultCommandId, sourceHeader.getMsgID(),
|
||||||
sourceSyncmlBody.getResults().getCommandId(), RESULTS_COMMAND_TEXT, null,
|
sourceSyncmlBody.getResults().getCommandId(), RESULTS_COMMAND_TEXT, null,
|
||||||
String.valueOf(Constants.SyncMLResponseCodes.ACCEPTED));
|
String.valueOf(Constants.SyncMLResponseCodes.ACCEPTED));
|
||||||
statuses.add(resultStatus);
|
statuses.add(resultStatus);
|
||||||
}
|
}
|
||||||
if (sourceSyncmlBody.getAlert() != null) {
|
if (sourceSyncmlBody.getAlert() != null) {
|
||||||
int alertCommandId = ++headerCommandId;
|
int alertCommandId = ++headerCommandId;
|
||||||
Status alertStatus = new Status(alertCommandId,
|
StatusTag alertStatus = new StatusTag(alertCommandId,
|
||||||
sourceHeader.getMsgID(),
|
sourceHeader.getMsgID(),
|
||||||
sourceSyncmlBody.getAlert().getCommandId(),
|
sourceSyncmlBody.getAlert().getCommandId(),
|
||||||
ALERT_COMMAND_TEXT, null,
|
ALERT_COMMAND_TEXT, null,
|
||||||
@ -171,7 +171,7 @@ public class OperationReply {
|
|||||||
}
|
}
|
||||||
if (sourceSyncmlBody.getReplace() != null) {
|
if (sourceSyncmlBody.getReplace() != null) {
|
||||||
int replaceCommandId = ++headerCommandId;
|
int replaceCommandId = ++headerCommandId;
|
||||||
Status replaceStatus = new Status(replaceCommandId, sourceHeader.getMsgID(),
|
StatusTag replaceStatus = new StatusTag(replaceCommandId, sourceHeader.getMsgID(),
|
||||||
sourceSyncmlBody.getReplace().getCommandId(), REPLACE_COMMAND_TEXT, null,
|
sourceSyncmlBody.getReplace().getCommandId(), REPLACE_COMMAND_TEXT, null,
|
||||||
String.valueOf(Constants.SyncMLResponseCodes.ACCEPTED)
|
String.valueOf(Constants.SyncMLResponseCodes.ACCEPTED)
|
||||||
);
|
);
|
||||||
@ -181,7 +181,7 @@ public class OperationReply {
|
|||||||
List<ExecuteTag> Executes = sourceSyncmlBody.getExec();
|
List<ExecuteTag> Executes = sourceSyncmlBody.getExec();
|
||||||
for (ExecuteTag exec : Executes) {
|
for (ExecuteTag exec : Executes) {
|
||||||
int execCommandId = ++headerCommandId;
|
int execCommandId = ++headerCommandId;
|
||||||
Status execStatus = new Status(execCommandId, sourceHeader.getMsgID(),
|
StatusTag execStatus = new StatusTag(execCommandId, sourceHeader.getMsgID(),
|
||||||
exec.getCommandId(), EXEC_COMMAND_TEXT, null, String.valueOf(
|
exec.getCommandId(), EXEC_COMMAND_TEXT, null, String.valueOf(
|
||||||
Constants.SyncMLResponseCodes.ACCEPTED));
|
Constants.SyncMLResponseCodes.ACCEPTED));
|
||||||
statuses.add(execStatus);
|
statuses.add(execStatus);
|
||||||
@ -189,7 +189,7 @@ public class OperationReply {
|
|||||||
}
|
}
|
||||||
if (sourceSyncmlBody.getGet() != null) {
|
if (sourceSyncmlBody.getGet() != null) {
|
||||||
int getCommandId = ++headerCommandId;
|
int getCommandId = ++headerCommandId;
|
||||||
Status execStatus = new Status(getCommandId, sourceHeader.getMsgID(), sourceSyncmlBody
|
StatusTag execStatus = new StatusTag(getCommandId, sourceHeader.getMsgID(), sourceSyncmlBody
|
||||||
.getGet().getCommandId(), GET_COMMAND_TEXT, null, String.valueOf(
|
.getGet().getCommandId(), GET_COMMAND_TEXT, null, String.valueOf(
|
||||||
Constants.SyncMLResponseCodes.ACCEPTED));
|
Constants.SyncMLResponseCodes.ACCEPTED));
|
||||||
statuses.add(execStatus);
|
statuses.add(execStatus);
|
||||||
@ -200,13 +200,13 @@ public class OperationReply {
|
|||||||
|
|
||||||
private void appendOperations(SyncmlBody syncmlBody) throws PolicyManagementException,
|
private void appendOperations(SyncmlBody syncmlBody) throws PolicyManagementException,
|
||||||
FeatureManagementException, JSONException, SyncmlOperationException {
|
FeatureManagementException, JSONException, SyncmlOperationException {
|
||||||
Get getElement = new Get();
|
GetTag getElement = new GetTag();
|
||||||
List<Item> getElements = new ArrayList<>();
|
List<ItemTag> getElements = new ArrayList<>();
|
||||||
List<ExecuteTag> executeElements = new ArrayList<>();
|
List<ExecuteTag> executeElements = new ArrayList<>();
|
||||||
AtomicTag atomicTagElement = new AtomicTag();
|
AtomicTag atomicTagElement = new AtomicTag();
|
||||||
List<AddTag> addElements = new ArrayList<>();
|
List<AddTag> addElements = new ArrayList<>();
|
||||||
Replace replaceElement = new Replace();
|
ReplaceTag replaceElement = new ReplaceTag();
|
||||||
List<Item> replaceItems = new ArrayList<>();
|
List<ItemTag> replaceItems = new ArrayList<>();
|
||||||
SequenceTag monitorSequence = new SequenceTag();
|
SequenceTag monitorSequence = new SequenceTag();
|
||||||
|
|
||||||
if (operations != null) {
|
if (operations != null) {
|
||||||
@ -215,8 +215,8 @@ public class OperationReply {
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case POLICY:
|
case POLICY:
|
||||||
if (this.syncmlDocument.getBody().getAlert() != null) {
|
if (this.syncmlDocument.getBody().getAlert() != null) {
|
||||||
if (this.syncmlDocument.getBody().getAlert().getData().equals
|
if ((Constants.INITIAL_ALERT_DATA.equals(this.syncmlDocument.getBody()
|
||||||
(Constants.INITIAL_ALERT_DATA)) {
|
.getAlert().getData()))) {
|
||||||
SequenceTag policySequence = new SequenceTag();
|
SequenceTag policySequence = new SequenceTag();
|
||||||
policySequence = buildSequence(operation, policySequence);
|
policySequence = buildSequence(operation, policySequence);
|
||||||
syncmlBody.setSequence(policySequence);
|
syncmlBody.setSequence(policySequence);
|
||||||
@ -233,46 +233,40 @@ public class OperationReply {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case INFO:
|
case INFO:
|
||||||
Item itemGet = appendGetInfo(operation);
|
ItemTag itemGet = appendGetInfo(operation);
|
||||||
getElements.add(itemGet);
|
getElements.add(itemGet);
|
||||||
break;
|
break;
|
||||||
case COMMAND:
|
case COMMAND:
|
||||||
if (operation.getCode().equals(PluginConstants
|
ExecuteTag execElement;
|
||||||
.OperationCodes.DEVICE_LOCK)) {
|
if ((PluginConstants.OperationCodes.DEVICE_LOCK.equals(operation.getCode()))) {
|
||||||
ExecuteTag execElement = executeCommand(operation);
|
execElement = executeCommand(operation);
|
||||||
executeElements.add(execElement);
|
executeElements.add(execElement);
|
||||||
}
|
}
|
||||||
if (operation.getCode().equals(PluginConstants
|
if ((PluginConstants.OperationCodes.DEVICE_RING.equals(operation.getCode()))) {
|
||||||
.OperationCodes.DEVICE_RING)) {
|
execElement = executeCommand(operation);
|
||||||
ExecuteTag execElement = executeCommand(operation);
|
|
||||||
executeElements.add(execElement);
|
executeElements.add(execElement);
|
||||||
}
|
}
|
||||||
if (operation.getCode().equals(PluginConstants
|
if ((PluginConstants.OperationCodes.DISENROLL.equals(operation.getCode()))) {
|
||||||
.OperationCodes.DISENROLL)) {
|
execElement = executeCommand(operation);
|
||||||
ExecuteTag execElement = executeCommand(operation);
|
|
||||||
executeElements.add(execElement);
|
executeElements.add(execElement);
|
||||||
}
|
}
|
||||||
if (operation.getCode().equals(PluginConstants
|
if ((PluginConstants.OperationCodes.WIPE_DATA.equals(operation.getCode()))) {
|
||||||
.OperationCodes.WIPE_DATA)) {
|
execElement = executeCommand(operation);
|
||||||
ExecuteTag execElement = executeCommand(operation);
|
|
||||||
executeElements.add(execElement);
|
executeElements.add(execElement);
|
||||||
}
|
}
|
||||||
if (operation.getCode().equals(PluginConstants
|
if ((PluginConstants.OperationCodes.LOCK_RESET.equals(operation.getCode()))) {
|
||||||
.OperationCodes.LOCK_RESET)) {
|
|
||||||
SequenceTag sequenceElement = new SequenceTag();
|
SequenceTag sequenceElement = new SequenceTag();
|
||||||
SequenceTag sequence = buildSequence(operation, sequenceElement);
|
SequenceTag sequence = buildSequence(operation, sequenceElement);
|
||||||
syncmlBody.setSequence(sequence);
|
syncmlBody.setSequence(sequence);
|
||||||
}
|
}
|
||||||
if (operation.getCode().equals(PluginConstants
|
if ((PluginConstants.OperationCodes.MONITOR.equals(operation.getCode()))) {
|
||||||
.OperationCodes.MONITOR)) {
|
GetTag monitorGetElement = new GetTag();
|
||||||
|
List<ItemTag> monitorItems;
|
||||||
Get monitorGetElement = new Get();
|
|
||||||
List<Item> monitorItems;
|
|
||||||
List<ProfileFeature> profileFeatures;
|
List<ProfileFeature> profileFeatures;
|
||||||
|
|
||||||
if (this.syncmlDocument.getBody().getAlert() != null) {
|
if (this.syncmlDocument.getBody().getAlert() != null) {
|
||||||
if (this.syncmlDocument.getBody().getAlert().getData().equals
|
if (Constants.INITIAL_ALERT_DATA.equals(this.syncmlDocument.getBody().
|
||||||
(Constants.INITIAL_ALERT_DATA)) {
|
getAlert().getData())) {
|
||||||
|
|
||||||
monitorSequence.setCommandId(operation.getId());
|
monitorSequence.setCommandId(operation.getId());
|
||||||
DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(
|
DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(
|
||||||
@ -298,15 +292,15 @@ public class OperationReply {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!replaceItems.isEmpty()) {
|
if (!replaceItems.isEmpty()) {
|
||||||
replaceElement.setCommandId(300);
|
replaceElement.setCommandId(Constants.SyncmlMessageCodes.replaceCommandId);
|
||||||
replaceElement.setItems(replaceItems);
|
replaceElement.setItems(replaceItems);
|
||||||
}
|
}
|
||||||
if (!getElements.isEmpty()) {
|
if (!getElements.isEmpty()) {
|
||||||
getElement.setCommandId(75);
|
getElement.setCommandId(Constants.SyncmlMessageCodes.elementCommandId);
|
||||||
getElement.setItems(getElements);
|
getElement.setItems(getElements);
|
||||||
}
|
}
|
||||||
if (!addElements.isEmpty()) {
|
if (!addElements.isEmpty()) {
|
||||||
atomicTagElement.setCommandId(400);
|
atomicTagElement.setCommandId(Constants.SyncmlMessageCodes.atomicCommandId);
|
||||||
atomicTagElement.setAdds(addElements);
|
atomicTagElement.setAdds(addElements);
|
||||||
}
|
}
|
||||||
syncmlBody.setGet(getElement);
|
syncmlBody.setGet(getElement);
|
||||||
@ -315,15 +309,15 @@ public class OperationReply {
|
|||||||
syncmlBody.setReplace(replaceElement);
|
syncmlBody.setReplace(replaceElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Item appendExecInfo(Operation operation) {
|
private ItemTag appendExecInfo(Operation operation) {
|
||||||
Item item = new Item();
|
ItemTag item = new ItemTag();
|
||||||
String operationCode = operation.getCode();
|
String operationCode = operation.getCode();
|
||||||
for (Command command : Command.values()) {
|
for (Command command : Command.values()) {
|
||||||
if (operationCode != null && operationCode.equals(command.name())) {
|
if (operationCode != null && operationCode.equals(command.name())) {
|
||||||
Target target = new Target();
|
TargetTag target = new TargetTag();
|
||||||
target.setLocURI(command.getCode());
|
target.setLocURI(command.getCode());
|
||||||
if (operation.getCode().equals(PluginConstants
|
if ((PluginConstants
|
||||||
.OperationCodes.DISENROLL)) {
|
.OperationCodes.DISENROLL.equals(operation.getCode()))) {
|
||||||
MetaTag meta = new MetaTag();
|
MetaTag meta = new MetaTag();
|
||||||
meta.setFormat(Constants.META_FORMAT_CHARACTER);
|
meta.setFormat(Constants.META_FORMAT_CHARACTER);
|
||||||
item.setMeta(meta);
|
item.setMeta(meta);
|
||||||
@ -335,22 +329,22 @@ public class OperationReply {
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Item appendGetInfo(Operation operation) {
|
private ItemTag appendGetInfo(Operation operation) {
|
||||||
Item item = new Item();
|
ItemTag item = new ItemTag();
|
||||||
String operationCode = operation.getCode();
|
String operationCode = operation.getCode();
|
||||||
for (Info info : Info.values()) {
|
for (Info info : Info.values()) {
|
||||||
if (operationCode != null && operationCode.equals(info.name())) {
|
if (operationCode != null && operationCode.equals(info.name())) {
|
||||||
Target target = new Target();
|
TargetTag target = new TargetTag();
|
||||||
target.setLocURI(info.getCode());
|
target.setLocURI(info.getCode());
|
||||||
item.setTarget(target);
|
item.setTarget(target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((operationCode != null) && operationCode.equals(
|
if ((operationCode != null) &&
|
||||||
PluginConstants.OperationCodes.LOCK_RESET)) {
|
PluginConstants.OperationCodes.LOCK_RESET.equals(operationCode)) {
|
||||||
operation.setCode(PluginConstants.OperationCodes.PIN_CODE);
|
operation.setCode(PluginConstants.OperationCodes.PIN_CODE);
|
||||||
for (Info getInfo : Info.values()) {
|
for (Info getInfo : Info.values()) {
|
||||||
if (operation.getCode().equals(getInfo.name())) {
|
if (operation.getCode().equals(getInfo.name())) {
|
||||||
Target target = new Target();
|
TargetTag target = new TargetTag();
|
||||||
target.setLocURI(getInfo.getCode());
|
target.setLocURI(getInfo.getCode());
|
||||||
item.setTarget(target);
|
item.setTarget(target);
|
||||||
}
|
}
|
||||||
@ -359,11 +353,11 @@ public class OperationReply {
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Item appendReplaceInfo(Operation operation) throws JSONException {
|
private ItemTag appendReplaceInfo(Operation operation) throws JSONException {
|
||||||
String policyAllowData = "1";
|
String policyAllowData = "1";
|
||||||
String policyDisallowData = "0";
|
String policyDisallowData = "0";
|
||||||
Item item = new Item();
|
ItemTag item = new ItemTag();
|
||||||
Target target = new Target();
|
TargetTag target = new TargetTag();
|
||||||
String operationCode = operation.getCode();
|
String operationCode = operation.getCode();
|
||||||
JSONObject payload = new JSONObject(operation.getPayLoad().toString());
|
JSONObject payload = new JSONObject(operation.getPayLoad().toString());
|
||||||
for (Command command : Command.values()) {
|
for (Command command : Command.values()) {
|
||||||
@ -371,8 +365,7 @@ public class OperationReply {
|
|||||||
if (operationCode != null && operationCode.equals(command.name())) {
|
if (operationCode != null && operationCode.equals(command.name())) {
|
||||||
target.setLocURI(command.getCode());
|
target.setLocURI(command.getCode());
|
||||||
|
|
||||||
if (operation.getCode().equals(PluginConstants
|
if ((PluginConstants.OperationCodes.CAMERA.equals(operation.getCode()))) {
|
||||||
.OperationCodes.CAMERA)) {
|
|
||||||
|
|
||||||
if (payload.getBoolean("enabled")) {
|
if (payload.getBoolean("enabled")) {
|
||||||
MetaTag meta = new MetaTag();
|
MetaTag meta = new MetaTag();
|
||||||
@ -388,8 +381,8 @@ public class OperationReply {
|
|||||||
item.setData(policyDisallowData);
|
item.setData(policyDisallowData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (operation.getCode().equals(PluginConstants
|
if ((PluginConstants.OperationCodes.ENCRYPT_STORAGE.
|
||||||
.OperationCodes.ENCRYPT_STORAGE)) {
|
equals(operation.getCode()))) {
|
||||||
|
|
||||||
if (payload.getBoolean("encrypted")) {
|
if (payload.getBoolean("encrypted")) {
|
||||||
MetaTag meta = new MetaTag();
|
MetaTag meta = new MetaTag();
|
||||||
@ -415,7 +408,7 @@ public class OperationReply {
|
|||||||
List<AddTag> addList = new ArrayList<>();
|
List<AddTag> addList = new ArrayList<>();
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
|
|
||||||
if (operation.getCode().equals(PluginConstants.OperationCodes.PASSCODE_POLICY)) {
|
if ((PluginConstants.OperationCodes.PASSCODE_POLICY.equals(operation.getCode()))) {
|
||||||
|
|
||||||
PasscodePolicy passcodeObject = gson.fromJson((String) operation.getPayLoad(), PasscodePolicy.class);
|
PasscodePolicy passcodeObject = gson.fromJson((String) operation.getPayLoad(), PasscodePolicy.class);
|
||||||
|
|
||||||
@ -489,11 +482,11 @@ public class OperationReply {
|
|||||||
|
|
||||||
MetaTag meta = new MetaTag();
|
MetaTag meta = new MetaTag();
|
||||||
meta.setFormat(Constants.META_FORMAT_CHARACTER);
|
meta.setFormat(Constants.META_FORMAT_CHARACTER);
|
||||||
List<Item> items = new ArrayList<>();
|
List<ItemTag> items = new ArrayList<>();
|
||||||
|
|
||||||
for (Configure configure : Configure.values()) {
|
for (Configure configure : Configure.values()) {
|
||||||
if (operationCode != null && operationCode.equals(configure.name())) {
|
if (operationCode != null && operationCode.equals(configure.name())) {
|
||||||
Target target = new Target();
|
TargetTag target = new TargetTag();
|
||||||
target.setLocURI(configure.getCode());
|
target.setLocURI(configure.getCode());
|
||||||
items.get(0).setTarget(target);
|
items.get(0).setTarget(target);
|
||||||
}
|
}
|
||||||
@ -512,8 +505,8 @@ public class OperationReply {
|
|||||||
public ExecuteTag executeCommand(Operation operation) {
|
public ExecuteTag executeCommand(Operation operation) {
|
||||||
ExecuteTag execElement = new ExecuteTag();
|
ExecuteTag execElement = new ExecuteTag();
|
||||||
execElement.setCommandId(operation.getId());
|
execElement.setCommandId(operation.getId());
|
||||||
List<Item> itemsExec = new ArrayList<>();
|
List<ItemTag> itemsExec = new ArrayList<>();
|
||||||
Item itemExec = appendExecInfo(operation);
|
ItemTag itemExec = appendExecInfo(operation);
|
||||||
itemsExec.add(itemExec);
|
itemsExec.add(itemExec);
|
||||||
execElement.setItems(itemsExec);
|
execElement.setItems(itemsExec);
|
||||||
return execElement;
|
return execElement;
|
||||||
@ -523,14 +516,14 @@ public class OperationReply {
|
|||||||
JSONException, SyncmlOperationException {
|
JSONException, SyncmlOperationException {
|
||||||
|
|
||||||
sequenceElement.setCommandId(operation.getId());
|
sequenceElement.setCommandId(operation.getId());
|
||||||
List<Replace> replaceItems = new ArrayList<>();
|
List<ReplaceTag> replaceItems = new ArrayList<>();
|
||||||
|
|
||||||
if (operation.getCode().equals(PluginConstants.OperationCodes.LOCK_RESET)) {
|
if ((PluginConstants.OperationCodes.LOCK_RESET.equals(operation.getCode()))) {
|
||||||
ExecuteTag execElement = executeCommand(operation);
|
ExecuteTag execElement = executeCommand(operation);
|
||||||
Get getElements = new Get();
|
GetTag getElements = new GetTag();
|
||||||
getElements.setCommandId(operation.getId());
|
getElements.setCommandId(operation.getId());
|
||||||
List<Item> getItems = new ArrayList<>();
|
List<ItemTag> getItems = new ArrayList<>();
|
||||||
Item itemGets = appendGetInfo(operation);
|
ItemTag itemGets = appendGetInfo(operation);
|
||||||
getItems.add(itemGets);
|
getItems.add(itemGets);
|
||||||
getElements.setItems(getItems);
|
getElements.setItems(getItems);
|
||||||
|
|
||||||
@ -538,7 +531,7 @@ public class OperationReply {
|
|||||||
sequenceElement.setGet(getElements);
|
sequenceElement.setGet(getElements);
|
||||||
return sequenceElement;
|
return sequenceElement;
|
||||||
|
|
||||||
} else if (operation.getCode().equals(PluginConstants.OperationCodes.POLICY_BUNDLE)) {
|
} else if ((PluginConstants.OperationCodes.POLICY_BUNDLE.equals(operation.getCode()))) {
|
||||||
List<? extends Operation> policyOperations;
|
List<? extends Operation> policyOperations;
|
||||||
try {
|
try {
|
||||||
policyOperations = (List<? extends Operation>) operation.getPayLoad();
|
policyOperations = (List<? extends Operation>) operation.getPayLoad();
|
||||||
@ -546,10 +539,12 @@ public class OperationReply {
|
|||||||
throw new ClassCastException();
|
throw new ClassCastException();
|
||||||
}
|
}
|
||||||
for (Operation policy : policyOperations) {
|
for (Operation policy : policyOperations) {
|
||||||
if (policy.getCode().equals(PluginConstants.OperationCodes.CAMERA)) {
|
|
||||||
Replace replaceCameraConfig = new Replace();
|
if (PluginConstants.OperationCodes.CAMERA.equals(policy.getCode())) {
|
||||||
Item cameraItem;
|
ReplaceTag replaceCameraConfig = new ReplaceTag();
|
||||||
List<Item> cameraItems = new ArrayList<>();
|
ItemTag cameraItem;
|
||||||
|
List<ItemTag> cameraItems = new ArrayList<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
cameraItem = appendReplaceInfo(policy);
|
cameraItem = appendReplaceInfo(policy);
|
||||||
cameraItems.add(cameraItem);
|
cameraItems.add(cameraItem);
|
||||||
@ -560,11 +555,11 @@ public class OperationReply {
|
|||||||
replaceCameraConfig.setItems(cameraItems);
|
replaceCameraConfig.setItems(cameraItems);
|
||||||
replaceItems.add(replaceCameraConfig);
|
replaceItems.add(replaceCameraConfig);
|
||||||
}
|
}
|
||||||
if (policy.getCode().equals(PluginConstants.OperationCodes.ENCRYPT_STORAGE)) {
|
if ((PluginConstants.OperationCodes.ENCRYPT_STORAGE.equals(policy.getCode()))) {
|
||||||
|
|
||||||
Replace replaceStorageConfig = new Replace();
|
ReplaceTag replaceStorageConfig = new ReplaceTag();
|
||||||
Item storageItem;
|
ItemTag storageItem;
|
||||||
List<Item> storageItems = new ArrayList<>();
|
List<ItemTag> storageItems = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
storageItem = appendReplaceInfo(policy);
|
storageItem = appendReplaceInfo(policy);
|
||||||
storageItems.add(storageItem);
|
storageItems.add(storageItem);
|
||||||
@ -576,14 +571,18 @@ public class OperationReply {
|
|||||||
replaceItems.add(replaceStorageConfig);
|
replaceItems.add(replaceStorageConfig);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (policy.getCode().equals(PluginConstants.OperationCodes.PASSCODE_POLICY)) {
|
if ((PluginConstants.OperationCodes.PASSCODE_POLICY.equals(policy.getCode()))) {
|
||||||
AtomicTag atomicTagElement = new AtomicTag();
|
AtomicTag atomicTagElement = new AtomicTag();
|
||||||
List<AddTag> addConfig;
|
List<AddTag> addConfig;
|
||||||
|
DeleteTag deleteTag = new DeleteTag();
|
||||||
try {
|
try {
|
||||||
addConfig = appendAddInfo(policy);
|
addConfig = appendAddInfo(policy);
|
||||||
atomicTagElement.setAdds(addConfig);
|
atomicTagElement.setAdds(addConfig);
|
||||||
atomicTagElement.setCommandId(operation.getId());
|
atomicTagElement.setCommandId(operation.getId());
|
||||||
|
List<ItemTag> deleteTagItems = buildDeletePasscodeData(policy);
|
||||||
|
deleteTag.setCommandId(operation.getId());
|
||||||
|
deleteTag.setItems(deleteTagItems);
|
||||||
|
sequenceElement.setDeleteTag(deleteTag);
|
||||||
sequenceElement.setAtomicTag(atomicTagElement);
|
sequenceElement.setAtomicTag(atomicTagElement);
|
||||||
} catch (WindowsOperationException e) {
|
} catch (WindowsOperationException e) {
|
||||||
throw new SyncmlOperationException("Error occurred while generating operation payload.", e);
|
throw new SyncmlOperationException("Error occurred while generating operation payload.", e);
|
||||||
@ -600,69 +599,70 @@ public class OperationReply {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Item> buildMonitorOperation(List<ProfileFeature> effectiveMonitoringFeature) {
|
public List<ItemTag> buildMonitorOperation(List<ProfileFeature> effectiveMonitoringFeature) {
|
||||||
List<Item> monitorItems = new ArrayList<>();
|
List<ItemTag> monitorItems = new ArrayList<>();
|
||||||
Operation monitorOperation;
|
Operation monitorOperation;
|
||||||
for (ProfileFeature profileFeature : effectiveMonitoringFeature) {
|
for (ProfileFeature profileFeature : effectiveMonitoringFeature) {
|
||||||
|
|
||||||
if (profileFeature.getFeatureCode().equals(PluginConstants
|
if ((PluginConstants.OperationCodes.CAMERA.equals
|
||||||
.OperationCodes.CAMERA)) {
|
(profileFeature.getFeatureCode()))) {
|
||||||
String cameraStatus = PluginConstants
|
String cameraStatus = PluginConstants
|
||||||
.OperationCodes.CAMERA_STATUS;
|
.OperationCodes.CAMERA_STATUS;
|
||||||
|
|
||||||
monitorOperation = new Operation();
|
monitorOperation = new Operation();
|
||||||
monitorOperation.setCode(cameraStatus);
|
monitorOperation.setCode(cameraStatus);
|
||||||
Item item = appendGetInfo(monitorOperation);
|
ItemTag item = appendGetInfo(monitorOperation);
|
||||||
monitorItems.add(item);
|
monitorItems.add(item);
|
||||||
}
|
}
|
||||||
if (profileFeature.getFeatureCode().equals(PluginConstants
|
if (PluginConstants.OperationCodes.ENCRYPT_STORAGE.equals
|
||||||
.OperationCodes.ENCRYPT_STORAGE)) {
|
(profileFeature.getFeatureCode())) {
|
||||||
String encryptStorageStatus = PluginConstants
|
String encryptStorageStatus = PluginConstants
|
||||||
.OperationCodes.ENCRYPT_STORAGE_STATUS;
|
.OperationCodes.ENCRYPT_STORAGE_STATUS;
|
||||||
|
|
||||||
monitorOperation = new Operation();
|
monitorOperation = new Operation();
|
||||||
monitorOperation.setCode(encryptStorageStatus);
|
monitorOperation.setCode(encryptStorageStatus);
|
||||||
Item item = appendGetInfo(monitorOperation);
|
ItemTag item = appendGetInfo(monitorOperation);
|
||||||
monitorItems.add(item);
|
monitorItems.add(item);
|
||||||
}
|
}
|
||||||
if (profileFeature.getFeatureCode().equals(PluginConstants
|
if ((PluginConstants.OperationCodes.PASSCODE_POLICY.equals
|
||||||
.OperationCodes.PASSCODE_POLICY)) {
|
(profileFeature.getFeatureCode()))) {
|
||||||
String passcodeStatus = PluginConstants
|
String passcodeStatus = PluginConstants
|
||||||
.OperationCodes.DEVICE_PASSWORD_STATUS;
|
.OperationCodes.DEVICE_PASSWORD_STATUS;
|
||||||
|
|
||||||
monitorOperation = new Operation();
|
monitorOperation = new Operation();
|
||||||
monitorOperation.setCode(passcodeStatus);
|
monitorOperation.setCode(passcodeStatus);
|
||||||
Item item = appendGetInfo(monitorOperation);
|
ItemTag item = appendGetInfo(monitorOperation);
|
||||||
monitorItems.add(item);
|
monitorItems.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return monitorItems;
|
return monitorItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Item> buildDeleteInfo(Operation operation) {
|
|
||||||
List<Item> deleteItems = new ArrayList<>();
|
public List<ItemTag> buildDeletePasscodeData(Operation operation) {
|
||||||
Item deleteItem = new Item();
|
List<ItemTag> deleteTagItems = new ArrayList<>();
|
||||||
Target target = new Target();
|
ItemTag itemTag = new ItemTag();
|
||||||
String operationCode = operation.getCode();
|
TargetTag target = new TargetTag();
|
||||||
if (operation.getCode().equals(PluginConstants.OperationCodes.PASSCODE_POLICY)) {
|
if ((PluginConstants.OperationCodes.PASSCODE_POLICY.equals(operation.getCode()))) {
|
||||||
operation.setCode(PluginConstants.OperationCodes.DEVICE_PASSCODE_DELETE);
|
operation.setCode(PluginConstants.OperationCodes.DEVICE_PASSCODE_DELETE);
|
||||||
for (Command command : Command.values()) {
|
for (Command command : Command.values()) {
|
||||||
|
if (operation.getCode() != null && operation.getCode().equals(command.name())) {
|
||||||
if (operationCode != null && operationCode.equals(command.name())) {
|
|
||||||
target.setLocURI(command.getCode());
|
target.setLocURI(command.getCode());
|
||||||
deleteItem.setTarget(target);
|
itemTag.setTarget(target);
|
||||||
|
deleteTagItems.add(itemTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return deleteItems;
|
return deleteTagItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AddTag generatePasscodePolicyData(Configure configure, int policyData) {
|
public AddTag generatePasscodePolicyData(Configure configure, int policyData) {
|
||||||
String attempt = String.valueOf(policyData);
|
String attempt = String.valueOf(policyData);
|
||||||
AddTag add = new AddTag();
|
AddTag add = new AddTag();
|
||||||
List<Item> itemList = new ArrayList<>();
|
List<ItemTag> itemList = new ArrayList<>();
|
||||||
Item item = new Item();
|
ItemTag item = new ItemTag();
|
||||||
Target target = new Target();
|
TargetTag target = new TargetTag();
|
||||||
target.setLocURI(configure.getCode());
|
target.setLocURI(configure.getCode());
|
||||||
MetaTag meta = new MetaTag();
|
MetaTag meta = new MetaTag();
|
||||||
meta.setFormat(Constants.META_FORMAT_INT);
|
meta.setFormat(Constants.META_FORMAT_INT);
|
||||||
@ -670,15 +670,15 @@ public class OperationReply {
|
|||||||
item.setMeta(meta);
|
item.setMeta(meta);
|
||||||
item.setData(attempt);
|
item.setData(attempt);
|
||||||
itemList.add(item);
|
itemList.add(item);
|
||||||
add.setCommandId(90);
|
add.setCommandId(Constants.SyncmlMessageCodes.addCommandId);
|
||||||
add.setItems(itemList);
|
add.setItems(itemList);
|
||||||
return add;
|
return add;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AddTag generatePasscodeBooleanData(Operation operation, Configure configure) {
|
public AddTag generatePasscodeBooleanData(Operation operation, Configure configure) {
|
||||||
Target target = new Target();
|
TargetTag target = new TargetTag();
|
||||||
MetaTag meta = new MetaTag();
|
MetaTag meta = new MetaTag();
|
||||||
AddTag add = new AddTag();
|
AddTag addTag = null;
|
||||||
|
|
||||||
PasscodePolicy passcodePolicy = gson.fromJson((String) operation.getPayLoad(), PasscodePolicy.class);
|
PasscodePolicy passcodePolicy = gson.fromJson((String) operation.getPayLoad(), PasscodePolicy.class);
|
||||||
if (operation.getCode() != null && (PluginConstants.OperationCodes.DEVICE_PASSWORD_ENABLE.
|
if (operation.getCode() != null && (PluginConstants.OperationCodes.DEVICE_PASSWORD_ENABLE.
|
||||||
@ -686,87 +686,38 @@ public class OperationReply {
|
|||||||
if (passcodePolicy.isEnablePassword()) {
|
if (passcodePolicy.isEnablePassword()) {
|
||||||
target.setLocURI(configure.getCode());
|
target.setLocURI(configure.getCode());
|
||||||
meta.setFormat(Constants.META_FORMAT_INT);
|
meta.setFormat(Constants.META_FORMAT_INT);
|
||||||
List<Item> itemList = new ArrayList<>();
|
addTag = TagUtil.buildAddTag(operation, Constants.SyncMLResponseCodes.NEGATIVE_CSP_DATA);
|
||||||
Item item = new Item();
|
|
||||||
item.setTarget(target);
|
|
||||||
item.setMeta(meta);
|
|
||||||
item.setData("0");
|
|
||||||
itemList.add(item);
|
|
||||||
|
|
||||||
add.setCommandId(operation.getId());
|
|
||||||
add.setItems(itemList);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
target.setLocURI(configure.getCode());
|
target.setLocURI(configure.getCode());
|
||||||
meta.setFormat(Constants.META_FORMAT_INT);
|
meta.setFormat(Constants.META_FORMAT_INT);
|
||||||
List<Item> itemList = new ArrayList<>();
|
addTag = TagUtil.buildAddTag(operation, Constants.SyncMLResponseCodes.POSITIVE_CSP_DATA);
|
||||||
Item item = new Item();
|
|
||||||
item.setTarget(target);
|
|
||||||
item.setMeta(meta);
|
|
||||||
item.setData("1");
|
|
||||||
itemList.add(item);
|
|
||||||
add.setCommandId(operation.getId());
|
|
||||||
add.setItems(itemList);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (PluginConstants.OperationCodes.ALPHANUMERIC_PASSWORD.
|
if (PluginConstants.OperationCodes.ALPHANUMERIC_PASSWORD.
|
||||||
equals(configure.name())) {
|
equals(configure.name())) {
|
||||||
if (passcodePolicy.isRequireAlphanumeric()) {
|
if (passcodePolicy.isRequireAlphanumeric()) {
|
||||||
Item item = new Item();
|
|
||||||
target.setLocURI(configure.getCode());
|
target.setLocURI(configure.getCode());
|
||||||
meta.setFormat(Constants.META_FORMAT_INT);
|
meta.setFormat(Constants.META_FORMAT_INT);
|
||||||
List<Item> itemList = new ArrayList<>();
|
addTag = TagUtil.buildAddTag(operation, Constants.SyncMLResponseCodes.POSITIVE_CSP_DATA);
|
||||||
item.setTarget(target);
|
|
||||||
item.setMeta(meta);
|
|
||||||
item.setData("1");
|
|
||||||
itemList.add(item);
|
|
||||||
add.setCommandId(operation.getId());
|
|
||||||
add.setItems(itemList);
|
|
||||||
} else {
|
} else {
|
||||||
target.setLocURI(configure.getCode());
|
target.setLocURI(configure.getCode());
|
||||||
meta.setFormat(Constants.META_FORMAT_INT);
|
meta.setFormat(Constants.META_FORMAT_INT);
|
||||||
List<Item> itemList = new ArrayList<>();
|
addTag = TagUtil.buildAddTag(operation, Constants.SyncMLResponseCodes.NEGATIVE_CSP_DATA);
|
||||||
Item item = new Item();
|
|
||||||
item.setTarget(target);
|
|
||||||
item.setMeta(meta);
|
|
||||||
item.setData("0");
|
|
||||||
itemList.add(item);
|
|
||||||
add.setCommandId(operation.getId());
|
|
||||||
add.setItems(itemList);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (PluginConstants.OperationCodes.SIMPLE_PASSWORD.
|
if (PluginConstants.OperationCodes.SIMPLE_PASSWORD.
|
||||||
equals(configure.name())) {
|
equals(configure.name())) {
|
||||||
if (passcodePolicy.isAllowSimple()) {
|
if (passcodePolicy.isAllowSimple()) {
|
||||||
Item item = new Item();
|
|
||||||
target.setLocURI(configure.getCode());
|
target.setLocURI(configure.getCode());
|
||||||
meta.setFormat(Constants.META_FORMAT_INT);
|
meta.setFormat(Constants.META_FORMAT_INT);
|
||||||
List<Item> itemList = new ArrayList<>();
|
addTag = TagUtil.buildAddTag(operation, Constants.SyncMLResponseCodes.POSITIVE_CSP_DATA);
|
||||||
item.setTarget(target);
|
|
||||||
item.setMeta(meta);
|
|
||||||
item.setData("1");
|
|
||||||
itemList.add(item);
|
|
||||||
add.setCommandId(operation.getId());
|
|
||||||
add.setItems(itemList);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Item item = new Item();
|
|
||||||
target.setLocURI(configure.getCode());
|
target.setLocURI(configure.getCode());
|
||||||
meta.setFormat(Constants.META_FORMAT_INT);
|
meta.setFormat(Constants.META_FORMAT_INT);
|
||||||
List<Item> itemList = new ArrayList<>();
|
addTag = TagUtil.buildAddTag(operation, Constants.SyncMLResponseCodes.NEGATIVE_CSP_DATA);
|
||||||
item.setTarget(target);
|
|
||||||
item.setMeta(meta);
|
|
||||||
item.setData("0");
|
|
||||||
itemList.add(item);
|
|
||||||
add.setCommandId(operation.getId());
|
|
||||||
add.setItems(itemList);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return add;
|
return addTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,502 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
|
||||||
*
|
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
|
||||||
* in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.operations.util;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
||||||
import org.wso2.carbon.device.mgt.common.FeatureManagementException;
|
|
||||||
import org.wso2.carbon.device.mgt.common.notification.mgt.Notification;
|
|
||||||
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException;
|
|
||||||
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService;
|
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.operations.*;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.services.syncml.beans.Profile;
|
|
||||||
import org.wso2.carbon.policy.mgt.common.ProfileFeature;
|
|
||||||
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature;
|
|
||||||
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils.convertToDeviceIdentifierObject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class contains Operation related utilities.
|
|
||||||
*/
|
|
||||||
public class OperationUtils {
|
|
||||||
private static Log log = LogFactory.getLog(OperationUtils.class);
|
|
||||||
List<? extends Operation> pendingDataOperations;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the operations using device status payload.
|
|
||||||
*
|
|
||||||
* @param status Client side status for the specific operations
|
|
||||||
* @param syncmlDocument syncml payload for operation status which parse through the syncml engine
|
|
||||||
* @param deviceIdentifier specific device identifier for each device
|
|
||||||
* @throws OperationManagementException
|
|
||||||
* @throws DeviceManagementException
|
|
||||||
*/
|
|
||||||
public void updateDeviceOperations(Status status, SyncmlDocument syncmlDocument,
|
|
||||||
DeviceIdentifier deviceIdentifier)
|
|
||||||
throws OperationManagementException, DeviceManagementException, NotificationManagementException,
|
|
||||||
WindowsOperationException {
|
|
||||||
|
|
||||||
pendingDataOperations = WindowsAPIUtils.getDeviceManagementService()
|
|
||||||
.getOperationsByDeviceAndStatus(deviceIdentifier, Operation.Status.PENDING);
|
|
||||||
if (status.getData().equals(Constants.SyncMLResponseCodes.ACCEPTED) || status.getData().equals
|
|
||||||
(Constants.SyncMLResponseCodes.ACCEPTED_FOR_PROCESSING)) {
|
|
||||||
for (Operation operation : pendingDataOperations) {
|
|
||||||
if (operation.getId() == status.getCommandReference()) {
|
|
||||||
operation.setStatus(Operation.Status.COMPLETED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
updateOperations(syncmlDocument.getHeader().getSource().getLocURI(), pendingDataOperations);
|
|
||||||
} else if (status.getData().equals(Constants.SyncMLResponseCodes.PIN_NOTFOUND)) {
|
|
||||||
for (Operation operation : pendingDataOperations) {
|
|
||||||
if (operation.getId() == status.getCommandReference() && operation.
|
|
||||||
getCode().equals(String.valueOf(OperationCode.Command.DEVICE_LOCK))) {
|
|
||||||
operation.setStatus(Operation.Status.ERROR);
|
|
||||||
updateOperations(syncmlDocument.getHeader().getSource().getLocURI(), pendingDataOperations);
|
|
||||||
try {
|
|
||||||
NotificationManagementService nmService = WindowsAPIUtils.getNotificationManagementService();
|
|
||||||
Notification lockResetNotification = new Notification();
|
|
||||||
lockResetNotification.setOperationId(status.getCommandReference());
|
|
||||||
lockResetNotification.setStatus(String.valueOf(Notification.Status.NEW));
|
|
||||||
lockResetNotification.setDescription(
|
|
||||||
Constants.SyncMLResponseCodes.LOCKRESET_NOTIFICATION);
|
|
||||||
nmService.addNotification(deviceIdentifier, lockResetNotification);
|
|
||||||
} catch (NotificationManagementException e) {
|
|
||||||
throw new WindowsOperationException("Failure occurred in getting notification service", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update operation statuses
|
|
||||||
*
|
|
||||||
* @param deviceId specific device Id
|
|
||||||
* @param operations operation list to be update
|
|
||||||
* @throws OperationManagementException
|
|
||||||
*/
|
|
||||||
public void updateOperations(String deviceId,
|
|
||||||
List<? extends org.wso2.carbon.device.mgt.common.operation.mgt.Operation> operations)
|
|
||||||
throws OperationManagementException {
|
|
||||||
|
|
||||||
for (Operation operation : operations) {
|
|
||||||
WindowsAPIUtils.updateOperation(deviceId, operation);
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("Updating operation '" + operation.toString() + "'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update Status of the lock operation.
|
|
||||||
*
|
|
||||||
* @param status Status of the operation.
|
|
||||||
* @param syncmlDocument parsed syncml payload.
|
|
||||||
* @param deviceIdentifier Device Id.
|
|
||||||
* @throws OperationManagementException
|
|
||||||
* @throws DeviceManagementException
|
|
||||||
* @throws NotificationManagementException
|
|
||||||
*/
|
|
||||||
public void lockOperationUpdate(Status status, SyncmlDocument syncmlDocument, DeviceIdentifier deviceIdentifier)
|
|
||||||
throws OperationManagementException, DeviceManagementException, NotificationManagementException {
|
|
||||||
|
|
||||||
pendingDataOperations = WindowsAPIUtils.getDeviceManagementService()
|
|
||||||
.getOperationsByDeviceAndStatus(deviceIdentifier, Operation.Status.PENDING);
|
|
||||||
if (status.getData().equals(Constants.SyncMLResponseCodes.ACCEPTED)) {
|
|
||||||
for (Operation operation : pendingDataOperations) {
|
|
||||||
if (operation.getCode().equals(OperationCode.Command.DEVICE_LOCK.getCode())
|
|
||||||
&& operation.getId() == status.getCommandReference()) {
|
|
||||||
operation.setStatus(Operation.Status.COMPLETED);
|
|
||||||
new OperationUtils().updateOperations(syncmlDocument.getHeader().getSource().getLocURI(),
|
|
||||||
pendingDataOperations);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (status.getData().equals(Constants.SyncMLResponseCodes.PIN_NOTFOUND)) {
|
|
||||||
for (Operation operation : pendingDataOperations) {
|
|
||||||
|
|
||||||
if (operation.getCode().equals(OperationCode.Command.DEVICE_LOCK.getCode()) &&
|
|
||||||
operation.getId() == status.getCommandReference()) {
|
|
||||||
operation.setStatus(Operation.Status.ERROR);
|
|
||||||
new OperationUtils().updateOperations(syncmlDocument.getHeader().getSource().getLocURI(),
|
|
||||||
pendingDataOperations);
|
|
||||||
try {
|
|
||||||
NotificationManagementService nmService = WindowsAPIUtils.getNotificationManagementService();
|
|
||||||
Notification lockResetNotification = new Notification();
|
|
||||||
lockResetNotification.setOperationId(status.getCommandReference());
|
|
||||||
lockResetNotification.setStatus(String.valueOf(Notification.Status.NEW));
|
|
||||||
lockResetNotification.setDescription(Constants.SyncMLResponseCodes.LOCKRESET_NOTIFICATION);
|
|
||||||
|
|
||||||
nmService.addNotification(deviceIdentifier, lockResetNotification);
|
|
||||||
} catch (NotificationManagementException e) {
|
|
||||||
String msg = "Failure occurred in getting notification service";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new NotificationManagementException(msg, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/***
|
|
||||||
* Update status of the ring operation.
|
|
||||||
*
|
|
||||||
* @param status Ring status of the device.
|
|
||||||
* @param syncmlDocument Parsed syncml payload from the syncml engine.
|
|
||||||
* @param deviceIdentifier specific device id to be update.
|
|
||||||
* @throws OperationManagementException
|
|
||||||
* @throws DeviceManagementException
|
|
||||||
*/
|
|
||||||
public void ring(Status status, SyncmlDocument syncmlDocument,
|
|
||||||
DeviceIdentifier deviceIdentifier)
|
|
||||||
throws OperationManagementException, DeviceManagementException {
|
|
||||||
|
|
||||||
if (status.getData().equals(Constants.SyncMLResponseCodes.ACCEPTED)) {
|
|
||||||
pendingDataOperations = WindowsAPIUtils.getDeviceManagementService()
|
|
||||||
.getOperationsByDeviceAndStatus(deviceIdentifier, Operation.Status.PENDING);
|
|
||||||
for (Operation operation : pendingDataOperations) {
|
|
||||||
if (operation.getCode().equals(OperationCode.Command.DEVICE_RING) &&
|
|
||||||
(operation.getId() == status.getCommandReference())) {
|
|
||||||
operation.setStatus(Operation.Status.COMPLETED);
|
|
||||||
new OperationUtils().updateOperations(syncmlDocument.getHeader().getSource().getLocURI(),
|
|
||||||
pendingDataOperations);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/***
|
|
||||||
* Update the status of the DataWipe operation.
|
|
||||||
*
|
|
||||||
* @param status Status of the datawipe.
|
|
||||||
* @param syncmlDocument Parsed syncml payload from the syncml engine.
|
|
||||||
* @param deviceIdentifier specific device id to be wiped.
|
|
||||||
* @throws OperationManagementException
|
|
||||||
* @throws DeviceManagementException
|
|
||||||
*/
|
|
||||||
public void dataWipe(Status status, SyncmlDocument syncmlDocument,
|
|
||||||
DeviceIdentifier deviceIdentifier)
|
|
||||||
throws OperationManagementException, DeviceManagementException {
|
|
||||||
|
|
||||||
if (status.getData().equals(Constants.SyncMLResponseCodes.ACCEPTED)) {
|
|
||||||
pendingDataOperations = WindowsAPIUtils.getDeviceManagementService()
|
|
||||||
.getOperationsByDeviceAndStatus(deviceIdentifier, Operation.Status.PENDING);
|
|
||||||
for (Operation operation : pendingDataOperations) {
|
|
||||||
|
|
||||||
if (operation.getCode().equals(OperationCode.Command.WIPE_DATA) &&
|
|
||||||
(operation.getId() == status.getCommandReference())) {
|
|
||||||
operation.setStatus(Operation.Status.COMPLETED);
|
|
||||||
updateOperations(syncmlDocument.getHeader().getSource().getLocURI(),
|
|
||||||
pendingDataOperations);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get pending operations.
|
|
||||||
*
|
|
||||||
* @param syncmlDocument SyncmlDocument object which creates from the syncml engine using syncml payload
|
|
||||||
* @return Return list of pending operations.
|
|
||||||
* @throws OperationManagementException
|
|
||||||
* @throws DeviceManagementException
|
|
||||||
* @throws FeatureManagementException
|
|
||||||
* @throws PolicyComplianceException
|
|
||||||
* @throws NotificationManagementException
|
|
||||||
*/
|
|
||||||
public List<? extends Operation> getPendingOperations(SyncmlDocument syncmlDocument)
|
|
||||||
throws OperationManagementException, DeviceManagementException, FeatureManagementException,
|
|
||||||
PolicyComplianceException, NotificationManagementException, WindowsDeviceEnrolmentException,
|
|
||||||
WindowsOperationException {
|
|
||||||
|
|
||||||
List<? extends Operation> pendingOperations;
|
|
||||||
DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(
|
|
||||||
syncmlDocument.getHeader().getSource().getLocURI());
|
|
||||||
UpdateUriOperations(syncmlDocument);
|
|
||||||
generateComplianceFeatureStatus(syncmlDocument);
|
|
||||||
|
|
||||||
pendingOperations = WindowsAPIUtils.getDeviceManagementService().getPendingOperations(deviceIdentifier);
|
|
||||||
return pendingOperations;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set compliance of the feature according to the device status for the specific feature.
|
|
||||||
*
|
|
||||||
* @param activeFeature
|
|
||||||
* @param deviceFeature
|
|
||||||
* @return Returns setting up compliance feature.
|
|
||||||
*/
|
|
||||||
public ComplianceFeature setComplianceFeatures(ProfileFeature activeFeature, Profile deviceFeature) {
|
|
||||||
ComplianceFeature complianceFeature = new ComplianceFeature();
|
|
||||||
complianceFeature.setFeature(activeFeature);
|
|
||||||
complianceFeature.setFeatureCode(activeFeature.getFeatureCode());
|
|
||||||
complianceFeature.setCompliance(deviceFeature.isCompliance());
|
|
||||||
return complianceFeature;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the completed/Error status of the operation which have the URI of the operation code in the syncml payload.
|
|
||||||
*
|
|
||||||
* @param syncmlDocument SyncmlDocument object generated from the the syncml engine.
|
|
||||||
* @throws DeviceManagementException
|
|
||||||
* @throws NotificationManagementException
|
|
||||||
* @throws OperationManagementException
|
|
||||||
*/
|
|
||||||
public void UpdateUriOperations(SyncmlDocument syncmlDocument) throws DeviceManagementException,
|
|
||||||
NotificationManagementException, OperationManagementException, WindowsOperationException {
|
|
||||||
DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(
|
|
||||||
syncmlDocument.getHeader().getSource().getLocURI());
|
|
||||||
List<Status> statuses = syncmlDocument.getBody().getStatus();
|
|
||||||
OperationUtils operationUtils = new OperationUtils();
|
|
||||||
|
|
||||||
for (Status status : statuses) {
|
|
||||||
|
|
||||||
if (status.getCommand().equals(Constants.EXECUTE)) {
|
|
||||||
if (status.getTargetReference() == null) {
|
|
||||||
operationUtils.updateDeviceOperations(status, syncmlDocument, deviceIdentifier);
|
|
||||||
} else {
|
|
||||||
if (status.getTargetReference().equals(OperationCode.Command.DEVICE_LOCK)) {
|
|
||||||
operationUtils.lockOperationUpdate(status, syncmlDocument, deviceIdentifier);
|
|
||||||
}
|
|
||||||
if (status.getTargetReference().equals(OperationCode.Command.DEVICE_RING)) {
|
|
||||||
operationUtils.ring(status, syncmlDocument, deviceIdentifier);
|
|
||||||
}
|
|
||||||
if (status.getTargetReference().equals(OperationCode.Command.WIPE_DATA)) {
|
|
||||||
operationUtils.dataWipe(status, syncmlDocument, deviceIdentifier);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (status.getCommand().equals(Constants.SEQUENCE)) {
|
|
||||||
if (status.getData().equals(Constants.SyncMLResponseCodes.ACCEPTED)) {
|
|
||||||
|
|
||||||
pendingDataOperations = WindowsAPIUtils.getDeviceManagementService()
|
|
||||||
.getOperationsByDeviceAndStatus(deviceIdentifier, Operation.Status.PENDING);
|
|
||||||
for (Operation operation : pendingDataOperations) {
|
|
||||||
if (operation.getCode().equals(PluginConstants.OperationCodes.POLICY_BUNDLE) &&
|
|
||||||
operation.getId() == status.getCommandReference()) {
|
|
||||||
operation.setStatus(Operation.Status.COMPLETED);
|
|
||||||
}
|
|
||||||
if (operation.getCode().equals(PluginConstants.OperationCodes.MONITOR) &&
|
|
||||||
operation.getId() == status.getCommandReference()) {
|
|
||||||
operation.setStatus(Operation.Status.COMPLETED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
operationUtils.updateOperations(syncmlDocument.getHeader().getSource().getLocURI(),
|
|
||||||
pendingDataOperations);
|
|
||||||
} else {
|
|
||||||
pendingDataOperations = WindowsAPIUtils.getDeviceManagementService()
|
|
||||||
.getOperationsByDeviceAndStatus(deviceIdentifier, Operation.Status.PENDING);
|
|
||||||
for (Operation operation : pendingDataOperations) {
|
|
||||||
|
|
||||||
if (operation.getCode().equals(PluginConstants.OperationCodes.POLICY_BUNDLE) &&
|
|
||||||
operation.getId() == status.getCommandReference()) {
|
|
||||||
operation.setStatus(Operation.Status.ERROR);
|
|
||||||
}
|
|
||||||
if (operation.getCode().equals(PluginConstants.OperationCodes.MONITOR) &&
|
|
||||||
operation.getId() == status.getCommandReference()) {
|
|
||||||
operation.setStatus(Operation.Status.ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
operationUtils.updateOperations(syncmlDocument.getHeader().getSource().getLocURI(),
|
|
||||||
pendingDataOperations);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate status of the features that have been activated on the device.
|
|
||||||
*
|
|
||||||
* @param syncmlDocument syncmlDocument object pasrsed from the syncml engine.
|
|
||||||
* @return device statuses for the activated features
|
|
||||||
* @throws NotificationManagementException
|
|
||||||
*/
|
|
||||||
public List<Profile> generateDeviceOperationStatusObject(SyncmlDocument syncmlDocument) throws
|
|
||||||
NotificationManagementException, WindowsOperationException {
|
|
||||||
|
|
||||||
DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(
|
|
||||||
syncmlDocument.getHeader().getSource().getLocURI());
|
|
||||||
String lockUri = null;
|
|
||||||
Results result = syncmlDocument.getBody().getResults();
|
|
||||||
|
|
||||||
List<Profile> profiles = new ArrayList<>();
|
|
||||||
if (result != null) {
|
|
||||||
List<Item> results = result.getItem();
|
|
||||||
for (OperationCode.Info info : OperationCode.Info.values()) {
|
|
||||||
if (PluginConstants.OperationCodes.PIN_CODE.equals(info
|
|
||||||
.name())) {
|
|
||||||
lockUri = info.getCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (Item item : results) {
|
|
||||||
for (OperationCode.Info info : OperationCode.Info.values()) {
|
|
||||||
if (item.getSource().getLocURI().equals(info.getCode()) && info.name().equals(
|
|
||||||
PluginConstants.OperationCodes.CAMERA_STATUS)) {
|
|
||||||
Profile cameraProfile = new Profile();
|
|
||||||
cameraProfile.setFeatureCode(PluginConstants.OperationCodes.CAMERA);
|
|
||||||
cameraProfile.setData(item.getData());
|
|
||||||
if (item.getData().equals(PluginConstants.SyncML.SYNCML_DATA_ONE)) {
|
|
||||||
cameraProfile.setEnable(true);
|
|
||||||
} else {
|
|
||||||
cameraProfile.setEnable(false);
|
|
||||||
}
|
|
||||||
profiles.add(cameraProfile);
|
|
||||||
}
|
|
||||||
if (item.getSource().getLocURI().equals(info.getCode()) && info.name().equals(
|
|
||||||
PluginConstants.OperationCodes.ENCRYPT_STORAGE_STATUS)) {
|
|
||||||
Profile encryptStorage = new Profile();
|
|
||||||
encryptStorage.setFeatureCode(PluginConstants.OperationCodes.ENCRYPT_STORAGE);
|
|
||||||
encryptStorage.setData(item.getData());
|
|
||||||
if (item.getData().equals(PluginConstants.SyncML.SYNCML_DATA_ONE)) {
|
|
||||||
encryptStorage.setEnable(true);
|
|
||||||
} else {
|
|
||||||
encryptStorage.setEnable(false);
|
|
||||||
}
|
|
||||||
profiles.add(encryptStorage);
|
|
||||||
}
|
|
||||||
if (item.getSource().getLocURI().equals(info.getCode()) && info.name().equals(
|
|
||||||
PluginConstants.OperationCodes.DEVICE_PASSWORD_STATUS)) {
|
|
||||||
Profile encryptStorage = new Profile();
|
|
||||||
encryptStorage.setFeatureCode(PluginConstants.OperationCodes.PASSCODE_POLICY);
|
|
||||||
encryptStorage.setData(item.getData());
|
|
||||||
if (item.getData().equals(PluginConstants.SyncML.SYNCML_DATA_ZERO)) {
|
|
||||||
encryptStorage.setEnable(true);
|
|
||||||
} else {
|
|
||||||
encryptStorage.setEnable(false);
|
|
||||||
}
|
|
||||||
profiles.add(encryptStorage);
|
|
||||||
}
|
|
||||||
if (!item.getData().isEmpty() && item.getSource().getLocURI().equals(lockUri)) {
|
|
||||||
String pinValue = item.getData();
|
|
||||||
NotificationManagementService nmService = WindowsAPIUtils.getNotificationManagementService();
|
|
||||||
Notification notification = new Notification();
|
|
||||||
notification.setDescription("Auto generated DevicePin : " + pinValue);
|
|
||||||
notification.setOperationId(result.getCommandReference());
|
|
||||||
notification.setStatus(String.valueOf(Notification.Status.NEW));
|
|
||||||
try {
|
|
||||||
nmService.addNotification(deviceIdentifier, notification);
|
|
||||||
} catch (NotificationManagementException e) {
|
|
||||||
String msg = "Failure Occurred in getting notification service.";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsOperationException(msg, e);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return profiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate Compliance Features
|
|
||||||
*
|
|
||||||
* @param syncmlDocument syncmlDocument object parsed from the syncml engine.
|
|
||||||
* @throws NotificationManagementException
|
|
||||||
* @throws FeatureManagementException
|
|
||||||
* @throws PolicyComplianceException
|
|
||||||
*/
|
|
||||||
public void generateComplianceFeatureStatus(SyncmlDocument syncmlDocument) throws NotificationManagementException,
|
|
||||||
FeatureManagementException, PolicyComplianceException, WindowsDeviceEnrolmentException,
|
|
||||||
WindowsOperationException {
|
|
||||||
List<Profile> profiles = generateDeviceOperationStatusObject(syncmlDocument);
|
|
||||||
DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(
|
|
||||||
syncmlDocument.getHeader().getSource().getLocURI());
|
|
||||||
boolean isCompliance = false;
|
|
||||||
if (profiles.size() != Constants.EMPTY) {
|
|
||||||
try {
|
|
||||||
List<ProfileFeature> profileFeatures = WindowsAPIUtils.getPolicyManagerService().getEffectiveFeatures(
|
|
||||||
deviceIdentifier);
|
|
||||||
List<ComplianceFeature> complianceFeatures = new ArrayList<>();
|
|
||||||
for (ProfileFeature activeFeature : profileFeatures) {
|
|
||||||
JSONObject policyContent = new JSONObject(activeFeature.getContent().toString());
|
|
||||||
|
|
||||||
for (Profile deviceFeature : profiles) {
|
|
||||||
if (deviceFeature.getFeatureCode().equals(activeFeature.getFeatureCode()) &&
|
|
||||||
deviceFeature.getFeatureCode().equals(PluginConstants.OperationCodes.CAMERA)) {
|
|
||||||
if (policyContent.getBoolean(PluginConstants.PolicyConfigProperties.
|
|
||||||
POLICY_ENABLE) == (deviceFeature.isEnable())) {
|
|
||||||
isCompliance = true;
|
|
||||||
deviceFeature.setCompliance(isCompliance);
|
|
||||||
} else {
|
|
||||||
deviceFeature.setCompliance(isCompliance);
|
|
||||||
}
|
|
||||||
ComplianceFeature complianceFeature = setComplianceFeatures(activeFeature, deviceFeature);
|
|
||||||
complianceFeatures.add(complianceFeature);
|
|
||||||
}
|
|
||||||
if (deviceFeature.getFeatureCode().equals(activeFeature.getFeatureCode()) &&
|
|
||||||
deviceFeature.getFeatureCode().equals(PluginConstants.OperationCodes.
|
|
||||||
ENCRYPT_STORAGE)) {
|
|
||||||
if (policyContent.getBoolean(PluginConstants.PolicyConfigProperties.
|
|
||||||
ENCRYPTED_ENABLE) == (deviceFeature.isEnable())) {
|
|
||||||
isCompliance = true;
|
|
||||||
deviceFeature.setCompliance(isCompliance);
|
|
||||||
} else {
|
|
||||||
deviceFeature.setCompliance(isCompliance);
|
|
||||||
}
|
|
||||||
ComplianceFeature complianceFeature = setComplianceFeatures(activeFeature, deviceFeature);
|
|
||||||
complianceFeatures.add(complianceFeature);
|
|
||||||
}
|
|
||||||
if (deviceFeature.getFeatureCode().equals(activeFeature.getFeatureCode()) &&
|
|
||||||
deviceFeature.getFeatureCode().equals(PluginConstants.OperationCodes.
|
|
||||||
PASSCODE_POLICY)) {
|
|
||||||
if (policyContent.getBoolean(PluginConstants.PolicyConfigProperties.
|
|
||||||
ENABLE_PASSWORD) == (deviceFeature.isEnable())) {
|
|
||||||
isCompliance = true;
|
|
||||||
deviceFeature.setCompliance(isCompliance);
|
|
||||||
} else {
|
|
||||||
deviceFeature.setCompliance(isCompliance);
|
|
||||||
}
|
|
||||||
ComplianceFeature complianceFeature = setComplianceFeatures(activeFeature, deviceFeature);
|
|
||||||
complianceFeatures.add(complianceFeature);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
WindowsAPIUtils.getPolicyManagerService().checkPolicyCompliance(deviceIdentifier, complianceFeatures);
|
|
||||||
} catch (org.wso2.carbon.policy.mgt.common.FeatureManagementException e) {
|
|
||||||
String msg = "Error occurred while getting effective policy.";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new FeatureManagementException(msg, e);
|
|
||||||
} catch (JSONException e) {
|
|
||||||
String msg = "Error occurred while parsing json object.";
|
|
||||||
log.error(msg);
|
|
||||||
throw new WindowsDeviceEnrolmentException(msg, e);
|
|
||||||
} catch (PolicyComplianceException e) {
|
|
||||||
String msg = "Error occurred while setting up policy compliance.";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new PolicyComplianceException(msg, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
@ -26,11 +26,11 @@ import java.security.MessageDigest;
|
|||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for generate security token for client and server.
|
* Generate security token to client and server.
|
||||||
*/
|
*/
|
||||||
public class SyncmlCredentials {
|
public class SyncmlCredentialUtil {
|
||||||
|
|
||||||
public String generateCredData(String nextNonce) throws SyncmlMessageFormatException {
|
public static String generateCredData(String nextNonce) throws SyncmlMessageFormatException {
|
||||||
MessageDigest digest;
|
MessageDigest digest;
|
||||||
String usrPwdNonceHash;
|
String usrPwdNonceHash;
|
||||||
String nonce;
|
String nonce;
|
||||||
@ -42,14 +42,15 @@ public class SyncmlCredentials {
|
|||||||
String usrPwdNonce = usrPwdHash + ":" + nonce;
|
String usrPwdNonce = usrPwdHash + ":" + nonce;
|
||||||
usrPwdNonceHash = Base64.encodeBase64String(digest.digest(usrPwdNonce.getBytes(Constants.UTF_8)));
|
usrPwdNonceHash = Base64.encodeBase64String(digest.digest(usrPwdNonce.getBytes(Constants.UTF_8)));
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
throw new SyncmlMessageFormatException("Problem occurred in encoding credentials data.", e);
|
throw new SyncmlMessageFormatException("Problem occurred while decoding credentials data.", e);
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
throw new SyncmlMessageFormatException("Problem occurred in generating password hash.", e);
|
throw new SyncmlMessageFormatException("Application environment does not have an implementation " +
|
||||||
|
"available/configured for the requested algorithm", e);
|
||||||
}
|
}
|
||||||
return usrPwdNonceHash;
|
return usrPwdNonceHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String generateRST(String username, String password) throws SyncmlMessageFormatException {
|
public static String generateRST(String username, String password) throws SyncmlMessageFormatException {
|
||||||
MessageDigest digest;
|
MessageDigest digest;
|
||||||
String usrPwdNonceHash;
|
String usrPwdNonceHash;
|
||||||
String nonce;
|
String nonce;
|
||||||
@ -61,9 +62,10 @@ public class SyncmlCredentials {
|
|||||||
String usrPwdNonce = usrPwdHash + ":" + nonce;
|
String usrPwdNonce = usrPwdHash + ":" + nonce;
|
||||||
usrPwdNonceHash = Base64.encodeBase64String(digest.digest(usrPwdNonce.getBytes(Constants.UTF_8)));
|
usrPwdNonceHash = Base64.encodeBase64String(digest.digest(usrPwdNonce.getBytes(Constants.UTF_8)));
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
throw new SyncmlMessageFormatException("Problem occurred in encoding credentials data.", e);
|
throw new SyncmlMessageFormatException("Problem occurred while decoding credentials data.", e);
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
throw new SyncmlMessageFormatException("Problem occurred in generating password hash.", e);
|
throw new SyncmlMessageFormatException("Application environment does not have an implementation " +
|
||||||
|
"available/configured for the requested algorithm", e);
|
||||||
}
|
}
|
||||||
return usrPwdNonceHash;
|
return usrPwdNonceHash;
|
||||||
}
|
}
|
||||||
@ -1,25 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.operations.util;
|
package org.wso2.carbon.mdm.mobileservices.windows.operations.util;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.SyncmlOperationException;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.SyncmlOperationException;
|
||||||
@ -36,13 +34,11 @@ import javax.xml.transform.stream.StreamResult;
|
|||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the response syncml xml file that should be sent to the phone.
|
* Generates the response syncml xml file that should be sent to the Device.
|
||||||
*/
|
*/
|
||||||
public class SyncmlGenerator {
|
public class SyncmlGenerator {
|
||||||
|
|
||||||
private static Log log = LogFactory.getLog(SyncmlGenerator.class);
|
public static String generatePayload(SyncmlDocument syncmlDocument) throws SyncmlOperationException {
|
||||||
|
|
||||||
public String generatePayload(SyncmlDocument syncmlDocument) throws SyncmlOperationException {
|
|
||||||
Document doc = generateDocument();
|
Document doc = generateDocument();
|
||||||
Element rootElement = createRootElement(doc);
|
Element rootElement = createRootElement(doc);
|
||||||
SyncmlHeader header = syncmlDocument.getHeader();
|
SyncmlHeader header = syncmlDocument.getHeader();
|
||||||
@ -58,9 +54,7 @@ public class SyncmlGenerator {
|
|||||||
try {
|
try {
|
||||||
docBuilder = documentFactory.newDocumentBuilder();
|
docBuilder = documentFactory.newDocumentBuilder();
|
||||||
} catch (ParserConfigurationException e) {
|
} catch (ParserConfigurationException e) {
|
||||||
String message = "Error while generating a new document of syncml";
|
throw new SyncmlOperationException("Error occurred while generating a new document of syncml", e);
|
||||||
log.error(message, e);
|
|
||||||
throw new SyncmlOperationException(message, e);
|
|
||||||
}
|
}
|
||||||
return docBuilder.newDocument();
|
return docBuilder.newDocument();
|
||||||
}
|
}
|
||||||
@ -72,16 +66,14 @@ public class SyncmlGenerator {
|
|||||||
return rootElement;
|
return rootElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String transformDocument(Document document) throws SyncmlOperationException {
|
private static String transformDocument(Document document) throws SyncmlOperationException {
|
||||||
DOMSource domSource = new DOMSource(document);
|
DOMSource domSource = new DOMSource(document);
|
||||||
TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
||||||
Transformer transformer;
|
Transformer transformer;
|
||||||
try {
|
try {
|
||||||
transformer = transformerFactory.newTransformer();
|
transformer = transformerFactory.newTransformer();
|
||||||
} catch (TransformerConfigurationException e) {
|
} catch (TransformerConfigurationException e) {
|
||||||
String message = "Error while retrieving a new transformer";
|
throw new SyncmlOperationException("Error occurred while retrieving a new transformer", e);
|
||||||
log.error(message, e);
|
|
||||||
throw new SyncmlOperationException(message, e);
|
|
||||||
}
|
}
|
||||||
transformer.setOutputProperty(OutputKeys.ENCODING, Constants.UTF_8);
|
transformer.setOutputProperty(OutputKeys.ENCODING, Constants.UTF_8);
|
||||||
transformer.setOutputProperty(OutputKeys.INDENT, Constants.YES);
|
transformer.setOutputProperty(OutputKeys.INDENT, Constants.YES);
|
||||||
@ -91,9 +83,7 @@ public class SyncmlGenerator {
|
|||||||
try {
|
try {
|
||||||
transformer.transform(domSource, streamResult);
|
transformer.transform(domSource, streamResult);
|
||||||
} catch (TransformerException e) {
|
} catch (TransformerException e) {
|
||||||
String message = "Error while transforming document to a string";
|
throw new SyncmlOperationException("Error occurred while transforming document to a string", e);
|
||||||
log.error(message, e);
|
|
||||||
throw new SyncmlOperationException(message, e);
|
|
||||||
}
|
}
|
||||||
return stringWriter.toString();
|
return stringWriter.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
@ -22,11 +22,9 @@ import org.w3c.dom.Document;
|
|||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.SyncmlMessageFormatException;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.operations.*;
|
import org.wso2.carbon.mdm.mobileservices.windows.operations.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.IllegalFormatCodePointException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -80,15 +78,17 @@ public class SyncmlParser {
|
|||||||
* @param syncmlPayload - Received SyncML XML payload
|
* @param syncmlPayload - Received SyncML XML payload
|
||||||
* @return - SyncmlDocument object generated from the received payload
|
* @return - SyncmlDocument object generated from the received payload
|
||||||
*/
|
*/
|
||||||
public static SyncmlDocument parseSyncmlPayload(Document syncmlPayload) throws SyncmlMessageFormatException {
|
public static SyncmlDocument parseSyncmlPayload(Document syncmlPayload) {
|
||||||
SyncmlDocument syncmlDocument = new SyncmlDocument();
|
SyncmlDocument syncmlDocument = new SyncmlDocument();
|
||||||
if (syncmlPayload.getElementsByTagName(SYNC_HEADER) == null) {
|
if (syncmlPayload.getElementsByTagName(SYNC_HEADER) == null) {
|
||||||
throw new SyncmlMessageFormatException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
NodeList syncHeaderList = syncmlPayload.getElementsByTagName(SYNC_HEADER);
|
NodeList syncHeaderList = syncmlPayload.getElementsByTagName(SYNC_HEADER);
|
||||||
Node syncHeader = syncHeaderList.item(0);
|
Node syncHeader = syncHeaderList.item(0);
|
||||||
SyncmlHeader header = generateSyncmlHeader(syncHeader);
|
SyncmlHeader header = generateSyncmlHeader(syncHeader);
|
||||||
|
if (syncmlPayload.getElementsByTagName(SYNC_BODY) == null) {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
NodeList syncBodyList = syncmlPayload.getElementsByTagName(SYNC_BODY);
|
NodeList syncBodyList = syncmlPayload.getElementsByTagName(SYNC_BODY);
|
||||||
Node syncBody = syncBodyList.item(0);
|
Node syncBody = syncBodyList.item(0);
|
||||||
SyncmlBody body = generateSyncmlBody(syncBody);
|
SyncmlBody body = generateSyncmlBody(syncBody);
|
||||||
@ -108,9 +108,9 @@ public class SyncmlParser {
|
|||||||
|
|
||||||
String sessionID = null;
|
String sessionID = null;
|
||||||
String messageID = null;
|
String messageID = null;
|
||||||
Target target = null;
|
TargetTag target = null;
|
||||||
Source source = null;
|
SourceTag source = null;
|
||||||
Credential credential = null;
|
CredentialTag credential = null;
|
||||||
SyncmlHeader header = new SyncmlHeader();
|
SyncmlHeader header = new SyncmlHeader();
|
||||||
|
|
||||||
NodeList headerElements = syncHeader.getChildNodes();
|
NodeList headerElements = syncHeader.getChildNodes();
|
||||||
@ -122,31 +122,31 @@ public class SyncmlParser {
|
|||||||
|
|
||||||
if (SyncMLHeaderParameter.MSG_ID.getValue().equals(nodeName)) {
|
if (SyncMLHeaderParameter.MSG_ID.getValue().equals(nodeName)) {
|
||||||
if (node.getTextContent().trim() == null) {
|
if (node.getTextContent().trim() == null) {
|
||||||
throw new IllegalFormatCodePointException(2);
|
throw new IllegalStateException();
|
||||||
} else {
|
} else {
|
||||||
messageID = node.getTextContent().trim();
|
messageID = node.getTextContent().trim();
|
||||||
}
|
}
|
||||||
} else if (SyncMLHeaderParameter.SESSION_ID.getValue().equals(nodeName)) {
|
} else if (SyncMLHeaderParameter.SESSION_ID.getValue().equals(nodeName)) {
|
||||||
if (node.getTextContent().trim() == null) {
|
if (node.getTextContent().trim() == null) {
|
||||||
throw new IllegalFormatCodePointException(2);
|
throw new IllegalStateException();
|
||||||
} else {
|
} else {
|
||||||
sessionID = node.getTextContent().trim();
|
sessionID = node.getTextContent().trim();
|
||||||
}
|
}
|
||||||
} else if (SyncMLHeaderParameter.TARGET.getValue().equals(nodeName)) {
|
} else if (SyncMLHeaderParameter.TARGET.getValue().equals(nodeName)) {
|
||||||
if (node.getTextContent().trim() == null) {
|
if (node.getTextContent().trim() == null) {
|
||||||
throw new IllegalFormatCodePointException(2);
|
throw new IllegalStateException();
|
||||||
} else {
|
} else {
|
||||||
target = generateTarget(node);
|
target = generateTarget(node);
|
||||||
}
|
}
|
||||||
} else if (SyncMLHeaderParameter.SOURCE.getValue().equals(nodeName)) {
|
} else if (SyncMLHeaderParameter.SOURCE.getValue().equals(nodeName)) {
|
||||||
if (node.getTextContent().trim() == null) {
|
if (node.getTextContent().trim() == null) {
|
||||||
throw new IllegalFormatCodePointException(2);
|
throw new IllegalStateException();
|
||||||
} else {
|
} else {
|
||||||
source = generateSource(node);
|
source = generateSource(node);
|
||||||
}
|
}
|
||||||
} else if (SyncMLHeaderParameter.CRED.getValue().equals(nodeName)) {
|
} else if (SyncMLHeaderParameter.CRED.getValue().equals(nodeName)) {
|
||||||
if (node.getTextContent().trim() == null) {
|
if (node.getTextContent().trim() == null) {
|
||||||
throw new IllegalFormatCodePointException(2);
|
throw new IllegalStateException();
|
||||||
} else {
|
} else {
|
||||||
credential = generateCredential(node);
|
credential = generateCredential(node);
|
||||||
}
|
}
|
||||||
@ -170,10 +170,10 @@ public class SyncmlParser {
|
|||||||
*/
|
*/
|
||||||
private static SyncmlBody generateSyncmlBody(Node syncBody) {
|
private static SyncmlBody generateSyncmlBody(Node syncBody) {
|
||||||
|
|
||||||
Alert alert = null;
|
AlertTag alert = null;
|
||||||
Replace replace = null;
|
ReplaceTag replace = null;
|
||||||
Results results = null;
|
ResultsTag results = null;
|
||||||
List<Status> status = new ArrayList<>();
|
List<StatusTag> status = new ArrayList<>();
|
||||||
NodeList bodyElements = syncBody.getChildNodes();
|
NodeList bodyElements = syncBody.getChildNodes();
|
||||||
|
|
||||||
for (int i = 0; i < bodyElements.getLength(); i++) {
|
for (int i = 0; i < bodyElements.getLength(); i++) {
|
||||||
@ -207,9 +207,9 @@ public class SyncmlParser {
|
|||||||
* @param node - XML node which represents Source
|
* @param node - XML node which represents Source
|
||||||
* @return - Source object
|
* @return - Source object
|
||||||
*/
|
*/
|
||||||
private static Source generateSource(Node node) {
|
private static SourceTag generateSource(Node node) {
|
||||||
|
|
||||||
Source source = new Source();
|
SourceTag source = new SourceTag();
|
||||||
Node sourceURIItem = node.getChildNodes().item(0);
|
Node sourceURIItem = node.getChildNodes().item(0);
|
||||||
Node sourceNameItem = node.getChildNodes().item(1);
|
Node sourceNameItem = node.getChildNodes().item(1);
|
||||||
String sourceURI = null;
|
String sourceURI = null;
|
||||||
@ -232,9 +232,9 @@ public class SyncmlParser {
|
|||||||
* @param node - XML node which represents Target
|
* @param node - XML node which represents Target
|
||||||
* @return - Target object
|
* @return - Target object
|
||||||
*/
|
*/
|
||||||
private static Target generateTarget(Node node) {
|
private static TargetTag generateTarget(Node node) {
|
||||||
|
|
||||||
Target target = new Target();
|
TargetTag target = new TargetTag();
|
||||||
Node targetURIItem = node.getChildNodes().item(0);
|
Node targetURIItem = node.getChildNodes().item(0);
|
||||||
Node targetNameItem = node.getChildNodes().item(1);
|
Node targetNameItem = node.getChildNodes().item(1);
|
||||||
String targetURI = null;
|
String targetURI = null;
|
||||||
@ -257,10 +257,10 @@ public class SyncmlParser {
|
|||||||
* @param node - XML node which represents Results
|
* @param node - XML node which represents Results
|
||||||
* @return - Results object
|
* @return - Results object
|
||||||
*/
|
*/
|
||||||
private static Results generateResults(Node node) {
|
private static ResultsTag generateResults(Node node) {
|
||||||
|
|
||||||
Results results = new Results();
|
ResultsTag results = new ResultsTag();
|
||||||
List<Item> item = new ArrayList<>();
|
List<ItemTag> item = new ArrayList<>();
|
||||||
|
|
||||||
if (node.getNodeType() == Node.ELEMENT_NODE) {
|
if (node.getNodeType() == Node.ELEMENT_NODE) {
|
||||||
|
|
||||||
@ -298,9 +298,9 @@ public class SyncmlParser {
|
|||||||
* @param node - XML node which represents Status
|
* @param node - XML node which represents Status
|
||||||
* @return - Status object
|
* @return - Status object
|
||||||
*/
|
*/
|
||||||
private static Status generateStatus(Node node) {
|
private static StatusTag generateStatus(Node node) {
|
||||||
|
|
||||||
Status status = new Status();
|
StatusTag status = new StatusTag();
|
||||||
for (int x = 0; x < node.getChildNodes().getLength(); x++) {
|
for (int x = 0; x < node.getChildNodes().getLength(); x++) {
|
||||||
String nodeName = node.getChildNodes().item(x).getNodeName();
|
String nodeName = node.getChildNodes().item(x).getNodeName();
|
||||||
switch (nodeName) {
|
switch (nodeName) {
|
||||||
@ -321,17 +321,17 @@ public class SyncmlParser {
|
|||||||
status.setCommand(command);
|
status.setCommand(command);
|
||||||
break;
|
break;
|
||||||
case PluginConstants.SyncML.SYNCML_CHAL:
|
case PluginConstants.SyncML.SYNCML_CHAL:
|
||||||
NodeList chalNodes = node.getChildNodes().item(x).getChildNodes();
|
NodeList childNodes = node.getChildNodes().item(x).getChildNodes();
|
||||||
MetaTag meta = new MetaTag();
|
MetaTag meta = new MetaTag();
|
||||||
ChallengeTag chal = new ChallengeTag();
|
ChallengeTag challengeTag = new ChallengeTag();
|
||||||
String format = chalNodes.item(0).getFirstChild().getTextContent();
|
String format = childNodes.item(0).getFirstChild().getTextContent();
|
||||||
meta.setFormat(format);
|
meta.setFormat(format);
|
||||||
String type = chalNodes.item(0).getFirstChild().getNextSibling().getTextContent();
|
String type = childNodes.item(0).getFirstChild().getNextSibling().getTextContent();
|
||||||
meta.setType(type);
|
meta.setType(type);
|
||||||
String nonce = chalNodes.item(0).getFirstChild().getNextSibling().getNextSibling().getTextContent();
|
String nonce = childNodes.item(0).getFirstChild().getNextSibling().getNextSibling().getTextContent();
|
||||||
meta.setNextNonce(nonce);
|
meta.setNextNonce(nonce);
|
||||||
chal.setMeta(meta);
|
challengeTag.setMeta(meta);
|
||||||
status.setChallenge(chal);
|
status.setChallenge(challengeTag);
|
||||||
break;
|
break;
|
||||||
case PluginConstants.SyncML.SYNCML_DATA:
|
case PluginConstants.SyncML.SYNCML_DATA:
|
||||||
String data = node.getChildNodes().item(x).getTextContent().trim();
|
String data = node.getChildNodes().item(x).getTextContent().trim();
|
||||||
@ -352,11 +352,11 @@ public class SyncmlParser {
|
|||||||
* @param node - XML node which represents Replace
|
* @param node - XML node which represents Replace
|
||||||
* @return - Replace object
|
* @return - Replace object
|
||||||
*/
|
*/
|
||||||
private static Replace generateReplace(Node node) {
|
private static ReplaceTag generateReplace(Node node) {
|
||||||
|
|
||||||
Replace replace = new Replace();
|
ReplaceTag replace = new ReplaceTag();
|
||||||
String commandId = node.getChildNodes().item(0).getTextContent().trim();
|
String commandId = node.getChildNodes().item(0).getTextContent().trim();
|
||||||
List<Item> items = new ArrayList<>();
|
List<ItemTag> items = new ArrayList<>();
|
||||||
for (int i = 0; i < node.getChildNodes().getLength() - 1; i++) {
|
for (int i = 0; i < node.getChildNodes().getLength() - 1; i++) {
|
||||||
items.add(generateItem(node.getChildNodes().item(i + 1)));
|
items.add(generateItem(node.getChildNodes().item(i + 1)));
|
||||||
}
|
}
|
||||||
@ -371,8 +371,8 @@ public class SyncmlParser {
|
|||||||
* @param node - XML node which represents Alert
|
* @param node - XML node which represents Alert
|
||||||
* @return - Alert object
|
* @return - Alert object
|
||||||
*/
|
*/
|
||||||
private static Alert generateAlert(Node node) {
|
private static AlertTag generateAlert(Node node) {
|
||||||
Alert alert = new Alert();
|
AlertTag alert = new AlertTag();
|
||||||
String commandID = node.getChildNodes().item(0).getTextContent().trim();
|
String commandID = node.getChildNodes().item(0).getTextContent().trim();
|
||||||
String data = node.getChildNodes().item(1).getTextContent().trim();
|
String data = node.getChildNodes().item(1).getTextContent().trim();
|
||||||
alert.setCommandId(Integer.valueOf(commandID));
|
alert.setCommandId(Integer.valueOf(commandID));
|
||||||
@ -386,39 +386,41 @@ public class SyncmlParser {
|
|||||||
* @param node - XML node which represents Item
|
* @param node - XML node which represents Item
|
||||||
* @return - Item object
|
* @return - Item object
|
||||||
*/
|
*/
|
||||||
private static Item generateItem(Node node) {
|
private static ItemTag generateItem(Node node) {
|
||||||
Item item = new Item();
|
ItemTag item = new ItemTag();
|
||||||
Source source = new Source();
|
SourceTag source = new SourceTag();
|
||||||
String data;
|
String data;
|
||||||
String nodeName;
|
String nodeName;
|
||||||
String childNodeName;
|
String childNodeName;
|
||||||
String locUri;
|
String locUri;
|
||||||
for (int x = 0; x < node.getChildNodes().getLength(); x++) {
|
for (int x = 0; x < node.getChildNodes().getLength(); x++) {
|
||||||
if (node.getChildNodes().item(x).getNodeName() != null) {
|
Node itemNode;
|
||||||
|
itemNode = node.getChildNodes().item(x);
|
||||||
|
if (itemNode.getNodeName() != null) {
|
||||||
nodeName = node.getChildNodes().item(x).getNodeName();
|
nodeName = node.getChildNodes().item(x).getNodeName();
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalFormatCodePointException(2);
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
if (nodeName == PluginConstants.SyncML.SYNCML_SOURCE) {
|
if (PluginConstants.SyncML.SYNCML_SOURCE.equals(nodeName)) {
|
||||||
if (node.getChildNodes().item(x).getChildNodes().item(x).getNodeName() != null) {
|
if (itemNode.getChildNodes().item(x).getNodeName() != null) {
|
||||||
childNodeName = node.getChildNodes().item(x).getChildNodes().item(x).getNodeName();
|
childNodeName = itemNode.getChildNodes().item(x).getNodeName();
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalFormatCodePointException(2);
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
if (childNodeName == PluginConstants.SyncML.SYNCML_LOCATION_URI) {
|
if ((PluginConstants.SyncML.SYNCML_LOCATION_URI.equals(childNodeName))) {
|
||||||
if (node.getChildNodes().item(x).getChildNodes().item(x).getTextContent().trim() != null) {
|
if (itemNode.getChildNodes().item(x).getTextContent().trim() != null) {
|
||||||
locUri = node.getChildNodes().item(x).getChildNodes().item(x).getTextContent().trim();
|
locUri = itemNode.getChildNodes().item(x).getTextContent().trim();
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalFormatCodePointException(2);
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
source.setLocURI(locUri);
|
source.setLocURI(locUri);
|
||||||
item.setSource(source);
|
item.setSource(source);
|
||||||
}
|
}
|
||||||
} else if (nodeName == PluginConstants.SyncML.SYNCML_DATA) {
|
} else if (PluginConstants.SyncML.SYNCML_DATA.equals(nodeName)) {
|
||||||
if (node.getChildNodes().item(x).getTextContent().trim() != null) {
|
if (itemNode.getTextContent().trim() != null) {
|
||||||
data = node.getChildNodes().item(x).getTextContent().trim();
|
data = itemNode.getTextContent().trim();
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalFormatCodePointException(2);
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
item.setData(data);
|
item.setData(data);
|
||||||
}
|
}
|
||||||
@ -432,8 +434,8 @@ public class SyncmlParser {
|
|||||||
* @param node - XML node which represents Credential
|
* @param node - XML node which represents Credential
|
||||||
* @return - Credential object
|
* @return - Credential object
|
||||||
*/
|
*/
|
||||||
private static Credential generateCredential(Node node) {
|
private static CredentialTag generateCredential(Node node) {
|
||||||
Credential credential = new Credential();
|
CredentialTag credential = new CredentialTag();
|
||||||
MetaTag meta = generateMeta(node.getChildNodes().item(0));
|
MetaTag meta = generateMeta(node.getChildNodes().item(0));
|
||||||
String data = node.getChildNodes().item(1).getTextContent().trim();
|
String data = node.getChildNodes().item(1).getTextContent().trim();
|
||||||
credential.setMeta(meta);
|
credential.setMeta(meta);
|
||||||
|
|||||||
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.mdm.mobileservices.windows.operations.util;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.operations.AddTag;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.operations.ItemTag;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.operations.MetaTag;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.operations.TargetTag;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains utility methods which are used while creating Syncml Messages.
|
||||||
|
*/
|
||||||
|
public class TagUtil {
|
||||||
|
/**
|
||||||
|
* Build syncml AddTag for Device response message.
|
||||||
|
*
|
||||||
|
* @param operation Policy operation
|
||||||
|
* @param data Configuration service provider(CSP) data value 1/0
|
||||||
|
* @return Syncml AddTag type object.
|
||||||
|
*/
|
||||||
|
public static AddTag buildAddTag(Operation operation, String data) {
|
||||||
|
TargetTag target = new TargetTag();
|
||||||
|
MetaTag meta = new MetaTag();
|
||||||
|
AddTag add = new AddTag();
|
||||||
|
|
||||||
|
List<ItemTag> itemTags = new ArrayList<>();
|
||||||
|
ItemTag itemTag = new ItemTag();
|
||||||
|
itemTag.setTarget(target);
|
||||||
|
itemTag.setMeta(meta);
|
||||||
|
itemTag.setData(data);
|
||||||
|
itemTags.add(itemTag);
|
||||||
|
add.setCommandId(operation.getId());
|
||||||
|
add.setItems(itemTags);
|
||||||
|
return add;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,27 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.services.adminoperations;
|
package org.wso2.carbon.mdm.mobileservices.windows.services.adminoperations;
|
||||||
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiResponse;
|
|
||||||
import io.swagger.annotations.ApiResponses;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException;
|
||||||
|
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
@ -32,8 +28,6 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* Interface for Admin operations persisting. This interface accepts operations added via UI.
|
* Interface for Admin operations persisting. This interface accepts operations added via UI.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Api(value = "Operations", description = "Windows Device Management REST-API implementation.")
|
|
||||||
@Path("/operation")
|
@Path("/operation")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@ -42,72 +36,22 @@ public interface Operations {
|
|||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("/devicelock")
|
@Path("/devicelock")
|
||||||
@ApiOperation(
|
|
||||||
produces = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Adding a Device Lock on Windows Devices via the REST API",
|
|
||||||
notes = "Adding a Device lock operation to the windows device"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
|
||||||
@ApiResponse(code = 500, message = "Internal Server error")
|
|
||||||
})
|
|
||||||
Response lock(@HeaderParam("Accept") String headerParam, List<String> deviceids) throws WindowsDeviceEnrolmentException;
|
Response lock(@HeaderParam("Accept") String headerParam, List<String> deviceids) throws WindowsDeviceEnrolmentException;
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("/devicedisenroll")
|
@Path("/devicedisenroll")
|
||||||
@ApiOperation(
|
|
||||||
produces = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Disenrolling Windows Devices via the REST API",
|
|
||||||
notes = "Enforcing Disenrolling operation to the windows device"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
|
||||||
@ApiResponse(code = 500, message = "Internal Server error")
|
|
||||||
})
|
|
||||||
Response disenroll(@HeaderParam("Accept") String headerParam, List<String> deviceids) throws WindowsDeviceEnrolmentException;
|
Response disenroll(@HeaderParam("Accept") String headerParam, List<String> deviceids) throws WindowsDeviceEnrolmentException;
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("/devicewipe")
|
@Path("/devicewipe")
|
||||||
@ApiOperation(
|
|
||||||
produces = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Wiping Information off Windows Devices via the REST API",
|
|
||||||
notes = "Enforce wipe operation to the windows device"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
|
||||||
@ApiResponse(code = 500, message = "Internal Server error")
|
|
||||||
})
|
|
||||||
Response wipe(@HeaderParam("Accept") String headerParam, List<String> deviceids) throws WindowsDeviceEnrolmentException;
|
Response wipe(@HeaderParam("Accept") String headerParam, List<String> deviceids) throws WindowsDeviceEnrolmentException;
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("/devicering")
|
@Path("/devicering")
|
||||||
@ApiOperation(
|
|
||||||
produces = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Ringing Windows Devices via the Rest API",
|
|
||||||
notes = "Adding a Device ring operation to the windows device."
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
|
||||||
@ApiResponse(code = 500, message = "Internal Server error")
|
|
||||||
})
|
|
||||||
Response ring(@HeaderParam("Accept") String headerParam, List<String> deviceids) throws WindowsDeviceEnrolmentException;
|
Response ring(@HeaderParam("Accept") String headerParam, List<String> deviceids) throws WindowsDeviceEnrolmentException;
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("/lockreset")
|
@Path("/lockreset")
|
||||||
@ApiOperation(
|
|
||||||
produces = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Resetting the Lock of Windows Devices via the REST API",
|
|
||||||
notes = "Adding a Device lock re-test operation to the windows device."
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
|
||||||
@ApiResponse(code = 500, message = "Internal Server error")
|
|
||||||
})
|
|
||||||
Response lockReset(@HeaderParam("Accept") String acceptHeader, List<String> deviceids)
|
Response lockReset(@HeaderParam("Accept") String acceptHeader, List<String> deviceids)
|
||||||
throws WindowsDeviceEnrolmentException;
|
throws WindowsDeviceEnrolmentException;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,32 +1,28 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.services.adminoperations.beans;
|
package org.wso2.carbon.mdm.mobileservices.windows.services.adminoperations.beans;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for get device IDS.
|
* Class for get device IDS.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "Device", description = "This class carries all information related to Device.")
|
|
||||||
public class Device {
|
public class Device {
|
||||||
@ApiModelProperty(name = "id", value = "DeviceIDs.", required = true)
|
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
public String getID() {
|
public String getID() {
|
||||||
|
|||||||
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.mdm.mobileservices.windows.services.adminoperations.beans;
|
||||||
|
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.services.syncml.beans.BasicOperation;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class for set basic operations.
|
||||||
|
*/
|
||||||
|
public class OperationRequest {
|
||||||
|
|
||||||
|
private List<Device> deviceList;
|
||||||
|
private BasicOperation basicOperation;
|
||||||
|
|
||||||
|
public BasicOperation getBasicOperation() {
|
||||||
|
return basicOperation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBasicOperation(BasicOperation basicOperation) {
|
||||||
|
this.basicOperation = basicOperation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Device> getDeviceList() {
|
||||||
|
return deviceList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceList(List<Device> deviceList) {
|
||||||
|
this.deviceList = deviceList;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
@ -51,7 +51,7 @@ public class OperationsImpl implements Operations {
|
|||||||
* REST endpoint for the Device Lock operation
|
* REST endpoint for the Device Lock operation
|
||||||
*
|
*
|
||||||
* @param acceptHeader header value of the request POST message.
|
* @param acceptHeader header value of the request POST message.
|
||||||
* @param deviceIDs list of device ids to be add device lockOperationUpdate operation.
|
* @param deviceIDs list of device ids to be add device updateLockOperation operation.
|
||||||
* @return Response object for client.
|
* @return Response object for client.
|
||||||
* @throws WindowsDeviceEnrolmentException
|
* @throws WindowsDeviceEnrolmentException
|
||||||
*/
|
*/
|
||||||
@ -60,7 +60,7 @@ public class OperationsImpl implements Operations {
|
|||||||
public Response lock(@HeaderParam("Accept") String acceptHeader, List<String> deviceIDs)
|
public Response lock(@HeaderParam("Accept") String acceptHeader, List<String> deviceIDs)
|
||||||
throws WindowsDeviceEnrolmentException {
|
throws WindowsDeviceEnrolmentException {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Invoking windows device lockOperationUpdate operation");
|
log.debug("Invoking windows device updateLockOperation operation");
|
||||||
}
|
}
|
||||||
MediaType responseMediaType = WindowsAPIUtils.getResponseMediaType(acceptHeader);
|
MediaType responseMediaType = WindowsAPIUtils.getResponseMediaType(acceptHeader);
|
||||||
Message message = new Message();
|
Message message = new Message();
|
||||||
@ -198,15 +198,15 @@ public class OperationsImpl implements Operations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* REST endpoint for the device lockOperationUpdate reset.
|
* REST endpoint for the device updateLockOperation reset.
|
||||||
* Lock reset have to be done, when device user does not set PIN for the lockOperationUpdate screen.
|
* Lock reset have to be done, when device user does not set PIN for the updateLockOperation screen.
|
||||||
* Admin set lockOperationUpdate operation for the specific device,If the device is in above scenario,
|
* Admin set updateLockOperation operation for the specific device,If the device is in above scenario,
|
||||||
* admin will be notified.since
|
* admin will be notified.since
|
||||||
* admin have to set lockOperationUpdate reset operation to the device so that automatically generate PIN value for the
|
* admin have to set updateLockOperation reset operation to the device so that automatically generate PIN value for the
|
||||||
* lockOperationUpdate screen.
|
* updateLockOperation screen.
|
||||||
*
|
*
|
||||||
* @param acceptHeader POST message header value.
|
* @param acceptHeader POST message header value.
|
||||||
* @param deviceIDs Device ids to be lockOperationUpdate reset.
|
* @param deviceIDs Device ids to be updateLockOperation reset.
|
||||||
* @return Response object for the client.
|
* @return Response object for the client.
|
||||||
* @throws WindowsDeviceEnrolmentException
|
* @throws WindowsDeviceEnrolmentException
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -0,0 +1,112 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//package org.wso2.carbon.mdm.mobileservices.windows.services.adminoperations.util;
|
||||||
|
//
|
||||||
|
//import com.google.gson.Gson;
|
||||||
|
//import org.apache.commons.logging.Log;
|
||||||
|
//import org.apache.commons.logging.LogFactory;
|
||||||
|
//import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
|
//import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
|
//import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
||||||
|
//import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
|
//import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
|
//import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||||
|
//import org.wso2.carbon.device.mgt.core.operation.mgt.ConfigOperation;
|
||||||
|
//import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
|
//import org.wso2.carbon.mdm.mobileservices.windows.common.SyncmlCommandType;
|
||||||
|
//import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException;
|
||||||
|
//import org.wso2.carbon.mdm.mobileservices.windows.services.adminoperations.beans.Device;
|
||||||
|
//import org.wso2.carbon.mdm.mobileservices.windows.services.adminoperations.beans.OperationRequest;
|
||||||
|
//import org.wso2.carbon.mdm.mobileservices.windows.services.syncml.beans.Wifi;
|
||||||
|
//
|
||||||
|
//import java.util.ArrayList;
|
||||||
|
//import java.util.List;
|
||||||
|
//
|
||||||
|
//public class OperationStore {
|
||||||
|
//
|
||||||
|
// private static Log log = LogFactory.getLog(OperationStore.class);
|
||||||
|
//
|
||||||
|
// public static boolean storeOperation(OperationRequest operationRequest, Operation.Type type,
|
||||||
|
// String commandType) throws
|
||||||
|
// WindowsDeviceEnrolmentException {
|
||||||
|
//
|
||||||
|
// List<Device> devices = operationRequest.getDeviceList();
|
||||||
|
// List<DeviceIdentifier> deviceIdentifiers = new ArrayList<DeviceIdentifier>();
|
||||||
|
// DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||||
|
//
|
||||||
|
// Operation operation = transformBasicOperation(operationRequest, type, commandType);
|
||||||
|
//
|
||||||
|
// for (int i = 0; i < devices.size(); i++) {
|
||||||
|
// try {
|
||||||
|
// deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
|
||||||
|
// deviceIdentifier.setId(devices.get(i).getID());
|
||||||
|
// deviceIdentifiers.add(deviceIdentifier);
|
||||||
|
// getDeviceManagementServiceProvider().getDevice(deviceIdentifier);
|
||||||
|
//
|
||||||
|
// } catch (DeviceManagementException e) {
|
||||||
|
// log.error("Cannot validate device ID: " + devices.get(i).getID());
|
||||||
|
// deviceIdentifiers.remove(i);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// try {
|
||||||
|
// getDeviceManagementServiceProvider().addOperation(operation, deviceIdentifiers);
|
||||||
|
// } catch (OperationManagementException e) {
|
||||||
|
// String msg = "Failure occurred while storing command operation.";
|
||||||
|
// log.error(msg);
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private static DeviceManagementProviderService getDeviceManagementServiceProvider() {
|
||||||
|
// DeviceManagementProviderService deviceManager;
|
||||||
|
// PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||||
|
// deviceManager =
|
||||||
|
// (DeviceManagementProviderService) ctx.getOSGiService(DeviceManagementProviderService.class, null);
|
||||||
|
//
|
||||||
|
// if (deviceManager == null) {
|
||||||
|
// String msg = "Device management service is not initialized.";
|
||||||
|
// log.error(msg);
|
||||||
|
// }
|
||||||
|
// return deviceManager;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private static Operation transformBasicOperation(OperationRequest operationRequest, Operation.Type type,
|
||||||
|
// String commandType) throws WindowsDeviceEnrolmentException {
|
||||||
|
//
|
||||||
|
// Operation operation = new Operation();
|
||||||
|
// operation.setCode(commandType);
|
||||||
|
// operation.setType(type);
|
||||||
|
// Gson gson = new Gson();
|
||||||
|
//
|
||||||
|
// if (commandType == SyncmlCommandType.WIFI.getValue()) {
|
||||||
|
//
|
||||||
|
// operation = new ConfigOperation();
|
||||||
|
// operation.setCode(commandType);
|
||||||
|
// operation.setType(type);
|
||||||
|
//
|
||||||
|
// Wifi wifiObject = (Wifi) operationRequest.getBasicOperation();
|
||||||
|
// operation.setPayLoad(gson.toJson(wifiObject));
|
||||||
|
// } else {
|
||||||
|
// // no operation.....
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return operation;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@ -1,27 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.services.authbst;
|
package org.wso2.carbon.mdm.mobileservices.windows.services.authbst;
|
||||||
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiResponse;
|
|
||||||
import io.swagger.annotations.ApiResponses;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.services.authbst.beans.Credentials;
|
import org.wso2.carbon.mdm.mobileservices.windows.services.authbst.beans.Credentials;
|
||||||
|
|
||||||
@ -34,23 +30,11 @@ import javax.ws.rs.core.Response;
|
|||||||
/**
|
/**
|
||||||
* Interface for handling authentication request comes via MDM login page.
|
* Interface for handling authentication request comes via MDM login page.
|
||||||
*/
|
*/
|
||||||
@Api(value = "BSTProvider", description = "Windows Device Management REST-API implementation.")
|
|
||||||
@Path("/bst")
|
@Path("/bst")
|
||||||
public interface BSTProvider {
|
public interface BSTProvider {
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@Path("/authentication")
|
@Path("/authentication")
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Getting Binary security token via the Rest API",
|
|
||||||
notes = "Getting binary security token to call next certificate endpoints.",
|
|
||||||
response = String.class
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
|
||||||
@ApiResponse(code = 500, message = "Internal Server error")
|
|
||||||
})
|
|
||||||
Response getBST(Credentials credentials) throws WindowsDeviceEnrolmentException;
|
Response getBST(Credentials credentials) throws WindowsDeviceEnrolmentException;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,26 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.services.authbst.beans;
|
package org.wso2.carbon.mdm.mobileservices.windows.services.authbst.beans;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
@ -29,28 +26,18 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||||||
/**
|
/**
|
||||||
* This bean class is for credentials coming from wab page at federated authentication step.
|
* This bean class is for credentials coming from wab page at federated authentication step.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "Credentials", description = "This class carries all information related to Credentials.")
|
|
||||||
@XmlRootElement(name = "credentials")
|
@XmlRootElement(name = "credentials")
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class Credentials {
|
public class Credentials {
|
||||||
|
|
||||||
@ApiModelProperty(name = "username", value = "User name", required = true)
|
|
||||||
@XmlElement(required = true, name = "username")
|
@XmlElement(required = true, name = "username")
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
@ApiModelProperty(name = "email", value = "Email Address of the user.", required = true)
|
|
||||||
@XmlElement(required = true, name = "email")
|
@XmlElement(required = true, name = "email")
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
@ApiModelProperty(name = "password", value = "password of the user.", required = true)
|
|
||||||
@XmlElement(required = true, name = "password")
|
@XmlElement(required = true, name = "password")
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
@ApiModelProperty(name = "ownership", value = "ownership of the user.(BYOD/COPE).", required = true)
|
|
||||||
@XmlElement(required = true, name = "ownership")
|
@XmlElement(required = true, name = "ownership")
|
||||||
private String ownership;
|
private String ownership;
|
||||||
|
|
||||||
@ApiModelProperty(name = "usertoken", value = "User Token.", required = true)
|
|
||||||
@XmlElement(required = true, name = "token")
|
@XmlElement(required = true, name = "token")
|
||||||
private String usertoken;
|
private String usertoken;
|
||||||
|
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
@ -19,12 +19,9 @@
|
|||||||
package org.wso2.carbon.mdm.mobileservices.windows.services.authbst.impl;
|
package org.wso2.carbon.mdm.mobileservices.windows.services.authbst.impl;
|
||||||
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.beans.Token;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.beans.Token;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.AuthenticationException;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.AuthenticationException;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException;
|
||||||
@ -43,15 +40,12 @@ import javax.ws.rs.core.Response;
|
|||||||
*/
|
*/
|
||||||
public class BSTProviderImpl implements BSTProvider {
|
public class BSTProviderImpl implements BSTProvider {
|
||||||
|
|
||||||
private static Log log = LogFactory.getLog(BSTProviderImpl.class);
|
|
||||||
private static final String DELIMITER = "@";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method validates the device user, checking passed credentials and returns the corresponding
|
* This method validates the device user, checking passed credentials and returns the corresponding
|
||||||
* binary security token which is used in XCEP and WSTEP stages for authentication.
|
* binary security token which is used in XCEP and WSTEP stages for authentication.
|
||||||
*
|
*
|
||||||
* @param credentials - Credential object passes from the wab page
|
* @param credentials - Credential object passes from the wab page.
|
||||||
* @return - Response with binary security token
|
* @return - Response with binary security token.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Response getBST(Credentials credentials) throws WindowsDeviceEnrolmentException {
|
public Response getBST(Credentials credentials) throws WindowsDeviceEnrolmentException {
|
||||||
@ -68,14 +62,9 @@ public class BSTProviderImpl implements BSTProvider {
|
|||||||
JSONObject tokenContent = new JSONObject();
|
JSONObject tokenContent = new JSONObject();
|
||||||
tokenContent.put("UserToken", userToken);
|
tokenContent.put("UserToken", userToken);
|
||||||
return Response.ok().entity(tokenContent.toString()).build();
|
return Response.ok().entity(tokenContent.toString()).build();
|
||||||
} catch (DeviceManagementException e) {
|
|
||||||
String msg = "Failure occurred in generating challenge token.";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsDeviceEnrolmentException(msg, e);
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
String msg = "Failure occurred in generating challenge token Json.";
|
throw new WindowsDeviceEnrolmentException(
|
||||||
log.error(msg, e);
|
"Failure occurred in generating Json payload for challenge token.", e);
|
||||||
throw new WindowsDeviceEnrolmentException(msg, e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,9 +88,7 @@ public class BSTProviderImpl implements BSTProvider {
|
|||||||
RealmService realmService = (RealmService) ctx.getOSGiService(RealmService.class, null);
|
RealmService realmService = (RealmService) ctx.getOSGiService(RealmService.class, null);
|
||||||
|
|
||||||
if (realmService == null) {
|
if (realmService == null) {
|
||||||
String msg = "RealmService not initialized.";
|
throw new AuthenticationException("RealmService not initialized.");
|
||||||
log.error(msg);
|
|
||||||
throw new AuthenticationException(msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int tenantId;
|
int tenantId;
|
||||||
@ -112,17 +99,13 @@ public class BSTProviderImpl implements BSTProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tenantId == MultitenantConstants.INVALID_TENANT_ID) {
|
if (tenantId == MultitenantConstants.INVALID_TENANT_ID) {
|
||||||
String msg = "Invalid tenant domain " + tenantDomain;
|
throw new AuthenticationException("Invalid tenant domain " + tenantDomain);
|
||||||
log.error(msg);
|
|
||||||
throw new AuthenticationException(msg);
|
|
||||||
}
|
}
|
||||||
UserRealm userRealm = realmService.getTenantUserRealm(tenantId);
|
UserRealm userRealm = realmService.getTenantUserRealm(tenantId);
|
||||||
|
|
||||||
return userRealm.getUserStoreManager().authenticate(username, password);
|
return userRealm.getUserStoreManager().authenticate(username, password);
|
||||||
} catch (UserStoreException e) {
|
} catch (UserStoreException e) {
|
||||||
String msg = "User store is not initialized.";
|
throw new AuthenticationException("User store is not initialized.", e);
|
||||||
log.error(msg, e);
|
|
||||||
throw new AuthenticationException(msg, e);
|
|
||||||
} finally {
|
} finally {
|
||||||
PrivilegedCarbonContext.endTenantFlow();
|
PrivilegedCarbonContext.endTenantFlow();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,34 +1,40 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.services.configurationmgtservice;
|
package org.wso2.carbon.mdm.mobileservices.windows.services.configurationmgtservice;
|
||||||
|
|
||||||
import io.swagger.annotations.Api;
|
import org.apache.commons.logging.Log;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import io.swagger.annotations.ApiResponse;
|
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
||||||
import io.swagger.annotations.ApiResponses;
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
|
||||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
||||||
|
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsConfigurationException;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsConfigurationException;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.util.Message;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.util.Message;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils;
|
||||||
|
|
||||||
import javax.jws.WebService;
|
import javax.jws.WebService;
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.Response;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Windows Platform Configuration REST-API implementation.
|
* Windows Platform Configuration REST-API implementation.
|
||||||
@ -37,8 +43,9 @@ import javax.ws.rs.core.MediaType;
|
|||||||
@WebService
|
@WebService
|
||||||
@Produces({"application/json", "application/xml"})
|
@Produces({"application/json", "application/xml"})
|
||||||
@Consumes({"application/json", "application/xml"})
|
@Consumes({"application/json", "application/xml"})
|
||||||
@Api(value = "ConfigurationMgtService", description = "Windows Device Management REST-API implementation.")
|
public class ConfigurationMgtService {
|
||||||
public interface ConfigurationMgtService {
|
|
||||||
|
private static Log log = LogFactory.getLog(ConfigurationMgtService.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save Tenant configurations.
|
* Save Tenant configurations.
|
||||||
@ -48,17 +55,49 @@ public interface ConfigurationMgtService {
|
|||||||
* @throws WindowsConfigurationException
|
* @throws WindowsConfigurationException
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@ApiOperation(
|
public Message ConfigureSettings(PlatformConfiguration configuration) throws WindowsConfigurationException {
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
Message responseMsg = new Message();
|
||||||
httpMethod = "POST",
|
ConfigurationEntry licenseEntry = null;
|
||||||
value = "Configuring Windows Platform Settings",
|
String message;
|
||||||
notes = "Configure the Windows platform settings using this REST API"
|
|
||||||
)
|
try {
|
||||||
@ApiResponses(value = {
|
configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
|
||||||
@ApiResponse(code = 201, message = "Windows platform configuration saved successfully"),
|
if (!configuration.getConfiguration().isEmpty()) {
|
||||||
@ApiResponse(code = 500, message = "Internal Server Error")
|
List<ConfigurationEntry> configs = configuration.getConfiguration();
|
||||||
})
|
for (ConfigurationEntry entry : configs) {
|
||||||
Message ConfigureSettings(PlatformConfiguration configuration) throws WindowsConfigurationException;
|
if (PluginConstants.TenantConfigProperties.LICENSE_KEY.equals(entry.getName())) {
|
||||||
|
License license = new License();
|
||||||
|
license.setName(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
|
||||||
|
license.setLanguage(PluginConstants.TenantConfigProperties.LANGUAGE_US);
|
||||||
|
license.setVersion("1.0.0");
|
||||||
|
license.setText(entry.getValue().toString());
|
||||||
|
WindowsAPIUtils.getDeviceManagementService().addLicense(DeviceManagementConstants.
|
||||||
|
MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS, license);
|
||||||
|
licenseEntry = entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (licenseEntry != null) {
|
||||||
|
configs.remove(licenseEntry);
|
||||||
|
}
|
||||||
|
configuration.setConfiguration(configs);
|
||||||
|
WindowsAPIUtils.getDeviceManagementService().saveConfiguration(configuration);
|
||||||
|
Response.status(Response.Status.CREATED);
|
||||||
|
responseMsg.setResponseMessage("Windows platform configuration saved successfully.");
|
||||||
|
responseMsg.setResponseCode(Response.Status.CREATED.toString());
|
||||||
|
return responseMsg;
|
||||||
|
} else {
|
||||||
|
Response.status(Response.Status.BAD_REQUEST);
|
||||||
|
responseMsg.setResponseMessage("Windows platform configuration can not be saved.");
|
||||||
|
responseMsg.setResponseCode(Response.Status.CREATED.toString());
|
||||||
|
}
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
message = "Error Occurred while configuring Windows Platform.";
|
||||||
|
log.error(message, e);
|
||||||
|
throw new WindowsConfigurationException(message, e);
|
||||||
|
}
|
||||||
|
return responseMsg;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve Tenant configurations according to the device type.
|
* Retrieve Tenant configurations according to the device type.
|
||||||
@ -67,17 +106,39 @@ public interface ConfigurationMgtService {
|
|||||||
* @throws WindowsConfigurationException
|
* @throws WindowsConfigurationException
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@ApiOperation(
|
public PlatformConfiguration getConfiguration() throws WindowsConfigurationException {
|
||||||
httpMethod = "GET",
|
String msg;
|
||||||
value = "Getting Windows Platform Configurations",
|
PlatformConfiguration tenantConfiguration;
|
||||||
notes = "Get the Windows platform configuration details using this REST API",
|
List<ConfigurationEntry> configs;
|
||||||
response = PlatformConfiguration.class
|
try {
|
||||||
)
|
tenantConfiguration = WindowsAPIUtils.getDeviceManagementService().
|
||||||
@ApiResponses(value = {
|
getConfiguration(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
|
||||||
@ApiResponse(code = 200, message = "Get Windows Configurations"),
|
if (tenantConfiguration != null) {
|
||||||
@ApiResponse(code = 500, message = "Server Error")
|
configs = tenantConfiguration.getConfiguration();
|
||||||
})
|
} else {
|
||||||
PlatformConfiguration getConfiguration() throws WindowsConfigurationException;
|
tenantConfiguration = new PlatformConfiguration();
|
||||||
|
configs = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigurationEntry entry = new ConfigurationEntry();
|
||||||
|
License license = WindowsAPIUtils.getDeviceManagementService().getLicense(
|
||||||
|
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS,
|
||||||
|
PluginConstants.TenantConfigProperties.LANGUAGE_US);
|
||||||
|
|
||||||
|
if (license != null && configs != null) {
|
||||||
|
entry.setContentType(PluginConstants.TenantConfigProperties.CONTENT_TYPE_TEXT);
|
||||||
|
entry.setName(PluginConstants.TenantConfigProperties.LICENSE_KEY);
|
||||||
|
entry.setValue(license.getText());
|
||||||
|
configs.add(entry);
|
||||||
|
tenantConfiguration.setConfiguration(configs);
|
||||||
|
}
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
msg = "Error occurred while retrieving the Windows tenant configuration";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new WindowsConfigurationException(msg, e);
|
||||||
|
}
|
||||||
|
return tenantConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update Tenant Configurations for the specific Device type.
|
* Update Tenant Configurations for the specific Device type.
|
||||||
@ -87,17 +148,39 @@ public interface ConfigurationMgtService {
|
|||||||
* @throws WindowsConfigurationException
|
* @throws WindowsConfigurationException
|
||||||
*/
|
*/
|
||||||
@PUT
|
@PUT
|
||||||
@ApiOperation(
|
public Message updateConfiguration(PlatformConfiguration configuration) throws WindowsConfigurationException {
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
String message;
|
||||||
produces = MediaType.APPLICATION_JSON,
|
Message responseMsg = new Message();
|
||||||
httpMethod = "PUT",
|
ConfigurationEntry licenseEntry = null;
|
||||||
value = "Updating Windows Platform Configurations",
|
try {
|
||||||
notes = "Update the Windows platform configurations using this REST API"
|
configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
|
||||||
)
|
List<ConfigurationEntry> configs = configuration.getConfiguration();
|
||||||
@ApiResponses(value = {
|
for (ConfigurationEntry entry : configs) {
|
||||||
@ApiResponse(code = 201, message = "Created"),
|
if (PluginConstants.TenantConfigProperties.LICENSE_KEY.equals(entry.getName())) {
|
||||||
@ApiResponse(code = 500, message = "Error occurred while modifying configuration settings of " +
|
License license = new License();
|
||||||
"windows platform")
|
license.setName(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
|
||||||
})
|
license.setLanguage(PluginConstants.TenantConfigProperties.LANGUAGE_US);
|
||||||
Message updateConfiguration(PlatformConfiguration configuration) throws WindowsConfigurationException;
|
license.setVersion("1.0.0");
|
||||||
|
license.setText(entry.getValue().toString());
|
||||||
|
WindowsAPIUtils.getDeviceManagementService().addLicense(DeviceManagementConstants.
|
||||||
|
MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS, license);
|
||||||
|
licenseEntry = entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (licenseEntry != null) {
|
||||||
|
configs.remove(licenseEntry);
|
||||||
|
}
|
||||||
|
configuration.setConfiguration(configs);
|
||||||
|
WindowsAPIUtils.getDeviceManagementService().saveConfiguration(configuration);
|
||||||
|
Response.status(Response.Status.CREATED);
|
||||||
|
responseMsg.setResponseMessage("Windows platform configuration succeeded.");
|
||||||
|
responseMsg.setResponseCode(Response.Status.CREATED.toString());
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
message = "Error occurred while modifying configuration settings of Windows platform.";
|
||||||
|
log.error(message, e);
|
||||||
|
throw new WindowsConfigurationException(message, e);
|
||||||
|
}
|
||||||
|
return responseMsg;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,182 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
|
||||||
*
|
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
|
||||||
* in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.services.configurationmgtservice.impl;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
||||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
|
|
||||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
|
||||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
|
||||||
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsConfigurationException;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.util.Message;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils;
|
|
||||||
|
|
||||||
import javax.jws.WebService;
|
|
||||||
import javax.ws.rs.*;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Windows Platform Configuration REST-API implementation.
|
|
||||||
* All end points supports JSON, XMl with content negotiation.
|
|
||||||
*/
|
|
||||||
@WebService
|
|
||||||
@Produces({"application/json", "application/xml"})
|
|
||||||
@Consumes({"application/json", "application/xml"})
|
|
||||||
public class ConfigurationMgtServiceImpl {
|
|
||||||
|
|
||||||
private static Log log = LogFactory.getLog(ConfigurationMgtServiceImpl.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save Tenant configurations.
|
|
||||||
*
|
|
||||||
* @param configuration Tenant Configurations to be saved.
|
|
||||||
* @return Message type object for the provide save status.
|
|
||||||
* @throws WindowsConfigurationException
|
|
||||||
*/
|
|
||||||
@POST
|
|
||||||
public Message ConfigureSettings(PlatformConfiguration configuration) throws WindowsConfigurationException {
|
|
||||||
Message responseMsg = new Message();
|
|
||||||
ConfigurationEntry licenseEntry = null;
|
|
||||||
String message;
|
|
||||||
|
|
||||||
try {
|
|
||||||
configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
|
|
||||||
if (!configuration.getConfiguration().isEmpty()) {
|
|
||||||
List<ConfigurationEntry> configs = configuration.getConfiguration();
|
|
||||||
for (ConfigurationEntry entry : configs) {
|
|
||||||
if (PluginConstants.TenantConfigProperties.LICENSE_KEY.equals(entry.getName())) {
|
|
||||||
License license = new License();
|
|
||||||
license.setName(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
|
|
||||||
license.setLanguage(PluginConstants.TenantConfigProperties.LANGUAGE_US);
|
|
||||||
license.setVersion("1.0.0");
|
|
||||||
license.setText(entry.getValue().toString());
|
|
||||||
WindowsAPIUtils.getDeviceManagementService().addLicense(DeviceManagementConstants.
|
|
||||||
MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS, license);
|
|
||||||
licenseEntry = entry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (licenseEntry != null) {
|
|
||||||
configs.remove(licenseEntry);
|
|
||||||
}
|
|
||||||
configuration.setConfiguration(configs);
|
|
||||||
WindowsAPIUtils.getDeviceManagementService().saveConfiguration(configuration);
|
|
||||||
Response.status(Response.Status.CREATED);
|
|
||||||
responseMsg.setResponseMessage("Windows platform configuration saved successfully.");
|
|
||||||
responseMsg.setResponseCode(Response.Status.CREATED.toString());
|
|
||||||
return responseMsg;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Response.status(Response.Status.BAD_REQUEST);
|
|
||||||
responseMsg.setResponseMessage("Windows platform configuration can not be saved.");
|
|
||||||
responseMsg.setResponseCode(Response.Status.CREATED.toString());
|
|
||||||
}
|
|
||||||
} catch (DeviceManagementException e) {
|
|
||||||
message = "Error Occurred in while configuring Windows Platform.";
|
|
||||||
log.error(message, e);
|
|
||||||
throw new WindowsConfigurationException(message, e);
|
|
||||||
}
|
|
||||||
return responseMsg;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve Tenant configurations according to the device type.
|
|
||||||
*
|
|
||||||
* @return Tenant configuration object contains specific tenant configurations.
|
|
||||||
* @throws WindowsConfigurationException
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
public PlatformConfiguration getConfiguration() throws WindowsConfigurationException {
|
|
||||||
String msg;
|
|
||||||
PlatformConfiguration PlatformConfiguration = null;
|
|
||||||
try {
|
|
||||||
if (WindowsAPIUtils.getDeviceManagementService().
|
|
||||||
getConfiguration(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS) != null) {
|
|
||||||
PlatformConfiguration = WindowsAPIUtils.getDeviceManagementService().
|
|
||||||
getConfiguration(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
|
|
||||||
List<ConfigurationEntry> configs = PlatformConfiguration.getConfiguration();
|
|
||||||
ConfigurationEntry entry = new ConfigurationEntry();
|
|
||||||
License license = WindowsAPIUtils.getDeviceManagementService().getLicense(
|
|
||||||
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS, PluginConstants.
|
|
||||||
TenantConfigProperties.LANGUAGE_US);
|
|
||||||
if(license != null) {
|
|
||||||
entry.setContentType(PluginConstants.TenantConfigProperties.CONTENT_TYPE_TEXT);
|
|
||||||
entry.setName(PluginConstants.TenantConfigProperties.LICENSE_KEY);
|
|
||||||
entry.setValue(license.getText());
|
|
||||||
configs.add(entry);
|
|
||||||
PlatformConfiguration.setConfiguration(configs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (DeviceManagementException e) {
|
|
||||||
msg = "Error occurred while retrieving the Windows tenant configuration";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsConfigurationException(msg, e);
|
|
||||||
}
|
|
||||||
return PlatformConfiguration;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update Tenant Configurations for the specific Device type.
|
|
||||||
*
|
|
||||||
* @param configuration Tenant configurations to be updated.
|
|
||||||
* @return Response message.
|
|
||||||
* @throws WindowsConfigurationException
|
|
||||||
*/
|
|
||||||
@PUT
|
|
||||||
public Message updateConfiguration(PlatformConfiguration configuration) throws WindowsConfigurationException {
|
|
||||||
String message;
|
|
||||||
Message responseMsg = new Message();
|
|
||||||
ConfigurationEntry licenseEntry = null;
|
|
||||||
try {
|
|
||||||
configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
|
|
||||||
List<ConfigurationEntry> configs = configuration.getConfiguration();
|
|
||||||
for (ConfigurationEntry entry : configs) {
|
|
||||||
if (PluginConstants.TenantConfigProperties.LICENSE_KEY.equals(entry.getName())) {
|
|
||||||
License license = new License();
|
|
||||||
license.setName(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
|
|
||||||
license.setLanguage(PluginConstants.TenantConfigProperties.LANGUAGE_US);
|
|
||||||
license.setVersion("1.0.0");
|
|
||||||
license.setText(entry.getValue().toString());
|
|
||||||
WindowsAPIUtils.getDeviceManagementService().addLicense(DeviceManagementConstants.
|
|
||||||
MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS, license);
|
|
||||||
licenseEntry = entry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (licenseEntry != null) {
|
|
||||||
configs.remove(licenseEntry);
|
|
||||||
}
|
|
||||||
configuration.setConfiguration(configs);
|
|
||||||
WindowsAPIUtils.getDeviceManagementService().saveConfiguration(configuration);
|
|
||||||
Response.status(Response.Status.CREATED);
|
|
||||||
responseMsg.setResponseMessage("Windows platform configuration succeeded.");
|
|
||||||
responseMsg.setResponseCode(Response.Status.CREATED.toString());
|
|
||||||
} catch (DeviceManagementException e) {
|
|
||||||
message = "Error occurred while modifying configuration settings of Windows platform.";
|
|
||||||
log.error(message, e);
|
|
||||||
throw new WindowsConfigurationException(message, e);
|
|
||||||
}
|
|
||||||
return responseMsg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,131 +1,154 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.services.devicemgtservice;
|
package org.wso2.carbon.mdm.mobileservices.windows.services.devicemgtservice;
|
||||||
|
|
||||||
import io.swagger.annotations.Api;
|
import org.apache.commons.logging.Log;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import io.swagger.annotations.ApiResponse;
|
|
||||||
import io.swagger.annotations.ApiResponses;
|
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsConfigurationException;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsConfigurationException;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.util.Message;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.util.Message;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils;
|
||||||
|
|
||||||
|
import javax.jws.WebService;
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Windows Device Management REST-API implementation.
|
* Windows Device Management REST-API implementation.
|
||||||
* All end points supports JSON, XMl with content negotiation.
|
* All end points supports JSON, XMl with content negotiation.
|
||||||
*/
|
*/
|
||||||
@Api(value = "DeviceManagementService", description = "Windows Device Management REST-API implementation.")
|
@WebService
|
||||||
@Produces({"application/json", "application/xml"})
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||||
@Consumes({"application/json", "application/xml"})
|
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||||
public interface DeviceManagementService {
|
public class DeviceManagementService {
|
||||||
|
|
||||||
|
private static Log log = LogFactory.getLog(DeviceManagementService.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all devices.Returns list of Windows devices registered in MDM.
|
* Get all devices.Returns list of Windows devices registered in MDM.
|
||||||
*
|
*
|
||||||
* @return Device List
|
* @return Returns retrieved devices.
|
||||||
* @throws WindowsConfigurationException
|
* @throws WindowsConfigurationException occurred while retrieving all the devices from DB.
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@ApiOperation(
|
public List<Device> getAllDevices() throws WindowsConfigurationException {
|
||||||
produces = MediaType.APPLICATION_JSON,
|
String msg;
|
||||||
httpMethod = "GET",
|
List<Device> devices;
|
||||||
value = "Getting Details of All Windows Devices",
|
try {
|
||||||
notes = "Use this REST API to retrieve the details " +
|
devices = WindowsAPIUtils.getDeviceManagementService().
|
||||||
"(e.g., the Android device type, serial number, International Mobile Station Equipment Identity " +
|
getAllDevices(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
|
||||||
"(IMEI), owner, version, model etc.) of all Windows devices that are registered with WSO2 EMM.",
|
} catch (DeviceManagementException e) {
|
||||||
response = Device.class,
|
msg = "Error occurred while fetching the device list.";
|
||||||
responseContainer = "List"
|
log.error(msg, e);
|
||||||
)
|
throw new WindowsConfigurationException(msg, e);
|
||||||
@ApiResponses(value = {
|
}
|
||||||
@ApiResponse(code = 200, message = "List of Devices"),
|
return devices;
|
||||||
@ApiResponse(code = 500, message = "Error occurred while fetching the device list")
|
}
|
||||||
})
|
|
||||||
List<Device> getAllDevices() throws WindowsConfigurationException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch Windows device details of a given device Id.
|
* Fetch Windows device details of a given device Id.
|
||||||
*
|
*
|
||||||
* @param id Device Id
|
* @param id Device Id
|
||||||
* @return Device
|
* @return Returns retrieved device.
|
||||||
* @throws WindowsConfigurationException
|
* @throws WindowsConfigurationException occurred while getting device from DB.
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@ApiOperation(
|
public Device getDevice(@PathParam("id") String id) throws WindowsConfigurationException {
|
||||||
produces = MediaType.APPLICATION_JSON,
|
String msg;
|
||||||
httpMethod = "GET",
|
Device device;
|
||||||
value = "Getting Details of an Windows Device",
|
try {
|
||||||
notes = "Use this REST API to retrieve the details " +
|
DeviceIdentifier deviceIdentifier = WindowsAPIUtils.convertToDeviceIdentifierObject(id);
|
||||||
"(e.g., the Android device type, serial number, International Mobile Station Equipment Identity " +
|
device = WindowsAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier);
|
||||||
"(IMEI), owner, version, model etc.) of a specific Windows device that is registered with WSO2 EMM",
|
if (device == null) {
|
||||||
response = Device.class
|
Response.status(Response.Status.NOT_FOUND);
|
||||||
)
|
}
|
||||||
@ApiResponses(value = {
|
} catch (DeviceManagementException e) {
|
||||||
@ApiResponse(code = 200, message = "Information of the given device"),
|
msg = "Error occurred while fetching the device information.";
|
||||||
@ApiResponse(code = 500, message = "Error occurred while fetching the device information")
|
log.error(msg, e);
|
||||||
})
|
throw new WindowsConfigurationException(msg, e);
|
||||||
org.wso2.carbon.device.mgt.common.Device getDevice(@PathParam("id") String id)
|
}
|
||||||
throws WindowsConfigurationException;
|
return device;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update Windows device details of given device id.
|
* Update Windows device details of given device id.
|
||||||
*
|
*
|
||||||
* @param id Device Id
|
* @param id Device Id.
|
||||||
* @param device Device Details
|
* @param device Device details to be updated.
|
||||||
* @return Message
|
* @return Returns the message whether device update or not.
|
||||||
* @throws WindowsConfigurationException
|
* @throws WindowsConfigurationException occurred while updating the Device Info.
|
||||||
*/
|
*/
|
||||||
@PUT
|
@PUT
|
||||||
@ApiOperation(
|
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
|
||||||
httpMethod = "PUT",
|
|
||||||
value = "Updating the Details of an Windows Device",
|
|
||||||
notes = "Use this REST API to update the details of an Windows device"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 202, message = "The device enrollment details has been updated successfully"),
|
|
||||||
@ApiResponse(code = 500, message = "Error occurred while modifying the device information"),
|
|
||||||
@ApiResponse(code = 304, message = "Device not found for the update")
|
|
||||||
})
|
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
Message updateDevice(@PathParam("id") String id, Device device) throws WindowsConfigurationException;
|
public Message updateDevice(@PathParam("id") String id, Device device) throws WindowsConfigurationException {
|
||||||
|
String msg;
|
||||||
|
Message responseMessage = new Message();
|
||||||
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||||
|
deviceIdentifier.setId(id);
|
||||||
|
deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
|
||||||
|
boolean isUpdated;
|
||||||
|
try {
|
||||||
|
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
|
||||||
|
isUpdated = WindowsAPIUtils.getDeviceManagementService().updateDeviceInfo(deviceIdentifier, device);
|
||||||
|
if (isUpdated) {
|
||||||
|
Response.status(Response.Status.ACCEPTED);
|
||||||
|
responseMessage.setResponseMessage("Device information has modified successfully.");
|
||||||
|
} else {
|
||||||
|
Response.status(Response.Status.NOT_MODIFIED);
|
||||||
|
responseMessage.setResponseMessage("Device not found for the update.");
|
||||||
|
}
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
msg = "Error occurred while modifying the device information.";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new WindowsConfigurationException(msg, e);
|
||||||
|
}
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch the Licence agreement for specific windows platform.
|
||||||
|
*
|
||||||
|
* @return Returns License agreement.
|
||||||
|
* @throws WindowsConfigurationException occurred while getting licence for specific platform and Language.
|
||||||
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("license")
|
@Path("license")
|
||||||
@Produces("application/json")
|
@Produces("application/json")
|
||||||
@ApiOperation(
|
public License getLicense() throws WindowsConfigurationException {
|
||||||
produces = MediaType.APPLICATION_JSON,
|
License license;
|
||||||
httpMethod = "GET",
|
try {
|
||||||
value = "Getting the License Agreement for Windows Device Registration",
|
license =
|
||||||
notes = "Use this REST API to retrieve the license agreement that is used for the Windows device " +
|
WindowsAPIUtils.getDeviceManagementService().getLicense(
|
||||||
"registration process",
|
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS,
|
||||||
response = String.class)
|
DeviceManagementConstants.LanguageCodes.LANGUAGE_CODE_ENGLISH_US);
|
||||||
@ApiResponses(value = {
|
} catch (DeviceManagementException e) {
|
||||||
@ApiResponse(code = 200, message = "Licence agreement"),
|
String msg = "Error occurred while retrieving the license configured for Windows device enrollment";
|
||||||
@ApiResponse(code = 500, message = "Error occurred while retrieving the license configured for Windows " +
|
log.error(msg, e);
|
||||||
"device enrolment")
|
throw new WindowsConfigurationException(msg, e);
|
||||||
})
|
}
|
||||||
License getLicense() throws WindowsConfigurationException;
|
return license;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,158 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
|
||||||
*
|
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
|
||||||
* in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.services.devicemgtservice.impl;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
||||||
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsConfigurationException;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.util.Message;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils;
|
|
||||||
|
|
||||||
import javax.jws.WebService;
|
|
||||||
import javax.ws.rs.*;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Windows Device Management REST-API implementation.
|
|
||||||
* All end points supports JSON, XMl with content negotiation.
|
|
||||||
*/
|
|
||||||
@WebService
|
|
||||||
@Produces({"application/json", "application/xml"})
|
|
||||||
@Consumes({"application/json", "application/xml"})
|
|
||||||
public class DeviceManagementServiceImpl {
|
|
||||||
|
|
||||||
private static Log log = LogFactory.getLog(DeviceManagementServiceImpl.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all devices.Returns list of Windows devices registered in MDM.
|
|
||||||
*
|
|
||||||
* @return Device List
|
|
||||||
* @throws WindowsConfigurationException
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
public List<Device> getAllDevices()
|
|
||||||
throws WindowsConfigurationException {
|
|
||||||
String msg;
|
|
||||||
List<Device> devices;
|
|
||||||
|
|
||||||
try {
|
|
||||||
devices = WindowsAPIUtils.getDeviceManagementService().
|
|
||||||
getAllDevices(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
|
|
||||||
} catch (DeviceManagementException e) {
|
|
||||||
msg = "Error occurred while fetching the device list.";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsConfigurationException(msg, e);
|
|
||||||
}
|
|
||||||
return devices;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetch Windows device details of a given device Id.
|
|
||||||
*
|
|
||||||
* @param id Device Id
|
|
||||||
* @return Device
|
|
||||||
* @throws WindowsConfigurationException
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
@Path("{id}")
|
|
||||||
public Device getDevice(@PathParam("id") String id)
|
|
||||||
throws WindowsConfigurationException {
|
|
||||||
|
|
||||||
String msg;
|
|
||||||
Device device;
|
|
||||||
|
|
||||||
try {
|
|
||||||
DeviceIdentifier deviceIdentifier = WindowsAPIUtils.convertToDeviceIdentifierObject(id);
|
|
||||||
device = WindowsAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier);
|
|
||||||
if (device == null) {
|
|
||||||
Response.status(Response.Status.NOT_FOUND);
|
|
||||||
}
|
|
||||||
} catch (DeviceManagementException deviceMgtEx) {
|
|
||||||
msg = "Error occurred while fetching the device information.";
|
|
||||||
log.error(msg, deviceMgtEx);
|
|
||||||
throw new WindowsConfigurationException(msg, deviceMgtEx);
|
|
||||||
}
|
|
||||||
return device;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update Windows device details of given device id.
|
|
||||||
*
|
|
||||||
* @param id Device Id
|
|
||||||
* @param device Device Details
|
|
||||||
* @return Message
|
|
||||||
* @throws WindowsConfigurationException
|
|
||||||
*/
|
|
||||||
@PUT
|
|
||||||
@Path("{id}")
|
|
||||||
public Message updateDevice(@PathParam("id") String id, Device device)
|
|
||||||
throws WindowsConfigurationException {
|
|
||||||
String msg;
|
|
||||||
Message responseMessage = new Message();
|
|
||||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
|
||||||
deviceIdentifier.setId(id);
|
|
||||||
deviceIdentifier
|
|
||||||
.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
|
|
||||||
boolean result;
|
|
||||||
try {
|
|
||||||
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
|
|
||||||
result = WindowsAPIUtils.getDeviceManagementService()
|
|
||||||
.updateDeviceInfo(deviceIdentifier, device);
|
|
||||||
if (result) {
|
|
||||||
Response.status(Response.Status.ACCEPTED);
|
|
||||||
responseMessage.setResponseMessage("Device information has modified successfully.");
|
|
||||||
} else {
|
|
||||||
Response.status(Response.Status.NOT_MODIFIED);
|
|
||||||
responseMessage.setResponseMessage("Device not found for the update.");
|
|
||||||
}
|
|
||||||
} catch (DeviceManagementException e) {
|
|
||||||
msg = "Error occurred while modifying the device information.";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsConfigurationException(msg, e);
|
|
||||||
}
|
|
||||||
return responseMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("license")
|
|
||||||
@Produces("application/json")
|
|
||||||
public License getLicense() throws WindowsConfigurationException {
|
|
||||||
License license;
|
|
||||||
|
|
||||||
try {
|
|
||||||
license =
|
|
||||||
WindowsAPIUtils.getDeviceManagementService().getLicense(
|
|
||||||
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS,
|
|
||||||
DeviceManagementConstants.LanguageCodes.LANGUAGE_CODE_ENGLISH_US);
|
|
||||||
} catch (DeviceManagementException e) {
|
|
||||||
String msg = "Error occurred while retrieving the license configured for Windows device enrollment";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsConfigurationException(msg, e);
|
|
||||||
}
|
|
||||||
return license;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,28 +1,25 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.services.discovery;
|
package org.wso2.carbon.mdm.mobileservices.windows.services.discovery;
|
||||||
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiResponse;
|
|
||||||
import io.swagger.annotations.ApiResponses;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.services.discovery.beans.DiscoveryRequest;
|
import org.wso2.carbon.mdm.mobileservices.windows.services.discovery.beans.DiscoveryRequest;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.services.discovery.beans.DiscoveryResponse;
|
import org.wso2.carbon.mdm.mobileservices.windows.services.discovery.beans.DiscoveryResponse;
|
||||||
|
|
||||||
@ -44,44 +41,23 @@ import javax.xml.ws.soap.SOAPBinding;
|
|||||||
@WebService(targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE,
|
@WebService(targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE,
|
||||||
name = "IDiscoveryService")
|
name = "IDiscoveryService")
|
||||||
@BindingType(value = SOAPBinding.SOAP12HTTP_BINDING)
|
@BindingType(value = SOAPBinding.SOAP12HTTP_BINDING)
|
||||||
@Api(value = "DiscoveryService", description = "Windows Device Management REST-API implementation.")
|
|
||||||
public interface DiscoveryService {
|
public interface DiscoveryService {
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@RequestWrapper(localName = "Discover", targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE)
|
@RequestWrapper(localName = "Discover", targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE)
|
||||||
@WebMethod(operationName = "Discover")
|
@WebMethod(operationName = "Discover")
|
||||||
@ResponseWrapper(localName = "DiscoverResponse", targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE)
|
@ResponseWrapper(localName = "DiscoverResponse", targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE)
|
||||||
@ApiOperation(
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Discover the EMM server via REST API.",
|
|
||||||
notes = "Request the server endpoints.",
|
|
||||||
response = DiscoveryResponse.class
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 200,
|
|
||||||
message = "Windows policy, policy endpoints, enrollment endpoints and authentication endpoint."),
|
|
||||||
@ApiResponse(code = 500, message = "Internal server error")
|
|
||||||
})
|
|
||||||
void discover(
|
void discover(
|
||||||
@WebParam(name = "request", targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE)
|
@WebParam(name = "request", targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE)
|
||||||
DiscoveryRequest request,
|
DiscoveryRequest request,
|
||||||
@WebParam(mode = WebParam.Mode.OUT, name = "DiscoverResult",
|
@WebParam(mode = WebParam.Mode.OUT, name = "DiscoverResult",
|
||||||
targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE)
|
targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE)
|
||||||
javax.xml.ws.Holder<DiscoveryResponse> response
|
javax.xml.ws.Holder<DiscoveryResponse> response
|
||||||
);
|
) throws WindowsDeviceEnrolmentException;
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@WebMethod
|
@WebMethod
|
||||||
@WebResult()
|
@WebResult()
|
||||||
@ApiOperation(
|
|
||||||
httpMethod = "GET",
|
|
||||||
value = "Discover the EMM server via REST API.",
|
|
||||||
notes = "Check the server availability."
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 200, message = "Ok."),
|
|
||||||
@ApiResponse(code = 500, message = "Internal server error.")
|
|
||||||
})
|
|
||||||
Response discoverGet();
|
Response discoverGet();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,26 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.services.discovery.beans;
|
package org.wso2.carbon.mdm.mobileservices.windows.services.discovery.beans;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
@ -30,20 +27,15 @@ import java.io.Serializable;
|
|||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
@XmlType(name = "DiscoveryRequest")
|
@XmlType(name = "DiscoveryRequest")
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@ApiModel(value = "DiscoveryRequest",
|
|
||||||
description = "This class carries all information related to Discovery request.")
|
|
||||||
public class DiscoveryRequest implements Serializable {
|
public class DiscoveryRequest implements Serializable {
|
||||||
|
|
||||||
@XmlElement(name = "EmailAddress", required = true)
|
@XmlElement(name = "EmailAddress", required = true)
|
||||||
@ApiModelProperty(name = "emailId", value = "Email ID.", required = true)
|
|
||||||
private String emailId;
|
private String emailId;
|
||||||
|
|
||||||
@XmlElement(name = "RequestVersion")
|
@XmlElement(name = "RequestVersion")
|
||||||
@ApiModelProperty(name = "version", value = "Request Version.", required = true)
|
|
||||||
private String version;
|
private String version;
|
||||||
|
|
||||||
@XmlElement(name = "DeviceType")
|
@XmlElement(name = "DeviceType")
|
||||||
@ApiModelProperty(name = "deviceType", value = "Type of the Device.", required = true)
|
|
||||||
private String deviceType;
|
private String deviceType;
|
||||||
|
|
||||||
public String getEmailId() {
|
public String getEmailId() {
|
||||||
|
|||||||
@ -1,26 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.services.discovery.beans;
|
package org.wso2.carbon.mdm.mobileservices.windows.services.discovery.beans;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
@ -30,28 +27,18 @@ import java.io.Serializable;
|
|||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
@XmlType(name = "DiscoveryResponse")
|
@XmlType(name = "DiscoveryResponse")
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@ApiModel(value = "DiscoveryResponse",
|
|
||||||
description = "This class carries all information related to DiscoverResponse.")
|
|
||||||
public class DiscoveryResponse implements Serializable {
|
public class DiscoveryResponse implements Serializable {
|
||||||
|
|
||||||
@XmlElement(name = "AuthPolicy")
|
@XmlElement(name = "AuthPolicy")
|
||||||
@ApiModelProperty(name = "authPolicy",
|
|
||||||
value = "Authentication policy(On-premise/Federated)", required = true)
|
|
||||||
private String authPolicy;
|
private String authPolicy;
|
||||||
|
|
||||||
@XmlElement(name = "EnrollmentPolicyServiceUrl")
|
@XmlElement(name = "EnrollmentPolicyServiceUrl")
|
||||||
@ApiModelProperty(name = "enrollmentPolicyServiceUrl",
|
|
||||||
value = "Enrollment policy(XCEP) endpoint URL.", required = true)
|
|
||||||
private String enrollmentPolicyServiceUrl;
|
private String enrollmentPolicyServiceUrl;
|
||||||
|
|
||||||
@XmlElement(name = "EnrollmentServiceUrl")
|
@XmlElement(name = "EnrollmentServiceUrl")
|
||||||
@ApiModelProperty(name = "enrollmentServiceUrl",
|
|
||||||
value = "Enrollment Service(WSTEP) endpoint URL.", required = true)
|
|
||||||
private String enrollmentServiceUrl;
|
private String enrollmentServiceUrl;
|
||||||
|
|
||||||
@XmlElement(name = "AuthenticationServiceUrl")
|
@XmlElement(name = "AuthenticationServiceUrl")
|
||||||
@ApiModelProperty(name = "authenticationServiceUrl",
|
|
||||||
value = "SOAP request authentication service URL", required = true)
|
|
||||||
private String authenticationServiceUrl;
|
private String authenticationServiceUrl;
|
||||||
|
|
||||||
public void setAuthenticationServiceUrl(String authenticationServiceUrl) {
|
public void setAuthenticationServiceUrl(String authenticationServiceUrl) {
|
||||||
|
|||||||
@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@javax.xml.bind.annotation.XmlSchema(namespace =
|
@javax.xml.bind.annotation.XmlSchema(namespace =
|
||||||
"http://schemas.microsoft.com/windows/management/2012/01/enrollment",
|
"http://schemas.microsoft.com/windows/management/2012/01/enrollment",
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
@ -20,22 +20,22 @@ package org.wso2.carbon.mdm.mobileservices.windows.services.discovery.impl;
|
|||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.beans.WindowsPluginProperties;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.services.discovery.beans.DiscoveryRequest;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.services.discovery.DiscoveryService;
|
import org.wso2.carbon.mdm.mobileservices.windows.services.discovery.DiscoveryService;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.services.discovery.beans.DiscoveryRequest;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.services.discovery.beans.DiscoveryResponse;
|
import org.wso2.carbon.mdm.mobileservices.windows.services.discovery.beans.DiscoveryResponse;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.jws.WebService;
|
import javax.jws.WebService;
|
||||||
import javax.servlet.ServletContext;
|
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import javax.xml.ws.BindingType;
|
import javax.xml.ws.BindingType;
|
||||||
import javax.xml.ws.Holder;
|
import javax.xml.ws.Holder;
|
||||||
import javax.xml.ws.WebServiceContext;
|
|
||||||
import javax.xml.ws.handler.MessageContext;
|
|
||||||
import javax.xml.ws.soap.Addressing;
|
import javax.xml.ws.soap.Addressing;
|
||||||
import javax.xml.ws.soap.SOAPBinding;
|
import javax.xml.ws.soap.SOAPBinding;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation class of Discovery Request. This class implements the first two services
|
* Implementation class of Discovery Request. This class implements the first two services
|
||||||
@ -48,9 +48,9 @@ import javax.xml.ws.soap.SOAPBinding;
|
|||||||
public class DiscoveryServiceImpl implements DiscoveryService {
|
public class DiscoveryServiceImpl implements DiscoveryService {
|
||||||
|
|
||||||
public static final String FEDERATED = "Federated";
|
public static final String FEDERATED = "Federated";
|
||||||
|
private static final String DELIMITER = "@";
|
||||||
|
private static final int DOMAIN_SEGMENT = 1;
|
||||||
private static Log log = LogFactory.getLog(DiscoveryServiceImpl.class);
|
private static Log log = LogFactory.getLog(DiscoveryServiceImpl.class);
|
||||||
@Resource
|
|
||||||
private WebServiceContext context;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method returns the OnPremise AuthPolicy and next two endpoint the mobile device should
|
* This method returns the OnPremise AuthPolicy and next two endpoint the mobile device should
|
||||||
@ -61,35 +61,26 @@ public class DiscoveryServiceImpl implements DiscoveryService {
|
|||||||
* @param response - DiscoveryResponse bean for response
|
* @param response - DiscoveryResponse bean for response
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void discover(DiscoveryRequest discoveryRequest, Holder<DiscoveryResponse> response) {
|
public void discover(DiscoveryRequest discoveryRequest, Holder<DiscoveryResponse> response)
|
||||||
|
throws WindowsDeviceEnrolmentException {
|
||||||
|
|
||||||
ServletContext ctx = (ServletContext) context.getMessageContext().get(MessageContext.SERVLET_CONTEXT);
|
String emailId = discoveryRequest.getEmailId();
|
||||||
WindowsPluginProperties windowsPluginProperties = (WindowsPluginProperties) ctx.getAttribute(
|
String[] userDomains = emailId.split(DELIMITER);
|
||||||
PluginConstants.WINDOWS_PLUGIN_PROPERTIES);
|
String domain = userDomains[DOMAIN_SEGMENT];
|
||||||
|
|
||||||
DiscoveryResponse discoveryResponse = new DiscoveryResponse();
|
DiscoveryResponse discoveryResponse = new DiscoveryResponse();
|
||||||
if (FEDERATED.equals(windowsPluginProperties.getAuthPolicy())) {
|
if (FEDERATED.equals(getAuthPolicy())) {
|
||||||
discoveryResponse.setAuthPolicy(windowsPluginProperties.getAuthPolicy());
|
discoveryResponse.setAuthPolicy(FEDERATED);
|
||||||
discoveryResponse.setEnrollmentPolicyServiceUrl(PluginConstants.Discovery.ENROLL_SUBDOMAIN +
|
discoveryResponse.setEnrollmentPolicyServiceUrl(PluginConstants.Discovery.DEVICE_ENROLLMENT_SUBDOMAIN +
|
||||||
windowsPluginProperties.getDomain() + PluginConstants.Discovery.
|
domain + PluginConstants.Discovery.
|
||||||
CERTIFICATE_ENROLLMENT_POLICY_SERVICE_URL);
|
CERTIFICATE_ENROLLMENT_POLICY_SERVICE_URL);
|
||||||
discoveryResponse.setEnrollmentServiceUrl(PluginConstants.Discovery.ENROLL_SUBDOMAIN +
|
discoveryResponse.setEnrollmentServiceUrl(PluginConstants.Discovery.DEVICE_ENROLLMENT_SUBDOMAIN +
|
||||||
windowsPluginProperties.getDomain() + PluginConstants.Discovery.
|
domain + PluginConstants.Discovery.
|
||||||
CERTIFICATE_ENROLLMENT_SERVICE_URL);
|
CERTIFICATE_ENROLLMENT_SERVICE_URL);
|
||||||
discoveryResponse.setAuthenticationServiceUrl(PluginConstants.Discovery.ENROLL_SUBDOMAIN +
|
discoveryResponse.setAuthenticationServiceUrl(PluginConstants.Discovery.DEVICE_ENROLLMENT_SUBDOMAIN +
|
||||||
windowsPluginProperties.getDomain() + PluginConstants.Discovery.WAB_URL);
|
domain + PluginConstants.Discovery.WAB_URL);
|
||||||
} else {
|
|
||||||
discoveryResponse.setAuthPolicy(windowsPluginProperties.getAuthPolicy());
|
|
||||||
discoveryResponse.setEnrollmentPolicyServiceUrl(PluginConstants.Discovery.ENROLL_SUBDOMAIN +
|
|
||||||
windowsPluginProperties.getDomain() + PluginConstants.Discovery.
|
|
||||||
ONPREMISE_CERTIFICATE_ENROLLMENT_POLICY);
|
|
||||||
discoveryResponse.setEnrollmentServiceUrl(PluginConstants.Discovery.ENROLL_SUBDOMAIN +
|
|
||||||
windowsPluginProperties.getDomain() + PluginConstants.Discovery.
|
|
||||||
ONPREMISE_CERTIFICATE_ENROLLMENT_SERVICE_URL);
|
|
||||||
discoveryResponse.setAuthenticationServiceUrl(null);
|
|
||||||
}
|
}
|
||||||
response.value = discoveryResponse;
|
response.value = discoveryResponse;
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Discovery service end point was triggered via POST method");
|
log.debug("Discovery service end point was triggered via POST method");
|
||||||
}
|
}
|
||||||
@ -109,4 +100,37 @@ public class DiscoveryServiceImpl implements DiscoveryService {
|
|||||||
}
|
}
|
||||||
return Response.ok().build();
|
return Response.ok().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get authentication policy from the tenant configuration, otherwise set default value as Federated.
|
||||||
|
*
|
||||||
|
* @return Authentication policy.
|
||||||
|
* @throws WindowsDeviceEnrolmentException
|
||||||
|
*/
|
||||||
|
public String getAuthPolicy() throws WindowsDeviceEnrolmentException {
|
||||||
|
String authPolicy = null;
|
||||||
|
List<ConfigurationEntry> tenantConfigurations;
|
||||||
|
try {
|
||||||
|
if (WindowsAPIUtils.getTenantConfigurationData() != null) {
|
||||||
|
tenantConfigurations = WindowsAPIUtils.getTenantConfigurationData();
|
||||||
|
|
||||||
|
for (ConfigurationEntry configurationEntry : tenantConfigurations) {
|
||||||
|
if (PluginConstants.TenantConfigProperties.AUTH_POLICY.equals(configurationEntry.getName())) {
|
||||||
|
authPolicy = configurationEntry.getValue().toString();
|
||||||
|
} else {
|
||||||
|
authPolicy = PluginConstants.TenantConfigProperties.DEFAULT_AUTH_POLICY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
authPolicy = PluginConstants.TenantConfigProperties.DEFAULT_AUTH_POLICY;
|
||||||
|
String msg = "Tenant configurations are not initialized yet.";
|
||||||
|
log.error(msg);
|
||||||
|
}
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String msg = "Error occurred while getting tenant configurations.";
|
||||||
|
log.error(msg);
|
||||||
|
throw new WindowsDeviceEnrolmentException(msg, e);
|
||||||
|
}
|
||||||
|
return authPolicy;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,52 +1,71 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.services.policymgtservice;
|
package org.wso2.carbon.mdm.mobileservices.windows.services.policymgtservice;
|
||||||
|
|
||||||
import io.swagger.annotations.Api;
|
import org.apache.commons.logging.Log;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import io.swagger.annotations.ApiResponse;
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
import io.swagger.annotations.ApiResponses;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsConfigurationException;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsConfigurationException;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.util.Message;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.util.Message;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils;
|
||||||
|
import org.wso2.carbon.policy.mgt.common.Policy;
|
||||||
|
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
||||||
|
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
||||||
|
|
||||||
|
import javax.jws.WebService;
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Endpoint for Enforce Effective Policy.
|
* Endpoint for Enforce Effective Policy.
|
||||||
*/
|
*/
|
||||||
@Api(value = "PolicyMgtService", description = "Windows Device Management REST-API implementation.")
|
@WebService
|
||||||
@Produces({"application/json", "application/xml"})
|
@Produces({"application/json", "application/xml"})
|
||||||
@Consumes({"application/json", "application/xml"})
|
@Consumes({"application/json", "application/xml"})
|
||||||
public interface PolicyMgtService {
|
public class PolicyMgtService {
|
||||||
|
private static Log log = LogFactory.getLog(PolicyMgtService.class);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@ApiOperation(
|
public Message getEffectivePolicy(@HeaderParam("Accept") String acceptHeader,
|
||||||
httpMethod = "GET",
|
@PathParam("id") String id) throws WindowsConfigurationException {
|
||||||
value = "Identifying whether a Policy is Enforced on an Windows Device",
|
|
||||||
notes = "When a device registers with WSO2 EMM, a policy is enforced on the device based on the policy " +
|
DeviceIdentifier deviceIdentifier = WindowsAPIUtils.convertToDeviceIdentifierObject(id);
|
||||||
"enforcement criteria. Using this API you are able to identify if a specific device has a policy " +
|
Message responseMessage = new Message();
|
||||||
"enforced or if no policy is enforced on the device."
|
Policy policy;
|
||||||
)
|
try {
|
||||||
@ApiResponses(value = {
|
PolicyManagerService policyManagerService = WindowsAPIUtils.getPolicyManagerService();
|
||||||
@ApiResponse(code = 200, message = "Effective policy added to operation"),
|
policy = policyManagerService.getEffectivePolicy(deviceIdentifier);
|
||||||
@ApiResponse(code = 204, message = "No effective policy found")
|
if (policy == null) {
|
||||||
})
|
responseMessage.setResponseCode(Response.Status.NO_CONTENT.toString());
|
||||||
Message getEffectivePolicy(@HeaderParam("Accept") String acceptHeader,
|
responseMessage.setResponseMessage("No effective policy found");
|
||||||
@PathParam("id") String id) throws WindowsConfigurationException;
|
return responseMessage;
|
||||||
|
} else {
|
||||||
|
responseMessage.setResponseCode(Response.Status.OK.toString());
|
||||||
|
responseMessage.setResponseMessage("Effective policy added to operation");
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (PolicyManagementException e) {
|
||||||
|
String msg = "Error occurred while getting the policy.";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new WindowsConfigurationException(msg, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,72 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
|
||||||
*
|
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
|
||||||
* in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.services.policymgtservice.impl;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsConfigurationException;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.util.Message;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils;
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.services.policymgtservice.PolicyMgtService;
|
|
||||||
import org.wso2.carbon.policy.mgt.common.Policy;
|
|
||||||
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
|
||||||
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
|
||||||
|
|
||||||
import javax.jws.WebService;
|
|
||||||
import javax.ws.rs.*;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Endpoint for Enforce Effective Policy.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@WebService
|
|
||||||
@Produces({"application/json", "application/xml"})
|
|
||||||
@Consumes({"application/json", "application/xml"})
|
|
||||||
public class PolicyMgtServiceImpl implements PolicyMgtService {
|
|
||||||
private static Log log = LogFactory.getLog(PolicyMgtServiceImpl.class);
|
|
||||||
|
|
||||||
@GET
|
|
||||||
public Message getEffectivePolicy(@HeaderParam("Accept") String acceptHeader,
|
|
||||||
@PathParam("id") String id) throws WindowsConfigurationException {
|
|
||||||
|
|
||||||
DeviceIdentifier deviceIdentifier = WindowsAPIUtils.convertToDeviceIdentifierObject(id);
|
|
||||||
Message responseMessage = new Message();
|
|
||||||
Policy policy;
|
|
||||||
try {
|
|
||||||
PolicyManagerService policyManagerService = WindowsAPIUtils.getPolicyManagerService();
|
|
||||||
policy = policyManagerService.getEffectivePolicy(deviceIdentifier);
|
|
||||||
if (policy == null) {
|
|
||||||
responseMessage.setResponseCode(Response.Status.NO_CONTENT.toString());
|
|
||||||
responseMessage.setResponseMessage("No effective policy found");
|
|
||||||
return responseMessage;
|
|
||||||
} else {
|
|
||||||
responseMessage.setResponseCode(Response.Status.OK.toString());
|
|
||||||
responseMessage.setResponseMessage("Effective policy added to operation");
|
|
||||||
return responseMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (PolicyManagementException e) {
|
|
||||||
String msg = "Error occurred while getting the policy.";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsConfigurationException(msg, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,27 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.services.syncml;
|
package org.wso2.carbon.mdm.mobileservices.windows.services.syncml;
|
||||||
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiResponse;
|
|
||||||
import io.swagger.annotations.ApiResponses;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException;
|
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants;
|
||||||
@ -39,7 +35,6 @@ import javax.ws.rs.core.Response;
|
|||||||
/**
|
/**
|
||||||
* Interface for Syncml message flow.
|
* Interface for Syncml message flow.
|
||||||
*/
|
*/
|
||||||
@Api(value = "SyncmlService", description = "Windows Device Management REST-API implementation.")
|
|
||||||
@Path("/devicemanagement")
|
@Path("/devicemanagement")
|
||||||
public interface SyncmlService {
|
public interface SyncmlService {
|
||||||
|
|
||||||
@ -47,17 +42,6 @@ public interface SyncmlService {
|
|||||||
@POST
|
@POST
|
||||||
@Consumes({PluginConstants.SYNCML_MEDIA_TYPE, MediaType.APPLICATION_XML})
|
@Consumes({PluginConstants.SYNCML_MEDIA_TYPE, MediaType.APPLICATION_XML})
|
||||||
@Produces(PluginConstants.SYNCML_MEDIA_TYPE)
|
@Produces(PluginConstants.SYNCML_MEDIA_TYPE)
|
||||||
@ApiOperation(
|
|
||||||
consumes = "application/vnd.syncml.dm+xml;charset=utf-8",
|
|
||||||
produces = "application/vnd.syncml.dm+xml;charset=utf-8",
|
|
||||||
httpMethod = "POST",
|
|
||||||
value = "Windows Device Management service REST API",
|
|
||||||
notes = "Windows device management session"
|
|
||||||
)
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 200, message = "Successfully completed syncml session"),
|
|
||||||
@ApiResponse(code = 500, message = "Internal server error")
|
|
||||||
})
|
|
||||||
Response getResponse(Document request) throws WindowsDeviceEnrolmentException, WindowsOperationException,
|
Response getResponse(Document request) throws WindowsDeviceEnrolmentException, WindowsOperationException,
|
||||||
NotificationManagementException, WindowsConfigurationException;
|
NotificationManagementException, WindowsConfigurationException;
|
||||||
|
|
||||||
|
|||||||
@ -1,33 +1,28 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.services.syncml.beans;
|
package org.wso2.carbon.mdm.mobileservices.windows.services.syncml.beans;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bean for get basic operations.
|
* Bean for get basic operations.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "BasicOperation",
|
|
||||||
description = "This class carries all information related to Basic operation.")
|
|
||||||
public class BasicOperation {
|
public class BasicOperation {
|
||||||
@ApiModelProperty(name = "name", value = "Name of the basic operation.", required = true)
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|||||||
@ -1,55 +1,36 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.services.syncml.beans;
|
package org.wso2.carbon.mdm.mobileservices.windows.services.syncml.beans;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bean for device lockOperationUpdate screen passcode policy.
|
* Bean for device updateLockOperation screen passcode policy.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "PasscodePolicy",
|
|
||||||
description = "This class carries all information related to Passcode Policy.")
|
|
||||||
public class PasscodePolicy extends BasicOperation {
|
public class PasscodePolicy extends BasicOperation {
|
||||||
|
|
||||||
@ApiModelProperty(name = "maxFailedAttempts", value = "No of Max fail attempts.", required = true)
|
|
||||||
private int maxFailedAttempts;
|
private int maxFailedAttempts;
|
||||||
@ApiModelProperty(name = "minLength", value = "Minimum length of the Passcode.", required = true)
|
|
||||||
private int minLength;
|
private int minLength;
|
||||||
@ApiModelProperty(name = "pinHistory",
|
|
||||||
value = "The number of passwords Windows 10 Mobile remembers in the password history.", required = true)
|
|
||||||
private int pinHistory;
|
private int pinHistory;
|
||||||
@ApiModelProperty(name = "minComplexChars",
|
|
||||||
value = "The number of password element types (in other words, uppercase letters, lowercase letters, " +
|
|
||||||
"numbers, or punctuation) required to create strong passwords.", required = true)
|
|
||||||
private int minComplexChars;
|
private int minComplexChars;
|
||||||
@ApiModelProperty(name = "maxPINAgeInDays",
|
|
||||||
value = "Number of Maximum days to expire the passcode.", required = true)
|
|
||||||
private int maxPINAgeInDays;
|
private int maxPINAgeInDays;
|
||||||
@ApiModelProperty(name = "requireAlphanumeric",
|
|
||||||
value = "An integer value that specifies the complexity of the password or PIN allowed.", required = true)
|
|
||||||
private boolean requireAlphanumeric;
|
private boolean requireAlphanumeric;
|
||||||
@ApiModelProperty(name = "allowSimple", value = "Set boolean value to allow simple password.", required = true)
|
|
||||||
private boolean allowSimple;
|
private boolean allowSimple;
|
||||||
@ApiModelProperty(name = "enablePassword", value = "Set boolean value enable password.", required = true)
|
|
||||||
private boolean enablePassword;
|
private boolean enablePassword;
|
||||||
@ApiModelProperty(name = "maxInactiveTime", value = "Maximum Inactive time.", required = true)
|
|
||||||
private int maxInactiveTime;
|
private int maxInactiveTime;
|
||||||
|
|
||||||
public int getMaxInactiveTime() {
|
public int getMaxInactiveTime() {
|
||||||
|
|||||||
@ -1,40 +1,31 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.services.syncml.beans;
|
package org.wso2.carbon.mdm.mobileservices.windows.services.syncml.beans;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for contains device active policy.
|
* Class for contains device active policy.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "Profile",
|
|
||||||
description = "This class carries all information related to Profile features.")
|
|
||||||
public class Profile {
|
public class Profile {
|
||||||
|
|
||||||
@ApiModelProperty(name = "featureCode", value = "Profile type operation feature code.", required = true)
|
|
||||||
String featureCode;
|
String featureCode;
|
||||||
@ApiModelProperty(name = "data", value = "Profile type operation data content..", required = true)
|
|
||||||
String data;
|
String data;
|
||||||
@ApiModelProperty(name = "enable", value = "Status of the Profile operation.", required = true)
|
|
||||||
boolean enable;
|
boolean enable;
|
||||||
@ApiModelProperty(name = "compliance", value = "Status of the operation compliance.", required = true)
|
|
||||||
boolean compliance;
|
boolean compliance;
|
||||||
|
|
||||||
public boolean isCompliance() {
|
public boolean isCompliance() {
|
||||||
|
|||||||
@ -1,50 +1,36 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.mdm.mobileservices.windows.services.syncml.beans;
|
package org.wso2.carbon.mdm.mobileservices.windows.services.syncml.beans;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bean for WIFI configurations.
|
* Bean for WIFI configurations.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "Wifi",
|
|
||||||
description = "This class carries all information related to Wifi policy.")
|
|
||||||
public class Wifi extends BasicOperation {
|
public class Wifi extends BasicOperation {
|
||||||
|
|
||||||
@ApiModelProperty(name = "networkName", value = "Name of the Wifi Network.", required = true)
|
|
||||||
private String networkName;
|
private String networkName;
|
||||||
@ApiModelProperty(name = "ssid", value = "SSID.", required = true)
|
|
||||||
private String ssid;
|
private String ssid;
|
||||||
@ApiModelProperty(name = "connectionType", value = "Type of the connection.", required = true)
|
|
||||||
private String connectionType;
|
private String connectionType;
|
||||||
@ApiModelProperty(name = "connectionMode", value = "Connection mode.", required = true)
|
|
||||||
private String connectionMode;
|
private String connectionMode;
|
||||||
@ApiModelProperty(name = "authentication", value = "Authentication type.", required = true)
|
|
||||||
private String authentication;
|
private String authentication;
|
||||||
@ApiModelProperty(name = "encryption", value = "Encryption type.", required = true)
|
|
||||||
private String encryption;
|
private String encryption;
|
||||||
@ApiModelProperty(name = "keyType", value = "Key type.", required = true)
|
|
||||||
private String keyType;
|
private String keyType;
|
||||||
@ApiModelProperty(name = "protection", value = "Protection.", required = true)
|
|
||||||
private String protection;
|
private String protection;
|
||||||
@ApiModelProperty(name = "keyMaterial", value = "Key Material.", required = true)
|
|
||||||
private String keyMaterial;
|
private String keyMaterial;
|
||||||
|
|
||||||
public String getNetworkName() {
|
public String getNetworkName() {
|
||||||
|
|||||||
@ -0,0 +1,100 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.mdm.mobileservices.windows.services.syncml.beans;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class for get windows device properties.
|
||||||
|
*/
|
||||||
|
public class WindowsDevice {
|
||||||
|
|
||||||
|
private String deviceType;
|
||||||
|
private String deviceId;
|
||||||
|
private String osVersion;
|
||||||
|
private String imsi;
|
||||||
|
private String imei;
|
||||||
|
private String manufacturer;
|
||||||
|
private String model;
|
||||||
|
private String user;
|
||||||
|
|
||||||
|
public String getImei() {
|
||||||
|
return imei;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImei(String imei) {
|
||||||
|
this.imei = imei;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeviceType() {
|
||||||
|
return deviceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceType(String deviceType) {
|
||||||
|
this.deviceType = deviceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeviceId() {
|
||||||
|
return deviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceId(String deviceId) {
|
||||||
|
this.deviceId = deviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOsVersion() {
|
||||||
|
return osVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOsVersion(String osVersion) {
|
||||||
|
this.osVersion = osVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getImsi() {
|
||||||
|
return imsi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImsi(String imsi) {
|
||||||
|
this.imsi = imsi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getManufacturer() {
|
||||||
|
return manufacturer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setManufacturer(String manufacturer) {
|
||||||
|
this.manufacturer = manufacturer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModel() {
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModel(String model) {
|
||||||
|
this.model = model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUser(String user) {
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
@ -20,7 +20,6 @@ package org.wso2.carbon.mdm.mobileservices.windows.services.syncml.impl;
|
|||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.json.JSONException;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
import org.wso2.carbon.device.mgt.common.*;
|
import org.wso2.carbon.device.mgt.common.*;
|
||||||
@ -33,13 +32,14 @@ import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.SyncmlMessag
|
|||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.SyncmlOperationException;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.SyncmlOperationException;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsConfigurationException;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsConfigurationException;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.exceptions.WindowsDeviceEnrolmentException;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.common.util.AuthenticationInfo;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.util.DeviceUtil;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.util.DeviceUtil;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.util.WindowsAPIUtils;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.operations.*;
|
import org.wso2.carbon.mdm.mobileservices.windows.operations.*;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.*;
|
import org.wso2.carbon.mdm.mobileservices.windows.operations.util.*;
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.services.syncml.SyncmlService;
|
import org.wso2.carbon.mdm.mobileservices.windows.services.syncml.SyncmlService;
|
||||||
|
import org.wso2.carbon.mdm.mobileservices.windows.services.syncml.beans.WindowsDevice;
|
||||||
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
||||||
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
|
|
||||||
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
||||||
|
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
@ -59,38 +59,32 @@ public class SyncmlServiceImpl implements SyncmlService {
|
|||||||
* This method is used to generate and return Device object from the received information at
|
* This method is used to generate and return Device object from the received information at
|
||||||
* the Syncml step.
|
* the Syncml step.
|
||||||
*
|
*
|
||||||
* @param deviceID - Unique device ID received from the Device
|
* @param windowsDevice Windows specific property object.
|
||||||
* @param osVersion - Device OS version
|
* @return - Generated device object.
|
||||||
* @param imsi - Device IMSI
|
|
||||||
* @param imei - Device IMEI
|
|
||||||
* @param manufacturer - Device Manufacturer name
|
|
||||||
* @param model - Device Model
|
|
||||||
* @return - Generated device object
|
|
||||||
*/
|
*/
|
||||||
private Device generateDevice(String type, String deviceID, String osVersion, String imsi,
|
private Device generateDevice(WindowsDevice windowsDevice) {
|
||||||
String imei, String manufacturer, String model, String user) {
|
|
||||||
|
|
||||||
Device generatedDevice = new Device();
|
Device generatedDevice = new Device();
|
||||||
|
|
||||||
Device.Property OSVersionProperty = new Device.Property();
|
Device.Property OSVersionProperty = new Device.Property();
|
||||||
OSVersionProperty.setName(PluginConstants.SyncML.OS_VERSION);
|
OSVersionProperty.setName(PluginConstants.SyncML.OS_VERSION);
|
||||||
OSVersionProperty.setValue(osVersion);
|
OSVersionProperty.setValue(windowsDevice.getOsVersion());
|
||||||
|
|
||||||
Device.Property IMSEIProperty = new Device.Property();
|
Device.Property IMSEIProperty = new Device.Property();
|
||||||
IMSEIProperty.setName(PluginConstants.SyncML.IMSI);
|
IMSEIProperty.setName(PluginConstants.SyncML.IMSI);
|
||||||
IMSEIProperty.setValue(imsi);
|
IMSEIProperty.setValue(windowsDevice.getImsi());
|
||||||
|
|
||||||
Device.Property IMEIProperty = new Device.Property();
|
Device.Property IMEIProperty = new Device.Property();
|
||||||
IMEIProperty.setName(PluginConstants.SyncML.IMEI);
|
IMEIProperty.setName(PluginConstants.SyncML.IMEI);
|
||||||
IMEIProperty.setValue(imei);
|
IMEIProperty.setValue(windowsDevice.getImei());
|
||||||
|
|
||||||
Device.Property DevManProperty = new Device.Property();
|
Device.Property DevManProperty = new Device.Property();
|
||||||
DevManProperty.setName(PluginConstants.SyncML.VENDOR);
|
DevManProperty.setName(PluginConstants.SyncML.VENDOR);
|
||||||
DevManProperty.setValue(manufacturer);
|
DevManProperty.setValue(windowsDevice.getManufacturer());
|
||||||
|
|
||||||
Device.Property DevModProperty = new Device.Property();
|
Device.Property DevModProperty = new Device.Property();
|
||||||
DevModProperty.setName(PluginConstants.SyncML.MODEL);
|
DevModProperty.setName(PluginConstants.SyncML.MODEL);
|
||||||
DevModProperty.setValue(model);
|
DevModProperty.setValue(windowsDevice.getModel());
|
||||||
|
|
||||||
List<Device.Property> propertyList = new ArrayList<>();
|
List<Device.Property> propertyList = new ArrayList<>();
|
||||||
propertyList.add(OSVersionProperty);
|
propertyList.add(OSVersionProperty);
|
||||||
@ -100,14 +94,14 @@ public class SyncmlServiceImpl implements SyncmlService {
|
|||||||
propertyList.add(DevModProperty);
|
propertyList.add(DevModProperty);
|
||||||
|
|
||||||
EnrolmentInfo enrolmentInfo = new EnrolmentInfo();
|
EnrolmentInfo enrolmentInfo = new EnrolmentInfo();
|
||||||
enrolmentInfo.setOwner(user);
|
enrolmentInfo.setOwner(windowsDevice.getUser());
|
||||||
enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.BYOD);
|
enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.BYOD);
|
||||||
enrolmentInfo.setStatus(EnrolmentInfo.Status.ACTIVE);
|
enrolmentInfo.setStatus(EnrolmentInfo.Status.ACTIVE);
|
||||||
|
|
||||||
generatedDevice.setEnrolmentInfo(enrolmentInfo);
|
generatedDevice.setEnrolmentInfo(enrolmentInfo);
|
||||||
generatedDevice.setDeviceIdentifier(deviceID);
|
generatedDevice.setDeviceIdentifier(windowsDevice.getDeviceId());
|
||||||
generatedDevice.setProperties(propertyList);
|
generatedDevice.setProperties(propertyList);
|
||||||
generatedDevice.setType(type);
|
generatedDevice.setType(windowsDevice.getDeviceType());
|
||||||
|
|
||||||
return generatedDevice;
|
return generatedDevice;
|
||||||
}
|
}
|
||||||
@ -133,48 +127,29 @@ public class SyncmlServiceImpl implements SyncmlService {
|
|||||||
SyncmlDocument syncmlDocument;
|
SyncmlDocument syncmlDocument;
|
||||||
List<Operation> deviceInfoOperations;
|
List<Operation> deviceInfoOperations;
|
||||||
List<? extends Operation> pendingOperations;
|
List<? extends Operation> pendingOperations;
|
||||||
OperationUtils operationUtils = new OperationUtils();
|
OperationHandler operationHandler = new OperationHandler();
|
||||||
DeviceInfo deviceInfo = new DeviceInfo();
|
DeviceInfo deviceInfo = new DeviceInfo();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (SyncmlParser.parseSyncmlPayload(request) != null) {
|
if (SyncmlParser.parseSyncmlPayload(request) != null) {
|
||||||
try {
|
syncmlDocument = SyncmlParser.parseSyncmlPayload(request);
|
||||||
syncmlDocument = SyncmlParser.parseSyncmlPayload(request);
|
|
||||||
} catch (SyncmlMessageFormatException e) {
|
|
||||||
String msg = "Error occurred due to bad syncml format.";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new SyncmlMessageFormatException(msg, e);
|
|
||||||
}
|
|
||||||
SyncmlHeader syncmlHeader = syncmlDocument.getHeader();
|
SyncmlHeader syncmlHeader = syncmlDocument.getHeader();
|
||||||
sessionId = syncmlHeader.getSessionId();
|
sessionId = syncmlHeader.getSessionId();
|
||||||
user = syncmlHeader.getSource().getLocName();
|
user = syncmlHeader.getSource().getLocName();
|
||||||
DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(syncmlHeader.getSource()
|
DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(syncmlHeader.getSource().
|
||||||
.getLocURI());
|
getLocURI());
|
||||||
msgId = syncmlHeader.getMsgID();
|
msgId = syncmlHeader.getMsgID();
|
||||||
if ((PluginConstants.SyncML.SYNCML_FIRST_MESSAGE_ID == msgId) &&
|
if ((PluginConstants.SyncML.SYNCML_FIRST_MESSAGE_ID == msgId) &&
|
||||||
(PluginConstants.SyncML.SYNCML_FIRST_SESSION_ID == sessionId)) {
|
(PluginConstants.SyncML.SYNCML_FIRST_SESSION_ID == sessionId)) {
|
||||||
token = syncmlHeader.getCredential().getData();
|
token = syncmlHeader.getCredential().getData();
|
||||||
CacheEntry cacheToken = (CacheEntry) DeviceUtil.getCacheEntry(token);
|
CacheEntry cacheToken = (CacheEntry) DeviceUtil.getCacheEntry(token);
|
||||||
|
|
||||||
if (cacheToken.getUsername().equals(user)) {
|
if ((cacheToken.getUsername() != null) && (cacheToken.getUsername().equals(user))) {
|
||||||
|
|
||||||
if (enrollDevice(request)) {
|
if (enrollDevice(request)) {
|
||||||
deviceInfoOperations = deviceInfo.getDeviceInfo();
|
deviceInfoOperations = deviceInfo.getDeviceInfo();
|
||||||
try {
|
response = generateReply(syncmlDocument, deviceInfoOperations);
|
||||||
response = generateReply(syncmlDocument, deviceInfoOperations);
|
return Response.status(Response.Status.OK).entity(response).build();
|
||||||
PolicyManagerService policyManagerService = WindowsAPIUtils.getPolicyManagerService();
|
|
||||||
policyManagerService.getEffectivePolicy(deviceIdentifier);
|
|
||||||
return Response.status(Response.Status.OK).entity(response).build();
|
|
||||||
} catch (PolicyManagementException e) {
|
|
||||||
String msg = "Error occurred in while getting effective policy.";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsConfigurationException(msg, e);
|
|
||||||
} catch (SyncmlOperationException e) {
|
|
||||||
String msg = "Error occurred in while generating hash value.";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsOperationException(msg, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
String msg = "Error occurred in device enrollment.";
|
String msg = "Error occurred in device enrollment.";
|
||||||
log.error(msg);
|
log.error(msg);
|
||||||
@ -187,15 +162,8 @@ public class SyncmlServiceImpl implements SyncmlService {
|
|||||||
}
|
}
|
||||||
} else if (PluginConstants.SyncML.SYNCML_SECOND_MESSAGE_ID == msgId &&
|
} else if (PluginConstants.SyncML.SYNCML_SECOND_MESSAGE_ID == msgId &&
|
||||||
PluginConstants.SyncML.SYNCML_FIRST_SESSION_ID == sessionId) {
|
PluginConstants.SyncML.SYNCML_FIRST_SESSION_ID == sessionId) {
|
||||||
|
|
||||||
if (enrollDevice(request)) {
|
if (enrollDevice(request)) {
|
||||||
try {
|
return Response.ok().entity(generateReply(syncmlDocument, null)).build();
|
||||||
return Response.ok().entity(generateReply(syncmlDocument, null)).build();
|
|
||||||
} catch (SyncmlOperationException e) {
|
|
||||||
String msg = "Error occurred in while getting effective feature";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsOperationException(msg, e);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
String msg = "Error occurred in modify enrollment.";
|
String msg = "Error occurred in modify enrollment.";
|
||||||
log.error(msg);
|
log.error(msg);
|
||||||
@ -204,83 +172,21 @@ public class SyncmlServiceImpl implements SyncmlService {
|
|||||||
} else if (sessionId >= PluginConstants.SyncML.SYNCML_SECOND_SESSION_ID) {
|
} else if (sessionId >= PluginConstants.SyncML.SYNCML_SECOND_SESSION_ID) {
|
||||||
if ((syncmlDocument.getBody().getAlert() != null)) {
|
if ((syncmlDocument.getBody().getAlert() != null)) {
|
||||||
if (!syncmlDocument.getBody().getAlert().getData().equals(Constants.DISENROLL_ALERT_DATA)) {
|
if (!syncmlDocument.getBody().getAlert().getData().equals(Constants.DISENROLL_ALERT_DATA)) {
|
||||||
try {
|
pendingOperations = operationHandler.getPendingOperations(syncmlDocument);
|
||||||
pendingOperations = operationUtils.getPendingOperations(syncmlDocument);
|
return Response.ok().entity(generateReply(syncmlDocument, pendingOperations)).build();
|
||||||
return Response.ok().entity(generateReply(syncmlDocument, pendingOperations)).build();
|
|
||||||
} catch (OperationManagementException e) {
|
|
||||||
String msg = "Cannot access operation management service.";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsOperationException(msg, e);
|
|
||||||
} catch (DeviceManagementException e) {
|
|
||||||
String msg = "Cannot access Device management service.";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsOperationException(msg, e);
|
|
||||||
} catch (FeatureManagementException e) {
|
|
||||||
String msg = "Error occurred in getting effective features. ";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsOperationException(msg, e);
|
|
||||||
} catch (PolicyComplianceException e) {
|
|
||||||
String msg = "Error occurred in setting policy compliance.";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsConfigurationException(msg, e);
|
|
||||||
} catch (NotificationManagementException e) {
|
|
||||||
String msg = "Error occurred in while getting notification service";
|
|
||||||
throw new WindowsOperationException(msg, e);
|
|
||||||
} catch (SyncmlOperationException e) {
|
|
||||||
String msg = "Error occurred in while encoding hash value.";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsOperationException(msg, e);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
if (WindowsAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier) != null) {
|
||||||
if (WindowsAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier) != null) {
|
WindowsAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier);
|
||||||
WindowsAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier);
|
return Response.ok().entity(generateReply(syncmlDocument, null)).build();
|
||||||
return Response.ok().entity(generateReply(syncmlDocument, null)).build();
|
} else {
|
||||||
} else {
|
String msg = "Enrolled device can not be found in the server.";
|
||||||
String msg = "Enrolled device can not be found in the server.";
|
log.error(msg);
|
||||||
log.error(msg);
|
return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
|
||||||
return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
|
|
||||||
}
|
|
||||||
} catch (DeviceManagementException e) {
|
|
||||||
String msg = "Failure occurred in dis-enrollment flow.";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsOperationException(msg, e);
|
|
||||||
} catch (SyncmlOperationException e) {
|
|
||||||
String msg = "Error occurred in while generating hash value.";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsOperationException(msg, e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
pendingOperations = operationHandler.getPendingOperations(syncmlDocument);
|
||||||
pendingOperations = operationUtils.getPendingOperations(syncmlDocument);
|
return Response.ok().entity(generateReply(syncmlDocument, pendingOperations)).build();
|
||||||
return Response.ok().entity(generateReply(syncmlDocument, pendingOperations))
|
|
||||||
.build();
|
|
||||||
} catch (OperationManagementException e) {
|
|
||||||
String msg = "Cannot access operation management service.";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsOperationException(msg, e);
|
|
||||||
} catch (DeviceManagementException e) {
|
|
||||||
String msg = "Cannot access Device management service.";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsOperationException(msg, e);
|
|
||||||
} catch (FeatureManagementException e) {
|
|
||||||
String msg = "Error occurred in getting effective features. ";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsConfigurationException(msg, e);
|
|
||||||
} catch (PolicyComplianceException e) {
|
|
||||||
String msg = "Error occurred in setting policy compliance.";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsConfigurationException(msg, e);
|
|
||||||
} catch (NotificationManagementException e) {
|
|
||||||
String msg = "Error occurred in while getting notification service.";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsOperationException(msg, e);
|
|
||||||
} catch (SyncmlOperationException e) {
|
|
||||||
String msg = "Error occurred in while getting effective feature.";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsConfigurationException(msg, e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String msg = "Failure occurred in Device request message.";
|
String msg = "Failure occurred in Device request message.";
|
||||||
@ -289,7 +195,19 @@ public class SyncmlServiceImpl implements SyncmlService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SyncmlMessageFormatException e) {
|
} catch (SyncmlMessageFormatException e) {
|
||||||
String msg = "Error occurred in parsing syncml request.";
|
String msg = "Error occurred while parsing syncml request.";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new WindowsOperationException(msg, e);
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
String msg = "Cannot access operation management service.";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new WindowsOperationException(msg, e);
|
||||||
|
} catch (SyncmlOperationException e) {
|
||||||
|
String msg = "Error occurred while getting effective feature.";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new WindowsConfigurationException(msg, e);
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String msg = "Failure occurred in dis-enrollment flow.";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new WindowsOperationException(msg, e);
|
throw new WindowsOperationException(msg, e);
|
||||||
}
|
}
|
||||||
@ -314,7 +232,7 @@ public class SyncmlServiceImpl implements SyncmlService {
|
|||||||
String devMan;
|
String devMan;
|
||||||
String devMod;
|
String devMod;
|
||||||
String devLang;
|
String devLang;
|
||||||
String vender;
|
String vendor;
|
||||||
String macAddress;
|
String macAddress;
|
||||||
String resolution;
|
String resolution;
|
||||||
String modVersion;
|
String modVersion;
|
||||||
@ -328,40 +246,51 @@ public class SyncmlServiceImpl implements SyncmlService {
|
|||||||
syncmlDocument = SyncmlParser.parseSyncmlPayload(request);
|
syncmlDocument = SyncmlParser.parseSyncmlPayload(request);
|
||||||
msgID = syncmlDocument.getHeader().getMsgID();
|
msgID = syncmlDocument.getHeader().getMsgID();
|
||||||
if (msgID == PluginConstants.SyncML.SYNCML_FIRST_MESSAGE_ID) {
|
if (msgID == PluginConstants.SyncML.SYNCML_FIRST_MESSAGE_ID) {
|
||||||
Replace replace = syncmlDocument.getBody().getReplace();
|
ReplaceTag replace = syncmlDocument.getBody().getReplace();
|
||||||
List<Item> itemList = replace.getItems();
|
List<ItemTag> itemList = replace.getItems();
|
||||||
devID = itemList.get(PluginConstants.SyncML.DEVICE_ID_POSITION).getData();
|
devID = itemList.get(PluginConstants.SyncML.DEVICE_ID_POSITION).getData();
|
||||||
devMan = itemList.get(PluginConstants.SyncML.DEVICE_MAN_POSITION).getData();
|
devMan = itemList.get(PluginConstants.SyncML.DEVICE_MAN_POSITION).getData();
|
||||||
devMod = itemList.get(PluginConstants.SyncML.DEVICE_MODEL_POSITION).getData();
|
devMod = itemList.get(PluginConstants.SyncML.DEVICE_MODEL_POSITION).getData();
|
||||||
modVersion = itemList.get(PluginConstants.SyncML.DEVICE_MOD_VER_POSITION).getData();
|
modVersion = itemList.get(PluginConstants.SyncML.DEVICE_MOD_VER_POSITION).getData();
|
||||||
devLang = itemList.get(PluginConstants.SyncML.DEVICE_LANG_POSITION).getData();
|
devLang = itemList.get(PluginConstants.SyncML.DEVICE_LANG_POSITION).getData();
|
||||||
user = syncmlDocument.getHeader().getSource().getLocName();
|
user = syncmlDocument.getHeader().getSource().getLocName();
|
||||||
|
AuthenticationInfo authenticationInfo = new AuthenticationInfo();
|
||||||
|
authenticationInfo.setUsername(user);
|
||||||
|
WindowsAPIUtils.startTenantFlow(authenticationInfo);
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug(
|
log.debug(
|
||||||
"OS Version:" + modVersion + ", DevID: " + devID + ", DevMan: " + devMan +
|
"OS Version:" + modVersion + ", DevID: " + devID + ", DevMan: " + devMan +
|
||||||
", DevMod: " + devMod + ", DevLang: " + devLang);
|
", DevMod: " + devMod + ", DevLang: " + devLang);
|
||||||
}
|
}
|
||||||
Device generateDevice = generateDevice(DeviceManagementConstants.MobileDeviceTypes.
|
WindowsDevice windowsDevice = new WindowsDevice();
|
||||||
MOBILE_DEVICE_TYPE_WINDOWS, devID, modVersion, imsi, imei, devMan, devMod, user);
|
windowsDevice.setDeviceType(DeviceManagementConstants.MobileDeviceTypes.
|
||||||
status = WindowsAPIUtils.getDeviceManagementService().enrollDevice(generateDevice);
|
MOBILE_DEVICE_TYPE_WINDOWS);
|
||||||
WindowsAPIUtils.startTenantFlow(user);
|
windowsDevice.setDeviceId(devID);
|
||||||
|
windowsDevice.setImei(imei);
|
||||||
|
windowsDevice.setImsi(imsi);
|
||||||
|
windowsDevice.setManufacturer(devMan);
|
||||||
|
windowsDevice.setOsVersion(modVersion);
|
||||||
|
windowsDevice.setModel(devMod);
|
||||||
|
windowsDevice.setUser(user);
|
||||||
|
Device device = generateDevice(windowsDevice);
|
||||||
|
status = WindowsAPIUtils.getDeviceManagementService().enrollDevice(device);
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
} else if (msgID == PluginConstants.SyncML.SYNCML_SECOND_MESSAGE_ID) {
|
} else if (msgID == PluginConstants.SyncML.SYNCML_SECOND_MESSAGE_ID) {
|
||||||
List<Item> itemList = syncmlDocument.getBody().getResults().getItem();
|
|
||||||
|
List<ItemTag> itemList = syncmlDocument.getBody().getResults().getItem();
|
||||||
osVersion = itemList.get(PluginConstants.SyncML.OSVERSION_POSITION).getData();
|
osVersion = itemList.get(PluginConstants.SyncML.OSVERSION_POSITION).getData();
|
||||||
imsi = itemList.get(PluginConstants.SyncML.IMSI_POSITION).getData();
|
imsi = itemList.get(PluginConstants.SyncML.IMSI_POSITION).getData();
|
||||||
imei = itemList.get(PluginConstants.SyncML.IMEI_POSITION).getData();
|
imei = itemList.get(PluginConstants.SyncML.IMEI_POSITION).getData();
|
||||||
vender = itemList.get(PluginConstants.SyncML.VENDER_POSITION).getData();
|
vendor = itemList.get(PluginConstants.SyncML.VENDOR_POSITION).getData();
|
||||||
devMod = itemList.get(PluginConstants.SyncML.MODEL_POSITION).getData();
|
devMod = itemList.get(PluginConstants.SyncML.MODEL_POSITION).getData();
|
||||||
macAddress = itemList.get(PluginConstants.SyncML.MACADDRESS_POSITION).getData();
|
macAddress = itemList.get(PluginConstants.SyncML.MAC_ADDRESS_POSITION).getData();
|
||||||
resolution = itemList.get(PluginConstants.SyncML.RESOLUTION_POSITION).getData();
|
resolution = itemList.get(PluginConstants.SyncML.RESOLUTION_POSITION).getData();
|
||||||
deviceName = itemList.get(PluginConstants.SyncML.DEVICE_NAME_POSITION).getData();
|
deviceName = itemList.get(PluginConstants.SyncML.DEVICE_NAME_POSITION).getData();
|
||||||
DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(syncmlDocument.
|
DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(syncmlDocument.
|
||||||
getHeader().getSource().getLocURI());
|
getHeader().getSource().getLocURI());
|
||||||
Device existingDevice = WindowsAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier);
|
Device existingDevice = WindowsAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier);
|
||||||
|
|
||||||
if (!existingDevice.getProperties().isEmpty()) {
|
if (!existingDevice.getProperties().isEmpty()) {
|
||||||
List<Device.Property> existingProperties = new ArrayList<>();
|
List<Device.Property> existingProperties = new ArrayList<>();
|
||||||
|
|
||||||
@ -380,10 +309,10 @@ public class SyncmlServiceImpl implements SyncmlService {
|
|||||||
imsiProperty.setValue(imsi);
|
imsiProperty.setValue(imsi);
|
||||||
existingProperties.add(imsiProperty);
|
existingProperties.add(imsiProperty);
|
||||||
|
|
||||||
Device.Property venderProperty = new Device.Property();
|
Device.Property vendorProperty = new Device.Property();
|
||||||
venderProperty.setName(PluginConstants.SyncML.VENDOR);
|
vendorProperty.setName(PluginConstants.SyncML.VENDOR);
|
||||||
venderProperty.setValue(vender);
|
vendorProperty.setValue(vendor);
|
||||||
existingProperties.add(venderProperty);
|
existingProperties.add(vendorProperty);
|
||||||
|
|
||||||
Device.Property macAddressProperty = new Device.Property();
|
Device.Property macAddressProperty = new Device.Property();
|
||||||
macAddressProperty.setName(PluginConstants.SyncML.MAC_ADDRESS);
|
macAddressProperty.setName(PluginConstants.SyncML.MAC_ADDRESS);
|
||||||
@ -416,17 +345,9 @@ public class SyncmlServiceImpl implements SyncmlService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
String msg = "Failure occurred in enrolling device.";
|
throw new WindowsDeviceEnrolmentException("Failure occurred while enrolling device.", e);
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsDeviceEnrolmentException(msg, e);
|
|
||||||
} catch (SyncmlMessageFormatException e) {
|
|
||||||
String msg = "Error occurred in bad format of the syncml payload.";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsOperationException(msg, e);
|
|
||||||
} catch (PolicyManagementException e) {
|
} catch (PolicyManagementException e) {
|
||||||
String msg = "Error occurred in getting effective policy.";
|
throw new WindowsOperationException("Error occurred while getting effective policy.", e);
|
||||||
log.error(msg, e);
|
|
||||||
throw new WindowsOperationException(msg, e);
|
|
||||||
} finally {
|
} finally {
|
||||||
PrivilegedCarbonContext.endTenantFlow();
|
PrivilegedCarbonContext.endTenantFlow();
|
||||||
}
|
}
|
||||||
@ -436,11 +357,10 @@ public class SyncmlServiceImpl implements SyncmlService {
|
|||||||
/**
|
/**
|
||||||
* Generate Device payloads.
|
* Generate Device payloads.
|
||||||
*
|
*
|
||||||
* @param syncmlDocument parsed syncml payload from the syncml engine.
|
* @param syncmlDocument Parsed syncml payload from the syncml engine.
|
||||||
* @param operations operations for generate payload.
|
* @param operations Operations for generate payload.
|
||||||
* @return String type syncml payload.
|
* @return String type syncml payload.
|
||||||
* @throws WindowsOperationException
|
* @throws WindowsOperationException
|
||||||
* @throws JSONException
|
|
||||||
* @throws PolicyManagementException
|
* @throws PolicyManagementException
|
||||||
* @throws org.wso2.carbon.policy.mgt.common.FeatureManagementException
|
* @throws org.wso2.carbon.policy.mgt.common.FeatureManagementException
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
@ -20,11 +20,7 @@ package org.wso2.carbon.mdm.mobileservices.windows.services.wstep.beans;
|
|||||||
|
|
||||||
import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants;
|
import org.wso2.carbon.mdm.mobileservices.windows.common.PluginConstants;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.*;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
|
||||||
import javax.xml.bind.annotation.XmlAttribute;
|
|
||||||
import javax.xml.bind.annotation.XmlType;
|
|
||||||
import javax.xml.bind.annotation.XmlValue;
|
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
@XmlType(name = "BinarySecurityToken", namespace = PluginConstants.WS_SECURITY_TARGET_NAMESPACE,
|
@XmlType(name = "BinarySecurityToken", namespace = PluginConstants.WS_SECURITY_TARGET_NAMESPACE,
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user