Merge branch 'release-2.0.x' of https://github.com/wso2/carbon-device-mgt into release-2.0.x

This commit is contained in:
ayyoob 2017-01-08 01:20:28 +05:30
commit c718d723c0
136 changed files with 3558 additions and 999 deletions

View File

@ -22,13 +22,13 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId> <artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Annotations</name> <name>WSO2 Carbon - API Management Annotations</name>
<description>WSO2 Carbon - API Management Custom Annotation Module</description> <description>WSO2 Carbon - API Management Custom Annotation Module</description>

View File

@ -1,42 +0,0 @@
/*
* Copyright (c) 2014, 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.apimgt.annotations.api;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* This class is the representation of custom developed Permission annotation.
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Permission {
/**
* Represents the permission name.
* @return Returns permission name.
*/
String name();
/**
* Represents the permission string.
* @return Returns permission string.
*/
String permission();
}

View File

@ -1,21 +1,3 @@
/*
* Copyright (c) 2016, 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.apimgt.annotations.api; package org.wso2.carbon.apimgt.annotations.api;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
@ -24,28 +6,18 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
/** /**
* This class is the representation of custom developed Permission annotation. * This class is the representation of custom developed Scopes annotation.
*/ */
@Target(ElementType.METHOD) @Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
public @interface Scope { public @interface Scope {
/**
* Represents the scope key which should be unique.
* @return Returns scope key.
*/
String key();
/**
* Represents the scope name.
* @return Returns scope name.
*/
String name(); String name();
/**
* Represents the scope description.
* @return Returns scope description.
*/
String description(); String description();
String key();
String[] permissions();
} }

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2016, 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.apimgt.annotations.api;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* This class is the representation of custom developed Scopes annotation.
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface Scopes {
Scope[] scopes();
}

View File

@ -21,12 +21,12 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<artifactId>org.wso2.carbon.apimgt.application.extension.api</artifactId> <artifactId>org.wso2.carbon.apimgt.application.extension.api</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<name>WSO2 Carbon - API Application Management API</name> <name>WSO2 Carbon - API Application Management API</name>

View File

@ -22,12 +22,12 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<artifactId>org.wso2.carbon.apimgt.application.extension</artifactId> <artifactId>org.wso2.carbon.apimgt.application.extension</artifactId>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Application Management</name> <name>WSO2 Carbon - API Application Management</name>

View File

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.handlers</artifactId>
<version>2.0.7-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - API Security Handler Component</name>
<description>WSO2 Carbon - API Management Security Handler Module</description>
<url>http://wso2.org</url>
<dependencies>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId>
</dependency>
<dependency>
<groupId>org.apache.synapse</groupId>
<artifactId>synapse-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.ws.security.wso2</groupId>
<artifactId>wss4j</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.certificate.mgt.core</artifactId>
</dependency>
<dependency>
<groupId>org.json.wso2</groupId>
<artifactId>json</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
<Bundle-Description>WSO2 Carbon - API Security Handler Component</Bundle-Description>
<Import-Package>
org.apache.axiom.*,
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
javax.xml.*,
org.apache.axis2.*,
org.apache.commons.*,
org.apache.http.*,
org.apache.http.util,
org.apache.ws.*;version="${org.apache.ws.security.wso2.version}",
org.json,
org.wso2.carbon.utils,
org.wso2.carbon.context,
com.google.gson,
org.w3c.dom,
org.apache.synapse,
org.apache.synapse.core.axis2,
org.apache.synapse.rest
</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,62 @@
/*
* Copyright (c) 2016, 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.apimgt.handlers;
/**
* Error handling class for the apimgt handler.
*/
public class APIMCertificateMGTException extends Exception{
private static final long serialVersionUID = -37676242646464497L;
private String errorMessage;
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
public APIMCertificateMGTException(String msg, Exception nestedEx) {
super(msg, nestedEx);
setErrorMessage(msg);
}
public APIMCertificateMGTException(String message, Throwable cause) {
super(message, cause);
setErrorMessage(message);
}
public APIMCertificateMGTException(String msg) {
super(msg);
setErrorMessage(msg);
}
public APIMCertificateMGTException() {
super();
}
public APIMCertificateMGTException(Throwable cause) {
super(cause);
}
}

View File

@ -0,0 +1,200 @@
/*
* Copyright (c) 2016, 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.apimgt.handlers;
import com.google.gson.Gson;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.description.HandlerDescription;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.core.axis2.Axis2MessageContext;
import org.apache.synapse.rest.AbstractHandler;
import org.wso2.carbon.apimgt.handlers.beans.Certificate;
import org.wso2.carbon.apimgt.handlers.beans.ValidationResponce;
import org.wso2.carbon.apimgt.handlers.config.IOTServerConfiguration;
import org.wso2.carbon.apimgt.handlers.invoker.RESTInvoker;
import org.wso2.carbon.apimgt.handlers.invoker.RESTResponse;
import org.wso2.carbon.apimgt.handlers.utils.AuthConstants;
import org.wso2.carbon.apimgt.handlers.utils.Utils;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;
/**
* Synapse gateway handler for API authentication.
*/
public class AuthenticationHandler extends AbstractHandler {
private static final Log log = LogFactory.getLog(AuthenticationHandler.class);
private static HandlerDescription EMPTY_HANDLER_METADATA = new HandlerDescription("API Security Handler");
private HandlerDescription handlerDesc;
private RESTInvoker restInvoker;
private IOTServerConfiguration iotServerConfiguration;
/**
* Setting up configurations at the constructor
*/
public AuthenticationHandler() {
log.info("Engaging API Security Handler..........");
restInvoker = new RESTInvoker();
this.handlerDesc = EMPTY_HANDLER_METADATA;
this.iotServerConfiguration = Utils.initConfig();
}
/**
* Handling the message and checking the security.
* @param messageContext
* @return
*/
@Override
public boolean handleRequest(org.apache.synapse.MessageContext messageContext) {
org.apache.axis2.context.MessageContext axisMC = ((Axis2MessageContext) messageContext).getAxis2MessageContext();
String ctxPath = messageContext.getTo().getAddress().trim();
if (log.isDebugEnabled()) {
log.debug("Authentication handler invoked by: " + ctxPath);
}
Map<String, String> headers = (Map<String, String>) axisMC.getProperty(MessageContext.TRANSPORT_HEADERS);
try {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
RESTResponse response;
if (headers.containsKey(AuthConstants.MDM_SIGNATURE)) {
String mdmSignature = headers.get(AuthConstants.MDM_SIGNATURE).toString();
if (log.isDebugEnabled()) {
log.debug("Verify Cert:\n" + mdmSignature);
}
String accessToken = Utils.getAccessToken(iotServerConfiguration);
String deviceType = this.getDeviceType(messageContext.getTo().getAddress().trim());
URI certVerifyUrl = new URI(iotServerConfiguration.getVerificationEndpoint() + deviceType);
Map<String, String> certVerifyHeaders = new HashMap<>();
certVerifyHeaders.put("Authorization", "Bearer " + accessToken);
certVerifyHeaders.put("Content-Type", "application/json");
Certificate certificate = new Certificate();
certificate.setPem(mdmSignature);
certificate.setTenantId(tenantId);
certificate.setSerial("");
Gson gson = new Gson();
String certVerifyContent = gson.toJson(certificate);
response = restInvoker.invokePOST(certVerifyUrl, certVerifyHeaders, null,
null, certVerifyContent);
String str = response.getContent();
if (str.contains("JWTToken")) {
ValidationResponce validationResponce = gson.fromJson(str, ValidationResponce.class);
// TODO: send the JWT token with user details.
// headers.put("X-JWT-Assertion", validationResponce.getJWTToken());
}
if (log.isDebugEnabled()) {
log.debug("Verify response:" + response.getContent());
log.debug("Response String : " + str);
}
} else if (headers.containsKey(AuthConstants.PROXY_MUTUAL_AUTH_HEADER)) {
String subjectDN = headers.get(AuthConstants.PROXY_MUTUAL_AUTH_HEADER).toString();
if (log.isDebugEnabled()) {
log.debug("Verify subject DN: " + subjectDN);
}
String accessToken = Utils.getAccessToken(iotServerConfiguration);
String deviceType = this.getDeviceType(messageContext.getTo().getAddress().trim());
URI certVerifyUrl = new URI(iotServerConfiguration.getVerificationEndpoint() + deviceType);
Map<String, String> certVerifyHeaders = new HashMap<>();
certVerifyHeaders.put("Authorization", "Bearer " + accessToken);
certVerifyHeaders.put("Content-Type", "application/json");
Certificate certificate = new Certificate();
certificate.setPem(subjectDN);
certificate.setTenantId(tenantId);
certificate.setSerial(AuthConstants.PROXY_MUTUAL_AUTH_HEADER);
Gson gson = new Gson();
String certVerifyContent = gson.toJson(certificate);
response = restInvoker.invokePOST(certVerifyUrl, certVerifyHeaders, null,
null, certVerifyContent);
if (log.isDebugEnabled()) {
log.debug("Verify response:" + response.getContent());
}
} else if (headers.containsKey(AuthConstants.ENCODED_PEM)) {
String encodedPem = headers.get(AuthConstants.ENCODED_PEM).toString();
if (log.isDebugEnabled()) {
log.debug("Verify Cert:\n" + encodedPem);
}
String accessToken = Utils.getAccessToken(iotServerConfiguration);
URI certVerifyUrl = new URI(iotServerConfiguration.getVerificationEndpoint() + "android");
Map<String, String> certVerifyHeaders = new HashMap<>();
certVerifyHeaders.put("Authorization", "Bearer " + accessToken);
certVerifyHeaders.put("Content-Type", "application/json");
Certificate certificate = new Certificate();
certificate.setPem(encodedPem);
certificate.setTenantId(tenantId);
certificate.setSerial("");
Gson gson = new Gson();
String certVerifyContent = gson.toJson(certificate);
response = restInvoker.invokePOST(certVerifyUrl, certVerifyHeaders, null,
null, certVerifyContent);
if (log.isDebugEnabled()) {
log.debug("Verify response:" + response.getContent());
}
} else {
log.warn("Unauthorized request for api: " + ctxPath);
return false;
}
if (response != null && !response.getContent().contains("invalid")) {
return true;
}
log.warn("Unauthorized request for api: " + ctxPath);
return false;
} catch (IOException e) {
log.error("Error while processing certificate.", e);
return false;
} catch (URISyntaxException e) {
log.error("Error while processing certificate.", e);
return false;
} catch (APIMCertificateMGTException e) {
log.error("Error while processing certificate.", e);
return false;
}
}
@Override
public boolean handleResponse(org.apache.synapse.MessageContext messageContext) {
return true;
}
// TODO : take this from the url.
private String getDeviceType(String url) {
if (url.contains("ios")) {
return "ios";
} else if (url.contains("android")) {
return "android";
} else return null;
}
}

View File

@ -0,0 +1,58 @@
/*
* Copyright (c) 2016, 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.apimgt.handlers.beans;
/**
* This class keeps the certificate data.
*/
public class Certificate {
// public key of the certificate
private String pem;
// Tenant id
private int tenantId;
// Serial of the certificate.
private String serial;
public String getPem() {
return pem;
}
public void setPem(String pem) {
this.pem = pem;
}
public int getTenantId() {
return tenantId;
}
public void setTenantId(int tenantId) {
this.tenantId = tenantId;
}
public String getSerial() {
return serial;
}
public void setSerial(String serial) {
this.serial = serial;
}
}

View File

@ -0,0 +1,68 @@
/*
* Copyright (c) 2016, 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.apimgt.handlers.beans;
/**
* This class holds the DCR endpoints data to create an application.
*/
public class DCR {
// Owner of the application
private String owner;
// Client name
private String clientName;
// Oauth Grant type
private String grantType;
// Scope of the token
private String tokenScope;
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
public String getClientName() {
return clientName;
}
public void setClientName(String clientName) {
this.clientName = clientName;
}
public String getGrantType() {
return grantType;
}
public void setGrantType(String grantType) {
this.grantType = grantType;
}
public String getTokenScope() {
return tokenScope;
}
public void setTokenScope(String tokenScope) {
this.tokenScope = tokenScope;
}
}

View File

@ -0,0 +1,64 @@
/*
* 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.apimgt.handlers.beans;
/**
* This class holds the data returned from the backend after the certificate was authenticated.
*/
public class ValidationResponce {
private String JWTToken; // X-JWT-Assertion
private String deviceId;
private String deviceType;
private int tenantId;
public String getJWTToken() {
return JWTToken;
}
public void setJWTToken(String JWTToken) {
this.JWTToken = JWTToken;
}
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public String getDeviceType() {
return deviceType;
}
public void setDeviceType(String deviceType) {
this.deviceType = deviceType;
}
public int getTenantId() {
return tenantId;
}
public void setTenantId(int tenantId) {
this.tenantId = tenantId;
}
}

View File

@ -0,0 +1,122 @@
/*
* Copyright (c) 2016, 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.apimgt.handlers.config;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlValue;
import java.util.List;
/**
* This class initialize the iot-api-config.xml and hold the values, in order to be read from the relevant classes. This
* get initialized at the start of the server when apis get loaded.
*/
@XmlRootElement(name = "ServerConfiguration")
public class IOTServerConfiguration {
private String hostname;
private String verificationEndpoint;
private String username;
private String password;
private String dynamicClientRegistrationEndpoint;
private String oauthTokenEndpoint;
private List<ContextPath> apis;
@XmlElement(name = "Hostname", required = true)
public String getHostname() {
return hostname;
}
public void setHostname(String hostname) {
this.hostname = hostname;
}
@XmlElement(name = "VerificationEndpoint", required = true)
public String getVerificationEndpoint() {
return verificationEndpoint;
}
public void setVerificationEndpoint(String verificationEndpoint) {
this.verificationEndpoint = verificationEndpoint;
}
@XmlElement(name = "Username", required = true)
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
@XmlElement(name = "Password", required = true)
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@XmlElement(name = "DynamicClientRegistrationEndpoint", required = true)
public String getDynamicClientRegistrationEndpoint() {
return dynamicClientRegistrationEndpoint;
}
public void setDynamicClientRegistrationEndpoint(String dynamicClientRegistrationEndpoint) {
this.dynamicClientRegistrationEndpoint = dynamicClientRegistrationEndpoint;
}
@XmlElement(name = "OauthTokenEndpoint", required = true)
public String getOauthTokenEndpoint() {
return oauthTokenEndpoint;
}
public void setOauthTokenEndpoint(String oauthTokenEndpoint) {
this.oauthTokenEndpoint = oauthTokenEndpoint;
}
@XmlElementWrapper(name="APIS")
@XmlElement(name = "ContextPath", required = true)
public List<ContextPath> getApis() {
return apis;
}
public void setApis(List<ContextPath> apis) {
this.apis = apis;
}
@XmlRootElement(name = "ContextPath")
public static class ContextPath {
private String contextPath;
@XmlValue()
public String getContextPath() {
return contextPath;
}
public void setContextPath(String contextPath) {
this.contextPath = contextPath;
}
}
}

View File

@ -0,0 +1,279 @@
/*
* Copyright (c) 2016, 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.apimgt.handlers.invoker;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.Header;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.*;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.Map;
public class RESTInvoker {
private static final Log log = LogFactory.getLog(RESTInvoker.class);
private int maxTotalConnections = 100;
private int maxTotalConnectionsPerRoute = 100;
private int connectionTimeout = 120000;
private int socketTimeout = 120000;
private CloseableHttpClient client = null;
private PoolingHttpClientConnectionManager connectionManager = null;
public RESTInvoker() {
configureHttpClient();
}
private void configureHttpClient() {
RequestConfig defaultRequestConfig = RequestConfig.custom()
.setExpectContinueEnabled(true)
.setConnectTimeout(connectionTimeout)
.setSocketTimeout(socketTimeout)
.build();
connectionManager = new PoolingHttpClientConnectionManager();
connectionManager.setDefaultMaxPerRoute(maxTotalConnectionsPerRoute);
connectionManager.setMaxTotal(maxTotalConnections);
client = HttpClients.custom()
.setConnectionManager(connectionManager)
.setDefaultRequestConfig(defaultRequestConfig)
.build();
if(log.isDebugEnabled()){
log.debug("REST client initialized with " +
"maxTotalConnection = " + maxTotalConnections +
"maxConnectionsPerRoute = " + maxTotalConnectionsPerRoute +
"connectionTimeout = " + connectionTimeout);
}
}
public void closeHttpClient() {
IOUtils.closeQuietly(client);
IOUtils.closeQuietly(connectionManager);
}
/**
* Invokes the http GET method
*
* @param uri endpoint/service url
* @param requestHeaders header list
* @param username username for authentication
* @param password password for authentication
* @return RESTResponse of the GET request (can be the response body or the response status code)
* @throws Exception
*/
public RESTResponse invokeGET(URI uri, Map<String, String> requestHeaders, String username, String password) throws IOException {
HttpGet httpGet = null;
CloseableHttpResponse response = null;
Header[] headers;
int httpStatus;
String contentType;
String output;
try {
httpGet = new HttpGet(uri);
if (requestHeaders != null && !requestHeaders.isEmpty()) {
Object keys[] = requestHeaders.keySet().toArray();
for (Object header : keys) {
httpGet.setHeader(header.toString(), requestHeaders.get(header).toString());
}
}
response = sendReceiveRequest(httpGet, username, password);
output = IOUtils.toString(response.getEntity().getContent());
headers = response.getAllHeaders();
httpStatus = response.getStatusLine().getStatusCode();
contentType = response.getEntity().getContentType().getValue();
if (log.isDebugEnabled()) {
log.debug("Invoked GET " + uri.toString() + " - Response message: " + output);
}
EntityUtils.consume(response.getEntity());
} finally {
if (response != null) {
IOUtils.closeQuietly(response);
}
if (httpGet != null) {
httpGet.releaseConnection();
}
}
return new RESTResponse(contentType, output, headers, httpStatus);
}
public RESTResponse invokePOST(URI uri, Map<String, String> requestHeaders, String username,
String password, String payload) throws IOException {
HttpPost httpPost = null;
CloseableHttpResponse response = null;
Header[] headers;
int httpStatus;
String contentType;
String output;
try {
httpPost = new HttpPost(uri);
httpPost.setEntity(new StringEntity(payload));
if (requestHeaders != null && !requestHeaders.isEmpty()) {
Object keys[] = requestHeaders.keySet().toArray();
for (Object header : keys) {
httpPost.setHeader(header.toString(), requestHeaders.get(header).toString());
}
}
response = sendReceiveRequest(httpPost, username, password);
output = IOUtils.toString(response.getEntity().getContent());
headers = response.getAllHeaders();
httpStatus = response.getStatusLine().getStatusCode();
contentType = response.getEntity().getContentType().getValue();
if (log.isDebugEnabled()) {
log.debug("Invoked POST " + uri.toString() +
" - Input payload: " + payload + " - Response message: " + output);
}
EntityUtils.consume(response.getEntity());
} finally {
if (response != null) {
IOUtils.closeQuietly(response);
}
if (httpPost != null) {
httpPost.releaseConnection();
}
}
return new RESTResponse(contentType, output, headers, httpStatus);
}
/**
* Invokes the http PUT method
*
* @param uri endpoint/service url
* @param requestHeaders header list
* @param username username for authentication
* @param password password for authentication
* @param payload payload body passed
* @return RESTResponse of the PUT request (can be the response body or the response status code)
* @throws Exception
*/
public RESTResponse invokePUT(URI uri, Map<String, String> requestHeaders, String username, String password,
String payload) throws IOException {
HttpPut httpPut = null;
CloseableHttpResponse response = null;
Header[] headers;
int httpStatus;
String contentType;
String output;
try {
httpPut = new HttpPut(uri);
httpPut.setEntity(new StringEntity(payload));
if (requestHeaders != null && !requestHeaders.isEmpty()) {
Object keys[] = requestHeaders.keySet().toArray();
for (Object header : keys) {
httpPut.setHeader(header.toString(), requestHeaders.get(header).toString());
}
}
response = sendReceiveRequest(httpPut, username, password);
output = IOUtils.toString(response.getEntity().getContent());
headers = response.getAllHeaders();
httpStatus = response.getStatusLine().getStatusCode();
contentType = response.getEntity().getContentType().getValue();
if (log.isDebugEnabled()) {
log.debug("Invoked PUT " + uri.toString() + " - Response message: " + output);
}
EntityUtils.consume(response.getEntity());
} finally {
if (response != null) {
IOUtils.closeQuietly(response);
}
if (httpPut != null) {
httpPut.releaseConnection();
}
}
return new RESTResponse(contentType, output, headers, httpStatus);
}
/**
* Invokes the http DELETE method
*
* @param uri endpoint/service url
* @param requestHeaders header list
* @param username username for authentication
* @param password password for authentication
* @return RESTResponse of the DELETE (can be the response status code or the response body)
* @throws Exception
*/
public RESTResponse invokeDELETE(URI uri, Map<String, String> requestHeaders, String username, String password) throws IOException {
HttpDelete httpDelete = null;
CloseableHttpResponse response = null;
Header[] headers;
int httpStatus;
String contentType;
String output;
try {
httpDelete = new HttpDelete(uri);
if (requestHeaders != null && !requestHeaders.isEmpty()) {
Object keys[] = requestHeaders.keySet().toArray();
for (Object header : keys) {
httpDelete.setHeader(header.toString(), requestHeaders.get(header).toString());
}
}
response = sendReceiveRequest(httpDelete, username, password);
output = IOUtils.toString(response.getEntity().getContent());
headers = response.getAllHeaders();
httpStatus = response.getStatusLine().getStatusCode();
contentType = response.getEntity().getContentType().getValue();
if (log.isDebugEnabled()) {
log.debug("Invoked DELETE " + uri.toString() + " - Response message: " + output);
}
EntityUtils.consume(response.getEntity());
} finally {
if (response != null) {
IOUtils.closeQuietly(response);
}
if (httpDelete != null) {
httpDelete.releaseConnection();
}
}
return new RESTResponse(contentType, output, headers, httpStatus);
}
private CloseableHttpResponse sendReceiveRequest(HttpRequestBase requestBase, String username, String password)
throws IOException {
CloseableHttpResponse response;
if (username != null && !username.equals("") && password != null) {
String combinedCredentials = username + ":" + password;
byte[] encodedCredentials = Base64.encodeBase64(combinedCredentials.getBytes(StandardCharsets.UTF_8));
requestBase.addHeader("Authorization", "Basic " + new String(encodedCredentials));
response = client.execute(requestBase);
} else {
response = client.execute(requestBase);
}
return response;
}
}

View File

@ -0,0 +1,81 @@
/*
* Copyright (c) 2016, 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.apimgt.handlers.invoker;
import org.apache.http.Header;
/**
* RESTResponse class holds the data retrieved from the HTTP invoke response.
*/
public class RESTResponse {
private String contentType;
private String content;
private Header[] headers;
private int httpStatus;
/**
* Constructor
*
* @param contentType from the REST invoke response
* @param content from the REST invoke response
* @param headers from the REST invoke response
* @param httpStatus from the REST invoke response
*/
public RESTResponse(String contentType, String content, Header[] headers, int httpStatus) {
this.contentType = contentType;
this.content = content;
this.headers = headers;
this.httpStatus = httpStatus;
}
/**
* Get the content type of the EST invoke response
*
* @return String content type of the response
*/
public String getContentType() {
return contentType;
}
/**
* Get contents of the REST invoke response
*
* @return contents of the REST invoke response
*/
public String getContent() {
return content;
}
/**
* Get headers of the REST invoke response
*
* @return headers of the REST invoke response
*/
public Header[] getHeaders() {
return headers;
}
/**
* Get the HTTP Status code from REST invoke response
*
* @return int HTTP status code
*/
public int getHttpStatus() {
return httpStatus;
}
}

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2016, 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.apimgt.handlers.utils;
/**
* This initializes the constance.
*/
public class AuthConstants {
// public static final String SEC_FAULT = "SECURITY_VALIDATION_FAILURE";
// public static final String HTTPS = "https";
// public static final String WSSE = "wsse";
// public static final String AUTH_CONFIGURATION_FILE_NAME = "api-filter-config.xml";
// public static final String API_FILTER_CONFIG_ELEMENT = "apiFilterConfig";
// public static final String API_LIST_PROPERTY = "apiList";
// public static final String HOST = "host";
// public static final String HTTPS_PORT = "httpsPort";
// public static final String USERNAME = "username";
// public static final String PASSWORD = "password";
// public static final String IOS_VERIFY_ENDPOINT = "ios-verify-endpoint";
// public static final String ANDROID_VERIFY_ENDPOINT = "android-verify-endpoint";
public static final String MDM_SIGNATURE = "mdm-signature";
public static final String PROXY_MUTUAL_AUTH_HEADER = "proxy-mutual-auth-header";
public static final String ENCODED_PEM = "encoded-pem";
}

