当前位置: 首页>>代码示例>>Java>>正文


Java AuditorAware类代码示例

本文整理汇总了Java中org.springframework.data.domain.AuditorAware的典型用法代码示例。如果您正苦于以下问题:Java AuditorAware类的具体用法?Java AuditorAware怎么用?Java AuditorAware使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AuditorAware类属于org.springframework.data.domain包,在下文中一共展示了AuditorAware类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: auditorAware

import org.springframework.data.domain.AuditorAware; //导入依赖的package包/类
@Bean
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public AuditorAware<Username> auditorAware() {

    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

    log.debug("current authentication:" + authentication);

    if (authentication == null || !authentication.isAuthenticated()) {
        return () -> Optional.<Username>empty();
    }

    return () -> Optional.of(
        Username.builder()
            .username(((UserDetails) authentication.getPrincipal()).getUsername())
            .build()
    );

}
 
开发者ID:hantsy,项目名称:spring-microservice-sample,代码行数:20,代码来源:DataJpaConfig.java

示例2: auditorProvider

import org.springframework.data.domain.AuditorAware; //导入依赖的package包/类
@Bean
public AuditorAware<String> auditorProvider() {
    return new AuditorAware<String>() {
        @Override
        public String getCurrentAuditor() {
            Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

            if (authentication == null || !authentication.isAuthenticated()) {
                return null;
            }

            return authentication.getPrincipal() instanceof User ?
                    ((User) authentication.getPrincipal()).getLogin() : authentication.getPrincipal().toString();
        }
    };
}
 
开发者ID:yuexine,项目名称:loafer,代码行数:17,代码来源:JPAAuditorConfiguration.java

示例3: auditorAware

import org.springframework.data.domain.AuditorAware; //导入依赖的package包/类
@Bean
public AuditorAware<String> auditorAware() {
    return new AuditorAware<String>() {
        @Override
        public String getCurrentAuditor() {
            Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

            if (authentication == null || !authentication.isAuthenticated()) {
                return null;
            }

            return authentication.getName();
        }
    };
}
 
开发者ID:weechang,项目名称:Taroco,代码行数:16,代码来源:ApiGateWayApplication.java

示例4: auditorAwareBean

