|
| 1 | +/* |
| 2 | + * ******************************************************************************* |
| 3 | + * Copyright (c) 2021,2024 Contributors to the Eclipse Foundation |
| 4 | + * |
| 5 | + * See the NOTICE file(s) distributed with this work for additional |
| 6 | + * information regarding copyright ownership. |
| 7 | + * |
| 8 | + * This program and the accompanying materials are made available under the |
| 9 | + * terms of the Apache License, Version 2.0 which is available at |
| 10 | + * https://www.apache.org/licenses/LICENSE-2.0. |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 15 | + * License for the specific language governing permissions and limitations |
| 16 | + * under the License. |
| 17 | + * |
| 18 | + * SPDX-License-Identifier: Apache-2.0 |
| 19 | + * ****************************************************************************** |
| 20 | + */ |
| 21 | + |
| 22 | +package org.eclipse.tractusx.managedidentitywallets.dto; |
| 23 | + |
| 24 | +import com.fasterxml.jackson.annotation.JsonProperty; |
| 25 | +import jakarta.validation.constraints.NotBlank; |
| 26 | +import jakarta.validation.constraints.NotNull; |
| 27 | +import lombok.AllArgsConstructor; |
| 28 | +import lombok.Builder; |
| 29 | +import lombok.Getter; |
| 30 | +import lombok.NoArgsConstructor; |
| 31 | +import lombok.Setter; |
| 32 | + |
| 33 | +@NoArgsConstructor |
| 34 | +@AllArgsConstructor |
| 35 | +@Builder |
| 36 | +@Getter |
| 37 | +@Setter |
| 38 | +public class SecureTokenRequest { |
| 39 | + @NotBlank |
| 40 | + private String audience; |
| 41 | + |
| 42 | + @NotBlank |
| 43 | + @NotNull |
| 44 | + @JsonProperty("client_id") |
| 45 | + private String clientId; |
| 46 | + |
| 47 | + @NotBlank |
| 48 | + @NotNull |
| 49 | + @JsonProperty("client_secret") |
| 50 | + private String clientSecret; |
| 51 | + |
| 52 | + @NotBlank |
| 53 | + @NotNull |
| 54 | + @JsonProperty("grant_type") |
| 55 | + private String grantType; |
| 56 | + |
| 57 | + @JsonProperty("access_token") |
| 58 | + private String accessToken; |
| 59 | + |
| 60 | + @JsonProperty("bearer_access_alias") |
| 61 | + private String bearerAccessAlias; |
| 62 | + |
| 63 | + @JsonProperty("bearer_access_scope") |
| 64 | + private String bearerAccessScope; |
| 65 | + |
| 66 | + public boolean assertValidWithScopes() { |
| 67 | + return bearerAccessScope != null && accessToken == null && !bearerAccessScope.isEmpty(); |
| 68 | + } |
| 69 | + |
| 70 | + public boolean assertValidWithAccessToken() { |
| 71 | + return accessToken != null && bearerAccessScope == null; |
| 72 | + } |
| 73 | + |
| 74 | + @Override |
| 75 | + public String toString() { |
| 76 | + return "SecureTokenRequest{" + |
| 77 | + "audience='" + audience + '\'' + |
| 78 | + ", clientId='" + clientId + '\'' + |
| 79 | + ", clientSecret='" + clientSecret + '\'' + |
| 80 | + ", grantType='" + grantType + '\'' + |
| 81 | + ", accessToken='" + accessToken + '\'' + |
| 82 | + ", bearerAccessAlias='" + bearerAccessAlias + '\'' + |
| 83 | + ", bearerAccessScope='" + bearerAccessScope + '\'' + |
| 84 | + '}'; |
| 85 | + } |
| 86 | +} |
0 commit comments