Skip to content

Commit

Permalink
Merge pull request #284 from KBbitsP/master
Browse files Browse the repository at this point in the history
Java Snippets
  • Loading branch information
reshmabidikar authored Dec 15, 2023
2 parents 7c7eea6 + 5a95ed6 commit 5d14204
Showing 1 changed file with 100 additions and 2 deletions.
102 changes: 100 additions & 2 deletions source/includes/_security.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ curl -v \
```

```java
import org.killbill.billing.client.api.gen.SecurityApi;
import org.killbill.billing.client.model.gen.Subject;

SecurityApi securityApi = new SecurityApi(killBillHttpClient);

Subject currentUserSubject = securityApi.getCurrentUserSubject(requestOptions);
```

```ruby
Expand Down Expand Up @@ -137,6 +143,20 @@ curl -v \
```

```java
import org.killbill.billing.client.api.gen.SecurityApi;
import org.killbill.billing.client.model.gen.UserRoles;

SecurityApi securityApi = new SecurityApi(killBillHttpClient);

List<String> roles = List.of("TestRole");

UserRoles userRoles = new UserRoles();

userRoles.setUsername("TestUserName");
userRoles.setPassword("TestUserPassword");
userRoles.setRoles(roles);

UserRoles newUserDetails = securityApi.addUserRoles(userRoles, requestOptions);
```

```ruby
Expand Down Expand Up @@ -200,6 +220,18 @@ curl -v \
```

```java
import org.killbill.billing.client.api.gen.SecurityApi;
import org.killbill.billing.client.model.gen.UserRoles;

SecurityApi securityApi = new SecurityApi(killBillHttpClient);

String userName = "TestUserName";

UserRoles userRoles = new UserRoles();

userRoles.setPassword("TestUserPassUpdated");

securityApi.updateUserPassword(userName, userRoles, requestOptions);
```

```ruby
Expand Down Expand Up @@ -259,6 +291,14 @@ curl -v \
```

```java
import org.killbill.billing.client.api.gen.SecurityApi;
import org.killbill.billing.client.model.gen.UserRoles;

SecurityApi securityApi = new SecurityApi(killBillHttpClient);

String userName = "testuser";

UserRoles userRoles = securityApi.getUserRoles(userName, requestOptions);
```

```ruby
Expand All @@ -285,10 +325,10 @@ $userRoles = $apiInstance->getUserRoles($username);
```json
{
"username": "testuser23rd_1",
"username": "testUser",
"password": null,
"roles": [
"TestRole23rd_1"
"TestRole"
]
}
```
Expand All @@ -310,6 +350,20 @@ curl -v \
```

```java
import org.killbill.billing.client.api.gen.SecurityApi;
import org.killbill.billing.client.model.gen.UserRoles;

SecurityApi securityApi = new SecurityApi(killBillHttpClient);

List<String> roles = List.of("UpdatedRole");

UserRoles userRoles = new UserRoles();

String userName = "TestUser";

userRoles.setRoles(roles);

securityApi.updateUserRoles(userName, userRoles, requestOptions);
```

```ruby
Expand Down Expand Up @@ -373,6 +427,13 @@ curl -v \
```

```java
import org.killbill.billing.client.api.gen.SecurityApi;

SecurityApi securityApi = new SecurityApi(killBillHttpClient);

String userName = "testuser";

securityApi.invalidateUser(userName, requestOptions);
```

```ruby
Expand Down Expand Up @@ -429,8 +490,17 @@ curl -v \
```

```java
import org.killbill.billing.client.api.gen.SecurityApi;
import org.killbill.billing.client.model.gen.RoleDefinition;

SecurityApi securityApi = new SecurityApi(killBillHttpClient);

String role = "TestRole";

RoleDefinition roleDefinition = securityApi.getRoleDefinition(role, requestOptions);
```


```ruby
```

Expand Down Expand Up @@ -499,6 +569,20 @@ curl -v \
```

```java
import org.killbill.billing.client.api.gen.SecurityApi;
import org.killbill.billing.client.model.gen.RoleDefinition;

SecurityApi securityApi = new SecurityApi(killBillHttpClient);

List<String> permissions = List.of("account:*", "invoice:trigger");

String role = "TestRole";

RoleDefinition roleDefinition = new RoleDefinition();
roleDefinition.setRole(role);
roleDefinition.setPermissions(permissions);

RoleDefinition newRoleDefinition = securityApi.addRoleDefinition(roleDefinition, requestOptions);
```

```ruby
Expand Down Expand Up @@ -571,6 +655,20 @@ curl -v \
```

```java
import org.killbill.billing.client.api.gen.SecurityApi;
import org.killbill.billing.client.model.gen.RoleDefinition;

SecurityApi securityApi = new SecurityApi(killBillHttpClient);

List<String> permissions = List.of("account:*", "invoice:trigger");

String role = "TestRole";

RoleDefinition roleDefinition = new RoleDefinition();
roleDefinition.setRole(role);
roleDefinition.setPermissions(permissions);

securityApi.updateRoleDefinition(roleDefinition, requestOptions);
```

```ruby
Expand Down

0 comments on commit 5d14204

Please sign in to comment.