test-my-signature/src/main/java/se/idsec/signservice/integration/app/controller/SignController.java
private AuthenticationInfo createAuthenticationInfo(final SignatureResult result) {
    AuthenticationInfo authenticationInfo = new AuthenticationInfo();

    final SignerAssertionInformation sai = result.getSignerAssertionInformation();

    final String loa = sai.getAuthnContextRef();

    authenticationInfo.setLoaUri(loa);
    LevelofAssuranceAuthenticationContextURI.LoaEnum loaEnum = LevelofAssuranceAuthenticationContextURI.LoaEnum.parse(loa);
    if (loaEnum != null) {
      String baseUri = loaEnum.getBaseUri();
      if (LevelofAssuranceAuthenticationContextURI.AUTH_CONTEXT_URI_LOA3.equals(baseUri)) {
        authenticationInfo.setLoaLevelMessageCode("sp.msg.authn-according-loa3");
        authenticationInfo.setLoaLevelDescriptionCode("sp.msg.authn-according-loa.desc");
      }
      else if (LevelofAssuranceAuthenticationContextURI.AUTH_CONTEXT_URI_UNCERTIFIED_LOA3.equals(baseUri)) {
        authenticationInfo.setLoaLevelMessageCode("sp.msg.authn-according-loa3-uncertified");
        authenticationInfo.setLoaLevelDescriptionCode("sp.msg.authn-according-loa.desc");
      }
      else if (LevelofAssuranceAuthenticationContextURI.AUTH_CONTEXT_URI_EIDAS_LOW.equals(baseUri)) {
        authenticationInfo.setLoaLevelMessageCode("sp.msg.authn-according-loa-low");
        authenticationInfo.setLoaLevelDescriptionCode("sp.msg.authn-according-loa-eidas.desc");
        authenticationInfo.setNotifiedInfoMessageCode(
          loaEnum.isNotified() ? "sp.msg.authn-according-notified" : "sp.msg.authn-according-non-notified");
        authenticationInfo.setEidasAssertion(true);
      }
      else if (LevelofAssuranceAuthenticationContextURI.AUTH_CONTEXT_URI_EIDAS_SUBSTANTIAL.equals(baseUri)) {
        authenticationInfo.setLoaLevelMessageCode("sp.msg.authn-according-loa-substantial");
        authenticationInfo.setLoaLevelDescriptionCode("sp.msg.authn-according-loa-eidas.desc");
        authenticationInfo.setNotifiedInfoMessageCode(
          loaEnum.isNotified() ? "sp.msg.authn-according-notified" : "sp.msg.authn-according-non-notified");
        authenticationInfo.setEidasAssertion(true);
      }
      else if (LevelofAssuranceAuthenticationContextURI.AUTH_CONTEXT_URI_EIDAS_HIGH.equals(baseUri)) {
        authenticationInfo.setLoaLevelMessageCode("sp.msg.authn-according-loa-high");
        authenticationInfo.setLoaLevelDescriptionCode("sp.msg.authn-according-loa-eidas.desc");
        authenticationInfo.setNotifiedInfoMessageCode(
          loaEnum.isNotified() ? "sp.msg.authn-according-notified" : "sp.msg.authn-according-non-notified");
        authenticationInfo.setEidasAssertion(true);
      }
      else if (LevelofAssuranceAuthenticationContextURI.AUTH_CONTEXT_URI_LOA2.equals(baseUri)) {
        authenticationInfo.setLoaLevelMessageCode("sp.msg.authn-according-loa2");
        authenticationInfo.setLoaLevelDescriptionCode("sp.msg.authn-according-loa.desc");
      }
      else if (LevelofAssuranceAuthenticationContextURI.AUTH_CONTEXT_URI_LOA4.equals(baseUri)) {
        authenticationInfo.setLoaLevelMessageCode("sp.msg.authn-according-loa4");
        authenticationInfo.setLoaLevelDescriptionCode("sp.msg.authn-according-loa.desc");
      }
      else {
        log.error("Uknown LoA: {}", loa);
      }
    }
    else {
      log.error("Uknown LoA: {}", loa);
    }

    final boolean isEidas = loaEnum.isEidasUri();

    for (SignerIdentityAttributeValue a : sai.getSignerAttributes()) {
      AttributeInfo ai = this.attributeInfoRegistry.resolve(a.getName(), a.getValue(), isEidas);
      if (ai != null) {
        if (!ai.isAdvanced()) {
          authenticationInfo.getAttributes().add(ai);
        }
        else {
          authenticationInfo.getAdvancedAttributes().add(ai);
        }
      }
    }

    authenticationInfo.setAttributes(authenticationInfo.getAttributes()
      .stream()
      .sorted(Comparator.comparing(AttributeInfo::getSortOrder))
      .collect(Collectors.toList()));

    authenticationInfo.setAdvancedAttributes(authenticationInfo.getAdvancedAttributes()
      .stream()
      .sorted(Comparator.comparing(AttributeInfo::getSortOrder))
      .collect(Collectors.toList()));

    return authenticationInfo;
  }
