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

Java KeycloakSession类代码示例

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

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



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

示例1: create

import org.keycloak.models.KeycloakSession; //导入依赖的package包/类
@Override
public PropertyFileUserStorageProvider create(KeycloakSession session, ComponentModel model) {
    String path = model.getConfig().getFirst("path");
    path = EnvUtil.replace(path);

    Properties props = new Properties();
    try {
        InputStream is = new FileInputStream(path);
        props.load(is);
        is.close();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    return new PropertyFileUserStorageProvider(session, model, props);
}
 
开发者ID:nmajorov,项目名称:keycloak_training,代码行数:17,代码来源:PropertyFileUserStorageProviderFactory.java


示例2: tryCreateMasterRealmAdminUser

import org.keycloak.models.KeycloakSession; //导入依赖的package包/类
private void tryCreateMasterRealmAdminUser() {

    KeycloakSession session = getSessionFactory().create();

    ApplianceBootstrap applianceBootstrap = new ApplianceBootstrap(session);

    AdminUser admin = keycloakServerProperties.getAdminUser();

    try {
      session.getTransactionManager().begin();
      applianceBootstrap.createMasterRealmUser(admin.getUsername(), admin.getPassword());
      session.getTransactionManager().commit();
    } catch (Exception ex) {
      System.out.println("Couldn't create keycloak master admin user: " + ex.getMessage());
      session.getTransactionManager().rollback();
    }

    session.close();
  }
 
开发者ID:thomasdarimont,项目名称:spring-boot-keycloak-server-example,代码行数:20,代码来源:EmbeddedKeycloakApplication.java


示例3: setup

import org.keycloak.models.KeycloakSession; //导入依赖的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: postWithRedirect

import org.keycloak.models.KeycloakSession; //导入依赖的package包/类
public static void postWithRedirect(KeycloakSession session, String url, HttpEntity postBody) throws IOException {
    HttpClient httpClient = session.getProvider(HttpClientProvider.class).getHttpClient();
    for (int i = 0; i < 2; i++) { // follow redirects once
        HttpPost post = new HttpPost(url);
        post.setEntity(postBody);
        HttpResponse response = httpClient.execute(post);
        try {
            int status = response.getStatusLine().getStatusCode();
            if (status == 302 && !url.endsWith("/")) {
                String redirect = response.getFirstHeader(HttpHeaders.LOCATION).getValue();
                String withSlash = url + "/";
                if (withSlash.equals(redirect)) {
                    url = withSlash;
                    continue;
                }
            }
        } finally {
            HttpEntity entity = response.getEntity();
            if (entity != null) {
                InputStream is = entity.getContent();
                if (is != null)
                    is.close();
            }

        }
        break;
    }
}
 
开发者ID:Doccrazy,项目名称:keycloak-protocol-cas,代码行数:29,代码来源:LogoutHelper.java


示例5: generateInstallation

import org.keycloak.models.KeycloakSession; //导入依赖的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: validateConfiguration

import org.keycloak.models.KeycloakSession; //导入依赖的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


示例7: create

import org.keycloak.models.KeycloakSession; //导入依赖的package包/类
@Override
public EjbExampleUserStorageProvider create(KeycloakSession session, ComponentModel model) {
    try {
        InitialContext ctx = new InitialContext();
        EjbExampleUserStorageProvider provider = (EjbExampleUserStorageProvider)ctx.lookup("java:global/user-storage-jpa-example/" + EjbExampleUserStorageProvider.class.getSimpleName());
        provider.setModel(model);
        provider.setSession(session);
        return provider;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:nmajorov,项目名称:keycloak_training,代码行数:13,代码来源:EjbExampleUserStorageProviderFactory.java


示例8: create

import org.keycloak.models.KeycloakSession; //导入依赖的package包/类
@Override
public AitEjbUserStorageProvider create(KeycloakSession session, ComponentModel model) {
    try {
        InitialContext ctx = new InitialContext();
        AitEjbUserStorageProvider provider = (AitEjbUserStorageProvider)ctx.lookup("java:global/keycloak-spi-sqlserver/" + AitEjbUserStorageProvider.class.getSimpleName());
        provider.setModel(model);
        provider.setSession(session);
        return provider;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:allianzit,项目名称:ait-platform,代码行数:13,代码来源:AitEjbUserStorageProviderFactory.java


示例9: ForwardingEventListenerProvider

import org.keycloak.models.KeycloakSession; //导入依赖的package包/类
/**
 * Creates a new {@link ForwardingEventListenerProvider}
 * 
 * @param keycloakSession
 * @param forwardedContextActions
 */
public ForwardingEventListenerProvider(KeycloakSession keycloakSession, Set<String> forwardedContextActions) {

	if (forwardedContextActions == null) {
		throw new NullPointerException("includedKeycloakContextActions must not be null!");
	}

	this.keycloakSession = keycloakSession;
	this.forwardedContextActions = forwardedContextActions;
}
 
开发者ID:jugsaar,项目名称:visit-yajug-20161023-keycloak,代码行数:16,代码来源:ForwardingEventListenerProvider.java


示例10: create

import org.keycloak.models.KeycloakSession; //导入依赖的package包/类
@Override
public EventListenerProvider create(KeycloakSession keycloakSession) {

	ForwardingEventListenerProvider provider = new ForwardingEventListenerProvider(keycloakSession,
			unmodifiableSet(includedContextActions));
	keycloakSession.enlistForClose(provider);

	return provider;
}
 
开发者ID:jugsaar,项目名称:visit-yajug-20161023-keycloak,代码行数:10,代码来源:JmsEventListenerProviderFactory.java


示例11: ScramSaslAuthenticator

import org.keycloak.models.KeycloakSession; //导入依赖的package包/类
public ScramSaslAuthenticator(final KeycloakSession keycloakSession,
                              final String hostname,
                              String digestName,
                              String hmacName,
                              Map<String, Function<CredentialModel, StoredAndServerKey>> keyRetrievalFunctions) {
    this.keycloakSession = keycloakSession;
    this.hostname = hostname;
    this.randomBytes = new byte[32];
    (new SecureRandom()).nextBytes(this.randomBytes);
    this.digestName = digestName;
    this.hmacName = hmacName;
    this.keyRetrievalFunctions = new HashMap<>(keyRetrievalFunctions);
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:14,代码来源:ScramSaslAuthenticator.java


示例12: setupDefaultRealm

import org.keycloak.models.KeycloakSession; //导入依赖的package包/类
@Override
protected void setupDefaultRealm(String contextPath) {
    super.setupDefaultRealm(contextPath);

    KeycloakSession session = getSessionFactory().create();
    session.getTransaction().begin();
    try {
        configureLiveOakConsole(session);
        session.getTransaction().commit();
    } finally {
        session.close();
    }
}
 
开发者ID:liveoak-io,项目名称:liveoak,代码行数:14,代码来源:KeycloakServerApplication.java


示例13: create

import org.keycloak.models.KeycloakSession; //导入依赖的package包/类
@Override
public final ProtocolMapper create(KeycloakSession session) {
    throw new RuntimeException("UNSUPPORTED METHOD");
}
 
开发者ID:Doccrazy,项目名称:keycloak-protocol-cas,代码行数:5,代码来源:AbstractCASProtocolMapper.java


示例14: create

import org.keycloak.models.KeycloakSession; //导入依赖的package包/类
@Override
public ClientInstallationProvider create(KeycloakSession session) {
    return this;
}
 
开发者ID:Doccrazy,项目名称:keycloak-protocol-cas,代码行数:5,代码来源:KeycloakCASClientInstallation.java


示例15: create

import org.keycloak.models.KeycloakSession; //导入依赖的package包/类
@Override
public EventListenerProvider create(KeycloakSession session) {
    return new MonitoringEventListenerProvider(eventsDirectory);
}
 
开发者ID:larscheid-schmitzhermes,项目名称:keycloak-monitoring-prometheus,代码行数:5,代码来源:MonitoringEventListenerProviderFactory.java


示例16: create

import org.keycloak.models.KeycloakSession; //导入依赖的package包/类
@Override
public HealthIndicator create(KeycloakSession session) {
  return new FilesystemHealthIndicator(config);
}
 
开发者ID:thomasdarimont,项目名称:keycloak-health-checks,代码行数:5,代码来源:FilesystemHealthIndicatorFactory.java


示例17: DatabaseHealthIndicator

import org.keycloak.models.KeycloakSession; //导入依赖的package包/类
DatabaseHealthIndicator(KeycloakSession session, Config.Scope config) {
  super("database");
  this.session = session;
  this.jndiName = config.get("jndiName", "java:jboss/datasources/KeycloakDS");
  this.healthQuery = config.get("query", "SELECT 1");
}
 
开发者ID:thomasdarimont,项目名称:keycloak-health-checks,代码行数:7,代码来源:DatabaseHealthIndicator.java


示例18: create

import org.keycloak.models.KeycloakSession; //导入依赖的package包/类
@Override
public HealthIndicator create(KeycloakSession session) {
  return new DatabaseHealthIndicator(session, config);
}
 
开发者ID:thomasdarimont,项目名称:keycloak-health-checks,代码行数:5,代码来源:DatabaseHealthIndicatorFactory.java


示例19: HealthCheckResource

import org.keycloak.models.KeycloakSession; //导入依赖的package包/类
HealthCheckResource(KeycloakSession session) {
  this.session = session;
}
 
开发者ID:thomasdarimont,项目名称:keycloak-health-checks,代码行数:4,代码来源:HealthCheckResource.java


示例20: HealthCheckResourceProvider

import org.keycloak.models.KeycloakSession; //导入依赖的package包/类
public HealthCheckResourceProvider(KeycloakSession session) {
  this.session = session;
}
 
开发者ID:thomasdarimont,项目名称:keycloak-health-checks,代码行数:4,代码来源:HealthCheckResourceProvider.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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