License Management

4.x.x
manoj 10 years ago
parent 0e96d82968
commit f4e9f1f15b

@ -0,0 +1,62 @@
/*
*
* 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.device.mgt.common;
public class LicenseManagementException extends Exception{
private static final long serialVersionUID = 8606378077242945475L;
private String errorMessage;
public static long getSerialVersionUID() {
return serialVersionUID;
}
public LicenseManagementException(String msg, Exception nestedEx) {
super(msg, nestedEx);
setErrorMessage(msg);
}
public LicenseManagementException(String message, Throwable cause) {
super(message, cause);
setErrorMessage(message);
}
public LicenseManagementException(String msg) {
super(msg);
setErrorMessage(msg);
}
public LicenseManagementException() {
super();
}
public LicenseManagementException(Throwable cause) {
super(cause);
}
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
}

@ -1,30 +1,30 @@
/*
*
* * 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.
* /
* 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.device.mgt.core;
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
public class LicenseManager {
import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
/* public void addLicense(DeviceType deviceType,String langCode, String
);*/
public interface LicenseManager {
public License getLicense(DeviceManagementConstants.MobileDeviceTypes deviceType,
DeviceManagementConstants.LanguageCodes languageCodes) throws LicenseManagementException;
}

@ -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.device.mgt.core;
import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
public class LicenseManagerImpl implements LicenseManager{
@Override
public License getLicense(DeviceManagementConstants.MobileDeviceTypes deviceType,
DeviceManagementConstants.LanguageCodes languageCodes) throws LicenseManagementException {
return null;
}
}

@ -0,0 +1,63 @@
/*
*
* 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.device.mgt.core.internal;
import org.wso2.carbon.device.mgt.core.LicenseManager;
import org.wso2.carbon.user.core.service.RealmService;
import org.wso2.carbon.user.core.tenant.TenantManager;
public class LicenseManagementDataHolder {
private RealmService realmService;
private TenantManager tenantManager;
private LicenseManager licenseManager;
private static LicenseManagementDataHolder thisInstance = new LicenseManagementDataHolder();
public RealmService getRealmService() {
return realmService;
}
public void setRealmService(RealmService realmService) {
this.realmService = realmService;
}
public TenantManager getTenantManager() {
return tenantManager;
}
public void setTenantManager(TenantManager tenantManager) {
this.tenantManager = tenantManager;
}
private LicenseManagementDataHolder() {
}
public static LicenseManagementDataHolder getInstance() {
return thisInstance;
}
public LicenseManager getLicenseManager() {
return licenseManager;
}
public void setLicenseManager(LicenseManager licenseManager) {
this.licenseManager = licenseManager;
}
}

@ -0,0 +1,83 @@
/*
*
* 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.device.mgt.core.internal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.device.mgt.core.LicenseManager;
import org.wso2.carbon.device.mgt.core.LicenseManagerImpl;
import org.wso2.carbon.device.mgt.core.service.LicenseManagementService;
import org.wso2.carbon.user.core.service.RealmService;
/**
* @scr.component name="org.wso2.carbon.license.manager" immediate="true"
* @scr.reference name="user.realmservice.default"
* interface="org.wso2.carbon.user.core.service.RealmService"
* cardinality="1..1"
* policy="dynamic"
* bind="setRealmService"
* unbind="unsetRealmService"
*/
public class LicenseManagementServiceComponent {
private static Log log = LogFactory.getLog(LicenseManagementServiceComponent.class);
protected void activate(ComponentContext componentContext) {
if (log.isDebugEnabled()) {
log.debug("Initializing license management core bundle");
}
LicenseManager licenseManager = new LicenseManagerImpl();
LicenseManagementDataHolder.getInstance().setLicenseManager(licenseManager);
if (log.isDebugEnabled()) {
log.debug("Registering OSGi service LicenseManagementService");
}
BundleContext bundleContext = componentContext.getBundleContext();
bundleContext.registerService(LicenseManagementService.class.getName(), new LicenseManagementService(), null);
if (log.isDebugEnabled()) {
log.debug("License management core bundle has been successfully initialized");
}
}
/**
* Sets Realm Service.
* @param realmService An instance of RealmService
*/
protected void setRealmService(RealmService realmService) {
if (log.isDebugEnabled()) {
log.debug("Setting Realm Service");
}
LicenseManagementDataHolder.getInstance().setRealmService(realmService);
}
/**
* Unsets Realm Service.
* @param realmService An instance of RealmService
*/
protected void unsetRealmService(RealmService realmService) {
if (log.isDebugEnabled()) {
log.debug("Unsetting Realm Service");
}
LicenseManagementDataHolder.getInstance().setRealmService(null);
}
}

@ -0,0 +1,38 @@
/*
*
* 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.device.mgt.core.service;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.common.License;
import org.wso2.carbon.device.mgt.common.LicenseManagementException;
import org.wso2.carbon.device.mgt.core.LicenseManager;
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import org.wso2.carbon.device.mgt.core.internal.LicenseManagementDataHolder;
public class LicenseManagementService implements LicenseManager{
@Override
public License getLicense(DeviceManagementConstants.MobileDeviceTypes deviceType,
DeviceManagementConstants.LanguageCodes languageCode) throws LicenseManagementException {
return LicenseManagementDataHolder.getInstance().getLicenseManager().getLicense(deviceType, languageCode);
}
}
Loading…
Cancel
Save