mharindu 10 years ago
commit 30edad0529

@ -60,13 +60,13 @@ public class PolicyFilterImpl implements PolicyFilter {
@Override @Override
public void filterOwnershipTypeBasedPolicies(String ownershipType, List<Policy> policies) { public void filterOwnershipTypeBasedPolicies(String ownershipType, List<Policy> policies) {
List<Policy> temp = new ArrayList<Policy>(); // List<Policy> temp = new ArrayList<Policy>();
for (Policy policy : policies) { // for (Policy policy : policies) {
if (ownershipType.equalsIgnoreCase(policy.getOwnershipType())) { // if (ownershipType.equalsIgnoreCase(policy.getOwnershipType())) {
temp.add(policy); // temp.add(policy);
} // }
} // }
policies = temp; // policies = temp;
} }
@Override @Override

@ -30,7 +30,9 @@ import org.wso2.carbon.policy.mgt.core.dao.*;
import org.wso2.carbon.policy.mgt.core.mgt.PolicyManager; import org.wso2.carbon.policy.mgt.core.mgt.PolicyManager;
import org.wso2.carbon.policy.mgt.core.mgt.ProfileManager; import org.wso2.carbon.policy.mgt.core.mgt.ProfileManager;
import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.List; import java.util.List;
public class PolicyManagerImpl implements PolicyManager { public class PolicyManagerImpl implements PolicyManager {
@ -58,9 +60,15 @@ public class PolicyManagerImpl implements PolicyManager {
try { try {
PolicyManagementDAOFactory.beginTransaction(); PolicyManagementDAOFactory.beginTransaction();
if (policy.getProfile() != null && policy.getProfile().getProfileId() == 0) { if (policy.getProfile() != null && policy.getProfile().getProfileId() == 0) {
profileDAO.addProfile(policy.getProfile()); Profile profile = policy.getProfile();
featureDAO.addProfileFeatures(policy.getProfile().getProfileFeaturesList(),
policy.getProfile().getProfileId()); Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime());
profile.setCreatedDate(currentTimestamp);
profile.setUpdatedDate(currentTimestamp);
profileDAO.addProfile(profile);
featureDAO.addProfileFeatures(profile.getProfileFeaturesList(), profile.getProfileId());
} }
policy = policyDAO.addPolicy(policy); policy = policyDAO.addPolicy(policy);

@ -28,7 +28,7 @@ import org.wso2.carbon.webapp.authenticator.framework.authenticator.OAuthAuthent
public class WebappAuthenticatorFactory { public class WebappAuthenticatorFactory {
public static WebappAuthenticator getAuthenticator(Request request) { public static WebappAuthenticator getAuthenticator(String authScheme) {
return new OAuthAuthenticator(); return new OAuthAuthenticator();
} }

@ -29,11 +29,14 @@ import javax.servlet.http.HttpServletResponse;
public class WebappAuthenticatorFrameworkValve extends CarbonTomcatValve { public class WebappAuthenticatorFrameworkValve extends CarbonTomcatValve {
private static final String AUTHENTICATION_SCHEME = "AuthenticationScheme";
private static final Log log = LogFactory.getLog(WebappAuthenticatorFrameworkValve.class); private static final Log log = LogFactory.getLog(WebappAuthenticatorFrameworkValve.class);
@Override @Override
public void invoke(Request request, Response response, CompositeValve compositeValve) { public void invoke(Request request, Response response, CompositeValve compositeValve) {
WebappAuthenticator authenticator = WebappAuthenticatorFactory.getAuthenticator(request); String authScheme =
request.getContext().findParameter(WebappAuthenticatorFrameworkValve.AUTHENTICATION_SCHEME);
WebappAuthenticator authenticator = WebappAuthenticatorFactory.getAuthenticator(authScheme);
WebappAuthenticator.Status status = authenticator.authenticate(request, response); WebappAuthenticator.Status status = authenticator.authenticate(request, response);
this.processResponse(request, response, compositeValve, status); this.processResponse(request, response, compositeValve, status);
} }

@ -49,8 +49,12 @@ public class OAuthAuthenticator implements WebappAuthenticator {
@Override @Override
public Status authenticate(Request request, Response response) { public Status authenticate(Request request, Response response) {
StringTokenizer tokenizer = new StringTokenizer(request.getRequestURI(), "/"); String requestUri = request.getRequestURI();
if (requestUri == null || "".equals(requestUri)) {
return Status.CONTINUE;
}
StringTokenizer tokenizer = new StringTokenizer(requestUri, "/");
String context = request.getContextPath(); String context = request.getContextPath();
if (context == null || "".equals(context)) { if (context == null || "".equals(context)) {
context = tokenizer.nextToken(); context = tokenizer.nextToken();
@ -59,13 +63,13 @@ public class OAuthAuthenticator implements WebappAuthenticator {
} }
} }
boolean isContextCached = false; // boolean isContextCached = false;
if (APIUtil.getAPIContextCache().get(context) != null) { // if (APIUtil.getAPIContextCache().get(context) != null) {
isContextCached = Boolean.parseBoolean(APIUtil.getAPIContextCache().get(context).toString()); // isContextCached = Boolean.parseBoolean(APIUtil.getAPIContextCache().get(context).toString());
} // }
if (!isContextCached) { // if (!isContextCached) {
return Status.CONTINUE; // return Status.CONTINUE;
} // }
try { try {
String apiVersion = tokenizer.nextToken(); String apiVersion = tokenizer.nextToken();

@ -27,7 +27,7 @@
<Transports>http,https</Transports> <Transports>http,https</Transports>
</API> </API>
<API> <API>
<Name>enrollment</Name> <Name>Enrollment</Name>
<Owner>admin</Owner> <Owner>admin</Owner>
<Context>enrollment</Context> <Context>enrollment</Context>
<Version>1.0.0</Version> <Version>1.0.0</Version>
@ -35,7 +35,7 @@
<Transports>http,https</Transports> <Transports>http,https</Transports>
</API> </API>
<API> <API>
<Name>license</Name> <Name>License</Name>
<Owner>admin</Owner> <Owner>admin</Owner>
<Context>license-mgt</Context> <Context>license-mgt</Context>
<Version>1.0.0</Version> <Version>1.0.0</Version>
@ -43,20 +43,36 @@
<Transports>http,https</Transports> <Transports>http,https</Transports>
</API> </API>
<API> <API>
<Name>operation</Name> <Name>Operation</Name>
<Owner>admin</Owner> <Owner>admin</Owner>
<Context>operation</Context> <Context>operation</Context>
<Version>1.0.0</Version> <Version>1.0.0</Version>
<Endpoint>http://localhost:9763/mdm-android-agent/operations</Endpoint> <Endpoint>http://localhost:9763/mdm-android-agent/operation</Endpoint>
<Transports>http,https</Transports> <Transports>http,https</Transports>
</API> </API>
<API> <API>
<Name>deviceList</Name> <Name>Device List</Name>
<Owner>admin</Owner> <Owner>admin</Owner>
<Context>mdm-admin/devices</Context> <Context>mdm-admin/devices</Context>
<Version>1.0.0</Version> <Version>1.0.0</Version>
<Endpoint>http://localhost:9763/mdm-admin/devices</Endpoint> <Endpoint>http://localhost:9763/mdm-admin/devices</Endpoint>
<Transports>http,https</Transports> <Transports>http,https</Transports>
</API> </API>
<API>
<Name>APP Install Operation</Name>
<Owner>admin</Owner>
<Context>operations</Context>
<Version>1.0.0</Version>
<Endpoint>http://localhost:9763/mdm-android-agent/operations/installApp</Endpoint>
<Transports>http,https</Transports>
</API>
<API>
<Name>APP UN Install Operation</Name>
<Owner>admin</Owner>
<Context>operations</Context>
<Version>1.0.0</Version>
<Endpoint>http://localhost:9763/mdm-android-agent/operations/uninstallApp</Endpoint>
<Transports>http,https</Transports>
</API>
</APIs> </APIs>
</APIPublisherConfig> </APIPublisherConfig>

Loading…
Cancel
Save