/**
   * Creates an authentication info model object based on the response result.
   * 
   * @param result
   *          the result from the signature service
   * @return the model
   */
Creates an authentication info model object based on the response result.

@param result
the result from the signature service
@return the model
Creates an authentication info model object based on the response result . @param result the result from the signature service @return the model
private AuthenticationInfo createAuthenticationInfo(final SignatureResult result) {
    AuthenticationInfo authenticationInfo = new AuthenticationInfo();
    final SignerAssertionInformation sai = result.getSignerAssertionInformation();
    final String loa = sai.getAuthnContextRef();
    authenticationInfo.setLoaUri(loa);
    LevelofAssuranceAuthenticationContextURI.LoaEnum loaEnum = LevelofAssuranceAuthenticationContextURI.LoaEnum.parse(loa);
    if (loaEnum != null) {
      String baseUri = loaEnum.getBaseUri();
      if (LevelofAssuranceAuthenticationContextURI.AUTH_CONTEXT_URI_LOA3.equals(baseUri)) {
        authenticationInfo.setLoaLevelMessageCode("sp.msg.authn-according-loa3");
        authenticationInfo.setLoaLevelDescriptionCode("sp.msg.authn-according-loa.desc");
      }
      else if (LevelofAssuranceAuthenticationContextURI.AUTH_CONTEXT_URI_UNCERTIFIED_LOA3.equals(baseUri)) {
        authenticationInfo.setLoaLevelMessageCode("sp.msg.authn-according-loa3-uncertified");
        authenticationInfo.setLoaLevelDescriptionCode("sp.msg.authn-according-loa.desc");
      }
      else if (LevelofAssuranceAuthenticationContextURI.AUTH_CONTEXT_URI_EIDAS_LOW.equals(baseUri)) {
        authenticationInfo.setLoaLevelMessageCode("sp.msg.authn-according-loa-low");
        authenticationInfo.setLoaLevelDescriptionCode("sp.msg.authn-according-loa-eidas.desc");
        authenticationInfo.setNotifiedInfoMessageCode(
          loaEnum.isNotified() ? "sp.msg.authn-according-notified" : "sp.msg.authn-according-non-notified");
        authenticationInfo.setEidasAssertion(true);
      }
      else if (LevelofAssuranceAuthenticationContextURI.AUTH_CONTEXT_URI_EIDAS_SUBSTANTIAL.equals(baseUri)) {
        authenticationInfo.setLoaLevelMessageCode("sp.msg.authn-according-loa-substantial");
        authenticationInfo.setLoaLevelDescriptionCode("sp.msg.authn-according-loa-eidas.desc");
        authenticationInfo.setNotifiedInfoMessageCode(
          loaEnum.isNotified() ? "sp.msg.authn-according-notified" : "sp.msg.authn-according-non-notified");
        authenticationInfo.setEidasAssertion(true);
      }
      else if (LevelofAssuranceAuthenticationContextURI.AUTH_CONTEXT_URI_EIDAS_HIGH.equals(baseUri)) {
        authenticationInfo.setLoaLevelMessageCode("sp.msg.authn-according-loa-high");
        authenticationInfo.setLoaLevelDescriptionCode("sp.msg.authn-according-loa-eidas.desc");
        authenticationInfo.setNotifiedInfoMessageCode(
          loaEnum.isNotified() ? "sp.msg.authn-according-notified" : "sp.msg.authn-according-non-notified");
        authenticationInfo.setEidasAssertion(true);
      }
      else if (LevelofAssuranceAuthenticationContextURI.AUTH_CONTEXT_URI_LOA2.equals(baseUri)) {
        authenticationInfo.setLoaLevelMessageCode("sp.msg.authn-according-loa2");
        authenticationInfo.setLoaLevelDescriptionCode("sp.msg.authn-according-loa.desc");
      }
      else if (LevelofAssuranceAuthenticationContextURI.AUTH_CONTEXT_URI_LOA4.equals(baseUri)) {
        authenticationInfo.setLoaLevelMessageCode("sp.msg.authn-according-loa4");
        authenticationInfo.setLoaLevelDescriptionCode("sp.msg.authn-according-loa.desc");
      }
      else {
        log.error("Uknown LoA: {}", loa);
      }
    }
    else {
      log.error("Uknown LoA: {}", loa);
    }
    final boolean isEidas = loaEnum.isEidasUri();
    for (SignerIdentityAttributeValue a : sai.getSignerAttributes()) {
      AttributeInfo ai = this.attributeInfoRegistry.resolve(a.getName(), a.getValue(), isEidas);
      if (ai != null) {
        if (!ai.isAdvanced()) {
          authenticationInfo.getAttributes().add(ai);
        }
        else {
          authenticationInfo.getAdvancedAttributes().add(ai);
        }
      }
    }
    authenticationInfo.setAttributes(authenticationInfo.getAttributes()
      .stream()
      .sorted(Comparator.comparing(AttributeInfo::getSortOrder))
      .collect(Collectors.toList()));
    authenticationInfo.setAdvancedAttributes(authenticationInfo.getAdvancedAttributes()
      .stream()
      .sorted(Comparator.comparing(AttributeInfo::getSortOrder))
      .collect(Collectors.toList()));
    return authenticationInfo;
  }
