forked from community/device-mgt-core
parent
f83d919ed1
commit
38e09d49bb
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.policy.mgt.common;
|
|
||||||
|
|
||||||
import java.sql.Date;
|
|
||||||
|
|
||||||
public class PolicyDates {
|
|
||||||
|
|
||||||
private Date startDate; // Start date to apply the policy
|
|
||||||
private Date endDate; // After this date policy will not be applied.
|
|
||||||
|
|
||||||
public Date getStartDate() {
|
|
||||||
return startDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStartDate(Date startDate) {
|
|
||||||
this.startDate = startDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getEndDate() {
|
|
||||||
return endDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEndDate(Date endDate) {
|
|
||||||
this.endDate = endDate;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.policy.mgt.common;
|
|
||||||
|
|
||||||
public class PolicyLocations {
|
|
||||||
|
|
||||||
private String latitude; // Latitude
|
|
||||||
private String longitude; // Longitude
|
|
||||||
|
|
||||||
public String getLatitude() {
|
|
||||||
return latitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLatitude(String latitude) {
|
|
||||||
this.latitude = latitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLongitude() {
|
|
||||||
return longitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLongitude(String longitude) {
|
|
||||||
this.longitude = longitude;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.policy.mgt.common;
|
|
||||||
|
|
||||||
import java.sql.Date;
|
|
||||||
|
|
||||||
public class PolicyTimes {
|
|
||||||
|
|
||||||
private int startTime; // Start time to apply the policy.
|
|
||||||
private int endTime; // After this time policy will not be applied
|
|
||||||
|
|
||||||
public int getStartTime() {
|
|
||||||
return startTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStartTime(int startTime) {
|
|
||||||
this.startTime = startTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getEndTime() {
|
|
||||||
return endTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEndTime(int endTime) {
|
|
||||||
this.endTime = endTime;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* 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.policy.mgt.core.impl;
|
||||||
|
|
||||||
|
import org.wso2.carbon.policy.mgt.common.Policy;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface PolicyFilter {
|
||||||
|
|
||||||
|
void filterRolesBasedPolicies(String roles[], List<Policy> policies);
|
||||||
|
|
||||||
|
void filterOwnershipTypeBasedPolicies(String ownershipType, List<Policy> policies);
|
||||||
|
|
||||||
|
void filterDeviceTypeBasedPolicies(String deviceType, List<Policy> policies);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -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.policy.mgt.core.impl;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.wso2.carbon.policy.mgt.common.Policy;
|
||||||
|
import org.wso2.carbon.policy.mgt.core.util.PolicyManagementConstants;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PolicyFilterImpl implements PolicyFilter {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(PolicyFilterImpl.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void filterRolesBasedPolicies(String roles[], List<Policy> policies) {
|
||||||
|
|
||||||
|
List<Policy> temp = new ArrayList<Policy>();
|
||||||
|
for (Policy policy : policies) {
|
||||||
|
|
||||||
|
List<String> tempRoles = policy.getRoles();
|
||||||
|
if (PolicyManagementConstants.ANY.equalsIgnoreCase(tempRoles.get(0))) {
|
||||||
|
temp.add(policy);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String role : roles) {
|
||||||
|
for (String policyRole : tempRoles) {
|
||||||
|
if (role.equalsIgnoreCase(policyRole)) {
|
||||||
|
temp.add(policy);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
policies = temp;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void filterOwnershipTypeBasedPolicies(String ownershipType, List<Policy> policies) {
|
||||||
|
|
||||||
|
List<Policy> temp = new ArrayList<Policy>();
|
||||||
|
for (Policy policy : policies) {
|
||||||
|
if (ownershipType.equalsIgnoreCase(policy.getOwnershipType())) {
|
||||||
|
temp.add(policy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
policies = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void filterDeviceTypeBasedPolicies(String deviceType, List<Policy> policies) {
|
||||||
|
List<Policy> temp = new ArrayList<Policy>();
|
||||||
|
for (Policy policy : policies) {
|
||||||
|
if (deviceType.equalsIgnoreCase(policy.getProfile().getDeviceType().getName())) {
|
||||||
|
temp.add(policy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
policies = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue