Skip to content

Commit

Permalink
fix: missing classes included
Browse files Browse the repository at this point in the history
  • Loading branch information
borisrizov-zf committed Jan 19, 2024
1 parent 0b83e27 commit a3e6485
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,32 @@

package org.eclipse.tractusx.managedidentitywallets.controller;

import java.util.Optional;
import java.util.Set;

import com.nimbusds.jwt.JWT;
import com.nimbusds.jwt.JWTParser;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.eclipse.tractusx.managedidentitywallets.UnsupportedGrantTypeException;
import org.eclipse.tractusx.managedidentitywallets.domain.DID;
import org.eclipse.tractusx.managedidentitywallets.dto.StsTokenErrorResponse;
import org.eclipse.tractusx.managedidentitywallets.dto.StsTokenResponse;
import org.eclipse.tractusx.managedidentitywallets.service.SecureTokenService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;

import com.nimbusds.jwt.JWT;
import com.nimbusds.jwt.JWTParser;

import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import java.util.Optional;
import java.util.Set;

@RestController
@RequiredArgsConstructor
public class SecureTokenController implements TokenApi {
public class SecureTokenController extends BaseController {

private static final String CLIENT_CREDENTIALS = "client_credentials";
private static final String TOKEN_TYPE_BEARER = "Bearer";

private final SecureTokenService tokenService;

@Override
@SneakyThrows
public ResponseEntity<StsTokenResponse> token(
@Valid String audience, @Valid String clientId, @Valid String clientSecret, @Valid String grantType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@
* ******************************************************************************
*/

package org.eclipse.tractusx.managedidentitywallets.controller;
package org.eclipse.tractusx.managedidentitywallets.dto;

import org.eclipse.tractusx.managedidentitywallets.service.SecureTokenService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
public class StsTokenErrorResponse {
private String error;
private String errorDescription;

import com.nimbusds.jwt.JWT;

import lombok.RequiredArgsConstructor;

@RestController
@RequiredArgsConstructor
public class SecureTokenControllerImpl implements SecureTokenController {
public void setError(String error) {
this.error = error;
}

private final SecureTokenService tokenService;
public String getError() {
return error;
}

public ResponseEntity<JWT> createToken() {
tokenService.issueToken(null, null);
return ResponseEntity.of(null);
public void setErrorDescription(String errorDescription) {
this.errorDescription = errorDescription;
}

public String getErrorDescription() {
return errorDescription;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* *******************************************************************************
* Copyright (c) 2021,2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
* ******************************************************************************
*/

package org.eclipse.tractusx.managedidentitywallets.dto;

public class StsTokenResponse {
protected String accessToken;
protected long expiresIn;
protected String tokenType;

public String getAccessToken() {
return accessToken;
}

public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}

public long getExpiresIn() {
return expiresIn;
}

public void setExpiresIn(long expiresIn) {
this.expiresIn = expiresIn;
}

public String getTokenType() {
return tokenType;
}

public void setTokenType(String tokenType) {
this.tokenType = tokenType;
}

public StsTokenResponse() {
}

;
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import java.time.Instant;
import java.util.Date;
import java.util.Set;
import java.util.UUID;

import org.eclipse.tractusx.managedidentitywallets.domain.DID;
Expand Down Expand Up @@ -56,7 +57,7 @@ public class SecureTokenIssuerImpl implements SecureTokenIssuer {
private final SecureTokenConfigurationProperties properties;

@Override
public JWT issueIdToken(DID self, DID partner, KeyPair keyPair) {
public JWT issueIdToken(DID self, DID partner, KeyPair keyPair, Set<String> scopes) {
log.info("Requested ID token for us: '{}' and partner '{}'", self, partner);
Instant expirationTime = Instant.now().plus(properties.tokenDuration());
JWT accessToken = createAccessToken(keyPair, self, partner, expirationTime);
Expand Down

0 comments on commit a3e6485

Please sign in to comment.