• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RealmModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getUsers

import org.keycloak.models.RealmModel; //导入依赖的package包/类
@Override
public List<UserModel> getUsers(RealmModel realm, int firstResult, int maxResults) {

	TypedQuery<UserEntity> query = em.createNamedQuery("getAllUsers", UserEntity.class);
	if (firstResult != -1) {
		query.setFirstResult(firstResult);
	}
	if (maxResults != -1) {
		query.setMaxResults(maxResults);
	}
	List<UserEntity> results = query.getResultList();
	List<UserModel> users = new LinkedList<>();
	for (UserEntity entity : results)
		users.add(new UserAdapter(session, realm, model, entity));
	return users;
}
 
开发者ID:allianzit,项目名称:ait-platform,代码行数:17,代码来源:AitEjbUserStorageProvider.java


示例2: searchForUser

import org.keycloak.models.RealmModel; //导入依赖的package包/类
@Override
public List<UserModel> searchForUser(String search, RealmModel realm, int firstResult, int maxResults) {
	TypedQuery<UserEntity> query = em.createNamedQuery("searchForUser", UserEntity.class);
	query.setParameter("search", "%" + search.toLowerCase() + "%");
	if (firstResult != -1) {
		query.setFirstResult(firstResult);
	}
	if (maxResults != -1) {
		query.setMaxResults(maxResults);
	}
	List<UserEntity> results = query.getResultList();
	List<UserModel> users = new LinkedList<>();
	for (UserEntity entity : results)
		users.add(new UserAdapter(session, realm, model, entity));
	return users;
}
 
开发者ID:allianzit,项目名称:ait-platform,代码行数:17,代码来源:AitEjbUserStorageProvider.java


示例3: setup