private AuthenticationInfo createAuthenticationInfo ( final SignatureResult result ) { AuthenticationInfo authenticationInfo = new AuthenticationInfo ( ) ; final SignerAssertionInformation sai = result . getSignerAssertionInformation ( ) ; final String loa = sai . getAuthnContextRef ( ) ; authenticationInfo . setLoaUri ( loa ) ; LevelofAssuranceAuthenticationContextURI . LoaEnum loaEnum = LevelofAssuranceAuthenticationContextURI . LoaEnum . parse ( loa ) ; if ( loaEnum != null ) { String baseUri = loaEnum . getBaseUri ( ) ; if ( LevelofAssuranceAuthenticationContextURI . AUTH_CONTEXT_URI_LOA3 . equals ( baseUri ) ) { authenticationInfo . setLoaLevelMessageCode ( "sp.msg.authn-according-loa3" ) ; authenticationInfo . setLoaLevelDescriptionCode ( "sp.msg.authn-according-loa.desc" ) ; } else if ( LevelofAssuranceAuthenticationContextURI . AUTH_CONTEXT_URI_UNCERTIFIED_LOA3 . equals ( baseUri ) ) { authenticationInfo . setLoaLevelMessageCode ( "sp.msg.authn-according-loa3-uncertified" ) ; authenticationInfo . setLoaLevelDescriptionCode ( "sp.msg.authn-according-loa.desc" ) ; } else if ( LevelofAssuranceAuthenticationContextURI . AUTH_CONTEXT_URI_EIDAS_LOW . equals ( baseUri ) ) { authenticationInfo . setLoaLevelMessageCode ( "sp.msg.authn-according-loa-low" ) ; authenticationInfo . setLoaLevelDescriptionCode ( "sp.msg.authn-according-loa-eidas.desc" ) ; authenticationInfo . setNotifiedInfoMessageCode ( loaEnum . isNotified ( ) ? "sp.msg.authn-according-notified" : "sp.msg.authn-according-non-notified" ) ; authenticationInfo . setEidasAssertion ( true ) ; } else if ( LevelofAssuranceAuthenticationContextURI . AUTH_CONTEXT_URI_EIDAS_SUBSTANTIAL . equals ( baseUri ) ) { authenticationInfo . setLoaLevelMessageCode ( "sp.msg.authn-according-loa-substantial" ) ; authenticationInfo . setLoaLevelDescriptionCode ( "sp.msg.authn-according-loa-eidas.desc" ) ; authenticationInfo . setNotifiedInfoMessageCode ( loaEnum . isNotified ( ) ? "sp.msg.authn-according-notified" : "sp.msg.authn-according-non-notified" ) ; authenticationInfo . setEidasAssertion ( true ) ; } else if ( LevelofAssuranceAuthenticationContextURI . AUTH_CONTEXT_URI_EIDAS_HIGH . equals ( baseUri ) ) { authenticationInfo . setLoaLevelMessageCode ( "sp.msg.authn-according-loa-high" ) ; authenticationInfo . setLoaLevelDescriptionCode ( "sp.msg.authn-according-loa-eidas.desc" ) ; authenticationInfo . setNotifiedInfoMessageCode ( loaEnum . isNotified ( ) ? "sp.msg.authn-according-notified" : "sp.msg.authn-according-non-notified" ) ; authenticationInfo . setEidasAssertion ( true ) ; } else if ( LevelofAssuranceAuthenticationContextURI . AUTH_CONTEXT_URI_LOA2 . equals ( baseUri ) ) { authenticationInfo . setLoaLevelMessageCode ( "sp.msg.authn-according-loa2" ) ; authenticationInfo . setLoaLevelDescriptionCode ( "sp.msg.authn-according-loa.desc" ) ; } else if ( LevelofAssuranceAuthenticationContextURI . AUTH_CONTEXT_URI_LOA4 . equals ( baseUri ) ) { authenticationInfo . setLoaLevelMessageCode ( "sp.msg.authn-according-loa4" ) ; authenticationInfo . setLoaLevelDescriptionCode ( "sp.msg.authn-according-loa.desc" ) ; } else { log . error ( "Uknown LoA: {}" , loa ) ; } } else { log . error ( "Uknown LoA: {}" , loa ) ; } final boolean isEidas = loaEnum . isEidasUri ( ) ; for ( SignerIdentityAttributeValue a : sai . getSignerAttributes ( ) ) { AttributeInfo ai = this . attributeInfoRegistry . resolve ( a . getName ( ) , a . getValue ( ) , isEidas ) ; if ( ai != null ) { if ( ! ai . isAdvanced ( ) ) { authenticationInfo . getAttributes ( ) . add ( ai ) ; } else { authenticationInfo . getAdvancedAttributes ( ) . add ( ai ) ; } } } authenticationInfo . setAttributes ( authenticationInfo . getAttributes ( ) . stream ( ) . sorted ( Comparator . comparing ( AttributeInfo :: getSortOrder ) ) . collect ( Collectors . toList ( ) ) ) ; authenticationInfo . setAdvancedAttributes ( authenticationInfo . getAdvancedAttributes ( ) . stream ( ) . sorted ( Comparator . comparing ( AttributeInfo :: getSortOrder ) ) . collect ( Collectors . toList ( ) ) ) ; return authenticationInfo ; }
Creates an authentication info model object based on the response result.
Creates an authentication info model object based on the response result .