added support for builds against keycloak v6-v15

This commit is contained in:
2021-10-21 15:24:18 -04:00
parent 7f6eb7b7c3
commit 919c288ba9
23 changed files with 1271 additions and 26 deletions

11
.gitignore vendored
View File

@@ -1 +1,12 @@
# Maven
target
pom.xml.versionsBackup
# Eclipse
.project
.classpath
.settings
# VS Code
.factorypath
.vscode

346
pom.xml
View File

@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.jpicht.keycloak.policy</groupId>
<artifactId>keycloak-group-password-policy</artifactId>
<version>0.1-SNAPSHOT</version>
<version>0.2-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
@@ -13,8 +13,8 @@
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<keycloak.version>6.0.1</keycloak.version>
<auto-service.version>1.0-rc5</auto-service.version>
<keycloak.version>${keycloak.majorVersion}.0.0</keycloak.version>
<auto-service.version>1.0</auto-service.version>
</properties>
<dependencies>
@@ -45,23 +45,6 @@
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.keycloak.testsuite</groupId>
<artifactId>integration-arquillian-tests-base</artifactId>
<version>6.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-test-helper</artifactId>
<version>6.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-services</artifactId>
<version>6.0.1</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
@@ -71,7 +54,330 @@
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.2.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<classifier>keycloak-v${keycloak.majorVersion}</classifier>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>keycloak-v6</id>
<properties>
<keycloak.majorVersion>6</keycloak.majorVersion>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source-keycloak-v6</id>
<goals><goal>add-source</goal></goals>
<configuration>
<sources>
<source>${basedir}/src/keycloak-v6-common/java</source>
<source>${basedir}/src/keycloak-v6-v11/java</source>
<source>${basedir}/src/keycloak-v6/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>keycloak-v7</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<keycloak.majorVersion>7</keycloak.majorVersion>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source-keycloak-v7</id>
<goals><goal>add-source</goal></goals>
<configuration>
<sources>
<source>${basedir}/src/keycloak-v6-common/java</source>
<source>${basedir}/src/keycloak-v6-v11/java</source>
<source>${basedir}/src/keycloak-v6/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>keycloak-v8</id>
<properties>
<keycloak.majorVersion>8</keycloak.majorVersion>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source-keycloak-v8</id>
<goals><goal>add-source</goal></goals>
<configuration>
<sources>
<source>${basedir}/src/keycloak-v6-common/java</source>
<source>${basedir}/src/keycloak-v8-common/java</source>
<source>${basedir}/src/keycloak-v6-v11/java</source>
<source>${basedir}/src/keycloak-v8/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>keycloak-v9</id>
<properties>
<keycloak.majorVersion>9</keycloak.majorVersion>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source-keycloak-v9</id>
<goals><goal>add-source</goal></goals>
<configuration>
<sources>
<source>${basedir}/src/keycloak-v6-common/java</source>
<source>${basedir}/src/keycloak-v8-common/java</source>
<source>${basedir}/src/keycloak-v9-common/java</source>
<source>${basedir}/src/keycloak-v6-v11/java</source>
<source>${basedir}/src/keycloak-v9/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>keycloak-v10</id>
<properties>
<keycloak.majorVersion>10</keycloak.majorVersion>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source-keycloak-v10</id>
<goals><goal>add-source</goal></goals>
<configuration>
<sources>
<source>${basedir}/src/keycloak-v6-common/java</source>
<source>${basedir}/src/keycloak-v8-common/java</source>
<source>${basedir}/src/keycloak-v9-common/java</source>
<source>${basedir}/src/keycloak-v10-common/java</source>
<source>${basedir}/src/keycloak-v6-v11/java</source>
<source>${basedir}/src/keycloak-v10/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>keycloak-v11</id>
<properties>
<keycloak.majorVersion>11</keycloak.majorVersion>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source-keycloak-v11</id>
<goals><goal>add-source</goal></goals>
<configuration>
<sources>
<source>${basedir}/src/keycloak-v6-common/java</source>
<source>${basedir}/src/keycloak-v8-common/java</source>
<source>${basedir}/src/keycloak-v9-common/java</source>
<source>${basedir}/src/keycloak-v10-common/java</source>
<source>${basedir}/src/keycloak-v11-common/java</source>
<source>${basedir}/src/keycloak-v6-v11/java</source>
<source>${basedir}/src/keycloak-v11/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>keycloak-v12</id>
<properties>
<keycloak.majorVersion>12</keycloak.majorVersion>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source-keycloak-v12</id>
<goals><goal>add-source</goal></goals>
<configuration>
<sources>
<source>${basedir}/src/keycloak-v6-common/java</source>
<source>${basedir}/src/keycloak-v8-common/java</source>
<source>${basedir}/src/keycloak-v9-common/java</source>
<source>${basedir}/src/keycloak-v10-common/java</source>
<source>${basedir}/src/keycloak-v11-common/java</source>
<source>${basedir}/src/keycloak-v12-common/java</source>
<source>${basedir}/src/keycloak-v12/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>keycloak-v13</id>
<properties>
<keycloak.majorVersion>13</keycloak.majorVersion>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source-keycloak-v13</id>
<goals><goal>add-source</goal></goals>
<configuration>
<sources>
<source>${basedir}/src/keycloak-v6-common/java</source>
<source>${basedir}/src/keycloak-v8-common/java</source>
<source>${basedir}/src/keycloak-v9-common/java</source>
<source>${basedir}/src/keycloak-v10-common/java</source>
<source>${basedir}/src/keycloak-v11-common/java</source>
<source>${basedir}/src/keycloak-v12-common/java</source>
<source>${basedir}/src/keycloak-v13-common/java</source>
<source>${basedir}/src/keycloak-v13/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>keycloak-v14</id>
<properties>
<keycloak.majorVersion>14</keycloak.majorVersion>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source-keycloak-v14</id>
<goals><goal>add-source</goal></goals>
<configuration>
<sources>
<source>${basedir}/src/keycloak-v6-common/java</source>
<source>${basedir}/src/keycloak-v8-common/java</source>
<source>${basedir}/src/keycloak-v9-common/java</source>
<source>${basedir}/src/keycloak-v10-common/java</source>
<source>${basedir}/src/keycloak-v11-common/java</source>
<source>${basedir}/src/keycloak-v12-common/java</source>
<source>${basedir}/src/keycloak-v13-common/java</source>
<source>${basedir}/src/keycloak-v14-common/java</source>
<source>${basedir}/src/keycloak-v14/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>keycloak-v15</id>
<properties>
<keycloak.majorVersion>15</keycloak.majorVersion>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source-keycloak-v15</id>
<goals><goal>add-source</goal></goals>
<configuration>
<sources>
<source>${basedir}/src/keycloak-v6-common/java</source>
<source>${basedir}/src/keycloak-v8-common/java</source>
<source>${basedir}/src/keycloak-v9-common/java</source>
<source>${basedir}/src/keycloak-v10-common/java</source>
<source>${basedir}/src/keycloak-v11-common/java</source>
<source>${basedir}/src/keycloak-v12-common/java</source>
<source>${basedir}/src/keycloak-v13-common/java</source>
<source>${basedir}/src/keycloak-v14-common/java</source>
<source>${basedir}/src/keycloak-v15-common/java</source>
<source>${basedir}/src/keycloak-v15/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@@ -0,0 +1,41 @@
/*
* Copyright 2021 Brian Long (brian@inteligr8.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jpicht.keycloak.policy;
public abstract class FakeRealmV10 extends FakeRealmV9 {
@Override
public int getClientSessionIdleTimeout() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setClientSessionIdleTimeout(int seconds) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getClientSessionMaxLifespan() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setClientSessionMaxLifespan(int seconds) {
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright 2019 Julian Picht
* Copyright 2021 Brian Long (brian@inteligr8.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jpicht.keycloak.policy;
import org.keycloak.models.PasswordPolicy;
public class FakeRealm extends FakeRealmV10 {
private PasswordPolicy passwordPolicy;
@Override
public PasswordPolicy getPasswordPolicy() {
return passwordPolicy;
}
@Override
public void setPasswordPolicy(PasswordPolicy policy) {
passwordPolicy = policy;
}
}

View File

@@ -0,0 +1,41 @@
/*
* Copyright 2021 Brian Long (brian@inteligr8.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jpicht.keycloak.policy;
public abstract class FakeRealmV11 extends FakeRealmV10 {
@Override
public int getClientOfflineSessionIdleTimeout() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setClientOfflineSessionIdleTimeout(int seconds) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getClientOfflineSessionMaxLifespan() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setClientOfflineSessionMaxLifespan(int seconds) {
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright 2019 Julian Picht
* Copyright 2021 Brian Long (brian@inteligr8.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jpicht.keycloak.policy;
import org.keycloak.models.PasswordPolicy;
public class FakeRealm extends FakeRealmV11 {
private PasswordPolicy passwordPolicy;
@Override
public PasswordPolicy getPasswordPolicy() {
return passwordPolicy;
}
@Override
public void setPasswordPolicy(PasswordPolicy policy) {
passwordPolicy = policy;
}
}

View File

@@ -0,0 +1,202 @@
/*
* Copyright 2021 Brian Long (brian@inteligr8.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jpicht.keycloak.policy;
import java.util.Map;
import java.util.stream.Stream;
import org.keycloak.component.ComponentModel;
import org.keycloak.models.AuthenticationExecutionModel;
import org.keycloak.models.AuthenticationFlowModel;
import org.keycloak.models.AuthenticatorConfigModel;
import org.keycloak.models.ClientModel;
import org.keycloak.models.ClientScopeModel;
import org.keycloak.models.GroupModel;
import org.keycloak.models.IdentityProviderMapperModel;
import org.keycloak.models.IdentityProviderModel;
import org.keycloak.models.RequiredActionProviderModel;
import org.keycloak.models.RequiredCredentialModel;
import org.keycloak.models.RoleModel;
public abstract class FakeRealmV12 extends FakeRealmV11 {
@Override
public Stream<RequiredCredentialModel> getRequiredCredentialsStream() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<GroupModel> getDefaultGroupsStream() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<ClientModel> getClientsStream() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<ClientModel> getClientsStream(Integer firstResult, Integer maxResults) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<ClientModel> getAlwaysDisplayInConsoleClientsStream() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<ClientModel> searchClientByClientIdStream(String clientId, Integer firstResult, Integer maxResults) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<AuthenticationFlowModel> getAuthenticationFlowsStream() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<AuthenticationExecutionModel> getAuthenticationExecutionsStream(String flowId) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<AuthenticatorConfigModel> getAuthenticatorConfigsStream() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<RequiredActionProviderModel> getRequiredActionProvidersStream() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<IdentityProviderModel> getIdentityProvidersStream() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<IdentityProviderMapperModel> getIdentityProviderMappersStream() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<IdentityProviderMapperModel> getIdentityProviderMappersByAliasStream(String brokerAlias) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<ComponentModel> getComponentsStream(String parentId, String providerType) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<ComponentModel> getComponentsStream(String parentId) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<ComponentModel> getComponentsStream() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<String> getEventsListenersStream() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<String> getEnabledEventTypesStream() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<String> getSupportedLocalesStream() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<GroupModel> getGroupsStream() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<GroupModel> getTopLevelGroupsStream() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<GroupModel> getTopLevelGroupsStream(Integer first, Integer max) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<GroupModel> searchForGroupByNameStream(String search, Integer first, Integer max) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<ClientScopeModel> getClientScopesStream() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void patchRealmLocalizationTexts(String locale, Map<String, String> localizationTexts) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean removeRealmLocalizationTexts(String locale) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Map<String, Map<String, String>> getRealmLocalizationTexts() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Map<String, String> getRealmLocalizationTextsByLocale(String locale) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<ClientScopeModel> getDefaultClientScopesStream(boolean defaultScope) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<RoleModel> getRolesStream() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<RoleModel> getRolesStream(Integer firstResult, Integer maxResults) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<RoleModel> searchForRolesStream(String search, Integer first, Integer max) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<String> getDefaultRolesStream() {
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@@ -0,0 +1,75 @@
/*
* Copyright 2019 Julian Picht
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jpicht.keycloak.policy;
import java.util.LinkedList;
import java.util.function.Consumer;
import org.jboss.logging.Logger;
import org.keycloak.models.GroupModel;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.RealmModel;
import org.keycloak.models.UserModel;
import org.keycloak.policy.PasswordPolicyConfigException;
public class GroupPasswordPolicyProvider extends PolicyProviderMultiplexer {
private static final Logger logger = Logger.getLogger(GroupPasswordPolicyProvider.class);
public GroupPasswordPolicyProvider(KeycloakSession session) {
super(session);
}
@Override
protected LinkedList<String> findPolicies(RealmModel realm, UserModel user) {
// First get the name of the attribute
String groupAttribute = realm.getPasswordPolicy().getPolicyConfig(GroupPasswordPolicyProviderFactory.ID);
logger.debugf("groupAttribute %s", groupAttribute);
logger.debugf("user %s", user.getUsername());
LinkedList<String> policyDefinitions = new LinkedList<>();
// Iterate groups and collect policy strings
user.getGroupsStream().forEach(new Consumer<GroupModel>() {
@Override
public void accept(GroupModel group) {
logger.debugf("group %s", group.getName());
group.getAttributeStream(groupAttribute).forEach(new Consumer<String>() {
@Override
public void accept(String policyString) {
logger.infof("adding group password policy: %s", policyString);
policyDefinitions.add(policyString);
}
});
}
});
return policyDefinitions;
}
@Override
public Object parseConfig(String value) {
if (value == null || value.isEmpty()) {
throw new PasswordPolicyConfigException("Attribute name cannot be blank");
}
return value;
}
@Override
public void close() {
}
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright 2019 Julian Picht
* Copyright 2021 Brian Long (brian@inteligr8.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jpicht.keycloak.policy;
import org.keycloak.models.PasswordPolicy;
public class FakeRealm extends FakeRealmV12 {
private PasswordPolicy passwordPolicy;
@Override
public PasswordPolicy getPasswordPolicy() {
return passwordPolicy;
}
@Override
public void setPasswordPolicy(PasswordPolicy policy) {
passwordPolicy = policy;
}
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright 2021 Brian Long (brian@inteligr8.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jpicht.keycloak.policy;
import java.util.stream.Stream;
import org.keycloak.models.CibaConfig;
import org.keycloak.models.ClientInitialAccessModel;
import org.keycloak.models.OAuth2DeviceConfig;
import org.keycloak.models.RoleModel;
public abstract class FakeRealmV13 extends FakeRealmV12 {
@Override
public OAuth2DeviceConfig getOAuth2DeviceConfig() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public CibaConfig getCibaPolicy() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public RoleModel getDefaultRole() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setDefaultRole(RoleModel role) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public ClientInitialAccessModel createClientInitialAccessModel(int expiration, int count) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public ClientInitialAccessModel getClientInitialAccessModel(String id) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void removeClientInitialAccessModel(String id) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<ClientInitialAccessModel> getClientInitialAccesses() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void decreaseRemainingCount(ClientInitialAccessModel clientInitialAccess) {
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright 2019 Julian Picht
* Copyright 2021 Brian Long (brian@inteligr8.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jpicht.keycloak.policy;
import org.keycloak.models.PasswordPolicy;
public class FakeRealm extends FakeRealmV13 {
private PasswordPolicy passwordPolicy;
@Override
public PasswordPolicy getPasswordPolicy() {
return passwordPolicy;
}
@Override
public void setPasswordPolicy(PasswordPolicy policy) {
passwordPolicy = policy;
}
}

View File

@@ -0,0 +1,31 @@
/*
* Copyright 2021 Brian Long (brian@inteligr8.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jpicht.keycloak.policy;
import java.util.Map;
import java.util.stream.Stream;
import org.keycloak.models.ClientModel;
public abstract class FakeRealmV14 extends FakeRealmV13 {
@Override
public Stream<ClientModel> searchClientByAttributes(Map<String, String> attributes, Integer firstResult, Integer maxResults) {
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright 2019 Julian Picht
* Copyright 2021 Brian Long (brian@inteligr8.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jpicht.keycloak.policy;
import org.keycloak.models.PasswordPolicy;
public class FakeRealm extends FakeRealmV14 {
private PasswordPolicy passwordPolicy;
@Override
public PasswordPolicy getPasswordPolicy() {
return passwordPolicy;
}
@Override
public void setPasswordPolicy(PasswordPolicy policy) {
passwordPolicy = policy;
}
}

View File

@@ -0,0 +1,28 @@
/*
* Copyright 2021 Brian Long (brian@inteligr8.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jpicht.keycloak.policy;
import org.keycloak.models.ParConfig;
public class FakeRealmV15 extends FakeRealmV14 {
@Override
public ParConfig getParPolicy() {
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright 2019 Julian Picht
* Copyright 2021 Brian Long (brian@inteligr8.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jpicht.keycloak.policy;
import org.keycloak.models.PasswordPolicy;
public class FakeRealm extends FakeRealmV15 {
private PasswordPolicy passwordPolicy;
@Override
public PasswordPolicy getPasswordPolicy() {
return passwordPolicy;
}
@Override
public void setPasswordPolicy(PasswordPolicy policy) {
passwordPolicy = policy;
}
}

View File

@@ -1,5 +1,6 @@
/*
* Copyright 2019 Julian Picht
* Copyright 2021 Brian Long (brian@inteligr8.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,7 +37,7 @@ import org.keycloak.models.RequiredActionProviderModel;
import org.keycloak.models.RequiredCredentialModel;
import org.keycloak.models.RoleModel;
public class FakeRealm implements RealmModel {
public abstract class FakeRealmV6 implements RealmModel {
@Override
public String getId() {
@@ -508,15 +509,14 @@ public class FakeRealm implements RealmModel {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
private PasswordPolicy passwordPolicy;
@Override
public PasswordPolicy getPasswordPolicy() {
return passwordPolicy;
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void setPasswordPolicy(PasswordPolicy policy) {
passwordPolicy = policy;
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override

View File

@@ -0,0 +1,36 @@
/*
* Copyright 2019 Julian Picht
* Copyright 2021 Brian Long (brian@inteligr8.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jpicht.keycloak.policy;
import org.keycloak.models.PasswordPolicy;
public class FakeRealm extends FakeRealmV6 {
private PasswordPolicy passwordPolicy;
@Override
public PasswordPolicy getPasswordPolicy() {
return passwordPolicy;
}
@Override
public void setPasswordPolicy(PasswordPolicy policy) {
passwordPolicy = policy;
}
}

View File

@@ -0,0 +1,39 @@
/*
* Copyright 2021 Brian Long (brian@inteligr8.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jpicht.keycloak.policy;
import org.keycloak.models.AuthenticationExecutionModel;
import org.keycloak.models.WebAuthnPolicy;
public abstract class FakeRealmV8 extends FakeRealmV6 {
@Override
public WebAuthnPolicy getWebAuthnPolicy() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setWebAuthnPolicy(WebAuthnPolicy policy) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public AuthenticationExecutionModel getAuthenticationExecutionByFlowId(String flowId) {
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright 2019 Julian Picht
* Copyright 2021 Brian Long (brian@inteligr8.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jpicht.keycloak.policy;
import org.keycloak.models.PasswordPolicy;
public class FakeRealm extends FakeRealmV8 {
private PasswordPolicy passwordPolicy;
@Override
public PasswordPolicy getPasswordPolicy() {
return passwordPolicy;
}
@Override
public void setPasswordPolicy(PasswordPolicy policy) {
passwordPolicy = policy;
}
}

View File

@@ -0,0 +1,74 @@
/*
* Copyright 2021 Brian Long (brian@inteligr8.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jpicht.keycloak.policy;
import java.util.List;
import java.util.Set;
import org.keycloak.models.ClientModel;
import org.keycloak.models.GroupModel;
import org.keycloak.models.RoleModel;
import org.keycloak.models.WebAuthnPolicy;
public abstract class FakeRealmV9 extends FakeRealmV8 {
@Override
public WebAuthnPolicy getWebAuthnPolicyPasswordless() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setWebAuthnPolicyPasswordless(WebAuthnPolicy policy) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<ClientModel> getClients(Integer firstResult, Integer maxResults) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Long getClientsCount() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<ClientModel> getAlwaysDisplayInConsoleClients() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<ClientModel> searchClientByClientId(String clientId, Integer firstResult, Integer maxResults) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public GroupModel createGroup(String id, String name, GroupModel toParent) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Set<RoleModel> getRoles(Integer firstResult, Integer maxResults) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Set<RoleModel> searchForRoles(String search, Integer first, Integer max) {
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright 2019 Julian Picht
* Copyright 2021 Brian Long (brian@inteligr8.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jpicht.keycloak.policy;
import org.keycloak.models.PasswordPolicy;
public class FakeRealm extends FakeRealmV9 {
private PasswordPolicy passwordPolicy;
@Override
public PasswordPolicy getPasswordPolicy() {
return passwordPolicy;
}
@Override
public void setPasswordPolicy(PasswordPolicy policy) {
passwordPolicy = policy;
}
}

View File

@@ -22,6 +22,7 @@ import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.PasswordPolicy;
import org.keycloak.models.RealmModel;
@@ -65,7 +66,6 @@ abstract public class PolicyProviderMultiplexer implements PasswordPolicyProvide
// use org.keycloak.models.PasswordPolicy to parse the policy string
protected PasswordPolicy parsePolicy(String policy) {
LinkedList<PasswordPolicyProvider> list = new LinkedList<>();
PasswordPolicy parsedPolicy = PasswordPolicy.parse(session, policy);
return parsedPolicy;
}