View File

@ -0,0 +1,178 @@
/*
* Copyright (c) 2016, 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.apimgt.handlers.utils;
import com.google.gson.Gson;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ws.security.util.Base64;
import org.json.JSONException;
import org.json.JSONObject;
import org.w3c.dom.Document;
import org.wso2.carbon.apimgt.handlers.APIMCertificateMGTException;
import org.wso2.carbon.apimgt.handlers.beans.DCR;
import org.wso2.carbon.apimgt.handlers.config.IOTServerConfiguration;
import org.wso2.carbon.apimgt.handlers.invoker.RESTInvoker;
import org.wso2.carbon.apimgt.handlers.invoker.RESTResponse;
import org.wso2.carbon.utils.CarbonUtils;
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;
/**
* Contains util methods for synapse gateway authentication handler
*/
public class Utils {
private static final Log log = LogFactory.getLog(Utils.class);
private static final String IOT_APIS_CONFIG_FILE = "iot-api-config.xml";
private static String clientId;
private static String clientSecret;
/**
* This method initializes the iot-api-config.xml file.
* @return
*/
public static IOTServerConfiguration initConfig() {
try {
String IOTServerAPIConfigurationPath =
CarbonUtils.getCarbonConfigDirPath() + File.separator + IOT_APIS_CONFIG_FILE;
File file = new File(IOTServerAPIConfigurationPath);
Document doc = Utils.convertToDocument(file);
JAXBContext fileContext = JAXBContext.newInstance(IOTServerConfiguration.class);
Unmarshaller unmarshaller = fileContext.createUnmarshaller();
return (IOTServerConfiguration) unmarshaller.unmarshal(doc);
} catch (JAXBException | APIMCertificateMGTException e) {
log.error("Error occurred while initializing Data Source config", e);
return null;
}
}
/**
* This class build the iot-api-config.xml file.
* @param file
* @return
* @throws APIMCertificateMGTException
*/
public static Document convertToDocument(File file) throws APIMCertificateMGTException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
try {
DocumentBuilder docBuilder = factory.newDocumentBuilder();
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
return docBuilder.parse(file);
} catch (Exception e) {
throw new APIMCertificateMGTException("Error occurred while parsing file, while converting " +
"to a org.w3c.dom.Document", e);
}
}
/**
* This class get the access token from the key manager.
* @param iotServerConfiguration
* @return
* @throws APIMCertificateMGTException
*/
public static String getAccessToken(IOTServerConfiguration iotServerConfiguration)
throws APIMCertificateMGTException {
try {
if (clientId == null || clientSecret == null) {
getClientSecretes(iotServerConfiguration);
}
URI tokenUrl = new URI(iotServerConfiguration.getOauthTokenEndpoint());
String tokenContent = "grant_type=password&username=" + iotServerConfiguration.getUsername()+ "&password=" +
iotServerConfiguration.getPassword() + "&scope=activity-view";
String tokenBasicAuth = "Basic " + Base64.encode((clientId + ":" + clientSecret).getBytes());
Map<String, String> tokenHeaders = new HashMap<String, String>();
tokenHeaders.put("Authorization", tokenBasicAuth);
tokenHeaders.put("Content-Type", "application/x-www-form-urlencoded");
RESTInvoker restInvoker = new RESTInvoker();
RESTResponse response = restInvoker.invokePOST(tokenUrl, tokenHeaders, null,
null, tokenContent);
if(log.isDebugEnabled()) {
log.debug("Token response:" + response.getContent());
}
JSONObject jsonResponse = new JSONObject(response.getContent());
String accessToken = jsonResponse.getString("access_token");
return accessToken;
} catch (URISyntaxException e) {
throw new APIMCertificateMGTException("Error occurred while trying to call oauth token endpoint", e);
} catch (JSONException e) {
throw new APIMCertificateMGTException("Error occurred while converting the json to object", e);
} catch (IOException e) {
throw new APIMCertificateMGTException("Error occurred while trying to call oauth token endpoint", e);
}
}
/**
* This method register an application to get the client key and secret.
* @param iotServerConfiguration
* @throws APIMCertificateMGTException
*/
private static void getClientSecretes(IOTServerConfiguration iotServerConfiguration)
throws APIMCertificateMGTException {
try {
DCR dcr = new DCR();
dcr.setOwner(iotServerConfiguration.getUsername());
dcr.setClientName("IOT-API-MANAGER");
dcr.setGrantType("refresh_token password client_credentials");
dcr.setTokenScope("default");
Gson gson = new Gson();
String dcrContent = gson.toJson(dcr);
Map<String, String> drcHeaders = new HashMap<String, String>();
drcHeaders.put("Content-Type", "application/json");
URI dcrUrl = new URI(iotServerConfiguration.getDynamicClientRegistrationEndpoint());
RESTInvoker restInvoker = new RESTInvoker();
RESTResponse response = restInvoker.invokePOST(dcrUrl, drcHeaders, null,
null, dcrContent);
if (log.isDebugEnabled()) {
log.debug("DCR response :" + response.getContent());
}
JSONObject jsonResponse = new JSONObject(response.getContent());
clientId = jsonResponse.getString("client_id");
clientSecret = jsonResponse.getString("client_secret");
} catch (JSONException e) {
throw new APIMCertificateMGTException("Error occurred while converting the json to object", e);
} catch (IOException e) {
throw new APIMCertificateMGTException("Error occurred while trying to call DCR endpoint", e);
} catch (URISyntaxException e) {
throw new APIMCertificateMGTException("Error occurred while trying to call DCR endpoint", e);
}
}
}

View File

@ -0,0 +1,40 @@
<?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.
-->
<ServerConfiguration>
<!-- IoT server host name, this is referred from APIM gateway to call to IoT server for certificate validation-->
<Hostname>https://localhost:9443/</Hostname>
<!--End point to verify the certificate-->
<VerificationEndpoint>https://localhost:9443/api/certificate-mgt/v1.0/admin/certificates/verify/</VerificationEndpoint>
<!--Admin username/password - this is to use for oauth token generation-->
<Username>admin</Username>
<Password>admin</Password>
<!--Dynamic client registration endpoint-->
<DynamicClientRegistrationEndpoint>https://localhost:9443/dynamic-client-web/register</DynamicClientRegistrationEndpoint>
<!--Oauth token endpoint-->
<OauthTokenEndpoint>https://localhost:9443/oauth2/token</OauthTokenEndpoint>
<APIS>
<ContextPath>/services/echo</ContextPath>
</APIS>
</ServerConfiguration>

View File

@ -22,13 +22,13 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId> <artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Webapp Publisher</name> <name>WSO2 Carbon - API Management Webapp Publisher</name>
<description>WSO2 Carbon - API Management Webapp Publisher</description> <description>WSO2 Carbon - API Management Webapp Publisher</description>

View File

