Skip to content

Commit

Permalink
KEYCLOAK-15184: Use static inner class where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
testn authored and hmlnarik committed Oct 9, 2020
1 parent 6e713b5 commit 269a72d
Show file tree
Hide file tree
Showing 38 changed files with 41 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ private Map<String, PathConfig> configureAllPathsForResourceServer(ProtectedReso
return paths;
}

public class PathConfigMatcher extends PathMatcher<PathConfig> {
public static class PathConfigMatcher extends PathMatcher<PathConfig> {

private final Map<String, PathConfig> paths;
private final PathCache pathCache;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public static UserIdentity createIdentity(KeycloakPrincipal<RefreshableKeycloakS
return new DefaultUserIdentity(theSubject, principal, theRoles);
}

private class DummyLoginService implements LoginService {
private static class DummyLoginService implements LoginService {
@Override
public String getName() {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ protected void forwardToLogoutPage(Request request, HttpServletResponse response

}

private class DummyLoginService implements LoginService {
private static class DummyLoginService implements LoginService {
@Override
public String getName() {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private static void checkSystemProperty(String name, String cfgValue, String def
}


private class LDAPIdentityStoreContext {
private static class LDAPIdentityStoreContext {

private LDAPIdentityStoreContext(LDAPConfig config, LDAPIdentityStore store) {
this.config = config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private SessionAndKeyHolder getCacheKeyToInvalidate(ProviderEvent event) {
}
}

private class SessionAndKeyHolder {
private static class SessionAndKeyHolder {
private final KeycloakSession session;
private final ArrayList<String> cacheKeys;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected void rollbackImpl() {
}


private class DCEventContext {
private static class DCEventContext {
private final ClusterProvider.DCNotify dcNotify;
private final SessionClusterEvent event;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ private String logTopologyData(TopologyInfo topology, int iteration) {
}


private class RemoteCacheContext {
private static class RemoteCacheContext {

private final RemoteCache remoteCache;
private final MaxIdleTimeLoader maxIdleTimeLoader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public void removeURIType(URIType aa) {
* ref="saml:AuthnContextDecl"/>
* <element ref="saml:AuthnContextDeclRef"/> </choice> </sequence>
*/
public class AuthnContextTypeSequence implements Serializable {
public static class AuthnContextTypeSequence implements Serializable {

private AuthnContextClassRefType classRef;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private Iterable<Iterable<Key>> getKeyLocatorIterators() {
return Collections.unmodifiableCollection(res);
}

private class JointKeyIterator implements Iterable<Key> {
private static class JointKeyIterator implements Iterable<Key> {

// based on http://stackoverflow.com/a/34126154/6930869
private final Iterator<Iterable<Key>> iterablesIterator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ private String containsBaseNamespace(StartElement startElement) {
return null;
}

private class CustomHolder {
private static class CustomHolder {
public Document doc;

public boolean encounteredTextNode = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public AuthnStatementType createAuthnStatement(String authnContextDeclRef, XMLGr
String authContextDeclRef = JBossSAMLURIConstants.AC_PASSWORD_PROTECTED_TRANSPORT.get();
act.addAuthenticatingAuthority(URI.create(authContextDeclRef));

AuthnContextType.AuthnContextTypeSequence sequence = act.new AuthnContextTypeSequence();
AuthnContextType.AuthnContextTypeSequence sequence = new AuthnContextType.AuthnContextTypeSequence();
sequence.setClassRef(new AuthnContextClassRefType(JBossSAMLURIConstants.AC_PASSWORD.getUri()));
act.setSequence(sequence);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected void processSubElement(XMLEventReader xmlEventReader, AuthnContextType
case AUTHN_CONTEXT_DECL:
Element dom = StaxParserUtil.getDOMElement(xmlEventReader);
AuthnContextDeclType authnContextDecl = new AuthnContextDeclType(dom);
authnContextSequence = target.getSequence() != null ? target.getSequence() : target.new AuthnContextTypeSequence();
authnContextSequence = target.getSequence() != null ? target.getSequence() : new AuthnContextType.AuthnContextTypeSequence();
authnContextSequence.setAuthnContextDecl(authnContextDecl);
target.setSequence(authnContextSequence);
break;
Expand All @@ -75,7 +75,7 @@ protected void processSubElement(XMLEventReader xmlEventReader, AuthnContextType
text = StaxParserUtil.getElementText(xmlEventReader);
AuthnContextClassRefType authnContextClassRef = new AuthnContextClassRefType(URI.create(text));

authnContextSequence = target.getSequence() != null ? target.getSequence() : target.new AuthnContextTypeSequence();
authnContextSequence = target.getSequence() != null ? target.getSequence() : new AuthnContextType.AuthnContextTypeSequence();
authnContextSequence.setClassRef(authnContextClassRef);

target.setSequence(authnContextSequence);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static AuthnStatementType createAuthnStatement(XMLGregorianCalendar insta
AuthnContextType authnContext = new AuthnContextType();
AuthnContextClassRefType authnContextClassRef = new AuthnContextClassRefType(URI.create(authnContextClassRefValue));

AuthnContextType.AuthnContextTypeSequence sequence = (authnContext).new AuthnContextTypeSequence();
AuthnContextType.AuthnContextTypeSequence sequence = new AuthnContextType.AuthnContextTypeSequence();
sequence.setClassRef(authnContextClassRef);
authnContext.setSequence(sequence);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void setCalendar(Calendar calendar) {
this.clock.setCalendar(calendar);
}

private class Clock {
private static class Clock {

private final int interval;
private Calendar calendar;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ private CloseableKeycloakIdentity createIdentity(PolicyEvaluationRequest represe
return new CloseableKeycloakIdentity(accessToken, keycloakSession, userSession);
}

public class EvaluationDecisionCollector extends DecisionPermissionCollector {
public static class EvaluationDecisionCollector extends DecisionPermissionCollector {

public EvaluationDecisionCollector(AuthorizationProvider authorizationProvider, ResourceServer resourceServer, AuthorizationRequest request) {
super(authorizationProvider, resourceServer, request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ public void close() {

//todo: we need to avoid creating this class when processing responses. The only reason for that is that
// UMA defines "resource_id" and "resource_scopes" claims but we use "rsid" and "scopes".
// To avoid breaking backward compatiblity we are just responding with all these claims.
public class UmaPermissionRepresentation extends Permission {
// To avoid breaking backward compatibility we are just responding with all these claims.
public static class UmaPermissionRepresentation extends Permission {

public UmaPermissionRepresentation(Permission permission) {
setResourceId(permission.getResourceId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ protected String toCamelCase(EventType event) {
return sb.toString();
}

protected class EmailTemplate {
protected static class EmailTemplate {

private String subject;
private String textBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public boolean isRemoveLinkPossible() {
return removeLinkPossible;
}

public class FederatedIdentityEntry implements OrderedModel {
public static class FederatedIdentityEntry implements OrderedModel {

private FederatedIdentityModel federatedIdentityModel;
private final String providerId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ private List<KeyProvider> getProviders(RealmModel realm) {
return providers;
}

private class ProviderComparator implements Comparator<ComponentModel> {
private static class ProviderComparator implements Comparator<ComponentModel> {

@Override
public int compare(ComponentModel o1, ComponentModel o2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ private String generateOIDCHash(String input) {

}

public class RefreshResult {
public static class RefreshResult {

private final AccessTokenResponse response;
private final boolean offlineToken;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,7 @@ private String generateS256CodeChallenge(String codeVerifier) throws Exception {
return codeVerifierEncoded;
}

private class TokenExchangeSamlProtocol extends SamlProtocol {
private static class TokenExchangeSamlProtocol extends SamlProtocol {
final SamlClient samlClient;

TokenExchangeSamlProtocol(SamlClient samlClient) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void run(KeycloakSession session) {
});
}

private class Holder {
private static class Holder {
ExecutionResult<SynchronizationResult> result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private Template getTemplate(String templateName, Theme theme) throws IOExceptio
return cfg.getTemplate(templateName, "UTF-8");
}

class ThemeTemplateLoader extends URLTemplateLoader {
static class ThemeTemplateLoader extends URLTemplateLoader {

private Theme theme;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public String getId() {



private class TruststoreCertificatesLoader {
private static class TruststoreCertificatesLoader {

private Map<X500Principal, X509Certificate> trustedRootCerts = new HashMap<>();
private Map<X500Principal, X509Certificate> intermediateCerts = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private void basicHttpUrlCheck(String field, String url) throws ValidationExcept
}
}

class ValidationException extends Exception {
static class ValidationException extends Exception {

public ValidationException(String message) {
super(message, null, false, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public String getId() {
return "test";
}

private class TestPolicyProvider implements PolicyProvider {
private static class TestPolicyProvider implements PolicyProvider {

private final AuthorizationProvider authorization;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ public void close() {
}


class MyUser {
static class MyUser {

private String username;
private CredentialModel hashedPassword;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ private List<String> getCurrentHostRoutes() {
private static final AttachmentKey<Integer> REMAINING_RETRY_ATTEMPTS = AttachmentKey.create(Integer.class);


private class ProxyCallbackDelegate implements ProxyCallback<ProxyConnection> {
private static class ProxyCallbackDelegate implements ProxyCallback<ProxyConnection> {

private final ProxyClient proxyClient;
private final ProxyCallback<ProxyConnection> delegate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void stop() {
server.stop();
}

public class ClassPathResourceManager implements ResourceManager {
public static class ClassPathResourceManager implements ResourceManager {

@Override
public Resource getResource(String className) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public String getRememberMeLabel() {
return getTextFromElement(rememberMeLabel);
}

public class TotpSetupForm extends Form {
public static class TotpSetupForm extends Form {
@FindBy(id = "totp")
private WebElement totpInputField;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public ConfigureMenu configure() {
// return realmsResource().realm(getConsoleRealm());
// }

public class ConfigureMenu {
public static class ConfigureMenu {

@FindBy(partialLinkText = "Realm Settings")
private WebElement realmSettingsLink;
Expand Down Expand Up @@ -111,7 +111,7 @@ public ManageMenu manage() {
return manageMenu;
}

public class ManageMenu {
public static class ManageMenu {

@FindBy(partialLinkText = "Users")
private WebElement usersLink;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public AdminEventsTable table() {
return table;
}

public class AdminEventsTable extends DataTable {
public static class AdminEventsTable extends DataTable {

@FindBy(xpath = "//button[text()[contains(.,'Filter')]]")
private WebElement filterButton;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public ConfigForm form() {
return form;
}

public class ConfigForm extends Form {
public static class ConfigForm extends Form {
@FindBy(id = "s2id_autogen1")
private WebElement eventListenersInput;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public LoginEventsTable table() {
return table;
}

public class LoginEventsTable extends DataTable {
public static class LoginEventsTable extends DataTable {

@FindBy(xpath = "//button[text()[contains(.,'Filter')]]")
private WebElement filterButton;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private void updateCapabilityKeys(String browser, WebDriverConfiguration webDriv
}
}

public class KcBrowserCapabilities implements BrowserCapabilities {
public static class KcBrowserCapabilities implements BrowserCapabilities {
private Capabilities capabilitiesToAdd;
private BrowserCapabilities origBrowserCapabilities;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ private String getHostnameForSASLPrincipal(String hostName) {
*
* @author Dominik Pospisil <dpospisi@redhat.com>
*/
class NoReplayKdcServer extends KdcServer {
static class NoReplayKdcServer extends KdcServer {

NoReplayKdcServer(KerberosConfig kdcConfig) {
super(kdcConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public String printUsage() {
}


private class MyWorker implements Runnable {
private static class MyWorker implements Runnable {

private final int workerId;
private final int lastCreatedOn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
*/
public class RangedAttributeInterceptor extends BaseInterceptor {

private class RangedEntryFilteringCursor implements EntryFilteringCursor {
private static class RangedEntryFilteringCursor implements EntryFilteringCursor {

private final EntryFilteringCursor c;
private final String name;
Expand Down

0 comments on commit 269a72d

Please sign in to comment.