在 Glassfish v3 中使用 jdbrealm 授权时的表设计

发布于 2024-10-08 23:15:22 字数 654 浏览 0 评论 0原文

在 Glassfish v3 中使用 jdbcrealm 时,我必须如何严格遵循有关表的建议?目前我有以下设置:

CREATE TABLE roles (
    id INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT,
    username VARCHAR(255) NOT NULL,
    rolename VARCHAR(255) NOT NULL,     
);

CREATE TABLE users (
id INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT, 
    username VARCHAR(255) PRIMARY KEY NOT NULL,
    password VARCHAR(255) NOT NULL, 
    firstname VARCHAR(255),
    lastname VARCHAR(255),  
    email VARCHAR(255),
    status VARCHAR(255),
    role_id INTEGER,
    CONSTRAINT FOREIGN KEY(role_id) REFERENCES roles(id)    
);

是否可以使用此设置而不更改任何内容来创建 jdbcrealm 或者我必须更改我的表?

提前致谢!

When using jdbcrealm in Glassfish v3 how strictly must I follow the recommendations regarding tables? Currently I have the following setup:

CREATE TABLE roles (
    id INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT,
    username VARCHAR(255) NOT NULL,
    rolename VARCHAR(255) NOT NULL,     
);

CREATE TABLE users (
id INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT, 
    username VARCHAR(255) PRIMARY KEY NOT NULL,
    password VARCHAR(255) NOT NULL, 
    firstname VARCHAR(255),
    lastname VARCHAR(255),  
    email VARCHAR(255),
    status VARCHAR(255),
    role_id INTEGER,
    CONSTRAINT FOREIGN KEY(role_id) REFERENCES roles(id)    
);

Is it possible to use this setup without changing anything to create a jdbcrealm or must I change my tables?

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

亚希 2024-10-15 23:15:23

你尝试过吗?看起来还可以。 jdbcRealm 的奇怪之处在于它需要一个非标准化的数据库,人们想要更像:

user (userid, username, passw, ...)
security_group (security_groupid, name)
user_in_group (user_in_groupid, userid, security_groupid)

Wich 更标准化。然而这个设置不起作用。但如果您像我一样并且认为这应该可行,请查看可爱的自定义 灵活 JDBC 领域。这对我有用。

Have you tried it? It seems ok. The strange thing with the jdbcRealm is that it expects an unnormalized database, one would like something more like:

user (userid, username, passw, ...)
security_group (security_groupid, name)
user_in_group (user_in_groupid, userid, security_groupid)

Wich is more normalized. However this setup does not work. But if you're like me and think this should work take a look at the lovely custom Flexible JDBC Realm. It worked for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文