@ -28,6 +28,7 @@ import org.wso2.carbon.apimgt.impl.utils.APIUtil;
import org.wso2.carbon.apimgt.webapp.publisher.config.APIResource; import org.wso2.carbon.apimgt.webapp.publisher.config.APIResource;
import org.wso2.carbon.apimgt.webapp.publisher.config.APIResourceConfiguration; import org.wso2.carbon.apimgt.webapp.publisher.config.APIResourceConfiguration;
import org.wso2.carbon.apimgt.webapp.publisher.config.WebappPublisherConfig; import org.wso2.carbon.apimgt.webapp.publisher.config.WebappPublisherConfig;
import org.wso2.carbon.apimgt.webapp.publisher.lifecycle.util.AnnotationProcessor;
import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.base.MultitenantConstants;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.core.util.Utils; import org.wso2.carbon.core.util.Utils;
@ -51,6 +52,9 @@ public class APIPublisherUtil {
private static final String PARAM_SHARED_WITH_ALL_TENANTS = "isSharedWithAllTenants"; private static final String PARAM_SHARED_WITH_ALL_TENANTS = "isSharedWithAllTenants";
private static final String PARAM_PROVIDER_TENANT_DOMAIN = "providerTenantDomain"; private static final String PARAM_PROVIDER_TENANT_DOMAIN = "providerTenantDomain";
private static final String NON_SECURED_RESOURCES = "nonSecuredEndPoints";
private static final String AUTH_TYPE_NON_SECURED = "None";
public static API getAPI(APIConfig config) throws APIManagementException { public static API getAPI(APIConfig config) throws APIManagementException {
@ -77,7 +81,7 @@ public class APIPublisherUtil {
api.setUrl(config.getEndpoint()); api.setUrl(config.getEndpoint());
api.addAvailableTiers(provider.getTiers()); api.addAvailableTiers(provider.getTiers());
api.setEndpointSecured(true); api.setEndpointSecured(false);
api.setStatus(APIStatus.CREATED); api.setStatus(APIStatus.CREATED);
api.setTransports(config.getTransports()); api.setTransports(config.getTransports());
api.setApiLevelPolicy(config.getPolicy()); api.setApiLevelPolicy(config.getPolicy());
@ -269,18 +273,7 @@ public class APIPublisherUtil {
} }
apiConfig.setOwner(owner); apiConfig.setOwner(owner);
String isSecuredParam = servletContext.getInitParameter(PARAM_MANAGED_API_IS_SECURED); apiConfig.setSecured(false);
boolean isSecured;
if (isSecuredParam == null || isSecuredParam.isEmpty()) {
if (log.isDebugEnabled()) {
log.debug("'managed-api-isSecured' attribute is not configured. Therefore, using the default, " +
"which is 'true'");
}
isSecured = false;
} else {
isSecured = Boolean.parseBoolean(isSecuredParam);
}
apiConfig.setSecured(isSecured);
String transports = servletContext.getInitParameter(PARAM_MANAGED_API_TRANSPORTS); String transports = servletContext.getInitParameter(PARAM_MANAGED_API_TRANSPORTS);
if (transports == null || transports.isEmpty()) { if (transports == null || transports.isEmpty()) {
@ -324,4 +317,29 @@ public class APIPublisherUtil {
return apiConfig; return apiConfig;
} }
public static void setResourceAuthTypes(ServletContext servletContext, APIConfig apiConfig) {
List<String> resourcesList = null;
String nonSecuredResources = servletContext.getInitParameter(NON_SECURED_RESOURCES);
if(null != nonSecuredResources){
resourcesList = Arrays.asList(nonSecuredResources.split(","));
}
Set<URITemplate> templates = apiConfig.getUriTemplates();
if(null != resourcesList) {
for (URITemplate template : templates) {
String fullPaath = "";
if( template.getUriTemplate() != AnnotationProcessor.WILD_CARD ) {
fullPaath = apiConfig.getContext() + template.getUriTemplate();
}
else{
fullPaath = apiConfig.getContext();
}
for(String context : resourcesList) {
if (context.trim().equals(fullPaath)) {
template.setAuthType(AUTH_TYPE_NON_SECURED);
}
}
}
}
}
} }

View File

@ -42,6 +42,7 @@ public class WebappPublisherConfig {
private boolean isPublished; private boolean isPublished;
private boolean isEnabledUpdateApi; private boolean isEnabledUpdateApi;
private Profiles profiles; private Profiles profiles;
private static boolean isInitialized = false;
private static WebappPublisherConfig config; private static WebappPublisherConfig config;
@ -52,9 +53,13 @@ public class WebappPublisherConfig {
} }
public static WebappPublisherConfig getInstance() { public static WebappPublisherConfig getInstance() {
if (config == null) { if (!isInitialized) {
throw new InvalidConfigurationStateException("Webapp Authenticator Configuration is not " + try {
"initialized properly"); init();
} catch (WebappPublisherConfigurationFailedException e) {
throw new InvalidConfigurationStateException("Webapp Authenticator Configuration is not " +
"initialized properly");
}
} }
return config; return config;
} }
@ -95,7 +100,10 @@ public class WebappPublisherConfig {
this.profiles = profiles; this.profiles = profiles;
} }
public static void init() throws WebappPublisherConfigurationFailedException { public synchronized static void init() throws WebappPublisherConfigurationFailedException {
if (isInitialized) {
return;
}
try { try {
File emailSenderConfig = new File(WEBAPP_PUBLISHER_CONFIG_PATH); File emailSenderConfig = new File(WEBAPP_PUBLISHER_CONFIG_PATH);
Document doc = WebappPublisherUtil.convertToDocument(emailSenderConfig); Document doc = WebappPublisherUtil.convertToDocument(emailSenderConfig);
@ -105,6 +113,7 @@ public class WebappPublisherConfig {
Unmarshaller unmarshaller = ctx.createUnmarshaller(); Unmarshaller unmarshaller = ctx.createUnmarshaller();
//unmarshaller.setSchema(getSchema()); //unmarshaller.setSchema(getSchema());
config = (WebappPublisherConfig) unmarshaller.unmarshal(doc); config = (WebappPublisherConfig) unmarshaller.unmarshal(doc);
isInitialized = true;
} catch (JAXBException e) { } catch (JAXBException e) {
throw new WebappPublisherConfigurationFailedException("Error occurred while un-marshalling Webapp " + throw new WebappPublisherConfigurationFailedException("Error occurred while un-marshalling Webapp " +
"Publisher Config", e); "Publisher Config", e);

View File

@ -69,6 +69,7 @@ public class APIPublisherLifecycleListener implements LifecycleListener {
annotatedSwaggerAPIClasses); annotatedSwaggerAPIClasses);
for (APIResourceConfiguration apiDefinition : apiDefinitions) { for (APIResourceConfiguration apiDefinition : apiDefinitions) {
APIConfig apiConfig = APIPublisherUtil.buildApiConfig(servletContext, apiDefinition); APIConfig apiConfig = APIPublisherUtil.buildApiConfig(servletContext, apiDefinition);
APIPublisherUtil.setResourceAuthTypes(servletContext,apiConfig);
try { try {
int tenantId = APIPublisherDataHolder.getInstance().getTenantManager(). int tenantId = APIPublisherDataHolder.getInstance().getTenantManager().
getTenantId(apiConfig.getTenantDomain()); getTenantId(apiConfig.getTenantDomain());

View File

@ -16,10 +16,12 @@
package org.wso2.carbon.apimgt.webapp.publisher.lifecycle.util; package org.wso2.carbon.apimgt.webapp.publisher.lifecycle.util;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.SwaggerDefinition; import io.swagger.annotations.SwaggerDefinition;
import org.apache.catalina.core.StandardContext; import org.apache.catalina.core.StandardContext;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.apimgt.api.model.Scope;
import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherUtil; import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherUtil;
import org.wso2.carbon.apimgt.webapp.publisher.config.APIResource; import org.wso2.carbon.apimgt.webapp.publisher.config.APIResource;
import org.wso2.carbon.apimgt.webapp.publisher.config.APIResourceConfiguration; import org.wso2.carbon.apimgt.webapp.publisher.config.APIResourceConfiguration;
@ -37,9 +39,7 @@ import java.net.URI;
import java.net.URL; import java.net.URL;
import java.security.AccessController; import java.security.AccessController;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Set;
public class AnnotationProcessor { public class AnnotationProcessor {
@ -51,16 +51,22 @@ public class AnnotationProcessor {
private static final String PACKAGE_ORG_APACHE = "org.apache"; private static final String PACKAGE_ORG_APACHE = "org.apache";
private static final String PACKAGE_ORG_CODEHAUS = "org.codehaus"; private static final String PACKAGE_ORG_CODEHAUS = "org.codehaus";
private static final String PACKAGE_ORG_SPRINGFRAMEWORK = "org.springframework"; private static final String PACKAGE_ORG_SPRINGFRAMEWORK = "org.springframework";
private static final String WILD_CARD = "/*"; public static final String WILD_CARD = "/*";
private static final String SWAGGER_ANNOTATIONS_INFO = "info"; private static final String SWAGGER_ANNOTATIONS_INFO = "info";
private static final String SWAGGER_ANNOTATIONS_TAGS = "tags"; private static final String SWAGGER_ANNOTATIONS_TAGS = "tags";
private static final String SWAGGER_ANNOTATIONS_EXTENSIONS = "extensions"; private static final String SWAGGER_ANNOTATIONS_EXTENSIONS = "extensions";
private static final String SWAGGER_ANNOTATIONS_PROPERTIES = "properties"; private static final String SWAGGER_ANNOTATIONS_PROPERTIES = "properties";
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_NAME = "name"; private static final String SWAGGER_ANNOTATIONS_PROPERTIES_NAME = "name";
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_DESCRIPTION = "description";
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_KEY = "key";
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_PERMISSIONS = "permissions";
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_VERSION = "version"; private static final String SWAGGER_ANNOTATIONS_PROPERTIES_VERSION = "version";
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_CONTEXT = "context"; private static final String SWAGGER_ANNOTATIONS_PROPERTIES_CONTEXT = "context";
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_VALUE = "value"; private static final String SWAGGER_ANNOTATIONS_PROPERTIES_VALUE = "value";
private static final String ANNOTATIONS_SCOPES = "scopes";
private static final String PERMISSION_PREFIX = "/permission/admin";
private StandardContext context; private StandardContext context;
@ -75,6 +81,10 @@ public class AnnotationProcessor {
private Class<io.swagger.annotations.Tag> tagClass; private Class<io.swagger.annotations.Tag> tagClass;
private Class<io.swagger.annotations.Extension> extensionClass; private Class<io.swagger.annotations.Extension> extensionClass;
private Class<io.swagger.annotations.ExtensionProperty> extensionPropertyClass; private Class<io.swagger.annotations.ExtensionProperty> extensionPropertyClass;
private Class<io.swagger.annotations.ApiOperation> apiOperation;
private Class<org.wso2.carbon.apimgt.annotations.api.Scope> scopeClass;
private Class<org.wso2.carbon.apimgt.annotations.api.Scopes> scopesClass;
private Map<String, Scope> apiScopes;
public AnnotationProcessor(final StandardContext context) { public AnnotationProcessor(final StandardContext context) {
servletContext = context.getServletContext(); servletContext = context.getServletContext();
@ -91,7 +101,13 @@ public class AnnotationProcessor {
extensionClass = (Class<io.swagger.annotations.Extension>)classLoader extensionClass = (Class<io.swagger.annotations.Extension>)classLoader
.loadClass((io.swagger.annotations.Extension.class.getName())); .loadClass((io.swagger.annotations.Extension.class.getName()));
extensionPropertyClass = (Class<io.swagger.annotations.ExtensionProperty>)classLoader extensionPropertyClass = (Class<io.swagger.annotations.ExtensionProperty>)classLoader
.loadClass((io.swagger.annotations.ExtensionProperty.class.getName())); .loadClass(io.swagger.annotations.ExtensionProperty.class.getName());
scopeClass = (Class<org.wso2.carbon.apimgt.annotations.api.Scope>) classLoader
.loadClass(org.wso2.carbon.apimgt.annotations.api.Scope.class.getName());
scopesClass = (Class<org.wso2.carbon.apimgt.annotations.api.Scopes>) classLoader
.loadClass(org.wso2.carbon.apimgt.annotations.api.Scopes.class.getName());
apiOperation = (Class<io.swagger.annotations.ApiOperation>)classLoader
.loadClass((io.swagger.annotations.ApiOperation.class.getName()));
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
log.error("An error has occurred while loading classes ", e); log.error("An error has occurred while loading classes ", e);
} }
@ -120,6 +136,7 @@ public class AnnotationProcessor {
try { try {
clazz = classLoader.loadClass(className); clazz = classLoader.loadClass(className);
Annotation swaggerDefinition = clazz.getAnnotation(apiClazz); Annotation swaggerDefinition = clazz.getAnnotation(apiClazz);
Annotation Scopes = clazz.getAnnotation(scopesClass);
List<APIResource> resourceList; List<APIResource> resourceList;
if (swaggerDefinition != null) { if (swaggerDefinition != null) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
@ -127,6 +144,9 @@ public class AnnotationProcessor {
} }
try { try {
apiResourceConfig = processAPIAnnotation(swaggerDefinition); apiResourceConfig = processAPIAnnotation(swaggerDefinition);
if (Scopes != null) {
apiScopes = processAPIScopes(Scopes);
}
if(apiResourceConfig != null){ if(apiResourceConfig != null){
String rootContext = servletContext.getContextPath(); String rootContext = servletContext.getContextPath();
pathClazzMethods = pathClazz.getMethods(); pathClazzMethods = pathClazz.getMethods();
@ -158,7 +178,7 @@ public class AnnotationProcessor {
} catch (ClassNotFoundException e1) { } catch (ClassNotFoundException e1) {
String msg = "Failed to load service class " + className + " for publishing APIs." + String msg = "Failed to load service class " + className + " for publishing APIs." +
" This API will not be published."; " This API will not be published.";
log.error(msg); log.error(msg, e1);
} catch (RuntimeException e) { } catch (RuntimeException e) {
log.error("Unexpected error has been occurred while publishing "+ className log.error("Unexpected error has been occurred while publishing "+ className
+"hence, this API will not be published."); +"hence, this API will not be published.");
@ -174,6 +194,39 @@ public class AnnotationProcessor {
return apiResourceConfigs; return apiResourceConfigs;
} }
private Map<String,Scope> processAPIScopes(Annotation annotation) throws Throwable {
Map<String, Scope> scopes = new HashMap<>();
InvocationHandler methodHandler = Proxy.getInvocationHandler(annotation);
Annotation[] annotatedScopes = (Annotation[]) methodHandler.invoke(annotation, scopesClass
.getMethod(ANNOTATIONS_SCOPES, null), null);
Scope scope;
String permissions[];
StringBuilder aggregatedPermissions;
for(int i=0; i<annotatedScopes.length; i++){
aggregatedPermissions = new StringBuilder();
methodHandler = Proxy.getInvocationHandler(annotatedScopes[i]);
scope = new Scope();
scope.setName(invokeMethod(scopeClass
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_NAME), annotatedScopes[i], STRING));
scope.setDescription(invokeMethod(scopeClass
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_DESCRIPTION), annotatedScopes[i], STRING));
scope.setKey(invokeMethod(scopeClass
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_KEY), annotatedScopes[i], STRING));
permissions = (String[])methodHandler.invoke(annotatedScopes[i], scopeClass
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_PERMISSIONS, null),null);
for (String permission : permissions) {
aggregatedPermissions.append(PERMISSION_PREFIX);
aggregatedPermissions.append(permission);
aggregatedPermissions.append(" ");
}
scope.setRoles(aggregatedPermissions.toString().trim());
scopes.put(scope.getKey(), scope);
}
return scopes;
}
/** /**
* Get Resources for each API * Get Resources for each API
* *
@ -211,6 +264,9 @@ public class AnnotationProcessor {
Annotation producesAnno = method.getAnnotation(producesClass); Annotation producesAnno = method.getAnnotation(producesClass);
resource.setProduces(invokeMethod(producesClassMethods[0], producesAnno, STRING_ARR)); resource.setProduces(invokeMethod(producesClassMethods[0], producesAnno, STRING_ARR));
} }
if (annotations[i].annotationType().getName().equals(ApiOperation.class.getName())) {
resource.setScope(this.getScope(annotations[i]));
}
} }
resourceList.add(resource); resourceList.add(resource);
} }
@ -375,4 +431,24 @@ public class AnnotationProcessor {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
private Scope getScope(Annotation currentMethod) throws Throwable {
InvocationHandler methodHandler = Proxy.getInvocationHandler(currentMethod);
Annotation[] extensions = (Annotation[]) methodHandler.invoke(currentMethod,
apiOperation.getMethod(SWAGGER_ANNOTATIONS_EXTENSIONS, null), null);
methodHandler = Proxy.getInvocationHandler(extensions[0]);
Annotation[] properties = (Annotation[])methodHandler.invoke(extensions[0], extensionClass
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES,null), null);
for (Annotation property : properties) {
methodHandler = Proxy.getInvocationHandler(property);
String scopeKey = (String) methodHandler.invoke(property, extensionPropertyClass
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_VALUE, null),null);
if (scopeKey.isEmpty()) {
return null;
}
return apiScopes.get(scopeKey);
}
return null;
}
} }

View File

@ -22,13 +22,13 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - API Management Extensions Component</name> <name>WSO2 Carbon - API Management Extensions Component</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
@ -38,6 +38,7 @@
<module>org.wso2.carbon.apimgt.application.extension</module> <module>org.wso2.carbon.apimgt.application.extension</module>
<module>org.wso2.carbon.apimgt.application.extension.api</module> <module>org.wso2.carbon.apimgt.application.extension.api</module>
<module>org.wso2.carbon.apimgt.annotations</module> <module>org.wso2.carbon.apimgt.annotations</module>
<module>org.wso2.carbon.apimgt.handlers</module>
</modules> </modules>
<build> <build>

View File

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>certificate-mgt</artifactId> <artifactId>certificate-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -1,18 +1,9 @@
package org.wso2.carbon.certificate.mgt.jaxrs.api; package org.wso2.carbon.certificate.mgt.jaxrs.api;
import io.swagger.annotations.Api; import io.swagger.annotations.*;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.AuthorizationScope;
import io.swagger.annotations.Extension;
import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Info;
import io.swagger.annotations.SwaggerDefinition;
import io.swagger.annotations.Tag;
import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.apimgt.annotations.api.Scopes;
import org.wso2.carbon.certificate.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.certificate.mgt.jaxrs.beans.ErrorResponse;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
@ -45,8 +36,19 @@ import javax.ws.rs.core.Response;
"related operations.") "related operations.")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Scopes(scopes = {
@Scope(
name = "Sign CSR",
description = "Sign CSR",
key = "perm:sign-csr",
permissions = {"/device-mgt/certificates/manage"}
)
}
)
public interface CertificateMgtService { public interface CertificateMgtService {
String SCOPE = "scope";
/** /**
* Sign the client's certificate signing request and save it in the database. * Sign the client's certificate signing request and save it in the database.
* *
@ -64,12 +66,10 @@ public interface CertificateMgtService {
value = "Process a given CSR and return signed certificates.", value = "Process a given CSR and return signed certificates.",
notes = "This will return a signed certificate upon a given CSR.", notes = "This will return a signed certificate upon a given CSR.",
tags = "Device Management", tags = "Device Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = SCOPE, value = "perm:sign-csr")
scopes = { @AuthorizationScope(scope = "/device-mgt/certificates/manage", })
description = "Sign CSR") }
)
} }
) )
@ApiResponses( @ApiResponses(
@ -87,7 +87,6 @@ public interface CertificateMgtService {
message = "Internal Server Error. \n Error occurred while retrieving signed certificate.", message = "Internal Server Error. \n Error occurred while retrieving signed certificate.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) })
@Scope(key = "certificate:sign-csr", name = "Sign CSR", description = "")
Response getSignedCertFromCSR( Response getSignedCertFromCSR(
@ApiParam( @ApiParam(
name = "If-Modified-Since", name = "If-Modified-Since",

View File

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>certificate-mgt</artifactId> <artifactId>certificate-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
@ -149,6 +149,11 @@
<artifactId>org.wso2.carbon.certificate.mgt.core</artifactId> <artifactId>org.wso2.carbon.certificate.mgt.core</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.identity.jwt.client.extension</artifactId>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>io.swagger</groupId> <groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId> <artifactId>swagger-annotations</artifactId>

View File

@ -6,18 +6,19 @@ import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Extension; import io.swagger.annotations.Extension;
import io.swagger.annotations.Tag; import io.swagger.annotations.Tag;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.AuthorizationScope;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ResponseHeader; import io.swagger.annotations.ResponseHeader;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.apimgt.annotations.api.Scopes;
import org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans.CertificateList; import org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans.CertificateList;
import org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans.EnrollmentCertificate; import org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans.EnrollmentCertificate;
import org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans.ErrorResponse; import org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans.ErrorResponse;
import org.wso2.carbon.certificate.mgt.core.dto.CertificateResponse; import org.wso2.carbon.certificate.mgt.core.dto.CertificateResponse;
import javax.validation.constraints.Size;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
@ -39,10 +40,39 @@ import javax.ws.rs.core.Response;
) )
@Api(value = "Certificate Management", description = "This API includes all the certificate management related operations") @Api(value = "Certificate Management", description = "This API includes all the certificate management related operations")
@Path("/admin/certificates") @Path("/admin/certificates")
@Scopes(scopes = {
@Scope(
name = "Adding a new SSL certificate",
description = "Adding a new SSL certificate",
key = "perm:admin:certificates:add",
permissions = {"/device-mgt/admin/certificates/add"}
),
@Scope(
name = "Getting Details of an SSL Certificate",
description = "Getting Details of an SSL Certificate",
key = "perm:admin:certificates:details",
permissions = {"/device-mgt/admin/certificates/details"}
),
@Scope(
name = "Getting Details of Certificates",
description = "Getting Details of Certificates",
key = "perm:admin:certificates:view",
permissions = {"/device-mgt/admin/certificates/view"}
),
@Scope(
name = "Deleting an SSL Certificate",
description = "Deleting an SSL Certificate",
key = "perm:admin:certificates:delete",
permissions = {"/device-mgt/admin/certificates/delete"}
)
}
)
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public interface CertificateManagementAdminService { public interface CertificateManagementAdminService {
String SCOPE = "scope";
/** /**
* Save a list of certificates and relevant information in the database. * Save a list of certificates and relevant information in the database.
* *
@ -58,12 +88,10 @@ public interface CertificateManagementAdminService {
value = "Adding a new SSL certificate", value = "Adding a new SSL certificate",
notes = "Add a new SSL certificate to the client end database.\n", notes = "Add a new SSL certificate to the client end database.\n",
tags = "Certificate Management", tags = "Certificate Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = SCOPE, value = "perm:admin:certificates:add")
scopes = { @AuthorizationScope(scope = "/device-mgt/certificates/manage", })
description = "Manage certificates") }
)
} }
) )
@ApiResponses( @ApiResponses(
@ -129,12 +157,10 @@ public interface CertificateManagementAdminService {
value = "Getting Details of an SSL Certificate", value = "Getting Details of an SSL Certificate",
notes = "Get the client side SSL certificate details.", notes = "Get the client side SSL certificate details.",
tags = "Certificate Management", tags = "Certificate Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = SCOPE, value = "perm:admin:certificates:details")
scopes = { @AuthorizationScope(scope = "/device-mgt/certificates/view", })
description = "View certificates") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -202,12 +228,10 @@ public interface CertificateManagementAdminService {
+ "view all the certificate details, it is not feasible to show all the details on one " + "view all the certificate details, it is not feasible to show all the details on one "
+ "page. Therefore, the details are paginated.", + "page. Therefore, the details are paginated.",
tags = "Certificate Management", tags = "Certificate Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = SCOPE, value = "perm:admin:certificates:view")
scopes = { @AuthorizationScope(scope = "/device-mgt/certificates/view", })
description = "View certificates") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -283,12 +307,10 @@ public interface CertificateManagementAdminService {
value = "Deleting an SSL Certificate", value = "Deleting an SSL Certificate",
notes = "Delete an SSL certificate that's on the client end.", notes = "Delete an SSL certificate that's on the client end.",
tags = "Certificate Management", tags = "Certificate Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = SCOPE, value = "perm:admin:certificates:delete")
scopes = { @AuthorizationScope(scope = "/device-mgt/certificates/manage", })
description = "Manage certificates") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -316,4 +338,125 @@ public interface CertificateManagementAdminService {
defaultValue = "12438035315552875930") defaultValue = "12438035315552875930")
@PathParam("serialNumber") String serialNumber); @PathParam("serialNumber") String serialNumber);
// /**
// * Verify IOS Certificate for the API security filter
// *
// * @param certificate to be verified as a String
// * @return Status of the certificate verification.
// */
// @POST
// @Path("/verify/ios")
// @ApiOperation(
// consumes = MediaType.APPLICATION_JSON,
// produces = MediaType.APPLICATION_JSON,
// httpMethod = "POST",
// value = "Verify IOS SSL certificate",
// notes = "Verify IOS Certificate for the API security filter.\n",
// tags = "Certificate Management")
// @ApiResponses(
// value = {
// @ApiResponse(
// code = 200,
// message = "Return the status of the IOS certificate verification.",
// responseHeaders = {
// @ResponseHeader(
// name = "Content-Type",
// description = "The content type of the body")}),
// @ApiResponse(
// code = 400,
// message = "Bad Request. \n Invalid request or validation error.",
// response = ErrorResponse.class)
// })
// Response verifyIOSCertificate(
// @ApiParam(
// name = "certificate",
// value = "The properties to verify certificate. It includes the following: \n" +
// "serial: The unique ID of the certificate. (optional) \n" +
// "pem: mdm-signature of the certificate",
// required = true) EnrollmentCertificate certificate);
//
// /**
// * Verify Android Certificate for the API security filter
// *
// * @param certificate to be verified as a String
// * @return Status of the certificate verification.
// */
// @POST
// @Path("/verify/android")
// @ApiOperation(
// consumes = MediaType.APPLICATION_JSON,
// produces = MediaType.APPLICATION_JSON,
// httpMethod = "POST",
// value = "Verify Android SSL certificate",
// notes = "Verify Android Certificate for the API security filter.\n",
// tags = "Certificate Management")
// @ApiResponses(
// value = {
// @ApiResponse(
// code = 200,
// message = "Return the status of the Android certificate verification.",
// responseHeaders = {
// @ResponseHeader(
// name = "Content-Type",
// description = "The content type of the body")}),
// @ApiResponse(
// code = 400,
// message = "Bad Request. \n Invalid request or validation error.",
// response = ErrorResponse.class)
// })
// Response verifyAndroidCertificate(
// @ApiParam(
// name = "certificate",
// value = "The properties to verify certificate. It includes the following: \n" +
// "serial: The unique ID of the certificate. (optional) \n" +
// "pem: pem String of the certificate",
// required = true) EnrollmentCertificate certificate);
//
/**
* Verify Android Certificate for the API security filter
*
* @param certificate to be verified as a String
* @return Status of the certificate verification.
*/
@POST
@Path("/verify/{type}")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Verify Android SSL certificate",
notes = "Verify Android Certificate for the API security filter.\n",
tags = "Certificate Management")
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "Return the status of the Android certificate verification.",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body")}),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error.",
response = ErrorResponse.class)
})
Response verifyCertificate(
@ApiParam(
name = "type",
value = "The device type, such as ios, android or windows.",
required = true,
allowableValues = "android, ios, windows")
@PathParam("type")
@Size(max = 45)
String type,
@ApiParam(
name = "certificate",
value = "The properties to verify certificate. It includes the following: \n" +
"serial: The unique ID of the certificate. (optional) \n" +
"pem: pem String of the certificate",
required = true) EnrollmentCertificate certificate);
} }

View File

@ -0,0 +1,61 @@
/*
* 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.certificate.mgt.cert.jaxrs.api.beans;
public class ValidationResponce {
private String JWTToken; // X-JWT-Assertion
private String deviceId;
private String deviceType;
private int tenantId;
public String getJWTToken() {
return JWTToken;
}
public void setJWTToken(String JWTToken) {
this.JWTToken = JWTToken;
}
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public String getDeviceType() {
return deviceType;
}
public void setDeviceType(String deviceType) {
this.deviceType = deviceType;
}
public int getTenantId() {
return tenantId;
}
public void setTenantId(int tenantId) {
this.tenantId = tenantId;
}
}

View File

@ -6,14 +6,22 @@ import org.wso2.carbon.certificate.mgt.cert.jaxrs.api.CertificateManagementAdmin
import org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans.CertificateList; import org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans.CertificateList;
import org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans.EnrollmentCertificate; import org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans.EnrollmentCertificate;
import org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans.ErrorResponse; import org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans.ErrorResponse;
import org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans.ValidationResponce;
import org.wso2.carbon.certificate.mgt.cert.jaxrs.api.util.CertificateMgtAPIUtils; import org.wso2.carbon.certificate.mgt.cert.jaxrs.api.util.CertificateMgtAPIUtils;
import org.wso2.carbon.certificate.mgt.cert.jaxrs.api.util.RequestValidationUtil; import org.wso2.carbon.certificate.mgt.cert.jaxrs.api.util.RequestValidationUtil;
import org.wso2.carbon.certificate.mgt.core.dto.CertificateResponse; import org.wso2.carbon.certificate.mgt.core.dto.CertificateResponse;
import org.wso2.carbon.certificate.mgt.core.exception.CertificateManagementException; import org.wso2.carbon.certificate.mgt.core.exception.CertificateManagementException;
import org.wso2.carbon.certificate.mgt.core.exception.KeystoreException; import org.wso2.carbon.certificate.mgt.core.exception.KeystoreException;
import org.wso2.carbon.certificate.mgt.core.scep.SCEPException;
import org.wso2.carbon.certificate.mgt.core.scep.SCEPManager;
import org.wso2.carbon.certificate.mgt.core.scep.TenantedDeviceWrapper;
import org.wso2.carbon.certificate.mgt.core.service.CertificateManagementService; import org.wso2.carbon.certificate.mgt.core.service.CertificateManagementService;
import org.wso2.carbon.certificate.mgt.core.service.PaginationResult; import org.wso2.carbon.certificate.mgt.core.service.PaginationResult;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException;
import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
@ -25,6 +33,7 @@ import java.util.List;
public class CertificateManagementAdminServiceImpl implements CertificateManagementAdminService { public class CertificateManagementAdminServiceImpl implements CertificateManagementAdminService {
private static Log log = LogFactory.getLog(CertificateManagementAdminServiceImpl.class); private static Log log = LogFactory.getLog(CertificateManagementAdminServiceImpl.class);
private static final String PROXY_AUTH_MUTUAL_HEADER = "proxy-mutual-auth-header";
/** /**
* Save a list of certificates and relevant information in the database. * Save a list of certificates and relevant information in the database.
@ -138,4 +147,138 @@ public class CertificateManagementAdminServiceImpl implements CertificateManagem
} }
} }
// @POST
// @Path("/verify/ios")
// public Response verifyIOSCertificate(@ApiParam(name = "certificate", value = "Mdm-Signature of the " +
// "certificate that needs to be verified", required = true) EnrollmentCertificate certificate) {
// try {
// CertificateManagementService certMgtService = CertificateMgtAPIUtils.getCertificateManagementService();
// X509Certificate cert = certMgtService.extractCertificateFromSignature(certificate.getPem());
// String challengeToken = certMgtService.extractChallengeToken(cert);
//
// if (challengeToken != null) {
// challengeToken = challengeToken.substring(challengeToken.indexOf("(") + 1).trim();
//
// SCEPManager scepManager = CertificateMgtAPIUtils.getSCEPManagerService();
// DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
// deviceIdentifier.setId(challengeToken);
// deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS);
// TenantedDeviceWrapper tenantedDeviceWrapper = scepManager.getValidatedDevice(deviceIdentifier);
//
// if (tenantedDeviceWrapper != null) {
// return Response.status(Response.Status.OK).entity("valid").build();
// }
// }
// } catch (SCEPException e) {
// String msg = "Error occurred while extracting information from certificate.";
// log.error(msg, e);
// return Response.serverError().entity(
// new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()).build();
// } catch (KeystoreException e) {
// String msg = "Error occurred while converting PEM file to X509Certificate.";
// log.error(msg, e);
// return Response.serverError().entity(
// new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()).build();
// }
// return Response.status(Response.Status.OK).entity("invalid").build();
// }
//
// @POST
// @Path("/verify/android")
// public Response verifyAndroidCertificate(@ApiParam(name = "certificate", value = "Base64 encoded .pem file of the " +
// "certificate that needs to be verified", required = true) EnrollmentCertificate certificate) {
// CertificateResponse certificateResponse = null;
// try {
// CertificateManagementService certMgtService = CertificateMgtAPIUtils.getCertificateManagementService();
// if (certificate.getSerial().toLowerCase().contains(PROXY_AUTH_MUTUAL_HEADER)) {
// certificateResponse = certMgtService.verifySubjectDN(certificate.getPem());
// } else {
// X509Certificate clientCertificate = certMgtService.pemToX509Certificate(certificate.getPem());
// if (clientCertificate != null) {
// certificateResponse = certMgtService.verifyPEMSignature(clientCertificate);
// }
// }
//
// if (certificateResponse != null && certificateResponse.getCommonName() != null && !certificateResponse
// .getCommonName().isEmpty()) {
// return Response.status(Response.Status.OK).entity("valid").build();
// }
// } catch (KeystoreException e) {
// String msg = "Error occurred while converting PEM file to X509Certificate.";
// log.error(msg, e);
// return Response.serverError().entity(
// new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()).build();
// }
// return Response.status(Response.Status.OK).entity("invalid").build();
// }
@POST
@Path("/verify/{type}")
public Response verifyCertificate(@PathParam("type") String type, EnrollmentCertificate certificate) {
try {
CertificateManagementService certMgtService = CertificateMgtAPIUtils.getCertificateManagementService();
if (DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS.equalsIgnoreCase(type)) {
X509Certificate cert = certMgtService.extractCertificateFromSignature(certificate.getPem());
String challengeToken = certMgtService.extractChallengeToken(cert);
if (challengeToken != null) {
challengeToken = challengeToken.substring(challengeToken.indexOf("(") + 1).trim();
SCEPManager scepManager = CertificateMgtAPIUtils.getSCEPManagerService();
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
deviceIdentifier.setId(challengeToken);
deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS);
TenantedDeviceWrapper tenantedDeviceWrapper = scepManager.getValidatedDevice(deviceIdentifier);
JWTClientManagerService jwtClientManagerService = CertificateMgtAPIUtils.getJwtClientManagerService();
String jwdToken = jwtClientManagerService.getJWTClient().getJwtToken(
tenantedDeviceWrapper.getDevice().getEnrolmentInfo().getOwner());
ValidationResponce validationResponce = new ValidationResponce();
validationResponce.setDeviceId(challengeToken);
validationResponce.setDeviceType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS);
validationResponce.setJWTToken(jwdToken);
validationResponce.setTenantId(tenantedDeviceWrapper.getTenantId());
if (tenantedDeviceWrapper != null) {
return Response.status(Response.Status.OK).entity(validationResponce).build();
}
}
}
if (DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID.equalsIgnoreCase(type)) {
CertificateResponse certificateResponse = null;
if (certificate.getSerial().toLowerCase().contains(PROXY_AUTH_MUTUAL_HEADER)) {
certificateResponse = certMgtService.verifySubjectDN(certificate.getPem());
} else {
X509Certificate clientCertificate = certMgtService.pemToX509Certificate(certificate.getPem());
if (clientCertificate != null) {
certificateResponse = certMgtService.verifyPEMSignature(clientCertificate);
}
}
if (certificateResponse != null && certificateResponse.getCommonName() != null && !certificateResponse
.getCommonName().isEmpty()) {
return Response.status(Response.Status.OK).entity("valid").build();
}
}
} catch (SCEPException e) {
String msg = "Error occurred while extracting information from certificate.";
log.error(msg, e);
return Response.serverError().entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()).build();
} catch (KeystoreException e) {
String msg = "Error occurred while converting PEM file to X509Certificate.";
log.error(msg, e);
return Response.serverError().entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()).build();
} catch (JWTClientException e) {
String msg = "Error occurred while converting PEM file to X509Certificate.";
log.error(msg, e);
return Response.serverError().entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()).build();
}
return Response.status(Response.Status.OK).entity("invalid").build();
}
} }

View File

@ -20,9 +20,11 @@ package org.wso2.carbon.certificate.mgt.cert.jaxrs.api.util;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.certificate.mgt.core.scep.SCEPManager;
import org.wso2.carbon.certificate.mgt.core.service.CertificateManagementService; import org.wso2.carbon.certificate.mgt.core.service.CertificateManagementService;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService; import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService;
import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
@ -50,6 +52,37 @@ public class CertificateMgtAPIUtils {
} }
public static JWTClientManagerService getJwtClientManagerService() {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
JWTClientManagerService jwtClientManagerService = (JWTClientManagerService)
ctx.getOSGiService(JWTClientManagerService.class, null);
if (jwtClientManagerService == null) {
String msg = "JWTClientManagerService Management service not initialized.";
log.error(msg);
throw new IllegalStateException(msg);
}
return jwtClientManagerService;
}
public static SCEPManager getSCEPManagerService() {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
SCEPManager scepManagerService = (SCEPManager)
ctx.getOSGiService(SCEPManager.class, null);
if (scepManagerService == null) {
String msg = "SCEPManagerImpl Management service not initialized.";
log.error(msg);
throw new IllegalStateException(msg);
}
return scepManagerService;
}
public static MediaType getResponseMediaType(String acceptHeader) { public static MediaType getResponseMediaType(String acceptHeader) {
MediaType responseMediaType; MediaType responseMediaType;
if (acceptHeader == null || MediaType.WILDCARD.equals(acceptHeader)) { if (acceptHeader == null || MediaType.WILDCARD.equals(acceptHeader)) {

View File

@ -21,13 +21,13 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt</artifactId> <artifactId>certificate-mgt</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.certificate.mgt.core</artifactId> <artifactId>org.wso2.carbon.certificate.mgt.core</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Certificate Management Core</name> <name>WSO2 Carbon - Certificate Management Core</name>
<description>WSO2 Carbon - Certificate Management Core</description> <description>WSO2 Carbon - Certificate Management Core</description>
@ -51,7 +51,8 @@
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version> <Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
<Bundle-Description>Device Management Core Bundle</Bundle-Description> <Bundle-Description>Device Management Core Bundle</Bundle-Description>
<Private-Package> <Private-Package>
org.wso2.carbon.certificate.mgt.core.internal org.wso2.carbon.certificate.mgt.core.internal,
org.wso2.carbon.certificate.mgt.core.util
</Private-Package> </Private-Package>
<Import-Package> <Import-Package>
org.osgi.framework, org.osgi.framework,
@ -59,7 +60,7 @@
org.apache.commons.logging, org.apache.commons.logging,
javax.security.auth.x500, javax.security.auth.x500,
javax.xml.*, javax.xml.*,
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
org.apache.commons.codec.binary, org.apache.commons.codec.binary,
org.bouncycastle.asn1, org.bouncycastle.asn1,
org.bouncycastle.asn1.x500, org.bouncycastle.asn1.x500,
@ -97,6 +98,7 @@
</Import-Package> </Import-Package>
<Export-Package> <Export-Package>
!org.wso2.carbon.certificate.mgt.core.internal.*, !org.wso2.carbon.certificate.mgt.core.internal.*,
!org.wso2.carbon.certificate.mgt.core.util,
org.wso2.carbon.certificate.mgt.core.* org.wso2.carbon.certificate.mgt.core.*
</Export-Package> </Export-Package>
</instructions> </instructions>

View File

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt</artifactId> <artifactId>certificate-mgt</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - Certificate Management Component</name> <name>WSO2 Carbon - Certificate Management Component</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

View File

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt-extensions</artifactId> <artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt-extensions</artifactId> <artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt-extensions</artifactId> <artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt-extensions</artifactId> <artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

View File

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -18,22 +18,13 @@
*/ */
package org.wso2.carbon.device.mgt.jaxrs.service.api; package org.wso2.carbon.device.mgt.jaxrs.service.api;
import io.swagger.annotations.SwaggerDefinition; import io.swagger.annotations.*;
import io.swagger.annotations.Info; import org.wso2.carbon.apimgt.annotations.api.Scope;
import io.swagger.annotations.ExtensionProperty; import org.wso2.carbon.apimgt.annotations.api.Scopes;
import io.swagger.annotations.Extension;
import io.swagger.annotations.Tag;
import io.swagger.annotations.Api;
import io.swagger.annotations.AuthorizationScope;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ResponseHeader;
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
import org.wso2.carbon.device.mgt.jaxrs.beans.ActivityList; import org.wso2.carbon.device.mgt.jaxrs.beans.ActivityList;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import javax.ws.rs.*; import javax.ws.rs.*;
@ -61,6 +52,16 @@ import javax.ws.rs.core.Response;
@Path("/activities") @Path("/activities")
@Api(value = "Activity Info Provider", description = "Activity related information manipulation. For example" + @Api(value = "Activity Info Provider", description = "Activity related information manipulation. For example" +
" operation details and responses from devices.") " operation details and responses from devices.")
@Scopes(
scopes = {
@Scope(
name = "Get activities",
description = "Get activities",
key = "perm:get-activity",
permissions = {"/device-mgt/devices/owning-device/view"}
)
}
)
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public interface ActivityInfoProviderService { public interface ActivityInfoProviderService {
@ -74,12 +75,10 @@ public interface ActivityInfoProviderService {
notes = "Retrieve the details of a specific activity/operation, such as the meta information of " + notes = "Retrieve the details of a specific activity/operation, such as the meta information of " +
"an operation, including the responses from the devices.", "an operation, including the responses from the devices.",
tags = "Activity Info Provider", tags = "Activity Info Provider",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:get-activity")
scopes = { @AuthorizationScope(scope = "/device-mgt/devices/owning-device/view" })
, description = "View Activities") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -149,12 +148,10 @@ public interface ActivityInfoProviderService {
notes = "Get the details of the operations/activities executed by the server on the devices registered" + notes = "Get the details of the operations/activities executed by the server on the devices registered" +
" with WSO2 EMM, during a defined time period.", " with WSO2 EMM, during a defined time period.",
tags = "Activity Info Provider", tags = "Activity Info Provider",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:get-activity")
scopes = { @AuthorizationScope(scope = "/device-mgt/devices/owning-device/view" })
, description = "View Activities") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {

View File

@ -31,8 +31,11 @@ import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ResponseHeader; import io.swagger.annotations.ResponseHeader;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.apimgt.annotations.api.Scopes;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
@ -61,6 +64,21 @@ import javax.ws.rs.core.Response;
"through this API.") "through this API.")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Scopes(scopes = {
@Scope(
name = "View configurations",
description = "",
key = "perm:view-configuration",
permissions = {"/device-mgt/platform-configurations/view"}
),
@Scope(
name = "Manage configurations",
description = "",
key = "perm:manage-configuration",
permissions = {"/device-mgt/platform-configurations/manage"}
)
}
)
public interface ConfigurationManagementService { public interface ConfigurationManagementService {
@GET @GET
@ -72,11 +90,10 @@ public interface ConfigurationManagementService {
"General platform configurations include the settings on how often the device need to be monitored. " + "General platform configurations include the settings on how often the device need to be monitored. " +
"Using this REST API you can get the general platform level configurations.", "Using this REST API you can get the general platform level configurations.",
tags = "Configuration Management", tags = "Configuration Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:view-configuration")
scopes = { @AuthorizationScope(scope = "/device-mgt/platform-configurations/view", description = "View Configurations") } })
)
} }
) )
@ApiResponses( @ApiResponses(
@ -132,11 +149,10 @@ public interface ConfigurationManagementService {
"General platform configurations include the settings on how often the the device need to be monitored." + "General platform configurations include the settings on how often the the device need to be monitored." +
"Using this REST API you can update the general platform level configurations.", "Using this REST API you can update the general platform level configurations.",
tags = "Configuration Management", tags = "Configuration Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:manage-configuration")
scopes = { @AuthorizationScope(scope = "/device-mgt/platform-configurations/manage", description = "Manage configurations") } })
)
} }
) )
@ApiResponses( @ApiResponses(

View File

@ -13,10 +13,13 @@ import io.swagger.annotations.Info;
import io.swagger.annotations.ResponseHeader; import io.swagger.annotations.ResponseHeader;
import io.swagger.annotations.SwaggerDefinition; import io.swagger.annotations.SwaggerDefinition;
import io.swagger.annotations.Tag; import io.swagger.annotations.Tag;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.apimgt.annotations.api.Scopes;
import org.wso2.carbon.device.mgt.analytics.dashboard.bean.DeviceCountByGroup; import org.wso2.carbon.device.mgt.analytics.dashboard.bean.DeviceCountByGroup;
import org.wso2.carbon.device.mgt.jaxrs.beans.DashboardGadgetDataWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.DashboardGadgetDataWrapper;
import org.wso2.carbon.device.mgt.jaxrs.beans.DashboardPaginationGadgetDataWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.DashboardPaginationGadgetDataWrapper;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.GET; import javax.ws.rs.GET;
@ -44,6 +47,70 @@ import javax.ws.rs.core.Response;
@Tag(name = "device_management", description = "Device Analytics Dashboard related APIs.") @Tag(name = "device_management", description = "Device Analytics Dashboard related APIs.")
} }
) )
@Scopes(
scopes = {
@Scope(
name = "Device Count Overview",
description = "Device Count Overview",
key = "perm:dashboard:count-overview",
permissions = {"/device-mgt/dashboard/view"}
),
@Scope(
name = "Device Counts by Potential Vulnerabilities",
description = "Device Counts by Potential Vulnerabilities",
key = "perm:dashboard:vulnerabilities",
permissions = {"/device-mgt/dashboard/view"}
),
@Scope(
name = "Get the number of devices that have not complied to a policy",
description = "Get the number of devices that have not complied to a policy",
key = "perm:dashboard:non-compliant",
permissions = {"/device-mgt/dashboard/view"}
),
@Scope(
name = "Get the number of devices for a given device type, such as connectivity status, "
+ "potential vulnerability, platform, and ownership",
description = "Get the number of devices for a given device type, such as connectivity status, "
+ "potential vulnerability, platform, and ownership",
key = "perm:dashboard:by-groups",
permissions = {"/device-mgt/dashboard/view"}
),
@Scope(
name = "Get the number of devices that have not complied to a given policy based on a particular",
description = "Get the number of devices that have not complied to a given policy based on a particular",
key = "perm:dashboard:device-counts",
permissions = {"/device-mgt/dashboard/view"}
),
@Scope(
name = "Get the number of devices that have not complied to a given policy based on a particular"
+ " device type.",
description = "Get the number of devices that have not complied to a given policy based on a " +
"particular device type.",
key = "perm:dashboard:filtered-count",
permissions = {"/device-mgt/dashboard/view"}
),
@Scope(
name = "Get the number of devices that have not complied to a given policy over the total"
+ " number of devices registered with WSO2 EMM.\n",
description = "Get the number of devices that have not complied to a given policy over the total"
+ " number of devices registered with WSO2 EMM.\n",
key = "perm:dashboard:non-compliant-count",
permissions = {"/device-mgt/dashboard/view"}
),
@Scope(
name = "Get device details of devices based on a particular device type.",
description = "Get device details of devices based on a particular device type.",
key = "perm:dashboard:details",
permissions = {"/device-mgt/dashboard/view"}
),
@Scope(
name = "Get device details of non-compliant devices which do not comply to a given policy.",
description = "Get device details of non-compliant devices which do not comply to a given policy.",
key = "perm:dashboard:feature-non-compliant",
permissions = {"/device-mgt/dashboard/view"}
)
}
)
@Path("/dashboard") @Path("/dashboard")
@Api(value = "Device Analytics Dashboard", @Api(value = "Device Analytics Dashboard",
description = "Device Analytics Dashboard related information APIs are described here.") description = "Device Analytics Dashboard related information APIs are described here.")
@ -70,13 +137,12 @@ public interface Dashboard {
notes = "Get the details of active, inactive, removed and total number of registered devices in" notes = "Get the details of active, inactive, removed and total number of registered devices in"
+ " WSO2 IoT.", + " WSO2 IoT.",
tags = "Dashboard", tags = "Dashboard",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value = "permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:dashboard:count-overview")
scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view", })
description = "View Dashboard")} }
) )
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
@ -127,13 +193,12 @@ public interface Dashboard {
httpMethod = "GET", httpMethod = "GET",
value = "Get the number of unmonitored and non-compliant devices in WSO2 IoT.", value = "Get the number of unmonitored and non-compliant devices in WSO2 IoT.",
tags = "Dashboard", tags = "Dashboard",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value = "permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:dashboard:vulnerabilities")
scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view", })
description = "View Dashboard")} }
) )
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
@ -185,13 +250,12 @@ public interface Dashboard {
value = "Get the number of devices that have not complied to a policy that was enforced on a " value = "Get the number of devices that have not complied to a policy that was enforced on a "
+ "device.", + "device.",
tags = "Dashboard", tags = "Dashboard",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value = "permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:dashboard:non-compliant")
scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view", })
description = "View Dashboard")} }
) )
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
@ -256,13 +320,12 @@ public interface Dashboard {
value = "Get the number of devices for a given device type, such as connectivity status, " value = "Get the number of devices for a given device type, such as connectivity status, "
+ "potential vulnerability, platform, and ownership.\n", + "potential vulnerability, platform, and ownership.\n",
tags = "Dashboard", tags = "Dashboard",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value = "permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:dashboard:by-groups")
scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view", })
description = "View Dashboard")} }
) )
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
@ -346,13 +409,12 @@ public interface Dashboard {
value = "Get the number of devices that have not complied to a given policy based on a particular" value = "Get the number of devices that have not complied to a given policy based on a particular"
+ " device type.", + " device type.",
tags = "Dashboard", tags = "Dashboard",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value = "permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:dashboard:device-counts")
scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view", })
description = "View Dashboard")} }
) )
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
@ -426,13 +488,12 @@ public interface Dashboard {
+ "The device ownership type, such as BYOD or COPE.\n" + "The device platform.\n" + "The device ownership type, such as BYOD or COPE.\n" + "The device platform.\n"
+ "The potential vulnerabilities faced by the devices.", + "The potential vulnerabilities faced by the devices.",
tags = "Dashboard", tags = "Dashboard",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value = "permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:dashboard:filtered-count")
scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view", })
description = "View Dashboard")} }
) )
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
@ -519,13 +580,12 @@ public interface Dashboard {
value = "Get the number of devices that have not complied to a given policy over the total" value = "Get the number of devices that have not complied to a given policy over the total"
+ " number of devices registered with WSO2 IoT.\n", + " number of devices registered with WSO2 IoT.\n",
tags = "Dashboard", tags = "Dashboard",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value = "permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:dashboard:non-compliant-count")
scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view", })
description = "View Dashboard")} }
) )
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
@ -595,13 +655,12 @@ public interface Dashboard {
httpMethod = "GET", httpMethod = "GET",
value = "Get device details of devices based on a particular device type.", value = "Get device details of devices based on a particular device type.",
tags = "Dashboard", tags = "Dashboard",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value = "permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:dashboard:details")
scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view", })
description = "View Dashboard")} }
) )
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
@ -698,13 +757,12 @@ public interface Dashboard {
httpMethod = "GET", httpMethod = "GET",
value = "Get device details of non-compliant devices which do not comply to a given policy.", value = "Get device details of non-compliant devices which do not comply to a given policy.",
tags = "Dashboard", tags = "Dashboard",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value = "permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:dashboard:feature-non-compliant")
scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view", })
description = "View Dashboard")} }
) )
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
@ -780,4 +838,4 @@ public interface Dashboard {
value = "Provide how many policy details you require from the starting pagination index.", value = "Provide how many policy details you require from the starting pagination index.",
required = true) required = true)
@QueryParam(RESULT_COUNT) int resultCount); @QueryParam(RESULT_COUNT) int resultCount);
} }

