0
0
Spring Bootframework~10 mins

@Secured annotation in Spring Boot - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to secure the method so only users with role 'ADMIN' can access it.

Spring Boot
@Secured({"[1]"})
public void adminOnlyMethod() {
    // method logic
}
Drag options to blanks, or click blank then click option'
AROLE_ADMIN
BADMIN
CROLE_USER
DUSER
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ADMIN' without 'ROLE_' prefix causes access to fail.
2fill in blank
medium

Complete the code to allow access to users with either 'USER' or 'ADMIN' roles.

Spring Boot
@Secured({"[1]", "ROLE_ADMIN"})
public void userOrAdminMethod() {
    // method logic
}
Drag options to blanks, or click blank then click option'
AGUEST
BROLE_USER
CROLE_GUEST
DUSER
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting 'ROLE_' prefix causes access denial.
3fill in blank
hard

Fix the error in the annotation to correctly secure the method for 'MANAGER' role.

Spring Boot
@Secured("[1]")
public void managerMethod() {
    // method logic
}
Drag options to blanks, or click blank then click option'
AMANAGER
B[ROLE_MANAGER]
CROLE_MANAGER
D{ROLE_MANAGER}
Attempts:
3 left
💡 Hint
Common Mistakes
Using brackets or missing 'ROLE_' prefix causes errors.
4fill in blank
hard

Fill both blanks to secure the method for roles 'ADMIN' and 'SUPERVISOR'.

Spring Boot
@Secured({"[1]", "[2]"})
public void adminSupervisorMethod() {
    // method logic
}
Drag options to blanks, or click blank then click option'
AROLE_ADMIN
BROLE_SUPERVISOR
CADMIN
DSUPERVISOR
Attempts:
3 left
💡 Hint
Common Mistakes
Using roles without 'ROLE_' prefix or wrong syntax.
5fill in blank
hard

Fill all three blanks to secure the method for roles 'USER', 'ADMIN', and 'GUEST'.

Spring Boot
@Secured({"[1]", "[2]", "[3]"})
public void multiRoleMethod() {
    // method logic
}
Drag options to blanks, or click blank then click option'
AROLE_GUEST
BROLE_ADMIN
CROLE_USER
DGUEST
Attempts:
3 left
💡 Hint
Common Mistakes
Missing 'ROLE_' prefix or incorrect array syntax.