Fixed TokenController

Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
Marcin Woźniak 2020-12-03 17:14:39 +01:00
parent f4db74b899
commit b897fce416
Signed by: y0rune
GPG Key ID: F204C385F57EB348

View File

@ -4,7 +4,7 @@ import com.plannaplan.entities.User;
import com.plannaplan.exceptions.UserNotFoundException; import com.plannaplan.exceptions.UserNotFoundException;
import com.plannaplan.security.cas.CasUserIdentity; import com.plannaplan.security.cas.CasUserIdentity;
import com.plannaplan.security.cas.CasValidationExcepiton; import com.plannaplan.security.cas.CasValidationExcepiton;
import com.plannaplan.security.cas.DefaultUAMCasValidator; import com.plannaplan.security.cas.CustomUAMCasValidator;
import com.plannaplan.services.UserService; import com.plannaplan.services.UserService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -24,7 +24,7 @@ import io.swagger.annotations.ApiParam;
@Api(tags = { "Token" }, value = "Token", description = "Enpoints to get authorization.") @Api(tags = { "Token" }, value = "Token", description = "Enpoints to get authorization.")
public class TokenController { public class TokenController {
private final static String SERVICE_URL = "http://localhost:3000"; private final static String SERVICE_URL = "https://wmi.plannaplan.pl";
@Autowired @Autowired
private UserService userService; private UserService userService;
@ -32,8 +32,8 @@ public class TokenController {
@GetMapping("/token") @GetMapping("/token")
@ApiOperation(value = "Endpoint to access token required to call secured endpoints. In order to access token we need to provide access token comming from unviersity CAS system") @ApiOperation(value = "Endpoint to access token required to call secured endpoints. In order to access token we need to provide access token comming from unviersity CAS system")
public ResponseEntity<String> getToken( public ResponseEntity<String> getToken(
@RequestParam("ticket") @ApiParam(value = "Ticket get from CAS system. It should look like ST-1376572-wo41gty5R0JCZFKMMie2-cas.amu.edu.pl") final String ticket) { @RequestParam("ticket") @ApiParam(value = "Ticket get from CAS system. It should look like ST-1376572-wo41gty5R0JCZFKMMie2-cas.amu.edu.psl") final String ticket) {
final DefaultUAMCasValidator validator = new DefaultUAMCasValidator(SERVICE_URL, ticket); final CustomUAMCasValidator validator = new CustomUAMCasValidator(SERVICE_URL, ticket);
try { try {
final CasUserIdentity casUserIdentity = validator.validate(); final CasUserIdentity casUserIdentity = validator.validate();