Skip to content

Commit

Permalink
chore: format java codes
Browse files Browse the repository at this point in the history
  • Loading branch information
junminahn committed Dec 8, 2021
1 parent 81db79d commit 641112d
Show file tree
Hide file tree
Showing 22 changed files with 1,355 additions and 948 deletions.
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ repos:
- id: prettier
name: Format js files with prettier
files: "scripts/.*$"
- repo: local
hooks:
- id: java-formatter
name: Format java codes
entry: docker/keycloak/format.sh
language: script
types: [python]
pass_filenames: false
- repo: git://github.com/antonbabenko/pre-commit-terraform
rev: v1.50.0
hooks:
Expand Down
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ terraform 1.0.7
terraform-docs 0.12.1
tflint 0.28.1
java openjdk-14.0.1
gradle 7.3.1
5 changes: 5 additions & 0 deletions docker/keycloak/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf
5 changes: 5 additions & 0 deletions docker/keycloak/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build
8 changes: 8 additions & 0 deletions docker/keycloak/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// see https://github.com/sherter/google-java-format-gradle-plugin
plugins {
id 'com.github.sherter.google-java-format' version '0.9'
}

repositories {
mavenCentral()
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package com.github.bcgov.keycloak;

import java.util.ArrayList;
import java.util.List;
import org.keycloak.Config;
import org.keycloak.authentication.Authenticator;
import org.keycloak.authentication.AuthenticatorFactory;
Expand All @@ -25,88 +27,77 @@
import org.keycloak.models.KeycloakSessionFactory;
import org.keycloak.provider.ProviderConfigProperty;

import java.util.ArrayList;
import java.util.List;

/**
* @author <a href="mailto:[email protected]">Marek Posolda</a>
*/
/** @author <a href="mailto:[email protected]">Marek Posolda</a> */
public class IdpCreateUserIfUniqueAuthenticatorFactory implements AuthenticatorFactory {

public static final String PROVIDER_ID = "bcgov-idp-create-user-if-unique";
static IdpCreateUserIfUniqueAuthenticator SINGLETON = new IdpCreateUserIfUniqueAuthenticator();


@Override
public Authenticator create(KeycloakSession session) {
return SINGLETON;
}

@Override
public void init(Config.Scope config) {

}

@Override
public void postInit(KeycloakSessionFactory factory) {

}

@Override
public void close() {

}

@Override
public String getId() {
return PROVIDER_ID;
}

@Override
public String getReferenceCategory() {
return "createUserIfUnique";
}

@Override
public boolean isConfigurable() {
return false;
}

public static final AuthenticationExecutionModel.Requirement[] REQUIREMENT_CHOICES = {
AuthenticationExecutionModel.Requirement.ALTERNATIVE,
AuthenticationExecutionModel.Requirement.REQUIRED,
AuthenticationExecutionModel.Requirement.DISABLED};

@Override
public AuthenticationExecutionModel.Requirement[] getRequirementChoices() {
return REQUIREMENT_CHOICES;
}

@Override
public String getDisplayType() {
return "Create User If Unique (BCGOV)";
}

@Override
public String getHelpText() {
return "Detect if there is existing Keycloak account with same email like identity provider. If no, create new user";
}

@Override
public boolean isUserSetupAllowed() {
return false;
}

private static final List<ProviderConfigProperty> configProperties = new ArrayList<ProviderConfigProperty>();

static {
//ProviderConfigProperty property;
//configProperties.add(property);
}


@Override
public List<ProviderConfigProperty> getConfigProperties() {
return configProperties;
}
public static final String PROVIDER_ID = "bcgov-idp-create-user-if-unique";
static IdpCreateUserIfUniqueAuthenticator SINGLETON = new IdpCreateUserIfUniqueAuthenticator();

@Override
public Authenticator create(KeycloakSession session) {
return SINGLETON;
}

@Override
public void init(Config.Scope config) {}

@Override
public void postInit(KeycloakSessionFactory factory) {}

@Override
public void close() {}

@Override
public String getId() {
return PROVIDER_ID;
}

@Override
public String getReferenceCategory() {
return "createUserIfUnique";
}

@Override
public boolean isConfigurable() {
return false;
}

public static final AuthenticationExecutionModel.Requirement[] REQUIREMENT_CHOICES = {
AuthenticationExecutionModel.Requirement.ALTERNATIVE,
AuthenticationExecutionModel.Requirement.REQUIRED,
AuthenticationExecutionModel.Requirement.DISABLED
};

@Override
public AuthenticationExecutionModel.Requirement[] getRequirementChoices() {
return REQUIREMENT_CHOICES;
}

@Override
public String getDisplayType() {
return "Create User If Unique (BCGOV)";
}

@Override
public String getHelpText() {
return "Detect if there is existing Keycloak account with same email like identity provider. If no, create new user";
}

@Override
public boolean isUserSetupAllowed() {
return false;
}

private static final List<ProviderConfigProperty> configProperties =
new ArrayList<ProviderConfigProperty>();

static {
// ProviderConfigProperty property;
// configProperties.add(property);
}

@Override
public List<ProviderConfigProperty> getConfigProperties() {
return configProperties;
}
}
Loading

0 comments on commit 641112d

Please sign in to comment.