View File

@ -24,13 +24,13 @@ import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Extension; import io.swagger.annotations.Extension;
import io.swagger.annotations.Tag; import io.swagger.annotations.Tag;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.AuthorizationScope;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ResponseHeader; import io.swagger.annotations.ResponseHeader;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.apimgt.annotations.api.Scopes;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.device.mgt.common.Feature;
import org.wso2.carbon.device.mgt.common.app.mgt.Application; import org.wso2.carbon.device.mgt.common.app.mgt.Application;
@ -38,6 +38,7 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.search.SearchContext; import org.wso2.carbon.device.mgt.common.search.SearchContext;
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceList; import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceList;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData; import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData;
@ -64,6 +65,64 @@ import javax.ws.rs.core.Response;
@Tag(name = "device_management", description = "") @Tag(name = "device_management", description = "")
} }
) )
@Scopes(
scopes = {
@Scope(
name = "Getting Details of Registered Devices",
description = "Getting Details of Registered Devices",
key = "perm:devices:view",
permissions = {"/device-mgt/devices/owning-device/view"}
),
@Scope(
name = "Getting Details of a Device",
description = "Getting Details of a Device",
key = "perm:devices:details",
permissions = {"/device-mgt/devices/owning-device/view"}
),
@Scope(
name = "Delete the device specified by device id",
description = "Delete the device specified by device id",
key = "perm:devices:delete",
permissions = {"/device-mgt/devices/owning-device/view"}
),
@Scope(
name = "Getting Feature Details of a Device",
description = "Getting Feature Details of a Device",
key = "perm:devices:features",
permissions = {"/device-mgt/devices/owning-device/view"}
),
@Scope(
name = "Advanced Search for Devices",
description = "Advanced Search for Devices",
key = "perm:devices:search",
permissions = {"/device-mgt/devices/owning-device/view"}
),
@Scope(
name = "Getting Installed Application Details of a Device",
description = "Getting Installed Application Details of a Device",
key = "perm:devices:applications",
permissions = {"/device-mgt/devices/owning-device/view"}
),
@Scope(
name = "Getting Device Operation Details",
description = "Getting Device Operation Details",
key = "perm:devices:operations",
permissions = {"/device-mgt/devices/owning-device/view"}
),
@Scope(
name = "Get the details of the policy that is enforced on a device.",
description = "Get the details of the policy that is enforced on a device.",
key = "perm:devices:effective-policy",
permissions = {"/device-mgt/devices/owning-device/view"}
),
@Scope(
name = "Getting Policy Compliance Details of a Device",
description = "Getting Policy Compliance Details of a Device",
key = "perm:devices:compliance-data",
permissions = {"/device-mgt/devices/owning-device/view"}
)
}
)
@Path("/devices") @Path("/devices")
@Api(value = "Device Management", description = "This API carries all device management related operations " + @Api(value = "Device Management", description = "This API carries all device management related operations " +
"such as get all the available devices, etc.") "such as get all the available devices, etc.")
@ -78,13 +137,11 @@ public interface DeviceManagementService {
value = "Getting Details of Registered Devices", value = "Getting Details of Registered Devices",
notes = "Provides details of all the devices enrolled with WSO2 EMM.", notes = "Provides details of all the devices enrolled with WSO2 EMM.",
tags = "Device Management", tags = "Device Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:view")
scopes = { @AuthorizationScope(scope = "/device-mgt/devices/owning-device/view" })
, description = "View Devices") } }
)
}
) )
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "OK. \n Successfully fetched the list of devices.", @ApiResponse(code = 200, message = "OK. \n Successfully fetched the list of devices.",
@ -205,12 +262,10 @@ public interface DeviceManagementService {
value = "Getting Details of a Device", value = "Getting Details of a Device",
notes = "Get the details of a device by specifying the device type and device identifier.", notes = "Get the details of a device by specifying the device type and device identifier.",
tags = "Device Management", tags = "Device Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:details")
scopes = { @AuthorizationScope(scope = "/device-mgt/devices/owning-device/view", })
description = "View Devices") }
)
} }
) )
@ApiResponses( @ApiResponses(
@ -282,15 +337,13 @@ public interface DeviceManagementService {
@ApiOperation( @ApiOperation(
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
httpMethod = "DELETE", httpMethod = "DELETE",
value = "Delete the device speccified by device id", value = "Delete the device specified by device id",
notes = "Returns the status of the deleted device operation.", notes = "Returns the status of the deleted device operation.",
tags = "Device Management", tags = "Device Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:delete")
scopes = { @AuthorizationScope(scope = "/device-mgt/devices/owning-device/view", })
description = "View Devices") }
)
} }
) )
@ApiResponses( @ApiResponses(
@ -359,13 +412,11 @@ public interface DeviceManagementService {
"Using this REST API you can get the features that can be carried out on a preferred device type," + "Using this REST API you can get the features that can be carried out on a preferred device type," +
" such as iOS, Android or Windows.", " such as iOS, Android or Windows.",
tags = "Device Management", tags = "Device Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:features")
scopes = { @AuthorizationScope(scope = "/device-mgt/devices/owning-device/view", })
description = "View Devices") } }
)
}
) )
@ApiResponses( @ApiResponses(
value = { value = {
@ -450,12 +501,10 @@ public interface DeviceManagementService {
value = "Advanced Search for Devices", value = "Advanced Search for Devices",
notes = "Search for devices by filtering the search result through the specified search terms.", notes = "Search for devices by filtering the search result through the specified search terms.",
tags = "Device Management", tags = "Device Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:search")
scopes = { @AuthorizationScope(scope = "/device-mgt/devices/owning-device/view", })
description = "View Devices") }
)
} }
) )
@ApiResponses( @ApiResponses(
@ -529,13 +578,12 @@ public interface DeviceManagementService {
value = "Getting Installed Application Details of a Device", value = "Getting Installed Application Details of a Device",
notes = "Get the list of applications subscribed to by a device.", notes = "Get the list of applications subscribed to by a device.",
tags = "Device Management", tags = "Device Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:applications")
scopes = { @AuthorizationScope(scope = "/device-mgt/devices/owning-device/view", })
description = "View Devices") }
) }
}
) )
@ApiResponses( @ApiResponses(
value = { value = {
@ -633,13 +681,11 @@ public interface DeviceManagementService {
value = "Getting Device Operation Details", value = "Getting Device Operation Details",
notes = "Get the details of operations carried out on a selected device.", notes = "Get the details of operations carried out on a selected device.",
tags = "Device Management", tags = "Device Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:operations")
scopes = { @AuthorizationScope(scope = "/device-mgt/devices/owning-device/view", })
description = "View Devices") } }
)
}
) )
@ApiResponses( @ApiResponses(
value = { value = {
@ -746,13 +792,11 @@ public interface DeviceManagementService {
"WSO2 EMM filters the policies based on the device platform (device type)," + "WSO2 EMM filters the policies based on the device platform (device type)," +
"the device ownership type, the user role or name and finally, the policy that matches these filters will be enforced on the device.", "the device ownership type, the user role or name and finally, the policy that matches these filters will be enforced on the device.",
tags = "Device Management", tags = "Device Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:effective-policy")
scopes = { @AuthorizationScope(scope = "/device-mgt/devices/owning-device/view", })
description = "View Devices") } }
)
}
) )
@ApiResponses( @ApiResponses(
value = { value = {
@ -837,12 +881,10 @@ public interface DeviceManagementService {
notes = "A policy is enforced on the devices that register with WSO2 EMM. " + notes = "A policy is enforced on the devices that register with WSO2 EMM. " +
"The server checks if the settings in the device comply with the policy that is enforced on the device using this REST API.", "The server checks if the settings in the device comply with the policy that is enforced on the device using this REST API.",
tags = "Device Management", tags = "Device Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:compliance-data")
scopes = { @AuthorizationScope(scope = "/device-mgt/devices/owning-device/view", })
description = "View Devices") }
)
} }
) )
@ApiResponses( @ApiResponses(

View File

@ -24,15 +24,16 @@ import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Extension; import io.swagger.annotations.Extension;
import io.swagger.annotations.Tag; import io.swagger.annotations.Tag;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.AuthorizationScope;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ResponseHeader; import io.swagger.annotations.ResponseHeader;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.apimgt.annotations.api.Scopes;
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceTypeList; import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceTypeList;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import javax.ws.rs.*; import javax.ws.rs.*;
@ -54,6 +55,22 @@ import javax.ws.rs.core.Response;
@Tag(name = "device_management", description = "") @Tag(name = "device_management", description = "")
} }
) )
@Scopes(
scopes = {
@Scope(
name = "Getting the Supported Device Platforms",
description = "Getting the Supported Device Platforms",
key = "perm:device-types:types",
permissions = {"/device-mgt/devices/owning-device/view"}
),
@Scope(
name = "Get Feature Details of a Device Type",
description = "Get Feature Details of a Device Type",
key = "perm:device-types:features",
permissions = {"/device-mgt/devices/owning-device/view"}
)
}
)
@Path("/device-types") @Path("/device-types")
@Api(value = "Device Type Management", description = "This API corresponds to all tasks related to device " + @Api(value = "Device Type Management", description = "This API corresponds to all tasks related to device " +
"type management") "type management")
@ -68,12 +85,10 @@ public interface DeviceTypeManagementService {
value = "Getting the Supported Device Platforms", value = "Getting the Supported Device Platforms",
notes = "Get the list of device platforms supported by WSO2 EMM.", notes = "Get the list of device platforms supported by WSO2 EMM.",
tags = "Device Type Management", tags = "Device Type Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:types")
scopes = { @AuthorizationScope(scope = "/device-mgt/devices/owning-device/view", })
description = "View Device Types") }
)
} }
) )
@ApiResponses( @ApiResponses(
@ -123,6 +138,7 @@ public interface DeviceTypeManagementService {
String ifModifiedSince); String ifModifiedSince);
@GET @GET
@Path("/{type}/features")
@ApiOperation( @ApiOperation(
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
httpMethod = "GET", httpMethod = "GET",
@ -131,12 +147,10 @@ public interface DeviceTypeManagementService {
"Using this REST API you can get the features that can be carried out on a preferred device type," + "Using this REST API you can get the features that can be carried out on a preferred device type," +
" such as iOS, Android or Windows.", " such as iOS, Android or Windows.",
tags = "Device Type Management", tags = "Device Type Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:features")
scopes = { @AuthorizationScope(scope = "/device-mgt/devices/owning-device/view", })
description = "View Device Types") }
)
} }
) )
@ApiResponses( @ApiResponses(

View File

@ -24,8 +24,6 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.AuthorizationScope;
import io.swagger.annotations.Extension; import io.swagger.annotations.Extension;
import io.swagger.annotations.ExtensionProperty; import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Info; import io.swagger.annotations.Info;
@ -33,6 +31,8 @@ import io.swagger.annotations.ResponseHeader;
import io.swagger.annotations.SwaggerDefinition; import io.swagger.annotations.SwaggerDefinition;
import io.swagger.annotations.Tag; import io.swagger.annotations.Tag;
import org.apache.axis2.transport.http.HTTPConstants; import org.apache.axis2.transport.http.HTTPConstants;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.apimgt.annotations.api.Scopes;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceGroupList; import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceGroupList;
@ -40,6 +40,7 @@ import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceList;
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceToGroupsAssignment; import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceToGroupsAssignment;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleList; import org.wso2.carbon.device.mgt.jaxrs.beans.RoleList;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
import javax.validation.Valid; import javax.validation.Valid;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
@ -75,6 +76,94 @@ import java.util.List;
"details.") "details.")
} }
) )
@Scopes(
scopes = {
@Scope(
name = "Get the list of groups belongs to current user.",
description = "Get the list of groups belongs to current user.",
key = "perm:groups:groups",
permissions = {"/device-mgt/groups/view"}
),
@Scope(
name = "Get the count of groups belongs to current user.",
description = "Get the count of groups belongs to current user.",
key = "perm:groups:count",
permissions = {"/device-mgt/groups/view"}
),
@Scope(
name = "Add new device group to the system.",
description = "Add new device group to the system.",
key = "perm:groups:add",
permissions = {"/device-mgt/groups/add"}
),
@Scope(
name = "View group specified",
description = "View group specified",
key = "perm:groups:groups-view",
permissions = {"/device-mgt/groups/view"}
),
@Scope(
name = "Update a group",
description = "Update a group",
key = "perm:groups:update",
permissions = {"/device-mgt/groups/update"}
),
@Scope(
name = "Delete a group",
description = "Delete a group",
key = "perm:groups:remove",
permissions = {"/device-mgt/groups/remove"}
),
@Scope(
name = "Manage group sharing with a user",
description = "Manage group sharing with a user",
key = "perm:groups:share",
permissions = {"/device-mgt/groups/share"}
),
@Scope(
name = "View list of roles of a device group",
description = "View list of roles of a device group",
key = "perm:groups:roles",
permissions = {"/device-mgt/groups/roles/view"}
),
@Scope(
name = "View list of devices in the device group",
description = "View list of devices in the device group",
key = "perm:groups:devices",
permissions = {"/device-mgt/groups/devices/view"}
),
@Scope(
name = "View list of device count in the device group",
description = "View list of device count in the device group",
key = "perm:groups:devices-count",
permissions = {"/device-mgt/groups/devices/view"}
),
@Scope(
name = "Add devices to group",
description = "Add devices to group",
key = "perm:groups:devices-add",
permissions = {"/device-mgt/groups/devices/add"}
),
@Scope(
name = "Remove devices from group",
description = "Remove devices from group",
key = "perm:groups:devices-remove",
permissions = {"/device-mgt/groups/devices/remove"}
),
@Scope(
name = "Assign devices to groups",
description = "Assign devices to groups",
key = "perm:groups:assign",
permissions = {"/device-mgt/groups/devices/add"}
),
@Scope(
name = "List of groups that have the device",
description = "List of groups that have the device",
key = "perm:groups:device",
permissions = {"/device-mgt/groups/devices/view"}
)
}
)
@Path("/groups") @Path("/groups")
@Api(value = "Device Group Management", description = "This API carries all device group management related " + @Api(value = "Device Group Management", description = "This API carries all device group management related " +
"operations such as get all the available groups, etc.") "operations such as get all the available groups, etc.")
@ -89,12 +178,10 @@ public interface GroupManagementService {
value = "Get the list of groups belongs to current user.", value = "Get the list of groups belongs to current user.",
notes = "Returns all permitted groups enrolled with the system.", notes = "Returns all permitted groups enrolled with the system.",
tags = "Device Group Management", tags = "Device Group Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:groups:groups")
scopes = { @AuthorizationScope(scope = "/device-mgt/groups/view", })
description = "View Groups") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -154,13 +241,12 @@ public interface GroupManagementService {
value = "Get the count of groups belongs to current user.", value = "Get the count of groups belongs to current user.",
notes = "Returns count of all permitted groups enrolled with the system.", notes = "Returns count of all permitted groups enrolled with the system.",
tags = "Device Group Management", tags = "Device Group Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:groups:count")
scopes = { @AuthorizationScope(scope = "/device-mgt/groups/view", })
description = "View Groups") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "OK. \n Successfully fetched the device group count.", @ApiResponse(code = 200, message = "OK. \n Successfully fetched the device group count.",
@ -203,12 +289,10 @@ public interface GroupManagementService {
value = "Add new device group to the system.", value = "Add new device group to the system.",
notes = "Add device group with current user as the owner.", notes = "Add device group with current user as the owner.",
tags = "Device Group Management", tags = "Device Group Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:groups:add")
scopes = { @AuthorizationScope(scope = "/device-mgt/groups/add", })
description = "Add Group") }
)
} }
) )
@ApiResponses( @ApiResponses(
@ -271,12 +355,10 @@ public interface GroupManagementService {
value = "View group specified.", value = "View group specified.",
notes = "Returns details of group enrolled with the system.", notes = "Returns details of group enrolled with the system.",
tags = "Device Group Management", tags = "Device Group Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:groups:groups-view")
scopes = { @AuthorizationScope(scope = "/device-mgt/groups/view", })
description = "View Groups") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -326,12 +408,10 @@ public interface GroupManagementService {
notes = "If you wish to make changes to an existing group, that can be done by updating the group using " + notes = "If you wish to make changes to an existing group, that can be done by updating the group using " +
"this resource.", "this resource.",
tags = "Device Group Management", tags = "Device Group Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:groups:update")
scopes = { @AuthorizationScope(scope = "/device-mgt/groups/update", })
description = "Update Group") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -385,12 +465,10 @@ public interface GroupManagementService {
notes = "If you wish to remove an existing group, that can be done by updating the group using " + notes = "If you wish to remove an existing group, that can be done by updating the group using " +
"this resource.", "this resource.",
tags = "Device Group Management", tags = "Device Group Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:groups:remove")
scopes = { @AuthorizationScope(scope = "/device-mgt/groups/remove", })
description = "Remove Group") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -439,12 +517,10 @@ public interface GroupManagementService {
notes = "If you wish to share /un share an existing group with a user under defined sharing roles, " + notes = "If you wish to share /un share an existing group with a user under defined sharing roles, " +
"that can be done using this resource.", "that can be done using this resource.",
tags = "Device Group Management", tags = "Device Group Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:groups:share")
scopes = { @AuthorizationScope(scope = "/device-mgt/groups/share", })
description = "Share Group") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -497,12 +573,10 @@ public interface GroupManagementService {
value = "View list of roles of a device group.", value = "View list of roles of a device group.",
notes = "Returns details of roles which particular group has been shared with.", notes = "Returns details of roles which particular group has been shared with.",
tags = "Device Group Management", tags = "Device Group Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:groups:roles")
scopes = { @AuthorizationScope(scope = "/device-mgt/groups/roles/view", })
description = "View roles") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -551,12 +625,10 @@ public interface GroupManagementService {
value = "View list of devices in the device group.", value = "View list of devices in the device group.",
notes = "Returns list of devices in the device group.", notes = "Returns list of devices in the device group.",
tags = "Device Group Management", tags = "Device Group Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:groups:devices")
scopes = { @AuthorizationScope(scope = "/device-mgt/groups/devices/view", })
description = "View devices") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -613,12 +685,10 @@ public interface GroupManagementService {
value = "View list of device count in the device group.", value = "View list of device count in the device group.",
notes = "Returns device count in the device group.", notes = "Returns device count in the device group.",
tags = "Device Group Management", tags = "Device Group Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:groups:devices-count")
scopes = { @AuthorizationScope(scope = "/device-mgt/groups/devices/view", })
description = "View devices") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -667,12 +737,10 @@ public interface GroupManagementService {
value = "Add devices to group.", value = "Add devices to group.",
notes = "Add existing devices to the device group.", notes = "Add existing devices to the device group.",
tags = "Device Group Management", tags = "Device Group Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:groups:devices-add")
scopes = { @AuthorizationScope(scope = "/device-mgt/groups/devices/add", })
description = "Add devices") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -725,12 +793,10 @@ public interface GroupManagementService {
value = "Remove devices from group.", value = "Remove devices from group.",
notes = "Remove existing devices from the device group.", notes = "Remove existing devices from the device group.",
tags = "Device Group Management", tags = "Device Group Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:groups:devices-remove")
scopes = { @AuthorizationScope(scope = "/device-mgt/groups/devices/remove", })
description = "Remove devices") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -783,12 +849,10 @@ public interface GroupManagementService {
value = "Assign devices to groups", value = "Assign devices to groups",
notes = "Add existing device to device groups.", notes = "Add existing device to device groups.",
tags = "Device Group Management", tags = "Device Group Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value = "permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:groups:assign")
scopes = {@AuthorizationScope(scope = "/device-mgt/groups/devices/add", })
description = "Add devices")}
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -837,12 +901,10 @@ public interface GroupManagementService {
value = "List of groups that have the device", value = "List of groups that have the device",
notes = "List of groups that have the device.", notes = "List of groups that have the device.",
tags = "Device Group Management", tags = "Device Group Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value = "permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:groups:device")
scopes = {@AuthorizationScope(scope = "/device-mgt/groups/devices/view", })
description = "Add devices")}
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {

View File

@ -24,16 +24,17 @@ import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Extension; import io.swagger.annotations.Extension;
import io.swagger.annotations.Tag; import io.swagger.annotations.Tag;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.AuthorizationScope;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ResponseHeader; import io.swagger.annotations.ResponseHeader;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.apimgt.annotations.api.Scopes;
import org.wso2.carbon.device.mgt.common.notification.mgt.Notification; import org.wso2.carbon.device.mgt.common.notification.mgt.Notification;
import org.wso2.carbon.device.mgt.jaxrs.NotificationList; import org.wso2.carbon.device.mgt.jaxrs.NotificationList;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
import javax.validation.constraints.Max; import javax.validation.constraints.Max;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
@ -60,6 +61,22 @@ import javax.ws.rs.core.Response;
@Tag(name = "device_management", description = "") @Tag(name = "device_management", description = "")
} }
) )
@Scopes(
scopes = {
@Scope(
name = "Getting All Device Notification Details",
description = "Getting All Device Notification Details",
key = "perm:notifications:view",
permissions = {"/device-mgt/notifications/view"}
),
@Scope(
name = "Updating the Device Notification Status",
description = "Updating the Device Notification Status",
key = "perm:notifications:mark-checked",
permissions = {"/device-mgt/notifications/view"}
)
}
)
@Api(value = "Device Notification Management", description = "Device notification related operations can be found here.") @Api(value = "Device Notification Management", description = "Device notification related operations can be found here.")
@Path("/notifications") @Path("/notifications")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@ -73,12 +90,10 @@ public interface NotificationManagementService {
value = "Getting All Device Notification Details", value = "Getting All Device Notification Details",
notes = "Get the details of all the notifications that were pushed to the devices registered with WSO2 EMM using this REST API.", notes = "Get the details of all the notifications that were pushed to the devices registered with WSO2 EMM using this REST API.",
tags = "Device Notification Management", tags = "Device Notification Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:notifications:view")
scopes = { @AuthorizationScope(scope = "/device-mgt/notifications/view", })
description = "View notifications") }
)
} }
) )
@ApiResponses( @ApiResponses(
@ -164,12 +179,10 @@ public interface NotificationManagementService {
notes = "When a user has read the the device notification the device notification status must " notes = "When a user has read the the device notification the device notification status must "
+ "change from NEW to CHECKED. This API is used to update device notification status.", + "change from NEW to CHECKED. This API is used to update device notification status.",
tags = "Device Notification Management", tags = "Device Notification Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:notifications:mark-checked")
scopes = { @AuthorizationScope(scope = "/device-mgt/notifications/view", })
description = "View notifications") }
)
} }
) )
@ApiResponses( @ApiResponses(

View File

@ -24,17 +24,17 @@ import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Extension; import io.swagger.annotations.Extension;
import io.swagger.annotations.Tag; import io.swagger.annotations.Tag;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.AuthorizationScope;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ResponseHeader; import io.swagger.annotations.ResponseHeader;
import org.wso2.carbon.apimgt.annotations.api.Permission; import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.apimgt.annotations.api.Scopes;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.beans.PolicyWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.PolicyWrapper;
import org.wso2.carbon.device.mgt.jaxrs.beans.PriorityUpdatedPolicyWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.PriorityUpdatedPolicyWrapper;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
import javax.validation.Valid; import javax.validation.Valid;
@ -63,6 +63,64 @@ import java.util.List;
@Tag(name = "device_management", description = "") @Tag(name = "device_management", description = "")
} }
) )
@Scopes(
scopes = {
@Scope(
name = "Adding a Policy",
description = "Adding a Policy",
key = "perm:policies:manage",
permissions = {"/device-mgt/policies/manage"}
),
@Scope(
name = "Getting Details of Policies",
description = "Getting Details of Policies",
key = "perm:policies:get-details",
permissions = {"/device-mgt/policies/view"}
),
@Scope(
name = "Getting Details of a Policy",
description = "Getting Details of a Policy",
key = "perm:policies:get-policy-details",
permissions = {"/device-mgt/policies/view"}
),
@Scope(
name = "Updating a Policy",
description = "Updating a Policy",
key = "perm:policies:update",
permissions = {"/device-mgt/policies/manage"}
),
@Scope(
name = "Removing Multiple Policies",
description = "Removing Multiple Policies",
key = "perm:policies:remove",
permissions = {"/device-mgt/policies/manage"}
),
@Scope(
name = "Activating Policies",
description = "Activating Policies",
key = "perm:policies:activate",
permissions = {"/device-mgt/policies/manage"}
),
@Scope(
name = "Deactivating Policies",
description = "Deactivating Policies",
key = "perm:policies:deactivate",
permissions = {"/device-mgt/policies/manage"}
),
@Scope(
name = "Applying Changes on Policies",
description = "Applying Changes on Policies",
key = "perm:policies:changes",
permissions = {"/device-mgt/policies/manage"}
),
@Scope(
name = "Updating the Policy Priorities",
description = "Updating the Policy Priorities",
key = "perm:policies:priorities",
permissions = {"/device-mgt/policies/manage"}
)
}
)
@Api(value = "Device Policy Management", description = "This API includes the functionality around device policy management") @Api(value = "Device Policy Management", description = "This API includes the functionality around device policy management")
@Path("/policies") @Path("/policies")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@ -78,12 +136,10 @@ public interface PolicyManagementService {
notes = "Add a policy using this REST API command. When adding a policy you will have the option of saving the policy or saving and publishing the policy." + notes = "Add a policy using this REST API command. When adding a policy you will have the option of saving the policy or saving and publishing the policy." +
"Using this REST API you are able to save a created Policy and this policy will be in the inactive state.", "Using this REST API you are able to save a created Policy and this policy will be in the inactive state.",
tags = "Device Policy Management", tags = "Device Policy Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:policies:manage")
scopes = { @AuthorizationScope(scope = "/device-mgt/policies/manage", })
description = "Manage policies") }
)
} }
) )
@ApiResponses( @ApiResponses(
@ -148,12 +204,10 @@ public interface PolicyManagementService {
notes = "Retrieve the details of all the policies in WSO2 EMM.", notes = "Retrieve the details of all the policies in WSO2 EMM.",
response = Policy.class, response = Policy.class,
tags = "Device Policy Management", tags = "Device Policy Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:policies:get-details")
scopes = { @AuthorizationScope(scope = "/device-mgt/policies/view", })
description = "View policies") }
)
} }
) )
@ApiResponses( @ApiResponses(
@ -225,12 +279,10 @@ public interface PolicyManagementService {
notes = "Retrieve the details of a policy that is in WSO2 EMM.", notes = "Retrieve the details of a policy that is in WSO2 EMM.",
response = Policy.class, response = Policy.class,
tags = "Device Policy Management", tags = "Device Policy Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:policies:get-policy-details")
scopes = { @AuthorizationScope(scope = "/device-mgt/policies/view", })
description = "View policies") }
)
} }
) )
@ApiResponses( @ApiResponses(
@ -295,12 +347,10 @@ public interface PolicyManagementService {
value = "Updating a Policy", value = "Updating a Policy",
notes = "Make changes to an existing policy by updating the policy using this resource.", notes = "Make changes to an existing policy by updating the policy using this resource.",
tags = "Device Policy Management", tags = "Device Policy Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:policies:update")
scopes = { @AuthorizationScope(scope = "/device-mgt/policies/manage", })
description = "Manage policies") }
)
} }
) )
@ApiResponses( @ApiResponses(
@ -365,12 +415,10 @@ public interface PolicyManagementService {
value = "Removing Multiple Policies", value = "Removing Multiple Policies",
notes = "Delete one or more than one policy using this API.", notes = "Delete one or more than one policy using this API.",
tags = "Device Policy Management", tags = "Device Policy Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:policies:remove")
scopes = { @AuthorizationScope(scope = "/device-mgt/policies/manage", })
description = "Manage policies") }
)
} }
) )
@ApiResponses( @ApiResponses(
@ -413,12 +461,10 @@ public interface PolicyManagementService {
value = "Activating Policies", value = "Activating Policies",
notes = "Publish a policy using this API to bring a policy that is in the inactive state to the active state.", notes = "Publish a policy using this API to bring a policy that is in the inactive state to the active state.",
tags = "Device Policy Management", tags = "Device Policy Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:policies:activate")
scopes = { @AuthorizationScope(scope = "/device-mgt/policies/manage", })
description = "Manage policies") }
)
} }
) )
@ApiResponses( @ApiResponses(
@ -456,12 +502,10 @@ public interface PolicyManagementService {
value = "Deactivating Policies", value = "Deactivating Policies",
notes = "Unpublish a policy using this API to bring a policy that is in the active state to the inactive state.", notes = "Unpublish a policy using this API to bring a policy that is in the active state to the inactive state.",
tags = "Device Policy Management", tags = "Device Policy Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:policies:deactivate")
scopes = { @AuthorizationScope(scope = "/device-mgt/policies/manage", })
description = "Manage policies") }
)
} }
) )
@ApiResponses( @ApiResponses(
@ -504,12 +548,10 @@ public interface PolicyManagementService {
" devices will not receive these changes immediately. Once all the required changes are made" + " devices will not receive these changes immediately. Once all the required changes are made" +
" you need to apply the changes to push the policy changes to the existing devices.", " you need to apply the changes to push the policy changes to the existing devices.",
tags = "Device Policy Management", tags = "Device Policy Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:policies:changes")
scopes = { @AuthorizationScope(scope = "/device-mgt/policies/manage", })
description = "Manage policies") }
)
} }
) )
@ApiResponses( @ApiResponses(
@ -534,13 +576,11 @@ public interface PolicyManagementService {
value = "Updating the Policy Priorities", value = "Updating the Policy Priorities",
notes = "Make changes to the existing policy priority order by updating the priority order using this API.", notes = "Make changes to the existing policy priority order by updating the priority order using this API.",
tags = "Device Policy Management", tags = "Device Policy Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:policies:priorities")
scopes = { @AuthorizationScope(scope = "/device-mgt/policies/manage", })
description = "Manage policies") } }
)
}
) )
@ApiResponses( @ApiResponses(
value = { value = {
@ -565,7 +605,6 @@ public interface PolicyManagementService {
@GET @GET
@Path("/effective-policy/{deviceType}/{deviceId}") @Path("/effective-policy/{deviceType}/{deviceId}")
@Permission(name = "Get Effective Policy of Devices", permission = "/device-mgt/policies/view")
Response getEffectivePolicy(@PathParam("deviceId") String deviceId, @PathParam("deviceType") String deviceType); Response getEffectivePolicy(@PathParam("deviceId") String deviceId, @PathParam("deviceType") String deviceType);
} }

View File

@ -24,16 +24,17 @@ import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Extension; import io.swagger.annotations.Extension;
import io.swagger.annotations.Tag; import io.swagger.annotations.Tag;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.AuthorizationScope;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ResponseHeader; import io.swagger.annotations.ResponseHeader;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.apimgt.annotations.api.Scopes;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleInfo; import org.wso2.carbon.device.mgt.jaxrs.beans.RoleInfo;
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleList; import org.wso2.carbon.device.mgt.jaxrs.beans.RoleList;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
import org.wso2.carbon.user.mgt.common.UIPermissionNode; import org.wso2.carbon.user.mgt.common.UIPermissionNode;
import javax.ws.rs.*; import javax.ws.rs.*;
@ -56,6 +57,58 @@ import java.util.List;
@Tag(name = "device_management", description = "") @Tag(name = "device_management", description = "")
} }
) )
@Scopes(
scopes = {
@Scope(
name = "Getting the List of Roles",
description = "Getting the List of Roles",
key = "perm:roles:view",
permissions = {"/device-mgt/roles/view"}
),
@Scope(
name = "Getting Permission Details of a Role",
description = "Getting Permission Details of a Role",
key = "perm:roles:permissions",
permissions = {"/device-mgt/roles/view"}
),
@Scope(
name = "Getting the List of Roles",
description = "Getting the List of Roles",
key = "perm:roles:details",
permissions = {"/device-mgt/roles/view"}
),
@Scope(
name = "Adding a Role",
description = "Adding a Role",
key = "perm:roles:add",
permissions = {"/device-mgt/roles/manage"}
),
@Scope(
name = "Adding a combined Role",
description = "Adding a combined Role",
key = "perm:roles:create-combined-role",
permissions = {"/device-mgt/roles/manage"}
),
@Scope(
name = "Updating Role Details",
description = "Updating Role Details",
key = "perm:roles:update",
permissions = {"/device-mgt/roles/manage"}
),
@Scope(
name = "Deleting a Role",
description = "Deleting a Role",
key = "perm:roles:delete",
permissions = {"/device-mgt/roles/manage"}
),
@Scope(
name = "Adding Users to a Role",
description = "Adding Users to a Role",
key = "perm:roles:add-users",
permissions = {"/device-mgt/roles/manage"}
)
}
)
@Path("/roles") @Path("/roles")
@Api(value = "Role Management", description = "Role management related operations can be found here.") @Api(value = "Role Management", description = "Role management related operations can be found here.")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@ -70,11 +123,10 @@ public interface RoleManagementService {
notes = "WSO2 EMM supports role-based access control (RBAC) and role management. Using this API you can the list of roles that are in WSO2 EMM.\n" + notes = "WSO2 EMM supports role-based access control (RBAC) and role management. Using this API you can the list of roles that are in WSO2 EMM.\n" +
"Note: Internal roles, roles created for service-providers, and application related roles will not be given in the output.", "Note: Internal roles, roles created for service-providers, and application related roles will not be given in the output.",
tags = "Role Management", tags = "Role Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:view")
scopes = { @AuthorizationScope(scope = "/device-mgt/roles/view", description = "View Roles") } })
)
} }
) )
@ApiResponses( @ApiResponses(
@ -151,11 +203,10 @@ public interface RoleManagementService {
response = UIPermissionNode.class, response = UIPermissionNode.class,
responseContainer = "List", responseContainer = "List",
tags = "Role Management", tags = "Role Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:permissions")
scopes = { @AuthorizationScope(scope = "/device-mgt/roles/view", description = "View Roles") } })
)
} }
) )
@ApiResponses( @ApiResponses(
@ -227,12 +278,10 @@ public interface RoleManagementService {
notes = "Get the permissions associated with a role and role specific details using this REST API.", notes = "Get the permissions associated with a role and role specific details using this REST API.",
response = RoleInfo.class, response = RoleInfo.class,
tags = "Role Management", tags = "Role Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:details")
scopes = { @AuthorizationScope(scope = "/device-mgt/roles/view", })
description = "View Roles") }
)
} }
) )
@ApiResponses( @ApiResponses(
@ -303,12 +352,10 @@ public interface RoleManagementService {
value = "Adding a Role", value = "Adding a Role",
notes = "WSO2 EMM supports role-based access control (RBAC) and role management. Add a new role to WSO2 EMM using this REST API.", notes = "WSO2 EMM supports role-based access control (RBAC) and role management. Add a new role to WSO2 EMM using this REST API.",
tags = "Role Management", tags = "Role Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:add")
scopes = { @AuthorizationScope(scope = "/device-mgt/roles/manage", })
description = "Manage Roles") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -365,12 +412,10 @@ public interface RoleManagementService {
value = "Adding a combined Role", value = "Adding a combined Role",
notes = "WSO2 EMM supports role-based access control (RBAC) and role management. Add a new combined role to WSO2 EMM using this REST API.", notes = "WSO2 EMM supports role-based access control (RBAC) and role management. Add a new combined role to WSO2 EMM using this REST API.",
tags = "Role Management", tags = "Role Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:create-combined-role")
scopes = { @AuthorizationScope(scope = "/device-mgt/roles/manage", })
description = "Manage Roles") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -430,12 +475,10 @@ public interface RoleManagementService {
notes = "There will be situations where you need to update the role details, such as the permissions" + notes = "There will be situations where you need to update the role details, such as the permissions" +
" or the role name. Update the role details using this REST API.", " or the role name. Update the role details using this REST API.",
tags = "Role Management", tags = "Role Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:update")
scopes = { @AuthorizationScope(scope = "/device-mgt/roles/manage", })
description = "Manage Roles") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -498,12 +541,10 @@ public interface RoleManagementService {
notes = "Roles become obsolete over time due to various reasons. In a situation where your Organization identifies that a specific role is no longer required, you " + notes = "Roles become obsolete over time due to various reasons. In a situation where your Organization identifies that a specific role is no longer required, you " +
"can delete a role using this REST API.", "can delete a role using this REST API.",
tags = "Role Management", tags = "Role Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:delete")
scopes = { @AuthorizationScope(scope = "/device-mgt/roles/manage", })
description = "Manage Roles") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -550,12 +591,10 @@ public interface RoleManagementService {
"be cumbersome. Therefore, you can define all the new employees that belong to the engineering " + "be cumbersome. Therefore, you can define all the new employees that belong to the engineering " +
"role using this API.", "role using this API.",
tags = "Role Management", tags = "Role Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:add-users")
scopes = { @AuthorizationScope(scope = "/device-mgt/roles/manage", })
description = "Manage Roles") }
)
} }
) )
@ApiResponses( @ApiResponses(

View File

@ -18,20 +18,22 @@
*/ */
package org.wso2.carbon.device.mgt.jaxrs.service.api; package org.wso2.carbon.device.mgt.jaxrs.service.api;
import io.swagger.annotations.SwaggerDefinition;
import io.swagger.annotations.Info;
import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Extension;
import io.swagger.annotations.Tag;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.AuthorizationScope;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.AuthorizationScope;
import io.swagger.annotations.Extension;
import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Info;
import io.swagger.annotations.ResponseHeader; import io.swagger.annotations.ResponseHeader;
import io.swagger.annotations.SwaggerDefinition;
import io.swagger.annotations.Tag;
import org.apache.axis2.transport.http.HTTPConstants; import org.apache.axis2.transport.http.HTTPConstants;
import org.wso2.carbon.apimgt.annotations.api.Scopes;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.device.mgt.jaxrs.beans.BasicUserInfo; import org.wso2.carbon.device.mgt.jaxrs.beans.BasicUserInfo;
import org.wso2.carbon.device.mgt.jaxrs.beans.BasicUserInfoList; import org.wso2.carbon.device.mgt.jaxrs.beans.BasicUserInfoList;
import org.wso2.carbon.device.mgt.jaxrs.beans.EnrollmentInvitation; import org.wso2.carbon.device.mgt.jaxrs.beans.EnrollmentInvitation;
@ -39,6 +41,7 @@ import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.beans.OldPasswordResetWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.OldPasswordResetWrapper;
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleList; import org.wso2.carbon.device.mgt.jaxrs.beans.RoleList;
import org.wso2.carbon.device.mgt.jaxrs.beans.UserInfo; import org.wso2.carbon.device.mgt.jaxrs.beans.UserInfo;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
import javax.validation.Valid; import javax.validation.Valid;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
@ -70,6 +73,76 @@ import java.util.List;
@Tag(name = "device_management", description = "") @Tag(name = "device_management", description = "")
} }
) )
@Scopes(
scopes = {
@Scope(
name = "Adding a User",
description = "Adding a User",
key = "perm:users:add",
permissions = {"/device-mgt/users/manage"}
),
@Scope(
name = "Getting Details of a User",
description = "Getting Details of a User",
key = "perm:users:details",
permissions = {"/device-mgt/users/view"}
),
@Scope(
name = "Updating Details of a User",
description = "Updating Details of a User",
key = "perm:users:update",
permissions = {"/device-mgt/users/manage"}
),
@Scope(
name = "Deleting a User",
description = "Deleting a User",
key = "perm:users:delete",
permissions = {"/device-mgt/users/manage"}
),
@Scope(
name = "Getting the Role Details of a User",
description = "Getting the Role Details of a User",
key = "perm:users:roles",
permissions = {"/device-mgt/users/view"}
),
@Scope(
name = "Getting Details of Users",
description = "Getting Details of Users",
key = "perm:users:user-details",
permissions = {"/device-mgt/users/view"}
),
@Scope(
name = "Getting the User Count",
description = "Getting the User Count",
key = "perm:users:count",
permissions = {"/device-mgt/users/view"}
),
@Scope(
name = "Getting the User existence status",
description = "Getting the User existence status",
key = "perm:users:is-exist",
permissions = {"/device-mgt/users/view"}
),
@Scope(
name = "Searching for a User Name",
description = "Searching for a User Name",
key = "perm:users:search",
permissions = {"/device-mgt/users/view"}
),
@Scope(
name = "Changing the User Password",
description = "Adding a User",
key = "perm:users:credentials",
permissions = {"/login"}
),
@Scope(
name = "Sending Enrollment Invitations to Users",
description = "Sending Enrollment Invitations to Users",
key = "perm:users:send-invitation",
permissions = {"/device-mgt/users/manage"}
)
}
)
@Path("/users") @Path("/users")
@Api(value = "User Management", description = "User management related operations can be found here.") @Api(value = "User Management", description = "User management related operations can be found here.")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@ -84,12 +157,10 @@ public interface UserManagementService {
value = "Adding a User", value = "Adding a User",
notes = "WSO2 IoTS supports user management. Add a new user to the WSO2 IoTS user management system via this REST API", notes = "WSO2 IoTS supports user management. Add a new user to the WSO2 IoTS user management system via this REST API",
tags = "User Management", tags = "User Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:users:add")
scopes = { @AuthorizationScope(scope = "/device-mgt/users/manage", })
description = "Manage Users") }
)
} }
) )
@ApiResponses( @ApiResponses(
@ -146,12 +217,10 @@ public interface UserManagementService {
notes = "Get the details of a user registered with WSO2 IoTS using the REST API.", notes = "Get the details of a user registered with WSO2 IoTS using the REST API.",
response = BasicUserInfo.class, response = BasicUserInfo.class,
tags = "User Management", tags = "User Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:users:details")
scopes = { @AuthorizationScope(scope = "/device-mgt/users/view", })
description = "View Users") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -219,12 +288,10 @@ public interface UserManagementService {
notes = "There will be situations where you will want to update the user details. In such " notes = "There will be situations where you will want to update the user details. In such "
+ "situation you can update the user details using this REST API.", + "situation you can update the user details using this REST API.",
tags = "User Management", tags = "User Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:users:update")
scopes = { @AuthorizationScope(scope = "/device-mgt/users/manage", })
description = "Manage Users") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -286,12 +353,10 @@ public interface UserManagementService {
value = "Deleting a User", value = "Deleting a User",
notes = "When an employee leaves the organization, you can remove the user details from WSO2 IoTS using this REST API.", notes = "When an employee leaves the organization, you can remove the user details from WSO2 IoTS using this REST API.",
tags = "User Management", tags = "User Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:users:delete")
scopes = { @AuthorizationScope(scope = "/device-mgt/users/manage", })
description = "Manage Users") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -331,12 +396,10 @@ public interface UserManagementService {
value = "Getting the Role Details of a User", value = "Getting the Role Details of a User",
notes = "A user can be assigned to one or more role in IoTS. Using this REST API you can get the role/roles a user is assigned to.", notes = "A user can be assigned to one or more role in IoTS. Using this REST API you can get the role/roles a user is assigned to.",
tags = "User Management", tags = "User Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:users:roles")
scopes = { @AuthorizationScope(scope = "/device-mgt/users/view", })
description = "View Users") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -395,12 +458,10 @@ public interface UserManagementService {
notes = "You are able to manage users in WSO2 IoTS by adding, updating and removing users. If you wish to get the list of users registered with WSO2 IoTS, you can do so " notes = "You are able to manage users in WSO2 IoTS by adding, updating and removing users. If you wish to get the list of users registered with WSO2 IoTS, you can do so "
+ "using this REST API", + "using this REST API",
tags = "User Management", tags = "User Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:users:user-details")
scopes = { @AuthorizationScope(scope = "/device-mgt/users/view", })
description = "View Users") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -468,11 +529,10 @@ public interface UserManagementService {
value = "Getting the User Count", value = "Getting the User Count",
notes = "Get the number of users in WSO2 IoTS via this REST API.", notes = "Get the number of users in WSO2 IoTS via this REST API.",
tags = "User Management", tags = "User Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:users:count")
scopes = { @AuthorizationScope(scope = "/device-mgt/users/view", description = "View Users") } })
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -504,12 +564,10 @@ public interface UserManagementService {
value = "Getting the User existence status", value = "Getting the User existence status",
notes = "Check if the user exists in the user store.", notes = "Check if the user exists in the user store.",
tags = "User Management", tags = "User Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:users:is-exist")
scopes = { @AuthorizationScope(scope = "/device-mgt/users/view", })
description = "View Users") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -549,11 +607,10 @@ public interface UserManagementService {
+ "You will be given a list of users having the user name in the exact order of the " + "You will be given a list of users having the user name in the exact order of the "
+ "characters you provided.", + "characters you provided.",
tags = "User Management", tags = "User Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:users:search")
scopes = { @AuthorizationScope(scope = "/device-mgt/users/view", description = "View Users") } })
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -627,11 +684,10 @@ public interface UserManagementService {
value = "Changing the User Password", value = "Changing the User Password",
notes = "A user is able to change the password to secure their WSO2 IoTS profile via this REST API.", notes = "A user is able to change the password to secure their WSO2 IoTS profile via this REST API.",
tags = "User Management", tags = "User Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:users:credentials")
scopes = { @AuthorizationScope(scope = "/login", description = "Reset user password") } })
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -673,11 +729,10 @@ public interface UserManagementService {
notes = "Send the users a mail inviting them to enroll their devices using the REST API given below.\n" + notes = "Send the users a mail inviting them to enroll their devices using the REST API given below.\n" +
"Before running the REST API command to send the enrollment invitations to users make sure to configure WSO2 IoTS as explained in step 4, under the WSO2 IoTS general server configurations documentation.", "Before running the REST API command to send the enrollment invitations to users make sure to configure WSO2 IoTS as explained in step 4, under the WSO2 IoTS general server configurations documentation.",
tags = "User Management", tags = "User Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:users:send-invitation")
scopes = { @AuthorizationScope(scope = "/device-mgt/users/manage", description = "Manage Users") } })
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {

View File

@ -18,11 +18,22 @@
*/ */
package org.wso2.carbon.device.mgt.jaxrs.service.api.admin; package org.wso2.carbon.device.mgt.jaxrs.service.api.admin;
import io.swagger.annotations.*; import io.swagger.annotations.SwaggerDefinition;
import org.wso2.carbon.apimgt.annotations.api.Permission; import io.swagger.annotations.Info;
import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Extension;
import io.swagger.annotations.Tag;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.apimgt.annotations.api.Scopes;
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
import org.wso2.carbon.device.mgt.jaxrs.beans.ApplicationWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.ApplicationWrapper;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.POST; import javax.ws.rs.POST;
@ -50,6 +61,22 @@ import javax.ws.rs.core.Response;
@Api(value = "Application Management Administrative Service", description = "This an API intended to be used by " + @Api(value = "Application Management Administrative Service", description = "This an API intended to be used by " +
"'internal' components to log in as an admin user and do a selected number of operations. " + "'internal' components to log in as an admin user and do a selected number of operations. " +
"Further, this is strictly restricted to admin users only ") "Further, this is strictly restricted to admin users only ")
@Scopes(
scopes = {
@Scope(
name = "Installing an Application (Internal API)",
description = "Installing an Application (Internal API)",
key = "perm:applications:install",
permissions = {"/device-mgt/applications/manage"}
),
@Scope(
name = "Uninstalling an Application (Internal API)",
description = "Uninstalling an Application (Internal API)",
key = "perm:applications:uninstall",
permissions = {"/device-mgt/applications/manage"}
)
}
)
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public interface ApplicationManagementAdminService { public interface ApplicationManagementAdminService {
@ -64,12 +91,10 @@ public interface ApplicationManagementAdminService {
notes = "This is an internal API that can be used to install an application on a device.", notes = "This is an internal API that can be used to install an application on a device.",
response = Activity.class, response = Activity.class,
tags = "Application Management Administrative Service", tags = "Application Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:applications:install")
scopes = { @AuthorizationScope(scope = "/device-mgt/applications/manage", description })
= "Install/Uninstall applications") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -110,12 +135,10 @@ public interface ApplicationManagementAdminService {
notes = "This is an internal API that can be used to uninstall an application.", notes = "This is an internal API that can be used to uninstall an application.",
response = Activity.class, response = Activity.class,
tags = "Application Management Administrative Service", tags = "Application Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:applications:uninstall")
scopes = { @AuthorizationScope(scope = "/device-mgt/applications/manage", description })
= "Install/Uninstall applications") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {

View File

@ -22,7 +22,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import org.wso2.carbon.apimgt.annotations.api.Permission;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAuthorizationResult; import org.wso2.carbon.device.mgt.common.authorization.DeviceAuthorizationResult;
import org.wso2.carbon.device.mgt.jaxrs.beans.AuthorizationRequest; import org.wso2.carbon.device.mgt.jaxrs.beans.AuthorizationRequest;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;

View File

@ -24,15 +24,16 @@ import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Extension; import io.swagger.annotations.Extension;
import io.swagger.annotations.Tag; import io.swagger.annotations.Tag;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.AuthorizationScope;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ResponseHeader; import io.swagger.annotations.ResponseHeader;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.apimgt.annotations.api.Scopes;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import javax.ws.rs.*; import javax.ws.rs.*;
@ -60,6 +61,16 @@ import javax.ws.rs.core.Response;
"Further, this is strictly restricted to admin users only ") "Further, this is strictly restricted to admin users only ")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Scopes(
scopes = {
@Scope(
name = "Getting Details of a Device",
description = "Getting Details of a Device",
key = "perm:admin:devices:view",
permissions = {"/device-mgt/devices/owning-device/view"}
)
}
)
public interface DeviceManagementAdminService { public interface DeviceManagementAdminService {
@GET @GET
@ -71,12 +82,10 @@ public interface DeviceManagementAdminService {
response = Device.class, response = Device.class,
responseContainer = "List", responseContainer = "List",
tags = "Device Management Administrative Service", tags = "Device Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:admin:devices:view")
scopes = { @AuthorizationScope(scope = "/device-mgt/devices/owning-device/view", description })
= "View Devices") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {

View File

@ -25,16 +25,17 @@ import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Extension; import io.swagger.annotations.Extension;
import io.swagger.annotations.Tag; import io.swagger.annotations.Tag;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.AuthorizationScope;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ResponseHeader; import io.swagger.annotations.ResponseHeader;
import org.apache.axis2.transport.http.HTTPConstants; import org.apache.axis2.transport.http.HTTPConstants;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.apimgt.annotations.api.Scopes;
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceGroupList; import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceGroupList;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
@ -61,6 +62,22 @@ import javax.ws.rs.core.Response;
@Api(value = "Group Management Administrative Service", description = "This an API intended to be used by " + @Api(value = "Group Management Administrative Service", description = "This an API intended to be used by " +
"'internal' components to log in as an admin user and do a selected number of operations. " + "'internal' components to log in as an admin user and do a selected number of operations. " +
"Further, this is strictly restricted to admin users only ") "Further, this is strictly restricted to admin users only ")
@Scopes(
scopes = {
@Scope(
name = "View groups",
description = "",
key = "perm:admin-groups:view",
permissions = {"/device-mgt/admin/groups/view"}
),
@Scope(
name = "Count groups",
description = "",
key = "perm:admin-groups:count",
permissions = {"/device-mgt/admin/groups/view"}
)
}
)
public interface GroupManagementAdminService { public interface GroupManagementAdminService {
@GET @GET
@ -70,12 +87,10 @@ public interface GroupManagementAdminService {
value = "Get the list of groups.", value = "Get the list of groups.",
notes = "Returns all groups enrolled with the system.", notes = "Returns all groups enrolled with the system.",
tags = "Device Group Management", tags = "Device Group Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:admin-groups:view")
scopes = { @AuthorizationScope(scope = "/device-mgt/admin/groups/view", description })
= "View Groups") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {
@ -135,12 +150,10 @@ public interface GroupManagementAdminService {
value = "Get the count of groups belongs to current user.", value = "Get the count of groups belongs to current user.",
notes = "Returns count of all permitted groups enrolled with the system.", notes = "Returns count of all permitted groups enrolled with the system.",
tags = "Device Group Management", tags = "Device Group Management",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:admin-groups:count")
scopes = { @AuthorizationScope(scope = "/device-mgt/admin/groups/view", description })
= "View Groups") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {

View File

@ -24,14 +24,15 @@ import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Extension; import io.swagger.annotations.Extension;
import io.swagger.annotations.Tag; import io.swagger.annotations.Tag;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.AuthorizationScope;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.apimgt.annotations.api.Scopes;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.beans.PasswordResetWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.PasswordResetWrapper;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import javax.ws.rs.*; import javax.ws.rs.*;
@ -53,6 +54,16 @@ import javax.ws.rs.core.Response;
@Tag(name = "device_management", description = "") @Tag(name = "device_management", description = "")
} }
) )
@Scopes(
scopes = {
@Scope(
name = "View Users",
description = "View Users",
key = "perm:admin-users:view",
permissions = {"/device-mgt/users/manage"}
)
}
)
@Path("/admin/users") @Path("/admin/users")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@ -71,12 +82,10 @@ public interface UserManagementAdminService {
notes = "The EMM administrator is able to change the password of the users in " + notes = "The EMM administrator is able to change the password of the users in " +
"the system and block them from logging into their EMM profile using this REST API.", "the system and block them from logging into their EMM profile using this REST API.",
tags = "User Management Administrative Service", tags = "User Management Administrative Service",
authorizations = { extensions = {
@Authorization( @Extension(properties = {
value="permission", @ExtensionProperty(name = Constants.SCOPE, value = "perm:admin-users:view")
scopes = { @AuthorizationScope(scope = "/device-mgt/users/manage", description })
= "View Users") }
)
} }
) )
@ApiResponses(value = { @ApiResponses(value = {

View File

@ -24,8 +24,11 @@ import io.swagger.jaxrs.config.ReaderListener;
import io.swagger.models.Swagger; import io.swagger.models.Swagger;
import io.swagger.models.auth.OAuth2Definition; import io.swagger.models.auth.OAuth2Definition;
import io.swagger.models.auth.SecuritySchemeDefinition; import io.swagger.models.auth.SecuritySchemeDefinition;
import org.wso2.carbon.device.mgt.jaxrs.beans.Scope;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
@SwaggerDefinition( @SwaggerDefinition(
@ -54,6 +57,7 @@ public class SecurityDefinitionConfigurator implements ReaderListener {
schemes.put(TOKEN_AUTH_SCHEME, tokenScheme); schemes.put(TOKEN_AUTH_SCHEME, tokenScheme);
swagger.setSecurityDefinitions(schemes); swagger.setSecurityDefinitions(schemes);
//TODO: Have to add wso2-scopes to swagger definition from here
} }
} }

View File

@ -27,6 +27,7 @@ public class Constants {
public static final String USER_CLAIM_FIRST_NAME = "http://wso2.org/claims/givenname"; public static final String USER_CLAIM_FIRST_NAME = "http://wso2.org/claims/givenname";
public static final String USER_CLAIM_LAST_NAME = "http://wso2.org/claims/lastname"; public static final String USER_CLAIM_LAST_NAME = "http://wso2.org/claims/lastname";
public static final String PRIMARY_USER_STORE = "PRIMARY"; public static final String PRIMARY_USER_STORE = "PRIMARY";
public static final String SCOPE = "scope";
public final class ErrorMessages { public final class ErrorMessages {
private ErrorMessages () { throw new AssertionError(); } private ErrorMessages () { throw new AssertionError(); }

View File

@ -21,7 +21,7 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -23,6 +23,7 @@ import io.swagger.models.Swagger;
import org.apache.catalina.core.StandardContext; import org.apache.catalina.core.StandardContext;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.apimgt.api.model.Scope;
import org.wso2.carbon.device.mgt.common.permission.mgt.Permission; import org.wso2.carbon.device.mgt.common.permission.mgt.Permission;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
@ -38,10 +39,7 @@ import java.net.URI;
import java.net.URL; import java.net.URL;
import java.security.AccessController; import java.security.AccessController;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
public class AnnotationProcessor { public class AnnotationProcessor {
@ -56,11 +54,16 @@ public class AnnotationProcessor {
private static final String STRING_ARR = "string_arr"; private static final String STRING_ARR = "string_arr";
private static final String STRING = "string"; private static final String STRING = "string";
private static final String SWAGGER_ANNOTATIONS_AUTHORIZATIONS = "authorizations"; private static final String SWAGGER_ANNOTATIONS_PROPERTIES = "properties";
private static final String SWAGGER_ANNOTATIONS_PERMISSION = "permission"; private static final String SWAGGER_ANNOTATIONS_EXTENSIONS = "extensions";
private static final String SWAGGER_ANNOTATIONS_SCOPES = "scopes"; private static final String SWAGGER_ANNOTATIONS_PROPERTIES_VALUE = "value";
private static final String SWAGGER_ANNOTATIONS_SCOPE = "scope"; private static final String SWAGGER_ANNOTATIONS_PROPERTIES_NAME = "name";
private static final String SWAGGER_ANNOTATIONS_DESCRIPTION = "description"; private static final String SWAGGER_ANNOTATIONS_PROPERTIES_DESCRIPTION = "description";
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_KEY = "key";
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_PERMISSIONS = "permissions";
private static final String ANNOTATIONS_SCOPES = "scopes";
private static final String PERMISSION_PREFIX = "/permission/admin";
private StandardContext context; private StandardContext context;
private Method[] pathClazzMethods; private Method[] pathClazzMethods;
@ -74,6 +77,11 @@ public class AnnotationProcessor {
private Class<io.swagger.annotations.ApiOperation> apiOperation; private Class<io.swagger.annotations.ApiOperation> apiOperation;
private Class<io.swagger.annotations.Authorization> authorizationClass; private Class<io.swagger.annotations.Authorization> authorizationClass;
private Class<io.swagger.annotations.AuthorizationScope> authorizationScopeClass; private Class<io.swagger.annotations.AuthorizationScope> authorizationScopeClass;
private Class<io.swagger.annotations.Extension> extensionClass;
private Class<io.swagger.annotations.ExtensionProperty> extensionPropertyClass;
private Class<org.wso2.carbon.apimgt.annotations.api.Scope> scopeClass;
private Class<org.wso2.carbon.apimgt.annotations.api.Scopes> scopesClass;
private Map<String, Scope> apiScopes;
public AnnotationProcessor(final StandardContext context) { public AnnotationProcessor(final StandardContext context) {
@ -90,6 +98,15 @@ public class AnnotationProcessor {
.loadClass((io.swagger.annotations.Authorization.class.getName())); .loadClass((io.swagger.annotations.Authorization.class.getName()));
authorizationScopeClass = (Class<io.swagger.annotations.AuthorizationScope>)classLoader authorizationScopeClass = (Class<io.swagger.annotations.AuthorizationScope>)classLoader
.loadClass((io.swagger.annotations.AuthorizationScope.class.getName())); .loadClass((io.swagger.annotations.AuthorizationScope.class.getName()));
extensionClass = (Class<io.swagger.annotations.Extension>)classLoader
.loadClass((io.swagger.annotations.Extension.class.getName()));
extensionPropertyClass = (Class<io.swagger.annotations.ExtensionProperty>)classLoader
.loadClass(io.swagger.annotations.ExtensionProperty.class.getName());
scopeClass = (Class<org.wso2.carbon.apimgt.annotations.api.Scope>) classLoader
.loadClass(org.wso2.carbon.apimgt.annotations.api.Scope.class.getName());
scopesClass = (Class<org.wso2.carbon.apimgt.annotations.api.Scopes>) classLoader
.loadClass(org.wso2.carbon.apimgt.annotations.api.Scopes.class.getName());
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
log.error("An error has occurred while loading classes ", e); log.error("An error has occurred while loading classes ", e);
} }
@ -135,6 +152,10 @@ public class AnnotationProcessor {
try { try {
clazz = classLoader.loadClass(className); clazz = classLoader.loadClass(className);
Annotation apiAnno = clazz.getAnnotation(apiClazz); Annotation apiAnno = clazz.getAnnotation(apiClazz);
Annotation scopesAnno = clazz.getAnnotation(scopesClass);
if (scopesAnno != null) {
apiScopes = processAPIScopes(scopesAnno);
}
List<Permission> resourceList; List<Permission> resourceList;
if (apiAnno != null) { if (apiAnno != null) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
@ -165,7 +186,9 @@ public class AnnotationProcessor {
} }
} }
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
log.error("Error when passing the api annotation for device type apis."); log.error("Error when passing the api annotation for device type apis.", e);
} catch (Throwable e) {
log.error("Error when passing the scopes annotation for device type apis.", e);
} }
return apiPermissions; return apiPermissions;
} }
@ -342,28 +365,55 @@ public class AnnotationProcessor {
private void setPermission(Annotation currentMethod, Permission permission) throws Throwable { private void setPermission(Annotation currentMethod, Permission permission) throws Throwable {
InvocationHandler methodHandler = Proxy.getInvocationHandler(currentMethod); InvocationHandler methodHandler = Proxy.getInvocationHandler(currentMethod);
Annotation[] authorizations = (Annotation[]) methodHandler.invoke(currentMethod Annotation[] extensions = (Annotation[]) methodHandler.invoke(currentMethod,
, apiOperation.getMethod(SWAGGER_ANNOTATIONS_AUTHORIZATIONS,null),null); apiOperation.getMethod(SWAGGER_ANNOTATIONS_EXTENSIONS, null), null);
for(int i=0; i<authorizations.length; i++){ methodHandler = Proxy.getInvocationHandler(extensions[0]);
methodHandler = Proxy.getInvocationHandler(authorizations[i]); Annotation[] properties = (Annotation[])methodHandler.invoke(extensions[0], extensionClass
String value =(String)methodHandler.invoke(authorizations[i], authorizationClass.getMethod("value", null) .getMethod(SWAGGER_ANNOTATIONS_PROPERTIES,null), null);
,null); Scope scope;
if(SWAGGER_ANNOTATIONS_PERMISSION.equals(value)){ for (Annotation property : properties) {
Annotation[] scopes =(Annotation[])methodHandler.invoke(authorizations[i], authorizationClass methodHandler = Proxy.getInvocationHandler(property);
.getMethod(SWAGGER_ANNOTATIONS_SCOPES, null),null); String scopeKey = (String) methodHandler.invoke(property, extensionPropertyClass
String[] scopesList = new String[scopes.length]; .getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_VALUE, null),null);
String[] descriptions = new String[scopes.length]; if (!scopeKey.isEmpty()) {
for(int j=0; j<scopes.length; j++){ scope = apiScopes.get(scopeKey);
methodHandler = Proxy.getInvocationHandler(scopes[j]); permission.setName(scope.getName());
scopesList[j] = (String)methodHandler.invoke(authorizations[j], authorizationScopeClass //TODO: currently permission tree supports only adding one permission per API point.
.getMethod(SWAGGER_ANNOTATIONS_SCOPE, null),null); permission.setPath(scope.getRoles().split(" ")[0]);
descriptions[j] = (String)methodHandler.invoke(authorizations[j], authorizationScopeClass
.getMethod(SWAGGER_ANNOTATIONS_DESCRIPTION, null),null);
}
//todo currently permission tree supports only adding one permission per API point.
permission.setName(descriptions[0]);
permission.setPath(scopesList[0]);
} }
} }
} }
private Map<String,Scope> processAPIScopes(Annotation annotation) throws Throwable {
Map<String, Scope> scopes = new HashMap<>();
InvocationHandler methodHandler = Proxy.getInvocationHandler(annotation);
Annotation[] annotatedScopes = (Annotation[]) methodHandler.invoke(annotation, scopesClass
.getMethod(ANNOTATIONS_SCOPES, null), null);
Scope scope;
String permissions[];
StringBuilder aggregatedPermissions;
for(int i=0; i<annotatedScopes.length; i++){
aggregatedPermissions = new StringBuilder();
methodHandler = Proxy.getInvocationHandler(annotatedScopes[i]);
scope = new Scope();
scope.setName(invokeMethod(scopeClass
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_NAME), annotatedScopes[i], STRING));
scope.setDescription(invokeMethod(scopeClass
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_DESCRIPTION), annotatedScopes[i], STRING));
scope.setKey(invokeMethod(scopeClass
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_KEY), annotatedScopes[i], STRING));
permissions = (String[])methodHandler.invoke(annotatedScopes[i], scopeClass
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_PERMISSIONS, null),null);
for (String permission : permissions) {
aggregatedPermissions.append(PERMISSION_PREFIX);
aggregatedPermissions.append(permission);
aggregatedPermissions.append(" ");
}
scope.setRoles(aggregatedPermissions.toString());
scopes.put(scope.getKey(), scope);
}
return scopes;
}
} }

View File

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -35,9 +35,9 @@
"usernameJSRegEx" : "^[\\S]{3,30}$", "usernameJSRegEx" : "^[\\S]{3,30}$",
"usernameRegExViolationErrorMsg" : "Provided username is invalid.", "usernameRegExViolationErrorMsg" : "Provided username is invalid.",
"usernameHelpMsg" : "Should be in minimum 3 characters long and do not include any whitespaces.", "usernameHelpMsg" : "Should be in minimum 3 characters long and do not include any whitespaces.",
"firstnameJSRegEx" : "^[\\S]{3,30}$", "firstnameJSRegEx" : "^.{3,30}$",
"firstnameRegExViolationErrorMsg" : "Provided first name is invalid.", "firstnameRegExViolationErrorMsg" : "Provided first name is invalid.",
"lastnameJSRegEx" : "^[\\S]{3,30}$", "lastnameJSRegEx" : "^.{3,30}$",
"lastnameRegExViolationErrorMsg" : "Provided last name is invalid.", "lastnameRegExViolationErrorMsg" : "Provided last name is invalid.",
"emailJSRegEx" : "/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/", "emailJSRegEx" : "/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/",
"emailRegExViolationErrorMsg" : "Provided email is invalid." "emailRegExViolationErrorMsg" : "Provided email is invalid."
@ -62,53 +62,84 @@
"copyrightSuffix" : " All Rights Reserved." "copyrightSuffix" : " All Rights Reserved."
}, },
"scopes" : [ "scopes" : [
"user:manage", "perm:sign-csr",
"user:view", "perm:admin:devices:view",
"device-type:admin:view", "perm:roles:add",
"device:view", "perm:roles:add-users",
"notification:view", "perm:roles:update",
"device:admin:view", "perm:roles:permissions",
"application:manage", "perm:roles:details",
"activity:view", "perm:roles:view",
"user:admin:reset-password", "perm:roles:create-combined-role",
"policy:manage", "perm:roles:delete",
"policy:view", "perm:dashboard:vulnerabilities",
"role:manage", "perm:dashboard:non-compliant-count",
"role:view", "perm:dashboard:non-compliant",
"configuration:view", "perm:dashboard:by-groups",
"configuration:modify", "perm:dashboard:device-counts",
"device:android:operation:reboot", "perm:dashboard:feature-non-compliant",
"device:android:operation:camera", "perm:dashboard:count-overview",
"device:android:operation:vpn", "perm:dashboard:filtered-count",
"device:android:operation:lock", "perm:dashboard:details",
"device:android:operation:ring", "perm:get-activity",
"device:android:operation:update-app", "perm:devices:delete",
"device:android:operation:wipe", "perm:devices:applications",
"device:android:operation:encrypt", "perm:devices:effective-policy",
"device:android:operation:blacklist-app", "perm:devices:compliance-data",
"device:android:operation:applications", "perm:devices:features",
"device:android:operation:enterprise-wipe", "perm:devices:operations",
"device:android:operation:info", "perm:devices:search",
"device:android:operation:wifi", "perm:devices:details",
"device:android:operation:uninstall-app", "perm:devices:view",
"device:android:operation:change-lock", "perm:view-configuration",
"device:android:operation:notification", "perm:manage-configuration",
"device:android:operation:upgrade", "perm:policies:remove",
"device:android:operation:unlock", "perm:policies:priorities",
"device:android:operation:mute", "perm:policies:deactivate",
"device:android:operation:location", "perm:policies:get-policy-details",
"device:android:operation:webclip", "perm:policies:manage",
"device:android:operation:clear-password", "perm:policies:activate",
"device:android:operation:password-policy", "perm:policies:update",
"device:android:operation:install-app", "perm:policies:changes",
"device:android:event:write", "perm:policies:get-details",
"device:android:event:read", "perm:users:add",
"device:android:enroll", "perm:users:details",
"configuration:manage", "perm:users:count",
"configuration:view", "perm:users:delete",
"device:android:enroll", "perm:users:roles",
"certificate:view", "perm:users:user-details",
"certificate:manage" "perm:users:credentials",
"perm:users:search",
"perm:users:is-exist",
"perm:users:update",
"perm:users:send-invitation",
"perm:admin-users:view",
"perm:groups:devices",
"perm:groups:update",
"perm:groups:add",
"perm:groups:device",
"perm:groups:devices-count",
"perm:groups:remove",
"perm:groups:groups",
"perm:groups:groups-view",
"perm:groups:share",
"perm:groups:count",
"perm:groups:roles",
"perm:groups:devices-remove",
"perm:groups:devices-add",
"perm:groups:assign",
"perm:device-types:features",
"perm:device-types:types",
"perm:applications:install",
"perm:applications:uninstall",
"perm:admin-groups:count",
"perm:admin-groups:view",
"perm:notifications:mark-checked",
"perm:notifications:view",
"perm:admin:certificates:delete",
"perm:admin:certificates:details",
"perm:admin:certificates:view",
"perm:admin:certificates:add"
], ],
"isOAuthEnabled" : true, "isOAuthEnabled" : true,
"backendRestEndpoints" : { "backendRestEndpoints" : {

View File

@ -73,9 +73,9 @@
click click
<b>"View Certificate List"</b> to complete the process and go back to the certificate list. <b>"View Certificate List"</b> to complete the process and go back to the certificate list.
<hr/> <hr/>
<button class="wr-btn" onclick="window.location.href='/emm/certificates'">View Certificate List <button class="wr-btn" onclick="window.location.href='{{@app.context}}/certificates'">View Certificate List
</button> </button>
<a href="/emm/certificates/add" class="cu-btn-inner"> <a href="{{@app.context}}/certificates/add" class="cu-btn-inner">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i> <i class="fw fw-add fw-stack-1x"></i>

View File

@ -102,7 +102,7 @@
<tbody> <tbody>
<tr role="row" class="even"> <tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Owner</td> <td class="sorting_1" style="padding:10px 15px; width: 15%;">Owner</td>
<td style="padding:10px 15px;">{{group.owner}}</td> <td id="group_owner" style="padding:10px 15px;">{{group.owner}}</td>
</tr> </tr>
<tr role="row" class="odd"> <tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Shared with roles</td> <td class="sorting_1" style="padding:10px 15px; width: 15%;">Shared with roles</td>
@ -175,19 +175,42 @@
<th data-for="By Ownership" class="select-filter"></th> <th data-for="By Ownership" class="select-filter"></th>
<th class="no-sort"></th> <th class="no-sort"></th>
</tr> </tr>
<!--TODO: Enable bulk action row after gain compatibility with iot operation bar--> <tr class="bulk-action-row">
<!--<tr class="bulk-action-row">--> <th colspan="7">
<!--<th colspan="7">--> <ul class="tiles">
<!--<div id="operation-bar" class="hidden">--> {{#unless group}}
<!--{{!unit "mdm.unit.device.operation-bar"}}--> <li>
<!--</div>--> <a href="#" style="width: 100px;height: 80px;;"
<!--<div id="operation-guide" class="bs-callout bs-callout-info">--> data-click-event="remove-form"
<!--<h4>Enabling Device Operations</h4>--> class="btn square-element add-devices-to-group-link"
<!--<p>To enable device operations, select the desired platform from above--> data-toggle="modal" data-target="#modalDemo">
<!--filter.</p>--> <span class="icon fw-stack">
<!--</div>--> <i class="fw fw-ring fw-stack-2x"></i>
<!--</th>--> <i class="fw fw-grouping fw-stack-1x"></i>
<!--</tr>--> </span>
Add to Group
</a>
</li>
{{/unless}}
<li>
<a href="#" style="width: 100px;height: 80px;"
data-click-event="remove-form"
class="btn square-element remove-device-link"
data-toggle="modal" data-target="#modalDemo">
<span class="icon fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-delete fw-stack-1x"></i>
</span>
{{#if group}}
Remove from group
{{else}}
Remove Device
{{/if}}
</a>
</li>
</ul>
</th>
</tr>
</thead> </thead>
<tbody id="ast-container"> <tbody id="ast-container">
@ -272,7 +295,10 @@
<a href="{{@app.context}}/group/add" id="group-add-link" class="btn-operations"> <a href="{{@app.context}}/group/add" id="group-add-link" class="btn-operations">
Add device group Add device group
</a> </a>
<a href="#" id="group-device-yes-link" class="btn-operations"> <a href="#" id="group-device-add-link" class="btn-operations">
Add devices to group
</a>
<a href="#" id="group-device-update-link" class="btn-operations">
Update assignment Update assignment
</a> </a>
<a href="#" id="group-device-cancel-link" class="btn-operations btn-default"> <a href="#" id="group-device-cancel-link" class="btn-operations btn-default">
@ -295,7 +321,11 @@
<div id="remove-device-modal-content" class="hide"> <div id="remove-device-modal-content" class="hide">
<div class="modal-header"> <div class="modal-header">
<h3 class="pull-left modal-title"> <h3 class="pull-left modal-title">
Do you really want to remove this device from your Devices List? {{#if group}}
Do you really want to remove this device(s) from '{{group.name}}' group?
{{else}}
Do you really want to remove this device(s) from your Devices?
{{/if}}
</h3> </h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i <button type="button" class="close" data-dismiss="modal" aria-label="Close"><i
class="fw fw-cancel"></i> class="fw fw-cancel"></i>
@ -320,26 +350,11 @@
<div id="remove-device-200-content" class="hide"> <div id="remove-device-200-content" class="hide">
<div class="modal-header"> <div class="modal-header">
<h3 class="pull-left modal-title"> <h3 class="pull-left modal-title">
Device was successfully removed. {{#if group}}
</h3> Successfully removed from '{{group.name}}' group.
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i {{else}}
class="fw fw-cancel"></i> Successfully removed.
</button> {{/if}}
</div>
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
</div>
<div class="modal-footer">
<div class="buttons">
<a href="javascript:hidePopup()" class="btn-operations">Ok</a>
</div>
</div>
</div>
<div id="remove-device-from-group-200-content" class="hide">
<div class="modal-header">
<h3 class="pull-left modal-title">
Device was successfully removed from group.
</h3> </h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i <button type="button" class="close" data-dismiss="modal" aria-label="Close"><i
class="fw fw-cancel"></i> class="fw fw-cancel"></i>
@ -475,6 +490,24 @@
</div> </div>
</div> </div>
</div> </div>
<div id="no-device-selected" class="hide">
<div class="modal-content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Please select one ore more devices in order to perform this
operation.</h3>
<br/>
<div class="buttons">
<a href="#" id="no-device-selected-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -488,3 +521,19 @@
type="text/x-handlebars-template"></script> type="text/x-handlebars-template"></script>
{{js "js/listing.js"}} {{js "js/listing.js"}}
{{/zone}} {{/zone}}
{{#zone "topCss"}}
<style>
.select2-dropdown {
z-index: 999999999;
}
.wr-input-control {
color: black;
}
.select2-selection__choice {
font-size: medium;
}
</style>
{{/zone}}

View File

@ -22,7 +22,8 @@
* initial mode and with out select mode. * initial mode and with out select mode.
*/ */
function InitiateViewOption(url) { function InitiateViewOption(url) {
if ($(".select-enable-btn").text() == "Select") { if ($(".select-enable-btn").text() == "Select" && !$(this).hasClass("btn")) {
url = $(this).parent().data("url");
$(location).attr('href', url); $(location).attr('href', url);
} }
} }
@ -84,18 +85,6 @@ $(document).ready(function () {
return $("#content-filter-types").html(); return $("#content-filter-types").html();
} }
}); });
$(".ast-container").on("click", ".claim-btn", function (e) {
e.stopPropagation();
var deviceId = $(this).data("deviceid");
var serviceURL = "/temp-controller-agent/enrollment/claim?username=" + currentUser;
var deviceIdentifier = {id: deviceId, type: "TemperatureController"};
invokerUtil.put(serviceURL, deviceIdentifier, function (message) {
console.log(message);
}, function (message) {
console.log(message.content);
});
});
}); });
/* /*
@ -166,7 +155,7 @@ function loadDevices(searchType, searchParam) {
serviceURL = "/api/device-mgt/v1.0/devices"; serviceURL = "/api/device-mgt/v1.0/devices";
} else if (permissionsUtil.hasPermission("LIST_OWN_DEVICES")) { } else if (permissionsUtil.hasPermission("LIST_OWN_DEVICES")) {
//Get authenticated users devices //Get authenticated users devices
serviceURL = "/api/device-mgt/v1.0/users/devices?username=" + currentUser; serviceURL = "/api/device-mgt/v1.0/devices?username=" + currentUser;
} else { } else {
$("#loading-content").remove(); $("#loading-content").remove();
$('#device-table').addClass('hidden'); $('#device-table').addClass('hidden');
@ -255,18 +244,16 @@ function loadDevices(searchType, searchParam) {
{ {
targets: 0, targets: 0,
data: 'name', data: 'name',
class: 'remove-padding icon-only content-fill', class: 'remove-padding icon-only content-fill viewEnabledIcon',
render: function (data, type, row, meta) { render: function (data, type, row, meta) {
return '<a href="' + context + '/device/' + row.deviceType + '?id=' + row.deviceIdentifier return '<div class="thumbnail icon"><img class="square-element text fw " src="'
+ '"><div class="thumbnail icon"><img class="square-element text fw " src="' + getDeviceTypeThumb(row.deviceType) + '"/></div>';
+ getDeviceTypeThumb(
row.deviceType) + '"/></div></a>';
} }
}, },
{ {
targets: 1, targets: 1,
data: 'name', data: 'name',
class: '', class: 'viewEnabledIcon',
render: function (name, type, row, meta) { render: function (name, type, row, meta) {
var model = getPropertyValue(row.properties, 'DEVICE_MODEL'); var model = getPropertyValue(row.properties, 'DEVICE_MODEL');
var vendor = getPropertyValue(row.properties, 'VENDOR'); var vendor = getPropertyValue(row.properties, 'VENDOR');
@ -280,12 +267,12 @@ function loadDevices(searchType, searchParam) {
{ {
targets: 2, targets: 2,
data: 'user', data: 'user',
class: 'remove-padding-top', class: 'remove-padding-top viewEnabledIcon'
}, },
{ {
targets: 3, targets: 3,
data: 'status', data: 'status',
class: 'remove-padding-top', class: 'remove-padding-top viewEnabledIcon',
render: function (status, type, row, meta) { render: function (status, type, row, meta) {
var html; var html;
switch (status) { switch (status) {
@ -308,7 +295,7 @@ function loadDevices(searchType, searchParam) {
{ {
targets: 4, targets: 4,
data: 'deviceType', data: 'deviceType',
class: 'remove-padding-top', class: 'remove-padding-top viewEnabledIcon',
render: function (status, type, row, meta) { render: function (status, type, row, meta) {
return getDeviceTypeLabel(row.deviceType); return getDeviceTypeLabel(row.deviceType);
} }
@ -316,7 +303,7 @@ function loadDevices(searchType, searchParam) {
{ {
targets: 5, targets: 5,
data: 'ownership', data: 'ownership',
class: 'remove-padding-top', class: 'remove-padding-top viewEnabledIcon',
render: function (status, type, row, meta) { render: function (status, type, row, meta) {
if (getDeviceTypeCategory(row.deviceType) == 'mobile') { if (getDeviceTypeCategory(row.deviceType) == 'mobile') {
return row.ownership; return row.ownership;
@ -357,20 +344,29 @@ function loadDevices(searchType, searchParam) {
html += html +=
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view edit-device-link" ' '<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view edit-device-link" '
+ + 'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType
'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType + '" data-devicename="' + row.name + '">'
+ '" data-devicename="' + row.name + '">' + + '<span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i>'
'<span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i>' + + '<i class="fw fw-edit fw-stack-1x"></i></span>'
'<i class="fw fw-edit fw-stack-1x"></i></span>' + + '<span class="hidden-xs hidden-on-grid-view">Edit</span></a>';
'<span class="hidden-xs hidden-on-grid-view">Edit</span></a>'; var groupOwner = $('#group_owner').text();
html += if (groupId && groupOwner != "wso2.system.user") {
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view remove-device-link" ' html +=
+ '<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view remove-device-link" '
'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType + 'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType
+ '" data-devicename="' + row.name + '">' + + '" data-devicename="' + row.name + '">'
'<span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i>' + + '<span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i>'
'<i class="fw fw-delete fw-stack-1x"></i></span>' + + '<i class="fw fw-delete fw-stack-1x"></i></span>'
'<span class="hidden-xs hidden-on-grid-view">Delete</span>'; + '<span class="hidden-xs hidden-on-grid-view">Remove from group</span>';
} else {
html +=
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view remove-device-link" '
+ 'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType
+ '" data-devicename="' + row.name + '">'
+ '<span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i>'
+ '<i class="fw fw-delete fw-stack-1x"></i></span>'
+ '<span class="hidden-xs hidden-on-grid-view">Delete</span>';
}
} }
return html; return html;
} }
@ -380,13 +376,14 @@ function loadDevices(searchType, searchParam) {
var fnCreatedRow = function (row, data, dataIndex) { var fnCreatedRow = function (row, data, dataIndex) {
$(row).attr('data-type', 'selectable'); $(row).attr('data-type', 'selectable');
$(row).attr('data-deviceid', data.deviceIdentifier); $(row).attr('data-deviceid', data.deviceIdentifier);
$(row).attr('data-devicetype', data.type); $(row).attr('data-devicetype', data.deviceType);
$(row).attr('data-url', context + '/device/' + data.deviceType + '?id=' + data.deviceIdentifier);
var model = getPropertyValue(data.properties, 'DEVICE_MODEL'); var model = getPropertyValue(data.properties, 'DEVICE_MODEL');
var vendor = getPropertyValue(data.properties, 'VENDOR'); var vendor = getPropertyValue(data.properties, 'VENDOR');
var owner = data.user; var owner = data.user;
var status = data.status; var status = data.status;
var ownership = data.ownership; var ownership = data.ownership;
var deviceType = data.type; var deviceType = data.deviceType;
var category = getDeviceTypeCategory(deviceType); var category = getDeviceTypeCategory(deviceType);
$.each($('td', row), function (colIndex) { $.each($('td', row), function (colIndex) {
switch (colIndex) { switch (colIndex) {
@ -560,17 +557,13 @@ function markAlreadyAssignedGroups(deviceId, deviceType) {
data = JSON.parse(data); data = JSON.parse(data);
if (xhr.status == 200) { if (xhr.status == 200) {
if (data.length > 0) { if (data.length > 0) {
var selectedValues = [];
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
$('.groupCheckBoxes').each( if (data[i].owner != "wso2.system.user") {
function () { selectedValues.push(data[i].id);
if (data[i].id == $(this).data('groupid')) { }
$(this).attr('checked', true);
}
}
);
} }
} else { $("#groups").val(selectedValues).trigger("change");
return;
} }
} else { } else {
displayErrors(xhr); displayErrors(xhr);
@ -600,7 +593,7 @@ function attachDeviceEvents() {
$(modalPopupContent).html($('#group-device-modal-content').html()); $(modalPopupContent).html($('#group-device-modal-content').html());
$('#user-groups').html( $('#user-groups').html(
'<div style="height:100px" data-state="loading" data-loading-text="Loading..." data-loading-style="icon-only" data-loading-inverse="true"></div>'); '<div style="height:100px" data-state="loading" data-loading-text="Loading..." data-loading-style="icon-only" data-loading-inverse="true"></div>');
$("a#group-device-yes-link").hide(); $("a#group-device-update-link").hide();
showPopup(); showPopup();
var serviceURL; var serviceURL;
@ -612,39 +605,39 @@ function attachDeviceEvents() {
} }
invokerUtil.get(serviceURL, function (data) { invokerUtil.get(serviceURL, function (data) {
$("a#group-device-add-link").hide();
var groups = JSON.parse(data); var groups = JSON.parse(data);
var html = ''; var html = '';
var hasGroups = false; var hasGroups = false;
for (var i = 0; i < groups.deviceGroups.length; i++) { for (var i = 0; i < groups.deviceGroups.length; i++) {
if (groups.deviceGroups[i].owner != "wso2.system.user") { if (groups.deviceGroups[i].owner != "wso2.system.user") {
html += '<div class="wr-input-control"><label class="wr-input-control checkbox">' + html += '<option value="' + groups.deviceGroups[i].id + '">' + groups.deviceGroups[i].name + '</option>';
'<input class="groupCheckBoxes" type="checkbox" data-groupid="' + groups.deviceGroups[i].id + '" />' +
'<span class="helper" title="' + groups.deviceGroups[i].name + '">' + groups.deviceGroups[i].name +
'</span></label></div>';
hasGroups = true; hasGroups = true;
} }
} }
if (hasGroups) { if (hasGroups) {
html = '<br/><h4>Please select device group(s)</h4><br/>' + html; html = '<br/><h4>Please select device group(s)</h4><br/>' +
'<div class="wr-input-control">' +
'<select id="groups" class="form-control select2" multiple="multiple">' +
html + '</select></div>';
markAlreadyAssignedGroups(deviceId, deviceType); markAlreadyAssignedGroups(deviceId, deviceType);
$("a#group-device-yes-link").show(); $("a#group-device-update-link").show();
$("a#group-add-link").hide(); $("a#group-add-link").hide();
} else { } else {
$("a#group-device-yes-link").hide(); $("a#group-device-update-link").hide();
$("a#group-add-link").show(); $("a#group-add-link").show();
html += '<br/><h4>You don\'t have any existing device groups. Please add new device group first.</h4>' html += '<br/><h4>You don\'t have any existing device groups. Please add new device group first.</h4>'
} }
$('#user-groups').html(html); $('#user-groups').html(html);
$("a#group-device-yes-link").click(function () { $("select.select2[multiple=multiple]").select2({
tags: false
});
$("a#group-device-update-link").click(function () {
var deviceIdentifier = {"id": deviceId, "type": deviceType}; var deviceIdentifier = {"id": deviceId, "type": deviceType};
var deviceGroupIds = []; var deviceGroupIds = $("#groups").val();
$('.modal .groupCheckBoxes').each( if (!deviceGroupIds) {
function () { deviceGroupIds = [];
if ($(this).is(':checked')) { }
deviceGroupIds.push($(this).data('groupid'));
}
}
);
var deviceToGroupsAssignment = { var deviceToGroupsAssignment = {
deviceIdentifier: deviceIdentifier, deviceIdentifier: deviceIdentifier,
deviceGroupIds: deviceGroupIds deviceGroupIds: deviceGroupIds
@ -684,36 +677,42 @@ function attachDeviceEvents() {
* on Device Management page in WSO2 MDM Console. * on Device Management page in WSO2 MDM Console.
*/ */
$("a.remove-device-link").click(function () { $("a.remove-device-link").click(function () {
var deviceIdentifiers = [];
var deviceId = $(this).data("deviceid"); var deviceId = $(this).data("deviceid");
var deviceType = $(this).data("devicetype"); var deviceType = $(this).data("devicetype");
var serviceURL = "/api/device-mgt/v1.0/devices/type/" + deviceType + "/id/" + deviceId;
if (deviceId && deviceType) {
deviceIdentifiers = [{"id": deviceId, "type": deviceType}];
} else {
deviceIdentifiers = getSelectedDevices();
}
if (deviceIdentifiers.length == 0) {
$(modalPopupContent).html($('#no-device-selected').html());
$("a#no-device-selected-link").click(function () {
hidePopup();
});
showPopup();
return;
}
$(modalPopupContent).html($('#remove-device-modal-content').html()); $(modalPopupContent).html($('#remove-device-modal-content').html());
showPopup(); showPopup();
$("a#remove-device-yes-link").click(function () { $("a#remove-device-yes-link").click(function () {
if (groupId) { if (groupId) {
var deviceIdentifiers = [{"id": deviceId, "type": deviceType}]; var serviceURL = "/api/device-mgt/v1.0/groups/id/" + groupId + "/devices/remove";
serviceURL = "/api/device-mgt/v1.0/groups/id/" + groupId + "/devices/remove";
invokerUtil.post(serviceURL, deviceIdentifiers, function (message) { invokerUtil.post(serviceURL, deviceIdentifiers, function (message) {
$(modalPopupContent).html($('#remove-device-from-group-200-content').html());
setTimeout(function () {
hidePopup();
location.reload(false);
}, 2000);
}, function (message) {
displayDeviceErrors(message);
});
} else {
invokerUtil.delete(serviceURL, function (message) {
$(modalPopupContent).html($('#remove-device-200-content').html()); $(modalPopupContent).html($('#remove-device-200-content').html());
setTimeout(function () { setTimeout(function () {
hidePopup(); hidePopup();
location.reload(false); location.reload(false);
}, 2000); }, 2000);
}, function (message) { }, function (jqXHR) {
displayDeviceErrors(jqXHR); displayDeviceErrors(jqXHR);
}); });
} else {
removeDevices(deviceIdentifiers);
} }
}); });
@ -745,7 +744,7 @@ function attachDeviceEvents() {
hidePopup(); hidePopup();
location.reload(false); location.reload(false);
}, 2000); }, 2000);
}, function (message) { }, function (jqXHR) {
displayDeviceErrors(jqXHR); displayDeviceErrors(jqXHR);
}); });
}); });
@ -754,6 +753,106 @@ function attachDeviceEvents() {
hidePopup(); hidePopup();
}); });
}); });
/**
* Following click function would execute
* when a user clicks on "Add to Group" link
* on Device Management page in WSO2 devicemgt Console.
*/
$("a.add-devices-to-group-link").click(function () {
$("a#group-device-update-link").hide();
var deviceIdentifiers = getSelectedDevices();
if (deviceIdentifiers.length == 0) {
$(modalPopupContent).html($('#no-device-selected').html());
$("a#no-device-selected-link").click(function () {
hidePopup();
});
showPopup();
return;
}
$(modalPopupContent).html($('#group-device-modal-content').html());
$('#user-groups').html(
'<div style="height:100px" data-state="loading" data-loading-text="Loading..." data-loading-style="icon-only" data-loading-inverse="true"></div>');
$("a#group-device-add-link").hide();
showPopup();
var serviceURL;
if ($.hasPermission("LIST_ALL_GROUPS")) {
serviceURL = "/api/device-mgt/v1.0/admin/groups?limit=100";
} else if ($.hasPermission("LIST_GROUPS")) {
//Get authenticated users groups
serviceURL = "/api/device-mgt/v1.0/groups?limit=100";
}
invokerUtil.get(serviceURL, function (data) {
var groups = JSON.parse(data);
var html = '';
var hasGroups = false;
for (var i = 0; i < groups.deviceGroups.length; i++) {
if (groups.deviceGroups[i].owner != "wso2.system.user") {
html += '<option value="' + groups.deviceGroups[i].id + '">' +
groups.deviceGroups[i].name + '</option>';
hasGroups = true;
}
}
if (hasGroups) {
html = '<br /><select id="assign-group-selector" style="color:#3f3f3f;padding:5px;width:250px;">' +
html + '</select>';
$("a#group-add-link").hide();
$("a#group-device-add-link").show();
} else {
html += '<br/><h4>You don\'t have any existing device groups. Please add new device group first.</h4>';
$("a#group-add-link").show();
$("a#group-device-add-link").hide();
}
$('#user-groups').html(html);
$("a#group-device-add-link").click(function () {
var selectedGroup = $('#assign-group-selector').val();
serviceURL = "/api/device-mgt/v1.0/groups/id/" + selectedGroup + "/devices/add";
invokerUtil.post(serviceURL, deviceIdentifiers, function (data) {
$(modalPopupContent).html($('#group-associate-device-200-content').html());
setTimeout(function () {
hidePopup();
location.reload(false);
}, 2000);
}, function (jqXHR) {
displayDeviceErrors(jqXHR);
});
});
}, function (jqXHR) {
if (jqXHR.status == 404) {
$(modalPopupContent).html($('#group-404-content').html());
$("a#cancel-link").click(function () {
hidePopup();
});
} else {
displayDeviceErrors(jqXHR);
}
});
$("a#group-device-cancel-link").click(function () {
hidePopup();
});
});
}
function removeDevices(deviceIdentifiers) {
var serviceURL = "/api/device-mgt/v1.0/devices/type/" + deviceIdentifiers[0].type + "/id/" + deviceIdentifiers[0].id;
invokerUtil.delete(serviceURL, function (message) {
if (deviceIdentifiers.length > 1) {
deviceIdentifiers.slice(1, deviceIdentifiers.length);
removeDevices(deviceIdentifiers);
} else {
$(modalPopupContent).html($('#remove-device-200-content').html());
setTimeout(function () {
hidePopup();
location.reload(false);
}, 2000);
}
}, function (jqXHR) {
displayDeviceErrors(jqXHR);
});
} }
function displayDeviceErrors(jqXHR) { function displayDeviceErrors(jqXHR) {
@ -788,3 +887,23 @@ function getParameterByName(name) {
results = regex.exec(location.search); results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
} }
/*
* Function to get selected devices.
*/
function getSelectedDevices() {
var deviceList = [];
var thisTable = $(".DTTT_selected").closest('.dataTables_wrapper').find('.dataTable').dataTable();
thisTable.api().rows().every(function () {
if ($(this.node()).hasClass('DTTT_selected')) {
deviceList.push(
{
"id": $(thisTable.api().row(this).node()).data('deviceid'),
"type": $(thisTable.api().row(this).node()).data('devicetype')
}
);
}
});
return deviceList;
}

View File

@ -23,6 +23,7 @@
*/ */
function InitiateViewOption(url) { function InitiateViewOption(url) {
if ($(".select-enable-btn").text() == "Select") { if ($(".select-enable-btn").text() == "Select") {
url = $(this).parent().data("url");
$(location).attr('href', url); $(location).attr('href', url);
} }
} }
@ -147,35 +148,30 @@ function loadGroups() {
return JSON.stringify(json); return JSON.stringify(json);
}; };
var columns = [{ var columns = [
targets: 0, {
data: 'id', targets: 0,
class: 'remove-padding icon-only content-fill', data: 'id',
render: function (data, type, row, meta) { class: 'remove-padding icon-only content-fill viewEnabledIcon',
if ($.hasPermission("VIEW_GROUP_DEVICES")) { render: function (data, type, row, meta) {
return '<a href="devices?groupId=' + row.groupId + '&groupName=' + row.name
+ '"><div class="thumbnail icon"><img class="square-element text fw " '
+ 'src="public/cdmf.page.groups/images/group-icon.png"/></div></a>';
} else {
return '<div class="thumbnail icon"><img class="square-element text fw " ' + return '<div class="thumbnail icon"><img class="square-element text fw " ' +
'src="public/cdmf.page.groups/images/group-icon.png"/></div>'; 'src="public/cdmf.page.groups/images/group-icon.png"/></div>';
} }
} },
},
{ {
targets: 1, targets: 1,
data: 'name', data: 'name',
class: '' class: 'viewEnabledIcon'
}, },
{ {
targets: 2, targets: 2,
data: 'owner', data: 'owner',
class: 'remove-padding-top', class: 'remove-padding-top viewEnabledIcon'
}, },
{ {
targets: 3, targets: 3,
data: 'description', data: 'description',
class: 'remove-padding-top', class: 'remove-padding-top viewEnabledIcon'
}, },
{ {
targets: 4, targets: 4,
@ -226,7 +222,9 @@ function loadGroups() {
var fnCreatedRow = function (row, data) { var fnCreatedRow = function (row, data) {
$(row).attr('data-type', 'selectable'); $(row).attr('data-type', 'selectable');
$(row).attr('data-groupid', data.id); if ($.hasPermission("VIEW_GROUP_DEVICES")) {
$(row).attr('data-url', 'devices?groupId=' + data.groupId + '&groupName=' + data.name);
}
$.each($('td', row), function (colIndex) { $.each($('td', row), function (colIndex) {
switch (colIndex) { switch (colIndex) {
case 1: case 1:

View File

@ -25,14 +25,14 @@
<div class="form-group"> <div class="form-group">
<label for="first_name" class="wr-input-label">First Name</label> <label for="first_name" class="wr-input-label">First Name</label>
<input type="text" id="first_name" name="first_name" class="form-control" placeholder="First Name" <input type="text" id="first_name" name="first_name" class="form-control" placeholder="First Name"
data-regex="{{usernameJSRegEx}}" data-lengthmsg="{{usernameHelpText}}" data-regex="{{firstnameJSRegEx}}" data-lengthmsg="{{usernameHelpText}}"
data-errormsg="{{usernameRegExViolationErrorMsg}}"/> data-errormsg="{{firstnameRegExViolationErrorMsg}}"/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="last_name" class="wr-input-label">Last Name</label> <label for="last_name" class="wr-input-label">Last Name</label>
<input type="text" id="last_name" name="last_name" class="form-control" placeholder="Last Name" <input type="text" id="last_name" name="last_name" class="form-control" placeholder="Last Name"
data-regex="{{usernameJSRegEx}}" data-errormsg="{{usernameRegExViolationErrorMsg}}"/> data-regex="{{lastnameJSRegEx}}" data-errormsg="{{lastnameRegExViolationErrorMsg}}"/>
</div> </div>
<div class="form-group"> <div class="form-group">

View File

@ -74,8 +74,7 @@
data-errormsg="{{usernameRegExViolationErrorMsg}}" class="form-control"/> data-errormsg="{{usernameRegExViolationErrorMsg}}" class="form-control"/>
<span class=" usernameError hidden glyphicon glyphicon-remove form-control-feedback"></span> <span class=" usernameError hidden glyphicon glyphicon-remove form-control-feedback"></span>
<label class="error usernameEmpty hidden" for="summary">This field is required. <label class="error usernameEmpty hidden" for="summary">This field is required.
Username should be in minimum 3 characters long and do not include any Username should be at least 3 characters long with no white spaces.</label>
whitespaces.</label>
</div> </div>
<label class="wr-input-label">First Name *</label> <label class="wr-input-label">First Name *</label>
<div id="firstNameField" class="form-group wr-input-control"> <div id="firstNameField" class="form-group wr-input-control">

View File

@ -43,7 +43,7 @@
<i class="fw fw-mobile fw-3x"></i> <i class="fw fw-mobile fw-3x"></i>
</h3> </h3>
<h3 class="text-muted">No device type is available to be displayed.</h3> <h3 class="text-muted">No device type is available to be displayed.</h3>
<a href="https://docs.wso2.com/display/IoTS100/Quick+Start+Guide" target="_blank" <a href="https://docs.wso2.com/display/IoTS300/Quick+Start+Guide" target="_blank"
class="btn-operations btn-default"> class="btn-operations btn-default">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>

View File

@ -17,8 +17,8 @@
}} }}
{{#zone "footer"}} {{#zone "footer"}}
<p> <p>
<span class="hidden-xs">WSO2 Carbon Device Management Framework v1.1.3</span> <span class="hidden-xs">WSO2 Carbon Device Management Framework v2.0.6</span>
<span class="visible-xs-inline">WSO2 CDMF v1.2.6</span> | &copy; <script>document.write(new Date().getFullYear());</script>, <span class="visible-xs-inline">WSO2 CDMF v2.0.6</span> | &copy; <script>document.write(new Date().getFullYear());</script>,
<a href="http://wso2.com/" target="_blank"><i class="icon fw fw-wso2"></i> Inc</a>. All Rights Reserved. <a href="http://wso2.com/" target="_blank"><i class="icon fw fw-wso2"></i> Inc</a>. All Rights Reserved.
</p> </p>
{{/zone}} {{/zone}}

View File

@ -6547,7 +6547,7 @@ select > option:hover {
@media (min-width: 1200px){ @media (min-width: 1200px){
table tbody tr { table tbody tr {
width: 18% !important; width: 14% !important;
} }
.table .fw-stack{ .table .fw-stack{
font-size: 1.2vw; font-size: 1.2vw;
@ -6556,7 +6556,7 @@ select > option:hover {
@media (min-width: 1500px){ @media (min-width: 1500px){
table tbody tr { table tbody tr {
width: 14% !important; width: 10% !important;
} }
.table .fw-stack{ .table .fw-stack{
font-size: 0.8vw; font-size: 0.8vw;

View File

@ -108,7 +108,7 @@
"contextParams" : [ "contextParams" : [
{ {
"name" : "Owasp.CsrfGuard.Config", "name" : "Owasp.CsrfGuard.Config",
"value" : "/repository/conf/security/Owasp.CsrfGuard.Carbon.properties" "value" : "/repository/conf/security/Owasp.CsrfGuard.dashboard.properties"
} }
] ]
} }

View File

@ -71,7 +71,7 @@
"contextParams" : [ "contextParams" : [
{ {
"name" : "Owasp.CsrfGuard.Config", "name" : "Owasp.CsrfGuard.Config",
"value" : "/repository/conf/security/Owasp.CsrfGuard.Carbon.properties" "value" : "/repository/conf/security/Owasp.CsrfGuard.dashboard.properties"
} }
] ]
} }

View File

@ -520,7 +520,7 @@ var module = {};
response.sendError(500, msg); response.sendError(500, msg);
return; return;
} }
/** /**
* @type {{sessionId: string, loggedInUser: string, sessionIndex: string, samlToken: * @type {{sessionId: string, loggedInUser: string, sessionIndex: string, samlToken:
* string}} * string}}
@ -533,7 +533,7 @@ var module = {};
if (ssoSession.sessionIndex) { if (ssoSession.sessionIndex) {
module.loadTenant(ssoSession.loggedInUser); module.loadTenant(ssoSession.loggedInUser);
var carbonUser = (require("carbon")).server.tenantUser(ssoSession.loggedInUser); var carbonUser = (require("carbon")).server.tenantUser(ssoSession.loggedInUser);
module.loadTenant(ssoSession.loggedInUser); module.loadTenant(ssoSession.loggedInUser);
utils.setCurrentUser(carbonUser.username, carbonUser.domain, carbonUser.tenantId); utils.setCurrentUser(carbonUser.username, carbonUser.domain, carbonUser.tenantId);
var scriptArgument = {input: {samlToken: ssoSession.samlToken}, user: module.getCurrentUser()}; var scriptArgument = {input: {samlToken: ssoSession.samlToken}, user: module.getCurrentUser()};
handleEvent(OPERATION_LOGIN, EVENT_SUCCESS, scriptArgument); handleEvent(OPERATION_LOGIN, EVENT_SUCCESS, scriptArgument);

View File

@ -23,7 +23,7 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

View File

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>email-sender</artifactId> <artifactId>email-sender</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

View File

@ -21,7 +21,7 @@
<parent> <parent>
<artifactId>dynamic-client-registration</artifactId> <artifactId>dynamic-client-registration</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -21,7 +21,7 @@
<parent> <parent>
<artifactId>dynamic-client-registration</artifactId> <artifactId>dynamic-client-registration</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -21,13 +21,13 @@
<parent> <parent>
<artifactId>dynamic-client-registration</artifactId> <artifactId>dynamic-client-registration</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.dynamic.client.registration</artifactId> <artifactId>org.wso2.carbon.dynamic.client.registration</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Dynamic client registration service</name> <name>WSO2 Carbon - Dynamic client registration service</name>
<description>WSO2 Carbon - Dynamic Client Registration Service</description> <description>WSO2 Carbon - Dynamic Client Registration Service</description>

View File

@ -21,13 +21,13 @@
<parent> <parent>
<artifactId>dynamic-client-registration</artifactId> <artifactId>dynamic-client-registration</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.dynamic.client.web.app.registration</artifactId> <artifactId>org.wso2.carbon.dynamic.client.web.app.registration</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Dynamic client web app registration</name> <name>WSO2 Carbon - Dynamic client web app registration</name>
<description>WSO2 Carbon - Dynamic Client Web-app Registration Service</description> <description>WSO2 Carbon - Dynamic Client Web-app Registration Service</description>

View File

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>identity-extensions</artifactId> <artifactId>identity-extensions</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>dynamic-client-registration</artifactId> <artifactId>dynamic-client-registration</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - Dynamic client registration</name> <name>WSO2 Carbon - Dynamic client registration</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

View File

@ -22,13 +22,13 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>identity-extensions</artifactId> <artifactId>identity-extensions</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.oauth.extensions</artifactId> <artifactId>org.wso2.carbon.device.mgt.oauth.extensions</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - OAuth Extensions</name> <name>WSO2 Carbon - OAuth Extensions</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

View File

@ -21,7 +21,7 @@
<parent> <parent>
<artifactId>identity-extensions</artifactId> <artifactId>identity-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>identity-extensions</artifactId> <artifactId>identity-extensions</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

View File

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.complex.policy.decision.point</artifactId> <artifactId>org.wso2.carbon.complex.policy.decision.point</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Decision Point</name> <name>WSO2 Carbon - Policy Decision Point</name>
<description>WSO2 Carbon - Policy Decision Point</description> <description>WSO2 Carbon - Policy Decision Point</description>

View File

@ -3,14 +3,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.decision.point</artifactId> <artifactId>org.wso2.carbon.policy.decision.point</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Decision Point</name> <name>WSO2 Carbon - Policy Decision Point</name>
<description>WSO2 Carbon - Policy Decision Point</description> <description>WSO2 Carbon - Policy Decision Point</description>

View File

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
@ -11,7 +11,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.information.point</artifactId> <artifactId>org.wso2.carbon.policy.information.point</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Information Point</name> <name>WSO2 Carbon - Policy Information Point</name>
<description>WSO2 Carbon - Policy Information Point</description> <description>WSO2 Carbon - Policy Information Point</description>

View File

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.mgt.common</artifactId> <artifactId>org.wso2.carbon.policy.mgt.common</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Management Common</name> <name>WSO2 Carbon - Policy Management Common</name>
<description>WSO2 Carbon - Policy Management Common</description> <description>WSO2 Carbon - Policy Management Common</description>

View File

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.mgt.core</artifactId> <artifactId>org.wso2.carbon.policy.mgt.core</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Management Core</name> <name>WSO2 Carbon - Policy Management Core</name>
<description>WSO2 Carbon - Policy Management Core</description> <description>WSO2 Carbon - Policy Management Core</description>

View File

@ -23,13 +23,13 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - Policy Management Component</name> <name>WSO2 Carbon - Policy Management Component</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

View File

@ -21,14 +21,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>webapp-authenticator-framework</artifactId> <artifactId>webapp-authenticator-framework</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.webapp.authenticator.framework</artifactId> <artifactId>org.wso2.carbon.webapp.authenticator.framework</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Web Application Authenticator Framework Bundle</name> <name>WSO2 Carbon - Web Application Authenticator Framework Bundle</name>
<description>WSO2 Carbon - Web Application Authenticator Framework Bundle</description> <description>WSO2 Carbon - Web Application Authenticator Framework Bundle</description>
@ -81,7 +81,8 @@
org.wso2.carbon.core.util, org.wso2.carbon.core.util,
org.wso2.carbon.identity.base; version="${carbon.identity.imp.pkg.version}", org.wso2.carbon.identity.base; version="${carbon.identity.imp.pkg.version}",
org.wso2.carbon.identity.core.util; version="${carbon.identity.imp.pkg.version}", org.wso2.carbon.identity.core.util; version="${carbon.identity.imp.pkg.version}",
org.wso2.carbon.identity.oauth2.*; version="${carbon.identity-inbound-auth-oauth.imp.pkg.version}", org.wso2.carbon.identity.oauth2.*;
version="${carbon.identity-inbound-auth-oauth.imp.pkg.version}",
org.wso2.carbon.tomcat.ext.valves, org.wso2.carbon.tomcat.ext.valves,
org.wso2.carbon.user.api, org.wso2.carbon.user.api,
org.wso2.carbon.user.core.service, org.wso2.carbon.user.core.service,
@ -111,7 +112,7 @@
org.apache.http.impl.conn, org.apache.http.impl.conn,
javax.xml.soap; version="${javax.xml.soap.imp.pkg.version}", javax.xml.soap; version="${javax.xml.soap.imp.pkg.version}",
javax.xml.stream, javax.xml.stream,
org.apache.axiom.*; version="${axiom.osgi.version.range}", org.apache.axiom.*; version="${axiom.osgi.version.range}",
org.wso2.carbon.registry.core.*, org.wso2.carbon.registry.core.*,
org.wso2.carbon.registry.common.*;version="${carbon.registry.imp.pkg.version.range}", org.wso2.carbon.registry.common.*;version="${carbon.registry.imp.pkg.version.range}",
org.wso2.carbon.registry.indexing.*; version="${carbon.registry.imp.pkg.version.range}", org.wso2.carbon.registry.indexing.*; version="${carbon.registry.imp.pkg.version.range}",

View File

@ -123,7 +123,7 @@ public class WebappAuthenticationValve extends CarbonTomcatValve {
StringTokenizer tokenizer = new StringTokenizer(param, ","); StringTokenizer tokenizer = new StringTokenizer(param, ",");
nonSecuredEndpoints.put(contextPath, "true"); nonSecuredEndpoints.put(contextPath, "true");
while (tokenizer.hasMoreTokens()) { while (tokenizer.hasMoreTokens()) {
skippedEndPoint = contextPath + tokenizer.nextToken(); skippedEndPoint = tokenizer.nextToken();
skippedEndPoint = skippedEndPoint.replace("\n", "").replace("\r", "").trim(); skippedEndPoint = skippedEndPoint.replace("\n", "").replace("\r", "").trim();
if(!skippedEndPoint.endsWith("/")) { if(!skippedEndPoint.endsWith("/")) {
skippedEndPoint = skippedEndPoint + "/"; skippedEndPoint = skippedEndPoint + "/";

View File

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>webapp-authenticator-framework</artifactId> <artifactId>webapp-authenticator-framework</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - Webapp Authenticator Framework</name> <name>WSO2 Carbon - Webapp Authenticator Framework</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

View File

@ -21,14 +21,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId> <artifactId>apimgt-extensions-feature</artifactId>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.application.extension.feature</artifactId> <artifactId>org.wso2.carbon.apimgt.application.extension.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>2.0.6-SNAPSHOT</version> <version>2.0.7-SNAPSHOT</version>
<name>WSO2 Carbon - API Management Application Extension Feature</name> <name>WSO2 Carbon - API Management Application Extension Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>This feature contains an implementation of a api application registration, which takes care of subscription <description>This feature contains an implementation of a api application registration, which takes care of subscription

View File

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2016, 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId>
<version>2.0.7-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.handler.server.feature</artifactId>
<packaging>pom</packaging>
<version>2.0.7-SNAPSHOT</version>
<name>WSO2 Carbon - Device Management - APIM handler Server Feature</name>
<url>http://wso2.org</url>
<description>This feature contains the handler for the api authentications
</description>
<dependencies>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.handlers</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>src/main/resources</outputDirectory>
<resources>
<resource>
<directory>resources</directory>
<includes>
<include>build.properties</include>
<include>p2.inf</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.wso2.maven</groupId>
<artifactId>carbon-p2-plugin</artifactId>
<version>${carbon.p2.plugin.version}</version>
<executions>
<execution>
<id>p2-feature-generation</id>
<phase>package</phase>
<goals>
<goal>p2-feature-gen</goal>
</goals>
<configuration>
<id>org.wso2.carbon.apimgt.handler.server</id>
<propertiesFile>../../../features/etc/feature.properties</propertiesFile>
<adviceFile>
<properties>
<propertyDef>org.wso2.carbon.p2.category.type:server</propertyDef>
<propertyDef>org.eclipse.equinox.p2.type.group:false</propertyDef>
</properties>
</adviceFile>
<bundles>
<bundleDef>
org.wso2.carbon.devicemgt:org.wso2.carbon.apimgt.handlers:${carbon.device.mgt.version}
</bundleDef>
<!--<bundleDef>-->
<!--org.apache.ws.security.wso2:wss4j:${org.apache.ws.security.wso2.version}-->
<!--</bundleDef>-->
</bundles>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

Some files were not shown because too many files have changed in this diff Show More