Abc

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.6 kB
1
Indexable
Never
SecurityContextHolder.getContext()
          .setAuthentication(
              new Authentication() {
                @Override
                public Collection<? extends GrantedAuthority> getAuthorities() {
                  return null;
                }

                @Override
                public Object getCredentials() {
                  return null;
                }

                @Override
                public Object getDetails() {
                  return null;
                }

                @Override
                public Object getPrincipal() {
                  return auditedByUser;
                }

                @Override
                public boolean isAuthenticated() {
                  return false;
                }

                @Override
                public void setAuthenticated(final boolean isAuthenticated)
                    throws IllegalArgumentException {}

                @Override
                public String getName() {
                  return null;
                }
              });
      //      AuditedUserThreadLocal.setAuditedByUser(auditedByUser);










final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    log.info("authentication {}", authentication);
    final String currentPrincipalName = (String) authentication.getPrincipal();
    log.info("currentPrincipalName {}", currentPrincipalName);
    final AuditDetailsDto auditDetailsDto =
        new AuditDetailsDto()
            .isRude(manualAuditRequest.getIsRude())
            .isZtp(manualAuditRequest.getIsZtp())
            .auditedBy(currentPrincipalName)
Leave a Comment