diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java index 839658ec2a..a3f8608de4 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java @@ -218,7 +218,7 @@ public class APIPublisherUtil { JsonObject httpVerb = new JsonObject(); httpVerb.add("responses", response); - httpVerb.addProperty("x-auth-type", "Application%20%26%20Application%20User"); + httpVerb.addProperty("x-auth-type", uriTemplate.getAuthType()); httpVerb.addProperty("x-throttling-tier", "Unlimited"); if (uriTemplate.getScope() != null) { httpVerb.addProperty("x-scope", uriTemplate.getScope().getKey()); @@ -289,5 +289,6 @@ public class APIPublisherUtil { } } } + apiConfig.setUriTemplates(templates); } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java index 52dc147790..dfc8dd7454 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java @@ -53,7 +53,7 @@ public class AnnotationProcessor { private static final Log log = LogFactory.getLog(AnnotationProcessor.class); - private static final String AUTH_TYPE = "Any"; + private static final String AUTH_TYPE = "Application & Application User"; private static final String STRING_ARR = "string_arr"; private static final String STRING = "string"; private static final String PACKAGE_ORG_APACHE = "org.apache"; diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Claimable.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Claimable.java new file mode 100644 index 0000000000..661778e62d --- /dev/null +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Claimable.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2017, 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.device.mgt.extensions.device.type.deployer.config; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; + + +/** + *
Java class for DeviceDetails complex type. + * + *
The following schema fragment specifies the expected content contained within this class. + * + *
+ * <complexType name="DeviceDetails"> + * <simpleContent> + * <extension base="<http://www.w3.org/2001/XMLSchema>string"> + * <attribute name="table-id" type="{http://www.w3.org/2001/XMLSchema}string" /> + * </extension> + * </simpleContent> + * </complexType> + *+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "Claimable", propOrder = { + "value" +}) +public class Claimable { + + @XmlValue + protected String value; + @XmlAttribute(name = "enabled") + protected boolean enabled; + + /** + * Gets the value of the value property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setValue(String value) { + this.value = value; + } + + /** + * Gets the value of the enabled property. + * + * @return + * possible object is + * {@link String } + * + */ + public boolean isEnabled() { + return enabled; + } + + /** + * Sets the value of the enabled property. + * + * @param enabled + * allowed object is + * {@link String } + * + */ + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + +} diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceTypeConfiguration.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceTypeConfiguration.java index 79ee14ba2d..00d20b4ebe 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceTypeConfiguration.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceTypeConfiguration.java @@ -53,6 +53,8 @@ public class DeviceTypeConfiguration { @XmlElement(name = "DeviceDetails", required = true) protected DeviceDetails deviceDetails; + @XmlElement(name = "Claimable", required = true) + protected Claimable claimable; @XmlElement(name = "Features", required = true) protected Features features; @XmlElement(name = "ProvisioningConfig", required = true) @@ -131,6 +133,27 @@ public class DeviceTypeConfiguration { this.deviceDetails = value; } + /** + * Gets the value of the Claimable property. + * + * @return possible object is + * {@link DeviceDetails } + */ + public Claimable getClaimable() { + return claimable; + } + + /** + * Sets the value of the deviceDetails property. + * + * @param value allowed object is + * {@link DeviceDetails } + */ + public void setClaimable(Claimable value) { + this.claimable = value; + } + + /** * Gets the value of the policyMonitoring property. * diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManager.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManager.java index eba2f18721..98c5ef2870 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManager.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManager.java @@ -65,6 +65,7 @@ public class DeviceTypeManager implements DeviceManager { private LicenseManager licenseManager; private boolean propertiesExist; private boolean requiredDeviceTypeAuthorization; + private boolean claimable; private FeatureManager featureManager; @@ -101,8 +102,13 @@ public class DeviceTypeManager implements DeviceManager { String msg = "Error occurred while adding default license for " + deviceType + " devices"; throw new DeviceTypeDeployerFileException(msg, e); } + claimable = false; + if (deviceTypeConfiguration.getClaimable() != null ) { + claimable = deviceTypeConfiguration.getClaimable().isEnabled(); + } DeviceDetails deviceDetails = deviceTypeConfiguration.getDeviceDetails(); + if (deviceDetails != null) { //Check whether device dao definition exist. @@ -341,7 +347,7 @@ public class DeviceTypeManager implements DeviceManager { @Override public boolean isClaimable(DeviceIdentifier deviceIdentifier) throws DeviceManagementException { - return false; + return claimable; } @Override diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml index 6542d9629b..414bcaa8dd 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml @@ -36,6 +36,8 @@ +