forked from community/device-mgt-core
parent
a9a0ac5899
commit
9ad8d6eab9
@ -1,88 +0,0 @@
|
||||
/*
|
||||
* 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.device.mgt.common;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class License {
|
||||
|
||||
private String name;
|
||||
private String version;
|
||||
private String language;
|
||||
private String provider;
|
||||
private Date validTo;
|
||||
private Date validFrom;
|
||||
private String text;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
public String getProvider() {
|
||||
return provider;
|
||||
}
|
||||
|
||||
public void setProvider(String provider) {
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
public Date getValidTo() {
|
||||
return validTo;
|
||||
}
|
||||
|
||||
public void setValidTo(Date validTo) {
|
||||
this.validTo = validTo;
|
||||
}
|
||||
|
||||
public Date getValidFrom() {
|
||||
return validFrom;
|
||||
}
|
||||
|
||||
public void setValidFrom(Date validFrom) {
|
||||
this.validFrom = validFrom;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* *
|
||||
* * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
* *
|
||||
* * Licensed 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.core.internal;
|
||||
|
||||
import org.apache.axis2.context.ConfigurationContext;
|
||||
import org.wso2.carbon.utils.Axis2ConfigurationContextObserver;
|
||||
|
||||
public class DeviceManagementAxis2ConfigurationObserver implements Axis2ConfigurationContextObserver {
|
||||
|
||||
@Override
|
||||
public void creatingConfigurationContext(int i) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createdConfigurationContext(ConfigurationContext configurationContext) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void terminatingConfigurationContext(ConfigurationContext configurationContext) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void terminatedConfigurationContext(ConfigurationContext configurationContext) {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* *
|
||||
* * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
* *
|
||||
* * Licensed 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.core.internal;
|
||||
|
||||
import org.apache.axis2.context.ConfigurationContext;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.core.LicenseManagementException;
|
||||
import org.wso2.carbon.device.mgt.core.util.LicenseManagerUtil;
|
||||
import org.wso2.carbon.utils.Axis2ConfigurationContextObserver;
|
||||
|
||||
public class LicenseManagementAxis2ConfigurationObserver implements Axis2ConfigurationContextObserver {
|
||||
|
||||
private static final Log log = LogFactory.getLog(LicenseManagementAxis2ConfigurationObserver.class);
|
||||
|
||||
@Override
|
||||
public void creatingConfigurationContext(int tenantId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createdConfigurationContext(ConfigurationContext configurationContext) {
|
||||
try {
|
||||
LicenseManagerUtil.addDefaultLicenses(null);
|
||||
} catch (LicenseManagementException e) {
|
||||
log.error("Error occurred while adding default license configurations of the tenant '");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void terminatingConfigurationContext(ConfigurationContext configurationContext) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void terminatedConfigurationContext(ConfigurationContext configurationContext) {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* *
|
||||
* * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
* *
|
||||
* * Licensed 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.core.util;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
||||
import org.wso2.carbon.device.mgt.core.LicenseManagementException;
|
||||
import org.wso2.carbon.device.mgt.core.config.license.License;
|
||||
import org.wso2.carbon.device.mgt.core.config.license.LicenseConfig;
|
||||
import org.wso2.carbon.device.mgt.core.license.mgt.GenericArtifactManagerFactory;
|
||||
import org.wso2.carbon.governance.api.common.GovernanceArtifactFilter;
|
||||
import org.wso2.carbon.governance.api.common.GovernanceArtifactManager;
|
||||
import org.wso2.carbon.governance.api.common.dataobjects.GovernanceArtifact;
|
||||
import org.wso2.carbon.governance.api.exception.GovernanceException;
|
||||
import org.wso2.carbon.governance.api.generic.GenericArtifactFilter;
|
||||
import org.wso2.carbon.governance.api.generic.GenericArtifactManager;
|
||||
import org.wso2.carbon.governance.api.generic.dataobjects.GenericArtifact;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import java.util.Date;
|
||||
|
||||
public class LicenseManagerUtil {
|
||||
|
||||
public static void addDefaultLicenses(LicenseConfig licenseConfig) throws LicenseManagementException {
|
||||
try {
|
||||
GenericArtifactManager artifactManager =
|
||||
GenericArtifactManagerFactory.getTenantAwareGovernanceArtifactManager();
|
||||
for (License license : licenseConfig.getLicenses()) {
|
||||
/* TODO: This method call can be expensive as it appears to do a complete table scan to check the existence
|
||||
* of an artifact for each license configuration. Need to find the optimal way of doing this */
|
||||
if (LicenseManagerUtil.isArtifactExists(artifactManager, license)) {
|
||||
continue;
|
||||
}
|
||||
GenericArtifact artifact =
|
||||
artifactManager.newGovernanceArtifact(new QName("http://www.wso2.com",
|
||||
DeviceManagementConstants.LicenseProperties.LICENSE_REGISTRY_KEY));
|
||||
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.OVERVIEW_NAME, license.getName());
|
||||
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.OVERVIEW_VERSION,
|
||||
license.getVersion());
|
||||
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.OVERVIEW_LANGUAGE,
|
||||
license.getLanguage());
|
||||
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.OVERVIEW_PROVIDER,
|
||||
license.getProvider());
|
||||
Date validTo = license.getValidTo();
|
||||
if (validTo != null) {
|
||||
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.VALID_TO, validTo.toString());
|
||||
}
|
||||
Date validFrom = license.getValidFrom();
|
||||
if (validFrom != null) {
|
||||
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.VALID_FROM, validFrom.toString());
|
||||
}
|
||||
artifact.setAttribute(DeviceManagementConstants.LicenseProperties.LICENSE, license.getText());
|
||||
artifactManager.addGenericArtifact(artifact);
|
||||
}
|
||||
} catch (GovernanceException e) {
|
||||
throw new LicenseManagementException("Error occurred while initializing default licences", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isArtifactExists(final GenericArtifactManager artifactManager,
|
||||
final License license) throws GovernanceException {
|
||||
GovernanceArtifact[] artifacts = artifactManager.findGenericArtifacts(new GenericArtifactFilter() {
|
||||
@Override
|
||||
public boolean matches(GenericArtifact artifact) throws GovernanceException {
|
||||
return artifact.getAttribute(DeviceManagementConstants.LicenseProperties.OVERVIEW_NAME).equals(
|
||||
license.getName());
|
||||
}
|
||||
});
|
||||
return (artifacts != null && artifacts.length > 0);
|
||||
}
|
||||
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
~
|
||||
~ 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.
|
||||
~
|
||||
-->
|
||||
|
||||
<DefaultLicense>
|
||||
<License>
|
||||
<provider>wso2</provider>
|
||||
<name>android</name>
|
||||
<version>1.0.0</version>
|
||||
<language>1.0.0</language>
|
||||
<validFrom>01-01-2014</validFrom>
|
||||
<validTo>31-12-2035</validTo>
|
||||
<license><![CDATA[Test License]]></license>
|
||||
</License>
|
||||
<License>
|
||||
<provider>wso2</provider>
|
||||
<name>ios</name>
|
||||
<version>1.0.0</version>
|
||||
<language>1.0.0</language>
|
||||
<validFrom>01-01-2014</validFrom>
|
||||
<validTo>31-12-2035</validTo>
|
||||
<license><![CDATA[IOS License]]></license>
|
||||
</License>
|
||||
<License>
|
||||
<provider>wso2</provider>
|
||||
<name>windows</name>
|
||||
<version>1.0.0</version>
|
||||
<language>1.0.0</language>
|
||||
<validFrom>01-01-2014</validFrom>
|
||||
<validTo>31-12-2035</validTo>
|
||||
<license><![CDATA[Windows License]]></license>
|
||||
</License>
|
||||
</DefaultLicense>
|
@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
~
|
||||
~ 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.
|
||||
~
|
||||
-->
|
||||
|
||||
<LicenseConfig>
|
||||
<Licenses>
|
||||
<License>
|
||||
<Provider>wso2</Provider>
|
||||
<Name>android</Name>
|
||||
<Version>1.0.0</Version>
|
||||
<Language>1.0.0</Language>
|
||||
<ValidFrom>01-01-2014</ValidFrom>
|
||||
<ValidTo>31-12-2035</ValidTo>
|
||||
<Text><![CDATA[Test License]]></Text>
|
||||
</License>
|
||||
<License>
|
||||
<Provider>wso2</Provider>
|
||||
<Name>ios</Name>
|
||||
<Version>1.0.0</Version>
|
||||
<Language>1.0.0</Language>
|
||||
<ValidFrom>01-01-2014</ValidFrom>
|
||||
<ValidTo>31-12-2035</ValidTo>
|
||||
<Text><![CDATA[IOS License]]></Text>
|
||||
</License>
|
||||
<License>
|
||||
<Provider>wso2</Provider>
|
||||
<Name>windows</Name>
|
||||
<Version>1.0.0</Version>
|
||||
<Language>1.0.0</Language>
|
||||
<ValidFrom>01-01-2014</ValidFrom>
|
||||
<ValidTo>31-12-2035</ValidTo>
|
||||
<Text><![CDATA[Windows License]]></Text>
|
||||
</License>
|
||||
</Licenses>
|
||||
</LicenseConfig>
|
@ -1,4 +1,5 @@
|
||||
instructions.configure = \
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/conf/cdm-config.xml,target:${installFolder}/../../conf/cdm-config.xml,overwrite:true);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/conf/license-config.xml,target:${installFolder}/../../conf/etc/license-config.xml,overwrite:true);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/dbscripts/cdm,target:${installFolder}/../../../dbscripts/cdm,overwrite:true);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/rxts/license.rxt,target:${installFolder}/../../../repository/resources/rxts/license.rxt,overwrite:true);\
|
Loading…
Reference in new issue