File tree Expand file tree Collapse file tree 4 files changed +24
-20
lines changed
servlet/spring-boot/java/saml2
login/src/main/java/example
refreshable-metadata/src/main/java/example
saml-extension-federation/src/main/java/example
saml-extension-urls/src/main/java/example Expand file tree Collapse file tree 4 files changed +24
-20
lines changed Original file line number Diff line number Diff line change 1616
1717package example ;
1818
19- import org .springframework .security .core . annotation . AuthenticationPrincipal ;
20- import org .springframework .security .saml2 .provider .service .authentication .Saml2AuthenticatedPrincipal ;
19+ import org .springframework .security .saml2 . provider . service . authentication . Saml2AssertionAuthentication ;
20+ import org .springframework .security .saml2 .provider .service .authentication .Saml2ResponseAssertionAccessor ;
2121import org .springframework .stereotype .Controller ;
2222import org .springframework .ui .Model ;
2323import org .springframework .web .bind .annotation .GetMapping ;
2626public class IndexController {
2727
2828 @ GetMapping ("/" )
29- public String index (Model model , @ AuthenticationPrincipal Saml2AuthenticatedPrincipal principal ) {
30- String emailAddress = principal .getFirstAttribute ("email" );
29+ public String index (Model model , Saml2AssertionAuthentication authentication ) {
30+ Saml2ResponseAssertionAccessor assertion = authentication .getCredentials ();
31+ String emailAddress = assertion .getFirstAttribute ("email" );
3132 model .addAttribute ("emailAddress" , emailAddress );
32- model .addAttribute ("userAttributes" , principal .getAttributes ());
33+ model .addAttribute ("userAttributes" , assertion .getAttributes ());
3334 return "index" ;
3435 }
3536
Original file line number Diff line number Diff line change 1616
1717package example ;
1818
19- import org .springframework .security .core . annotation . AuthenticationPrincipal ;
20- import org .springframework .security .saml2 .provider .service .authentication .Saml2AuthenticatedPrincipal ;
19+ import org .springframework .security .saml2 . provider . service . authentication . Saml2AssertionAuthentication ;
20+ import org .springframework .security .saml2 .provider .service .authentication .Saml2ResponseAssertionAccessor ;
2121import org .springframework .stereotype .Controller ;
2222import org .springframework .ui .Model ;
2323import org .springframework .web .bind .annotation .GetMapping ;
2626public class IndexController {
2727
2828 @ GetMapping ("/" )
29- public String index (Model model , @ AuthenticationPrincipal Saml2AuthenticatedPrincipal principal ) {
30- String emailAddress = principal .getFirstAttribute ("email" );
29+ public String index (Model model , Saml2AssertionAuthentication authentication ) {
30+ Saml2ResponseAssertionAccessor assertion = authentication .getCredentials ();
31+ String emailAddress = assertion .getFirstAttribute ("email" );
3132 model .addAttribute ("emailAddress" , emailAddress );
32- model .addAttribute ("userAttributes" , principal .getAttributes ());
33+ model .addAttribute ("userAttributes" , assertion .getAttributes ());
3334 return "index" ;
3435 }
3536
Original file line number Diff line number Diff line change 1616
1717package example ;
1818
19- import org .springframework .security .core . annotation . AuthenticationPrincipal ;
20- import org .springframework .security .saml2 .provider .service .authentication .Saml2AuthenticatedPrincipal ;
19+ import org .springframework .security .saml2 . provider . service . authentication . Saml2AssertionAuthentication ;
20+ import org .springframework .security .saml2 .provider .service .authentication .Saml2ResponseAssertionAccessor ;
2121import org .springframework .stereotype .Controller ;
2222import org .springframework .ui .Model ;
2323import org .springframework .web .bind .annotation .GetMapping ;
2626public class IndexController {
2727
2828 @ GetMapping ("/" )
29- public String index (Model model , @ AuthenticationPrincipal Saml2AuthenticatedPrincipal principal ) {
30- String emailAddress = principal .getFirstAttribute ("email" );
29+ public String index (Model model , Saml2AssertionAuthentication authentication ) {
30+ Saml2ResponseAssertionAccessor assertion = authentication .getCredentials ();
31+ String emailAddress = assertion .getFirstAttribute ("email" );
3132 model .addAttribute ("emailAddress" , emailAddress );
32- model .addAttribute ("userAttributes" , principal .getAttributes ());
33+ model .addAttribute ("userAttributes" , assertion .getAttributes ());
3334 return "index" ;
3435 }
3536
Original file line number Diff line number Diff line change 1616
1717package example ;
1818
19- import org .springframework .security .core . annotation . AuthenticationPrincipal ;
20- import org .springframework .security .saml2 .provider .service .authentication .Saml2AuthenticatedPrincipal ;
19+ import org .springframework .security .saml2 . provider . service . authentication . Saml2AssertionAuthentication ;
20+ import org .springframework .security .saml2 .provider .service .authentication .Saml2ResponseAssertionAccessor ;
2121import org .springframework .stereotype .Controller ;
2222import org .springframework .ui .Model ;
2323import org .springframework .web .bind .annotation .GetMapping ;
2626public class IndexController {
2727
2828 @ GetMapping ("/" )
29- public String index (Model model , @ AuthenticationPrincipal Saml2AuthenticatedPrincipal principal ) {
30- String emailAddress = principal .getFirstAttribute ("email" );
29+ public String index (Model model , Saml2AssertionAuthentication authentication ) {
30+ Saml2ResponseAssertionAccessor assertion = authentication .getCredentials ();
31+ String emailAddress = assertion .getFirstAttribute ("email" );
3132 model .addAttribute ("emailAddress" , emailAddress );
32- model .addAttribute ("userAttributes" , principal .getAttributes ());
33+ model .addAttribute ("userAttributes" , assertion .getAttributes ());
3334 return "index" ;
3435 }
3536
You can’t perform that action at this time.
0 commit comments