import org.springframework.data.domain.AuditorAware; //导入依赖的package包/类
@Bean
public AuditorAware<String> auditorAwareBean() {
  return () -> {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    if (authentication == null
        || new AuthenticationTrustResolverImpl().isAnonymous(authentication)) {
      return "@SYSTEM";
    }

    Object principal = authentication.getPrincipal();
    if (principal instanceof String) {
      return (String) principal;
    } else if (principal instanceof UserDetails) {
      return ((UserDetails) principal).getUsername();
    } else {
      return String.valueOf(principal);
    }
  };
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:20,代码来源:WebSecurityConfiguration.java

示例5: MybatisMetamodelEntityInformation

import org.springframework.data.domain.AuditorAware; //导入依赖的package包/类
/**
 * Creates a new {@link AbstractEntityInformation} from the given domain class.
 *
 * @param domainClass must not be {@literal null}.
 */
protected MybatisMetamodelEntityInformation(PersistentEntity<T, ?> persistentEntity,
    AuditorAware<?> auditorAware, AuditDateAware<?> auditDateAware, Class<T> domainClass) {
  super(persistentEntity, auditorAware, auditDateAware, domainClass);

  createdDateProperty = persistentEntity.getPersistentProperty(CreatedDate.class);
  lastModifiedDateProperty = persistentEntity.getPersistentProperty(LastModifiedDate.class);
  createdByProperty = persistentEntity.getPersistentProperty(CreatedBy.class);
  lastModifiedByProperty = persistentEntity.getPersistentProperty(LastModifiedBy.class);
}
 
开发者ID:hatunet,项目名称:spring-data-mybatis,代码行数:15,代码来源:MybatisMetamodelEntityInformation.java

示例6: deploymentManagement

import org.springframework.data.domain.AuditorAware; //导入依赖的package包/类
/**
 * {@link JpaDeploymentManagement} bean.
 *
 * @return a new {@link DeploymentManagement}
 */
@Bean
@ConditionalOnMissingBean
DeploymentManagement deploymentManagement(final EntityManager entityManager,
        final ActionRepository actionRepository, final DistributionSetRepository distributionSetRepository,
        final TargetRepository targetRepository, final ActionStatusRepository actionStatusRepository,
        final TargetManagement targetManagement, final AuditorAware<String> auditorProvider,
        final ApplicationEventPublisher eventPublisher, final ApplicationContext applicationContext,
        final AfterTransactionCommitExecutor afterCommit, final VirtualPropertyReplacer virtualPropertyReplacer,
        final PlatformTransactionManager txManager,
        final TenantConfigurationManagement tenantConfigurationManagement,
        final SystemSecurityContext systemSecurityContext) {
    return new JpaDeploymentManagement(entityManager, actionRepository, distributionSetRepository, targetRepository,
            actionStatusRepository, targetManagement, auditorProvider, eventPublisher, applicationContext,
            afterCommit, virtualPropertyReplacer, txManager, tenantConfigurationManagement, systemSecurityContext);
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:21,代码来源:RepositoryApplicationConfiguration.java

示例7: auditorAware

import org.springframework.data.domain.AuditorAware; //导入依赖的package包/类
@Bean
public AuditorAware<String> auditorAware() {
    return () -> {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        if (authentication == null || !authentication.isAuthenticated()) {
            return "Anonymous";
        }

        //TODO fix fetching user name
        return authentication.getPrincipal().toString();
    };
}
 
开发者ID:rozidan,项目名称:project-template,代码行数:13,代码来源:AuditingConfig.java

示例8: auditorAware

import org.springframework.data.domain.AuditorAware; //导入依赖的package包/类
@Bean
public AuditorAware<User> auditorAware() {
	return new AuditorAware<User>() {

		@Override
		public User getCurrentAuditor() {
			System.out.println("\n\nJPAConfig.auditorAware().new AuditorAware() {...}.getCurrentAuditor()");

			return UserUtil.getUser();
		}
	};
}
 
开发者ID:xwjie,项目名称:ElementVueSpringbootCodeTemplate,代码行数:13,代码来源:JPAConfig.java

示例9: MybatisRepositoryFactory

import org.springframework.data.domain.AuditorAware; //导入依赖的package包/类
public MybatisRepositoryFactory(final MybatisMappingContext mappingContext,
                                final SqlSessionTemplate sessionTemplate,
                                final Dialect dialect,
                                AuditorAware<?> auditorAware,
                                AuditDateAware<?> auditDateAware) {
    Assert.notNull(sessionTemplate);
    Assert.notNull(dialect);
    this.mappingContext = mappingContext;
    this.sessionTemplate = sessionTemplate;
    this.dialect = dialect;
    this.auditorAware = auditorAware;
    this.auditDateAware = auditDateAware;
}
 
开发者ID:hatunet,项目名称:spring-data-mybatis,代码行数:14,代码来源:MybatisRepositoryFactory.java

示例10: MybatisEntityInformationSupport

import org.springframework.data.domain.AuditorAware; //导入依赖的package包/类
/**
 * Creates a new {@link AbstractEntityInformation} from the given domain class.
 *
 * @param auditDateAware
 * @param domainClass    must not be {@literal null}.
 */
protected MybatisEntityInformationSupport(
        PersistentEntity<T, ?> persistentEntity,
        AuditorAware<?> auditorAware,
        AuditDateAware<?> auditDateAware, Class<T> domainClass) {
    super(domainClass);
    this.persistentEntity = persistentEntity;
    this.auditorAware = auditorAware;
    this.auditDateAware = auditDateAware;
}
 
开发者ID:hatunet,项目名称:spring-data-mybatis,代码行数:16,代码来源:MybatisEntityInformationSupport.java

示例11: getEntityInformation

import org.springframework.data.domain.AuditorAware; //导入依赖的package包/类
public static <T, ID extends Serializable> MybatisEntityInformation<T, ID> getEntityInformation(MybatisMappingContext mappingContext,
                                                                                                AuditorAware<?> auditorAware,
                                                                                                AuditDateAware<?> auditDateAware,
                                                                                                Class<T> domainClass) {
    Assert.notNull(domainClass);
    PersistentEntity<T, ?> persistentEntity = (PersistentEntity<T, ?>) mappingContext.getPersistentEntity(domainClass);
    if (Persistable.class.isAssignableFrom(domainClass)) {
        return new MybatisPersistableEntityInformation(persistentEntity, auditorAware, auditDateAware, domainClass);
    }

    return new MybatisMetamodelEntityInformation<T, ID>(persistentEntity, auditorAware, auditDateAware, domainClass);
}
 
开发者ID:hatunet,项目名称:spring-data-mybatis,代码行数:13,代码来源:MybatisEntityInformationSupport.java

示例12: auditorAware

import org.springframework.data.domain.AuditorAware; //导入依赖的package包/类
@Bean
public AuditorAware<Long> auditorAware() {
    return new AuditorAware<Long>() {
        @Override
        public Long getCurrentAuditor() {
            return 1001L;
        }
    };
}
 
开发者ID:hatunet,项目名称:spring-data-mybatis,代码行数:10,代码来源:TestConfig.java

示例13: auditorProvider

import org.springframework.data.domain.AuditorAware; //导入依赖的package包/类
@Bean
public AuditorAware<String> auditorProvider() {
    return new AuditorAware<String>() {
        @Override
        public String getCurrentAuditor() {
            return "nemo"; //TODO once authentication is working, make this return the real user
        }
    };
}
 
开发者ID:EMBL-EBI-SUBS-OLD,项目名称:subs,代码行数:10,代码来源:RestRepositoryConfig.java

示例14: testAuthenticationAuditorAware

import org.springframework.data.domain.AuditorAware; //导入依赖的package包/类
/**
 * Test method for {@link io.springlets.data.jpa.config.SpringletsDataJpaAuthenticationAuditorConfiguration#authenticationAuditorAware()}.
 */
@Test
public void testAuthenticationAuditorAware() {
  // Setup

  // Exercise
  AuditorAware<String> authenticationAuditorAware = configuration.auditorProvider();

  // Verify
  assertThat(authenticationAuditorAware).isNotNull()
      .isInstanceOf(AuthenticationAuditorAware.class);
}
 
开发者ID:DISID,项目名称:springlets,代码行数:15,代码来源:SpringletsDataJpaAuthenticationAuditorConfigurationTest.java

示例15: auditorProvider

import org.springframework.data.domain.AuditorAware; //导入依赖的package包/类
@Bean
public AuditorAware<String> auditorProvider() {
  return
    () -> {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

    if ((authentication == null) || !authentication.isAuthenticated()) {
      return null;
    }

    return ((Client) authentication.getPrincipal()).getUsername();
  };
}
 
开发者ID:ImmobilienScout24,项目名称:switchman,代码行数:14,代码来源:Persistence.java


注:本文中的org.springframework.data.domain.AuditorAware类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。