File tree Expand file tree Collapse file tree 4 files changed +18
-6
lines changed
example/src/main/java/eu/webeid/example Expand file tree Collapse file tree 4 files changed +18
-6
lines changed Original file line number Diff line number Diff line change 4242
4343@ Configuration
4444@ EnableWebSecurity
45- @ EnableMethodSecurity (securedEnabled = true , jsr250Enabled = true )
45+ @ EnableMethodSecurity (securedEnabled = true )
4646public class ApplicationConfiguration implements WebMvcConfigurer {
4747 final AuthTokenDTOAuthenticationProvider authTokenDTOAuthenticationProvider ;
4848 final SecurityContextRepository securityContextRepository ;
Original file line number Diff line number Diff line change 2929import eu .webeid .example .service .dto .FileDTO ;
3030import eu .webeid .example .service .dto .SignatureDTO ;
3131import eu .webeid .security .certificate .CertificateData ;
32+ import jakarta .servlet .http .HttpSession ;
33+ import jakarta .xml .bind .DatatypeConverter ;
3234import org .apache .commons .io .FilenameUtils ;
3335import org .digidoc4j .Configuration ;
3436import org .digidoc4j .Container ;
4446import org .slf4j .LoggerFactory ;
4547import org .springframework .beans .factory .ObjectFactory ;
4648import org .springframework .core .io .ByteArrayResource ;
49+ import org .springframework .security .access .annotation .Secured ;
4750import org .springframework .stereotype .Service ;
4851
49- import jakarta .servlet .http .HttpSession ;
50- import jakarta .xml .bind .DatatypeConverter ;
5152import java .io .IOException ;
5253import java .io .InputStream ;
5354import java .security .NoSuchAlgorithmException ;
5455import java .security .cert .CertificateException ;
5556import java .security .cert .X509Certificate ;
5657import java .util .Objects ;
5758
59+ import static eu .webeid .example .security .AuthTokenDTOAuthenticationProvider .ROLE_USER ;
60+
5861@ Service
62+ @ Secured (ROLE_USER )
5963public class SigningService {
6064
6165 private static final String SESSION_ATTR_FILE = "file-to-sign" ;
Original file line number Diff line number Diff line change 2424
2525import org .slf4j .Logger ;
2626import org .slf4j .LoggerFactory ;
27- import org .springframework .security .access .prepost . PreAuthorize ;
27+ import org .springframework .security .access .annotation . Secured ;
2828import org .springframework .stereotype .Controller ;
2929import org .springframework .ui .Model ;
3030import org .springframework .web .bind .annotation .GetMapping ;
3535import static eu .webeid .example .security .AuthTokenDTOAuthenticationProvider .ROLE_USER ;
3636
3737@ Controller
38+ @ Secured (ROLE_USER )
3839public class WelcomeController {
3940 private static final Logger LOG = LoggerFactory .getLogger (WelcomeController .class );
4041
41- @ PreAuthorize ("hasAuthority('" + ROLE_USER + "')" )
4242 @ GetMapping ("welcome" )
4343 public String welcome (Model model , Principal principal ) {
4444 Objects .requireNonNull (principal );
Original file line number Diff line number Diff line change 3232import org .springframework .core .io .Resource ;
3333import org .springframework .http .HttpHeaders ;
3434import org .springframework .http .ResponseEntity ;
35- import org .springframework .web .bind .annotation .*;
35+ import org .springframework .security .access .annotation .Secured ;
36+ import org .springframework .web .bind .annotation .GetMapping ;
37+ import org .springframework .web .bind .annotation .PostMapping ;
38+ import org .springframework .web .bind .annotation .RequestBody ;
39+ import org .springframework .web .bind .annotation .RequestMapping ;
40+ import org .springframework .web .bind .annotation .RestController ;
3641
3742import java .io .IOException ;
3843import java .security .NoSuchAlgorithmException ;
3944import java .security .cert .CertificateException ;
4045
46+ import static eu .webeid .example .security .AuthTokenDTOAuthenticationProvider .ROLE_USER ;
47+
4148@ RestController
4249@ RequestMapping ("sign" )
50+ @ Secured (ROLE_USER )
4351public class SigningController {
4452
4553 private final SigningService signingService ;
You can’t perform that action at this time.
0 commit comments