This is an automated email from the ASF dual-hosted git repository.
isjarana pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata-custos.git
The following commit(s) were added to refs/heads/develop by this push:
new 199b4478f Improve README
new 961223722 Merge pull request #377 from isururanawaka/develop
199b4478f is described below
commit 199b4478f572f5e1391aa15ec6746d47663b2a10
Author: Isuru Ranawaka <[email protected]>
AuthorDate: Thu Apr 20 18:46:49 2023 -0400
Improve README
---
README.md | 56 +++++++++++++++-------
.../apache/custos/clients/core/AbstractClient.java | 16 +++++++
.../management/client/UserManagementClient.java | 15 ++++++
.../custos/clients/CustosClientProvider.java | 17 +++++--
.../src/main/containers/portal/docker-compose.yml | 16 +++++++
5 files changed, 101 insertions(+), 19 deletions(-)
diff --git a/README.md b/README.md
index c08ab5096..51f9f680a 100644
--- a/README.md
+++ b/README.md
@@ -27,21 +27,6 @@ Science gateways represent potential targets for
cybersecurity threats to users,
**To find out more, please check out the [Custos
website](https://airavata.apache.org/custos/) and the [Custos
wiki](https://cwiki.apache.org/confluence/display/CUSTOS/Home).**
-## Custos POM changes for MAC M1:
-
-
-For successfully running the maven build for custom on Mac M1 laptops
following changes are needed in the parent configuration files . These changes
are related to protobuf and gen-grpc-java plugins as the the compatible version
with Mac M1 are needed for both . These changes should be made at both the
places where the plugins are specified .The architecture of the Mac M1 which is
osx-x86_64 has to be passed along with versions for build to be successful.
-
-
- <configuration>
- <protocArtifact>com.google.protobuf:protoc:3.1.0:exe:osx-x86_64
- </protocArtifact>
- <pluginId>grpc-java</pluginId>
- <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.0.0:exe:osx-x86_64
- </pluginArtifact>
- </configuration>
-
-
## Quickstart
## Installation Instructions
@@ -88,7 +73,7 @@ For successfully running the maven build for custom on Mac M1
laptops following
docker-compose up
```
-#### Bootstrapping Custos
+#### Bootstrapping Custos Super Tenant
If all services were successfully ran. Custos bootstrap service needs to be
run to create a Super tenant to launch Custos Portal
```
@@ -106,6 +91,45 @@ Following the following link to access portal deployment
instructions
[custos
portal](https://github.com/apache/airavata-custos-portal/blob/master/README.md)
+## Custos Integration With External Applications
+Custos can be integrated with external applications using Custos REST
Endpoints, Python SDK, or Java SDK.
+
+### Integrate Using Java SDK
+In order to perform this operation you need to have a already activated tenant
in either Custos Managed Services or Your own deployment.
+Following instructions are given for locally deployed custos setup which can
be extended to any deployment,
+
+####Initializing Custos Java SDK
+
+* Add maven dependency to your project
+```
+<dependency>
+ <groupId>org.apache.custos</groupId>
+ <artifactId>custos-java-sdk</artifactId>
+ <version>1.1-SNAPSHOT</version>
+</dependency>
+
+```
+* Initialize Custos Client Provider in your application
+```
+ CustosClientProvider custosClientProvider = new
CustosClientProvider.Builder().setServerHost("localhost")
+ .setServerPort(7000)
+ .setClientId(CUSTOS CLIENT ID) // client Id generated from
above step or any active tenant id
+ .setClientSec(CUSTOS CLIENT SECRET)
+ .usePlainText(true) // Don't use this in production setup
+ .build();
+```
+Once above step is done, you can use custos available methods for
authentication and authorization purposes
+* Sample client code to register and enable a User
+
+```
+ UserManagementClient userManagementClient =
custosClientProvider.getUserManagementClient();
+ userManagementClient.registerUser("Jhon","Smith","testpassword","smith@1",
+ "[email protected]",false);
+ userManagementClient.enableUser("Jhon");
+ OperationStatus status = userManagementClient.isUserEnabled("Jhon");
+```
+#####
+
## Roadmap
## Contributing
diff --git
a/custos-client-sdks/custos-java-clients/custos-clients-core/src/main/java/org/apache/custos/clients/core/AbstractClient.java
b/custos-client-sdks/custos-java-clients/custos-clients-core/src/main/java/org/apache/custos/clients/core/AbstractClient.java
index f56d5239c..7b4967ee6 100644
---
a/custos-client-sdks/custos-java-clients/custos-clients-core/src/main/java/org/apache/custos/clients/core/AbstractClient.java
+++
b/custos-client-sdks/custos-java-clients/custos-clients-core/src/main/java/org/apache/custos/clients/core/AbstractClient.java
@@ -53,6 +53,22 @@ public abstract class AbstractClient implements Closeable {
.usePlaintext().build();
}
+ public AbstractClient(String serviceHost, int servicePort,String clientId,
+ String clientSecret, boolean plainText) throws
IOException {
+ if (plainText) {
+ managedChannel = ManagedChannelBuilder.forAddress(serviceHost,
servicePort)
+ .usePlaintext().build();
+ }else {
+ managedChannel = NettyChannelBuilder.forAddress(serviceHost,
servicePort)
+ .sslContext(GrpcSslContexts
+ .forClient()
+
.trustManager(ClientUtils.getServerCertificate(serviceHost, clientId,
clientSecret)) // public key
+ .build())
+ .build();
+
+ }
+ }
+
@Override
public void close() throws IOException {
if (managedChannel != null){
diff --git
a/custos-client-sdks/custos-java-clients/user-management-client/src/main/java/org/apache/custos/user/management/client/UserManagementClient.java
b/custos-client-sdks/custos-java-clients/user-management-client/src/main/java/org/apache/custos/user/management/client/UserManagementClient.java
index 363498474..9de27126f 100644
---
a/custos-client-sdks/custos-java-clients/user-management-client/src/main/java/org/apache/custos/user/management/client/UserManagementClient.java
+++
b/custos-client-sdks/custos-java-clients/user-management-client/src/main/java/org/apache/custos/user/management/client/UserManagementClient.java
@@ -66,6 +66,21 @@ public class UserManagementClient extends AbstractClient {
}
+ public UserManagementClient(String serviceHost, int servicePort, String
clientId,
+ String clientSecret, boolean plainText) throws
IOException {
+ super(serviceHost, servicePort, clientId, clientSecret,plainText);
+
+ blockingStub =
UserManagementServiceGrpc.newBlockingStub(managedChannel);
+
+ blockingStub = MetadataUtils.attachHeaders(blockingStub,
+ ClientUtils.getAuthorizationHeader(clientId, clientSecret));
+
+ this.clientId = clientId;
+
+ this.clientSec = clientSecret;
+
+ }
+
public RegisterUserResponse registerUser(String username, String
firstName, String lastName,
String password, String email,
boolean isTempPassword) {
diff --git
a/custos-client-sdks/custos-java-sdk/src/main/java/org/apache/custos/clients/CustosClientProvider.java
b/custos-client-sdks/custos-java-sdk/src/main/java/org/apache/custos/clients/CustosClientProvider.java
index d4c582ee4..1c23bdb53 100644
---
a/custos-client-sdks/custos-java-sdk/src/main/java/org/apache/custos/clients/CustosClientProvider.java
+++
b/custos-client-sdks/custos-java-sdk/src/main/java/org/apache/custos/clients/CustosClientProvider.java
@@ -46,11 +46,15 @@ public class CustosClientProvider {
private String clientSec;
- private CustosClientProvider(String serverHost, int serverPort, String
clientId, String clientSec) {
+ private boolean plainText;
+
+
+ private CustosClientProvider(String serverHost, int serverPort, String
clientId, String clientSec, boolean plainText) {
this.serverHost = serverHost;
this.serverPort = serverPort;
this.clientId = clientId;
this.clientSec = clientSec;
+ this.plainText = plainText;
}
@@ -81,7 +85,7 @@ public class CustosClientProvider {
}
public UserManagementClient getUserManagementClient() throws IOException {
- return new UserManagementClient(this.serverHost, this.serverPort,
this.clientId, this.clientSec);
+ return new UserManagementClient(this.serverHost, this.serverPort,
this.clientId, this.clientSec, this.plainText);
}
public ResourceSecretManagementClient
getResourceSecretManagementClientForAgents() throws IOException {
@@ -97,6 +101,8 @@ public class CustosClientProvider {
private String clientSec;
+ private boolean plainText;
+
public Builder() {
}
@@ -121,13 +127,18 @@ public class CustosClientProvider {
return this;
}
+ public Builder usePlainText(boolean plainText) {
+ this.plainText = plainText;
+ return this;
+ }
+
public CustosClientProvider build() {
if (serverHost == null || serverPort == 0 || clientId == null ||
clientSec == null) {
throw new NullPointerException("Server Host, Server Port,
clientId, clientSec should not be null");
}
- return new CustosClientProvider(this.serverHost, this.serverPort,
this.clientId, this.clientSec);
+ return new CustosClientProvider(this.serverHost, this.serverPort,
this.clientId, this.clientSec, this.plainText);
}
diff --git
a/custos-utilities/ide-integration/src/main/containers/portal/docker-compose.yml
b/custos-utilities/ide-integration/src/main/containers/portal/docker-compose.yml
new file mode 100644
index 000000000..136749fd0
--- /dev/null
+++
b/custos-utilities/ide-integration/src/main/containers/portal/docker-compose.yml
@@ -0,0 +1,16 @@
+version: "3.3"
+services:
+ keycloak:
+ image: apachecustos/airavata-custos-portal:latest
+ ports:
+ - "8081:8080"
+ - "8444:443"
+ volumes:
+ -
/Users/isururanawaka/Documents/Airavata_Repository/airavata-custos/custos-utilities/ide-integration/src/main/containers/key.pem:/etc/nginx/privkey.pem
+ -
/Users/isururanawaka/Documents/Airavata_Repository/airavata-custos/custos-utilities/ide-integration/src/main/containers/certificate.pem:/etc/nginx/fullchain.pem
+ environment:
+ CUSTOS_CLIENT_ID: "custos-zhldgdoy5squtlqvfphu-10000000"
+ CUSTOS_CLIENT_SEC: "ZeIdfLOzqL3g1sXyfl3271KNHCWHCIYc6wl4nLEw"
+ CUSTOS_API_URL: "http://localhost:10000/"
+ CUSTOS_SUPER_CLIENT_ID: "custos-zhldgdoy5squtlqvfphu-10000000"
+ UNDER_MAINTENANCE: "false"
\ No newline at end of file