Skip to content

Commit

Permalink
Added capability to fetch certificate to send from the CertificateInf…
Browse files Browse the repository at this point in the history
…oService

Signed-off-by: Alberto Codutti <alberto.codutti@eurotech.com>
  • Loading branch information
Coduz committed Jun 15, 2021
1 parent cade3e4 commit 96892b3
Show file tree
Hide file tree
Showing 26 changed files with 727 additions and 13 deletions.
10 changes: 10 additions & 0 deletions console/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@
<classifier>sources</classifier>
</dependency>

<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-console-module-certificate</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-console-module-certificate</artifactId>
<classifier>sources</classifier>
</dependency>

<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-console-module-data</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<inherits name="org.eclipse.kapua.app.console.module.account.adminModuleAccount"/>
<inherits name="org.eclipse.kapua.app.console.module.authentication.adminModuleAuthentication"/>
<inherits name="org.eclipse.kapua.app.console.module.authorization.adminModuleAuthorization"/>
<inherits name="org.eclipse.kapua.app.console.module.certificate.adminModuleCertificate"/>
<inherits name="org.eclipse.kapua.app.console.module.device.adminModuleDevice"/>
<inherits name="org.eclipse.kapua.app.console.module.job.adminModuleJob"/>
<inherits name="org.eclipse.kapua.app.console.module.data.adminModuleData"/>
Expand Down
36 changes: 36 additions & 0 deletions console/module/certificate/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>About</title>
</head>
<body lang="EN-US">
<h2>About This Content</h2>

<p>November 30, 2017</p>
<h3>License</h3>

<p>
The Eclipse Foundation makes available all content in this plug-in
(&quot;Content&quot;). Unless otherwise indicated below, the Content
is provided to you under the terms and conditions of the Eclipse
Public License Version 2.0 (&quot;EPL&quot;). A copy of the EPL is
available at <a href="http://www.eclipse.org/legal/epl-2.0">http://www.eclipse.org/legal/epl-2.0</a>.
For purposes of the EPL, &quot;Program&quot; will mean the Content.
</p>

<p>
If you did not receive this Content directly from the Eclipse
Foundation, the Content is being redistributed by another party
(&quot;Redistributor&quot;) and different terms and conditions may
apply to your use of any object code in the Content. Check the
Redistributor's license that was provided with the Content. If no such
license exists, contact the Redistributor. Unless otherwise indicated
below, the terms and conditions of the EPL still apply to any source
code in the Content and such source code may be obtained at <a
href="http://www.eclipse.org/">http://www.eclipse.org</a>.
</p>

</body>
</html>
50 changes: 50 additions & 0 deletions console/module/certificate/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2017, 2021 Eurotech and/or its affiliates and others
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0
Contributors:
Eurotech - initial API and implementation
-->
<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">
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>kapua-console-module</artifactId>
<groupId>org.eclipse.kapua</groupId>
<version>1.5.0-SNAPSHOT</version>
</parent>

<artifactId>kapua-console-module-certificate</artifactId>

<dependencies>
<!-- Console modules -->
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-console-module-api</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<!-- GWT Maven Plugin -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>

<configuration>
<module>org.eclipse.kapua.app.console.module.certificate.certificateModuleAbout</module>
<i18nMessagesBundles>
<i18nMessagesBundle>org.eclipse.kapua.app.console.module.certificate.client.messages.ConsoleCertificateMessages</i18nMessagesBundle>
</i18nMessagesBundles>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*******************************************************************************
* Copyright (c) 2021 Eurotech and/or its affiliates and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.app.console.module.certificate.server;

import org.eclipse.kapua.app.console.module.api.client.GwtKapuaException;
import org.eclipse.kapua.app.console.module.api.server.KapuaRemoteServiceServlet;
import org.eclipse.kapua.app.console.module.api.server.util.KapuaExceptionHandler;
import org.eclipse.kapua.app.console.module.api.shared.util.KapuaGwtCommonsModelConverter;
import org.eclipse.kapua.app.console.module.certificate.shared.model.GwtCertificateInfo;
import org.eclipse.kapua.app.console.module.certificate.shared.service.GwtCertificateInfoService;
import org.eclipse.kapua.commons.model.id.KapuaEid;
import org.eclipse.kapua.locator.KapuaLocator;
import org.eclipse.kapua.model.id.KapuaId;
import org.eclipse.kapua.service.certificate.info.CertificateInfo;
import org.eclipse.kapua.service.certificate.info.CertificateInfoFactory;
import org.eclipse.kapua.service.certificate.info.CertificateInfoListResult;
import org.eclipse.kapua.service.certificate.info.CertificateInfoQuery;
import org.eclipse.kapua.service.certificate.info.CertificateInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