import org.keycloak.models.RealmModel; //导入依赖的package包/类
@Before
public void setup() {
    keycloakSession = mock(KeycloakSession.class);
    KeycloakTransactionManager txnManager = mock(KeycloakTransactionManager.class);
    when(keycloakSession.getTransactionManager()).thenReturn(txnManager);
    RealmProvider realms = mock(RealmProvider.class);
    when(keycloakSession.realms()).thenReturn(realms);
    RealmModel realm = mock(RealmModel.class);
    when(realms.getRealmByName(eq("realm"))).thenReturn(realm);
    UserProvider userProvider = mock(UserProvider.class);
    UserModel user = mock(UserModel.class);
    when(userProvider.getUserByUsername(eq("user"), eq(realm))).thenReturn(user);
    when(keycloakSession.userStorageManager()).thenReturn(userProvider);
    UserCredentialManager userCredentialManager = mock(UserCredentialManager.class);
    when(keycloakSession.userCredentialManager()).thenReturn(userCredentialManager);
    when(userCredentialManager.isValid(eq(realm), eq(user), argThat(new PasswordCredentialMatcher("password")))).thenReturn(true);

    config = mock(Config.Scope.class);
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:20,代码来源:PlainSaslServerMechanismTest.java


示例4: validCredentials

import org.keycloak.models.RealmModel; //导入依赖的package包/类
@Override
public boolean validCredentials(RealmModel realm, UserModel user, List<UserCredentialModel> input) {

    LOG.infof("Validating credentials for %s", user.getUsername());

    if (input == null || input.isEmpty()) {
        throw new IllegalArgumentException("UserCredentialModel list is empty or null!");
    }

    UserCredentialModel credentials = input.get(0);
    Response response = federatedUserService.validateLogin(user.getUsername(), new UserCredentialsDto(credentials.getValue()));
    boolean valid = HttpStatus.SC_OK == response.getStatus();

    if (valid) {
        user.updateCredential(credentials);
        user.setFederationLink(null);
    }

    return valid;
}
 
开发者ID:Smartling,项目名称:keycloak-user-migration-provider,代码行数:21,代码来源:RemoteUserFederationProvider.java


示例5: generateInstallation

import org.keycloak.models.RealmModel; //导入依赖的package包/类
@Override
public Response generateInstallation(KeycloakSession session, RealmModel realm, ClientModel client, URI baseUri) {
    UriBuilder bindingUrlBuilder = UriBuilder.fromUri(baseUri);
    String bindingUrl = RealmsResource.protocolUrl(bindingUrlBuilder)
            .build(realm.getName(), CASLoginProtocol.LOGIN_PROTOCOL).toString();
    String description = "CAS Server URL: " + bindingUrl + "\n" +
            "CAS Protocol: CAS 2.0/3.0 (SAML 1.1 is not supported)\n" +
            "Use CAS REST API: false (unsupported)";
    return Response.ok(description, MediaType.TEXT_PLAIN_TYPE).build();
}
 
开发者ID:Doccrazy,项目名称:keycloak-protocol-cas,代码行数:11,代码来源:KeycloakCASClientInstallation.java


示例6: getUserByUsername

import org.keycloak.models.RealmModel; //导入依赖的package包/类
@Override
public UserModel getUserByUsername(String username, RealmModel realm) {
    UserModel adapter = loadedUsers.get(username);
    if (adapter == null) {
        String password = properties.getProperty(username);
        if (password != null) {
            adapter = createAdapter(realm, username);
            loadedUsers.put(username, adapter);
        }
    }
    return adapter;
}
 
开发者ID:nmajorov,项目名称:keycloak_training,代码行数:13,代码来源:PropertyFileUserStorageProvider.java


示例7: createAdapter

import org.keycloak.models.RealmModel; //导入依赖的package包/类
protected UserModel createAdapter(RealmModel realm, String username) {
    return new AbstractUserAdapter(session, realm, model) {
        @Override
        public String getUsername() {
            return username;
        }
    };
}
 
开发者ID:nmajorov,项目名称:keycloak_training,代码行数:9,代码来源:PropertyFileUserStorageProvider.java


示例8: isValid

import org.keycloak.models.RealmModel; //导入依赖的package包/类
@Override
public boolean isValid(RealmModel realm, UserModel user, CredentialInput input) {
    if (!supportsCredentialType(input.getType()) || !(input instanceof UserCredentialModel)) return false;

    UserCredentialModel cred = (UserCredentialModel)input;
    String password = properties.getProperty(user.getUsername());
    if (password == null) return false;
    return password.equals(cred.getValue());
}
 
开发者ID:nmajorov,项目名称:keycloak_training,代码行数:10,代码来源:PropertyFileUserStorageProvider.java


示例9: getUsers

import org.keycloak.models.RealmModel; //导入依赖的package包/类
@Override
public List<UserModel> getUsers(RealmModel realm, int firstResult, int maxResults) {
    List<UserModel> users = new LinkedList<>();
    int i = 0;
    for (Object obj : properties.keySet()) {
        if (i++ < firstResult) continue;
        String username = (String)obj;
        UserModel user = getUserByUsername(username, realm);
        users.add(user);
        if (users.size() >= maxResults) break;
    }
    return users;
}
 
开发者ID:nmajorov,项目名称:keycloak_training,代码行数:14,代码来源:PropertyFileUserStorageProvider.java


示例10: searchForUser

import org.keycloak.models.RealmModel; //导入依赖的package包/类
@Override
public List<UserModel> searchForUser(String search, RealmModel realm, int firstResult, int maxResults) {
    List<UserModel> users = new LinkedList<>();
    int i = 0;
    for (Object obj : properties.keySet()) {
        String username = (String)obj;
        if (!username.contains(search)) continue;
        if (i++ < firstResult) continue;
        UserModel user = getUserByUsername(username, realm);
        users.add(user);
        if (users.size() >= maxResults) break;
    }
    return users;
}
 
开发者ID:nmajorov,项目名称:keycloak_training,代码行数:15,代码来源:PropertyFileUserStorageProvider.java


示例11: addUser

import org.keycloak.models.RealmModel; //导入依赖的package包/类
@Override
public UserModel addUser(RealmModel realm, String username) {
    synchronized (properties) {
        properties.setProperty(username, UNSET_PASSWORD);
        save();
    }
    return createAdapter(realm, username);
}
 
开发者ID:nmajorov,项目名称:keycloak_training,代码行数:9,代码来源:PropertyFileUserStorageProvider.java


示例12: removeUser

import org.keycloak.models.RealmModel; //导入依赖的package包/类
@Override
public boolean removeUser(RealmModel realm, UserModel user) {
    synchronized (properties) {
        if (properties.remove(user.getUsername()) == null) return false;
        save();
        return true;
    }
}
 
开发者ID:nmajorov,项目名称:keycloak_training,代码行数:9,代码来源:PropertyFileUserStorageProvider.java


示例13: isValid

import org.keycloak.models.RealmModel; //导入依赖的package包/类
@Override
public boolean isValid(RealmModel realm, UserModel user, CredentialInput input) {
    if (!supportsCredentialType(input.getType()) || !(input instanceof UserCredentialModel)) return false;

    UserCredentialModel cred = (UserCredentialModel)input;
    String password = properties.getProperty(user.getUsername());
    if (password == null || UNSET_PASSWORD.equals(password)) return false;
    return password.equals(cred.getValue());
}
 
开发者ID:nmajorov,项目名称:keycloak_training,代码行数:10,代码来源:PropertyFileUserStorageProvider.java


示例14: updateCredential

import org.keycloak.models.RealmModel; //导入依赖的package包/类
@Override
public boolean updateCredential(RealmModel realm, UserModel user, CredentialInput input) {
    if (!(input instanceof UserCredentialModel)) return false;
    if (!input.getType().equals(CredentialModel.PASSWORD)) return false;
    UserCredentialModel cred = (UserCredentialModel)input;
    synchronized (properties) {
        properties.setProperty(user.getUsername(), cred.getValue());
        save();
    }
    return true;
}
 
开发者ID:nmajorov,项目名称:keycloak_training,代码行数:12,代码来源:PropertyFileUserStorageProvider.java


示例15: disableCredentialType

import org.keycloak.models.RealmModel; //导入依赖的package包/类
@Override
public void disableCredentialType(RealmModel realm, UserModel user, String credentialType) {
    if (!credentialType.equals(CredentialModel.PASSWORD)) return;
    synchronized (properties) {
        properties.setProperty(user.getUsername(), UNSET_PASSWORD);
        save();
    }

}
 
开发者ID:nmajorov,项目名称:keycloak_training,代码行数:10,代码来源:PropertyFileUserStorageProvider.java


示例16: validateConfiguration

import org.keycloak.models.RealmModel; //导入依赖的package包/类
@Override
public void validateConfiguration(KeycloakSession session, RealmModel realm, ComponentModel config) throws ComponentValidationException {
    String fp = config.getConfig().getFirst("path");
    if (fp == null) throw new ComponentValidationException("user property file does not exist");
    fp = EnvUtil.replace(fp);
    File file = new File(fp);
    if (!file.exists()) {
        throw new ComponentValidationException("user property file does not exist");
    }
}
 
开发者ID:nmajorov,项目名称:keycloak_training,代码行数:11,代码来源:PropertyFileUserStorageProviderFactory.java


示例17: getUserById

import org.keycloak.models.RealmModel; //导入依赖的package包/类
@Override
public UserModel getUserById(String id, RealmModel realm) {
    logger.info("getUserById: " + id);
    String persistenceId = StorageId.externalId(id);
    UserEntity entity = em.find(UserEntity.class, persistenceId);
    if (entity == null) {
        logger.info("could not find user by id: " + id);
        return null;
    }
    return new UserAdapter(session, realm, model, entity);
}
 
开发者ID:nmajorov,项目名称:keycloak_training,代码行数:12,代码来源:EjbExampleUserStorageProvider.java


示例18: getUserByUsername

import org.keycloak.models.RealmModel; //导入依赖的package包/类
@Override
public UserModel getUserByUsername(String username, RealmModel realm) {
    logger.info("getUserByUsername: " + username);
    TypedQuery<UserEntity> query = em.createNamedQuery("getUserByUsername", UserEntity.class);
    query.setParameter("username", username);
    List<UserEntity> result = query.getResultList();
    if (result.isEmpty()) {
        logger.info("could not find username: " + username);
        return null;
    }

    return new UserAdapter(session, realm, model, result.get(0));
}
 
开发者ID:nmajorov,项目名称:keycloak_training,代码行数:14,代码来源:EjbExampleUserStorageProvider.java


示例19: getUserByEmail

import org.keycloak.models.RealmModel; //导入依赖的package包/类
@Override
public UserModel getUserByEmail(String email, RealmModel realm) {
    TypedQuery<UserEntity> query = em.createNamedQuery("getUserByEmail", UserEntity.class);
    query.setParameter("email", email);
    List<UserEntity> result = query.getResultList();
    if (result.isEmpty()) return null;
    return new UserAdapter(session, realm, model, result.get(0));
}
 
开发者ID:nmajorov,项目名称:keycloak_training,代码行数:9,代码来源:EjbExampleUserStorageProvider.java


示例20: addUser

import org.keycloak.models.RealmModel; //导入依赖的package包/类
@Override
public UserModel addUser(RealmModel realm, String username) {
    UserEntity entity = new UserEntity();
    entity.setId(UUID.randomUUID().toString());
    entity.setUsername(username);
    em.persist(entity);
    logger.info("added user: " + username);
    return new UserAdapter(session, realm, model, entity);
}
 
开发者ID:nmajorov,项目名称:keycloak_training,代码行数:10,代码来源:EjbExampleUserStorageProvider.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BubbleChartRenderer类代码示例发布时间:2022-05-23
下一篇:
Java SimpleFilterProvider类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap