Skip to content

Commit

Permalink
feat: rename classes (#67)
Browse files Browse the repository at this point in the history
* add:ApplicationTest.java add test cases for user、application objects and user、application operations

* fix:update ApplicationTest and add TestDefaultConfig

* fix: add test case for application
Slimmed down the files starting with Casdoor, removed the corresponding toString method, and changed the permission modifier to public.
  • Loading branch information
WindyDante authored Oct 12, 2023
1 parent b24f6ce commit 0d6f1c6
Show file tree
Hide file tree
Showing 65 changed files with 1,290 additions and 1,255 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Initialization requires 5 parameters, which are all string type:
| applicationName | No | The name for the Casdoor application |

```java
CasdoorConfig casdoorConfig = new CasdoorConfig(endpoint, clientId, clientSecret, certificate, organizationName, applicationName);
CasdoorConfig config = new CasdoorConfig(endpoint, clientId, clientSecret, certificate, organizationName, applicationName);
```

## Step2. Get Service and use
Expand All @@ -36,7 +36,7 @@ Now provide two services: ``CasdoorUserService``, ``CasdoorAuthService``
You can create them like

```Java
CasdoorUserService casdoorUserService = new CasdoorUserService(casdoorConfig);
CasdoorUserService casdoorUserService = new CasdoorUserService(config);
```

## UserService
Expand All @@ -58,14 +58,14 @@ Your web application can get the `code`,`state` and call `GetOAuthToken(code, st
The general process is as follows:

```java
String token = casdoorAuthService.getOAuthToken(code, state);
String token = authService.getOAuthToken(code, state);

CasdoorUser casdoorUser = casdoorAuthService.parseJwtToken(token);
CasdoorUser user = authService.parseJwtToken(token);
```

2. **Set Session in your app**

`casdoorUser` contains the basic information about the user provided by casdoor, you can use it as a keyword to set the session in your application, like this:
`user` contains the basic information about the user provided by casdoor, you can use it as a keyword to set the session in your application, like this:

```java
HttpSession session = request.getSession();
Expand Down
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,18 @@
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 The Casdoor Authors. All Rights Reserved.
// Copyright 2021 The casbin Authors. 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.
Expand All @@ -18,18 +18,18 @@
* CasdoorConfig is the core configuration.
* The first step to use this SDK is to initialize the global casdoorConfig.
*/
public class CasdoorConfig {
public class Config {
private String endpoint;
private String clientId;
private String clientSecret;
private String certificate;
private String organizationName;
private String applicationName;

public CasdoorConfig() {
public Config() {
}

public CasdoorConfig(String endpoint, String clientId, String clientSecret, String certificate, String organizationName, String applicationName) {
public Config(String endpoint, String clientId, String clientSecret, String certificate, String organizationName, String applicationName) {
this.endpoint = endpoint;
this.clientId = clientId;
this.clientSecret = clientSecret;
Expand Down Expand Up @@ -86,15 +86,4 @@ public void setApplicationName(String applicationName) {
this.applicationName = applicationName;
}

@Override
public String toString() {
return "CasdoorConfig{" +
"endpoint='" + endpoint + '\'' +
", clientId='" + clientId + '\'' +
", clientSecret='" + clientSecret + '\'' +
", certificate='" + certificate + '\'' +
", organizationName='" + organizationName + '\'' +
", applicationName='" + applicationName + '\'' +
'}';
}
}
Loading

0 comments on commit 0d6f1c6

Please sign in to comment.