public class GwtCertificateInfoServiceImpl extends KapuaRemoteServiceServlet implements GwtCertificateInfoService {

private static final Logger LOG = LoggerFactory.getLogger(GwtCertificateInfoServiceImpl.class);

private static final KapuaLocator LOCATOR = KapuaLocator.getInstance();

private static final CertificateInfoService CERTIFICATE_INFO_SERVICE = LOCATOR.getService(CertificateInfoService.class);
private static final CertificateInfoFactory CERTIFICATE_INFO_FACTORY = LOCATOR.getFactory(CertificateInfoFactory.class);

@Override
public List<GwtCertificateInfo> findAllCertificates(String scopeIdString) throws GwtKapuaException {
try {
KapuaId scopeId = KapuaEid.parseCompactId(scopeIdString);

List<GwtCertificateInfo> gwtCertificateInfos = new ArrayList<GwtCertificateInfo>();

CertificateInfoQuery query = CERTIFICATE_INFO_FACTORY.newQuery(scopeId);
CertificateInfoListResult certificateInfos = CERTIFICATE_INFO_SERVICE.query(query);

for (CertificateInfo certificateInfo : certificateInfos.getItems()) {
GwtCertificateInfo gwtCertificateInfo = new GwtCertificateInfo();
gwtCertificateInfo.setId(KapuaGwtCommonsModelConverter.convertKapuaId(certificateInfo.getId()));
gwtCertificateInfo.setName(certificateInfo.getName());

gwtCertificateInfos.add(gwtCertificateInfo);
}

return gwtCertificateInfos;
} catch (Exception e) {
throw KapuaExceptionHandler.buildExceptionFromError(e);
}
}

@Override
public boolean isFindSupported() {
try {
CERTIFICATE_INFO_SERVICE.find(null, null);
return false;
} catch (UnsupportedOperationException uoe) {
LOG.warn("The current deployment does not support CertificateInfoService.find(...). Some of the UI features will be disabled...");
return false;
} catch (Exception e) {
return true;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*******************************************************************************
* Copyright (c) 2021 Eurotech and/or its affiliates and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.app.console.module.certificate.shared.model;

import com.google.gwt.user.client.rpc.IsSerializable;
import org.eclipse.kapua.app.console.module.api.shared.model.GwtUpdatableEntityModel;

public class GwtCertificateInfo extends GwtUpdatableEntityModel implements IsSerializable {

public String getName() {
return get("name");
}

public void setName(String name) {
set("name", name);
}

public String getCertificate() {
return get("certificate");
}

public void setCertificate(String certificate) {
set("certificate", certificate);
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright (c) 2021 Eurotech and/or its affiliates and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.app.console.module.certificate.shared.service;

import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
import org.eclipse.kapua.app.console.module.api.client.GwtKapuaException;
import org.eclipse.kapua.app.console.module.certificate.shared.model.GwtCertificateInfo;

import java.util.List;

/**
* This service retrieves a subset of configuration values for front-end usage.
*/
@RemoteServiceRelativePath("certificateInfo")
public interface GwtCertificateInfoService extends RemoteService {

List<GwtCertificateInfo> findAllCertificates(String scopeIdString) throws GwtKapuaException;

boolean isFindSupported();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
################################################################################
# Copyright (c) 2021 Eurotech and/or its affiliates and others
#
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Eurotech - initial API and implementation
#################################################################################
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright (c) 2021 Eurotech and/or its affiliates and others
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0
Contributors:
Eurotech - initial API and implementation
-->
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.4.0//EN"
"https://raw.githubusercontent.com/gwtproject/gwt/2.4.0/distro-source/core/src/gwt-module.dtd">

<module rename-to="adminModuleCertificate">

<inherits name="org.eclipse.kapua.app.console.module.api.adminModuleApi"/>

<!-- Specify the paths for translatable code -->
<source path='shared'/>
<source path="client"/>

</module>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
################################################################################
# Copyright (c) 2021 Eurotech and/or its affiliates and others
#
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Eurotech - initial API and implementation
#################################################################################
certificate=Certificate
4 changes: 4 additions & 0 deletions console/module/device/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-console-module-authorization</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-console-module-certificate</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-console-module-tag</artifactId>
Expand Down
Loading

0 comments on commit 96892b3

Please sign in to comment.