我正在使用Spring Security通过OpenID进行身份验证的应用程序.当用户登录时,会话中会加载某些权限.
我拥有完全权限的用户,可以修改其他用户的权限(撤销,添加角色).我的问题是,如何动态更改用户会话权限?(不能使用SecurityContextHolder,因为我想更改另一个用户会话).
简单方法:使用户会话无效,但如何?更好的方法:刷新用户会话与新权限,但如何?
我想用ManyToMany关系来保持我的实体.但是在持久化过程中我遇到了一些问题.
我的实体:
@Entity
@Table(name = "USER")
public class User implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "ID")
@GeneratedValue(strategy = GenerationType.IDENTITY)
Long userId;
@Column(name = "NAME", unique = true, nullable = false)
String userName;
@Column(name = "FORNAME")
String userForname;
@Column(name = "EMAIL")
String userEmail;
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(name = "USER_USER_ROLES", joinColumns = @JoinColumn(name = "ID_USER"), inverseJoinColumns = @JoinColumn(name = "ID_ROLE"))
List<UserRoles> userRoles = new ArrayList<UserRoles>();
// getter et setter
}
Run Code Online (Sandbox Code Playgroud)
和
@Entity …
Run Code Online (Sandbox Code Playgroud) 我正在尝试将旧的 React navigation v4 迁移到 v6(超过 100 条路线)。但我面临着如何找到最佳结构来分割单独文件/组件中的屏幕组。
我已经尝试过这样做,以移出模态:
const ModalGroup = () => (
<Stack.Group screenOptions={{ presentation: "modal" }}>
<Stack.Screen name="ModalA" component={ModalAScreen} />
<Stack.Screen name="ModalB" component={ModalBScreen} />
</Stack.Group>
);
export const RootNavigator = () => (
<Stack.Navigator initialRouteName="Home">
<Stack.Screen name="Home" component={HomeScreen} />
<ModalGroup />
</Stack.Navigator>
);
Run Code Online (Sandbox Code Playgroud)
但在运行时不允许出现此错误:
错误:导航器只能包含“Screen”、“Group”或“React.Fragment”作为其直接子级(找到“ModalGroup”)。要在导航器中渲染此组件,请将其在 'component' 属性中传递给 'Screen'。
但这是有效的(但对我来说看起来很难看):
export const RootNavigator = () => (
<Stack.Navigator initialRouteName="Home">
<Stack.Screen name="Home" component={HomeScreen} />
{ModalGroup()}
</Stack.Navigator>
);
Run Code Online (Sandbox Code Playgroud)
那么,在单独的文件中构建/组织屏幕组以避免创建包含所有配置和导入的巨大根导航器的最佳方法是什么?
我想使用 JUnit 和 Spring 创建 2 个测试用例,它们需要相同的类路径资源batch-configuration.properties,但该文件的内容根据测试而有所不同。
实际上在我的 Maven 项目中,我创建了这些文件树:
但是我如何根据我的测试用例定义我的根类路径(文件是在ExtractionBatchConfiguration
using中加载的classpath:batch-configuration.properties
)
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { ExtractionBatchConfiguration.class }, loader = AnnotationConfigContextLoader.class)
@PropertySource("classpath:test1/batch-configuration.properties") // does not override ExtractionBatchConfiguration declaration
public class ExtractBatchTestCase {
private static ConfigurableApplicationContext context;
private JobLauncherTestUtils jobLauncherTestUtils;
@BeforeClass
public static void beforeClass() {
context = SpringApplication.run(ExtractionBatchConfiguration.class);
}
@Before
public void setup() throws Exception {
jobLauncherTestUtils = new JobLauncherTestUtils();
jobLauncherTestUtils.setJobLauncher(context.getBean(JobLauncher.class));
jobLauncherTestUtils.setJobRepository(context.getBean(JobRepository.class));
}
@Test
public void testGeneratedFiles() throws Exception {
jobLauncherTestUtils.setJob(context.getBean("extractJob1", Job.class));
JobExecution …
Run Code Online (Sandbox Code Playgroud) 我刚刚使用 eslint-plugin-prettier 将我的应用程序从 prettier 1.19.1 升级到 2.5.1。但我面临着巨大的变化。我希望之前的行为符合此规则:
// prettier v1
const [
currentRouteName,
currentParams
] = getActiveRoute(currentState);
// prettier v2 - note line break after "="
const [currentRouteName, currentParams] =
getActiveRoute(currentState);
Run Code Online (Sandbox Code Playgroud)
是否可以覆盖此更改换行符的规则(似乎与 printWith 有关,但此设置在我的 .prettierrc 中没有更改)?
我正在尝试使用Spring Ldap为嵌入式ldap进行单元测试.但是我需要为自定义objectClasses/attributes定义使用自定义模式.如何使用Spring Ldap测试(LdapTestUtils?)进行配置?
实际上,如果我运行测试,它失败说我的自定义objectClass"myOb"未在模式中定义,并带有以下消息:
org.springframework.ldap.UncategorizedLdapException: Failed to populate LDIF; nested exception is javax.naming.directory.NoSuchAttributeException: [LDAP: error code 16 - NO_SUCH_ATTRIBUTE: failed for Add Request :
...
: OID for name 'myOb' was not found within the OID registry]; remaining name 'cn=123456, ou=MyUser, o=company.com'
Run Code Online (Sandbox Code Playgroud)
如果我objectClass: myOb
从ldif 发表评论,则测试失败并显示空值(未读取属性).
这是我的测试类:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = LdapConfiguration.class, loader = AnnotationConfigContextLoader.class)
public class LdapTest {
// Ldap port
private static final int LDAP_PORT = 18880;
// Base DN for test data
private static final …
Run Code Online (Sandbox Code Playgroud) 我读了一个平面文件(例如.csv文件,每个用户1行,Ex:UserId; Data1; Date2).
但是如何在阅读器中处理重复的用户项目(哪里没有previus readed用户列表......)
stepBuilderFactory.get("createUserStep1")
.<User, User>chunk(1000)
.reader(flatFileItemReader) // FlatFileItemReader
.writer(itemWriter) // For example JDBC Writer
.build();
Run Code Online (Sandbox Code Playgroud) 我在我的公司Google 帐户中收到了 Firebase 应用分发邀请。但是,当我通过单击电子邮件中的“开始设置”接受邀请时,我错误地使用我的 Android 手机中的个人谷歌帐户接受了邀请。我试图用我的公司谷歌帐户重新接受邀请,但App Tester应用程序说:
邀请已被接受
我试图撤销我在 Firebase 控制台中的访问权限,并再次添加我的公司google 帐户。但它保持邀请状态已“接受”。有没有办法从谷歌帐户中删除应用程序,以便能够再次接受另一个帐户的邀请?谢谢。
android google-account firebase google-fabric firebase-app-distribution
有一个简单的正则表达式模式可以检测文本中的 IBAN(包括特定国家/地区格式?)
实际上我正在用这个正则表达式找到 IBAN :
[a-zA-Z]{2}[0-9]{2}[0-9a-zA-Z]{10,30}
Run Code Online (Sandbox Code Playgroud)
但这与格式化的 IBAN 不匹配(正常,我没有引入空格检测):
FR76 30003 02420 002202XXXXX 77
Run Code Online (Sandbox Code Playgroud)
或者
PT50 0002 0123 1234 5678 9015 4
Run Code Online (Sandbox Code Playgroud)
你能帮助我吗 ?在哪里可以找到按国家/地区划分的所有格式化 IBAN 模式?
例子 :
“我的 IBAN 是 PT50 0002 0123 1234 5678 9015 1 用正则表达式捕获它,这也是 PT50000201231234567890151 !”
我想提取/处理“PT50 0002 0123 1234 5678 9015 1”和“PT50000201231234567890151”。
编辑: 解决方案 1 - 很长的模式:
((NO)[0-9A-Z]{2}[ ][0-9A-Z]{4}[ ][0-9A-Z]{4}[ ][0-9A-Z]{3}|(NO)[0-9A-Z]{13}|(BE)[0-9A-Z]{2}[ ][0-9A-Z]{4}[ ][0-9A-Z]{4}[ ][0-9A-Z]{4}|(BE)[0-9A-Z]{14}|(DK|FO|FI|GL|NL)[0-9A-Z]{2}[ ][0-9A-Z]{4}[ ][0-9A-Z]{4}[ ][0-9A-Z]{4}[ ][0-9A-Z]{2}|(DK|FO|FI|GL|NL)[0-9A-Z]{16}|(MK|SI)[0-9A-Z]{2}[ ][0-9A-Z]{4}[ ][0-9A-Z]{4}[ ][0-9A-Z]{4}[ ][0-9A-Z]{3}|(MK|SI)[0-9A-Z]{17}|(BA|EE|KZ|LT|LU|AT)[0-9A-Z]{2}[ ][0-9A-Z]{4}[ ][0-9A-Z]{4}[ ][0-9A-Z]{4}[ ][0-9A-Z]{4}|(BA|EE|KZ|LT|LU|AT)[0-9A-Z]{18}|(HR|LI|LV|CH)[0-9A-Z]{2}[ ][0-9A-Z]{4}[ ][0-9A-Z]{4}[ ][0-9A-Z]{4}[ ][0-9A-Z]{4}[ ][0-9A-Z]{1}|(HR|LI|LV|CH)[0-9A-Z]{19}|(BG|DE|IE|ME|RS|GB)[0-9A-Z]{2}[ ][0-9A-Z]{4}[ ][0-9A-Z]{4}[ ][0-9A-Z]{4}[ …
Run Code Online (Sandbox Code Playgroud) java ×4
spring ×4
spring-batch ×2
unit-testing ×2
android ×1
detection ×1
duplicates ×1
firebase ×1
iban ×1
javascript ×1
jpa ×1
ldap ×1
many-to-many ×1
prettier ×1
react-native ×1
regex ×1
spring-boot ×1
spring-ldap ×1