KEYCLOAK-12309 Fix warnings with collections in packages:
authentification, authorization, broker, email, events, exportimport from module "services"
This commit is contained in:
parent
1ac76fde59
commit
697eaa4f36
13 changed files with 33 additions and 41 deletions
|
@ -89,7 +89,7 @@ public class BasicAuthAuthenticatorFactory implements AuthenticatorFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ProviderConfigProperty> getConfigProperties() {
|
public List<ProviderConfigProperty> getConfigProperties() {
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class BasicAuthOTPAuthenticatorFactory implements AuthenticatorFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ProviderConfigProperty> getConfigProperties() {
|
public List<ProviderConfigProperty> getConfigProperties() {
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class NoCookieFlowRedirectAuthenticatorFactory implements AuthenticatorFa
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ProviderConfigProperty> getConfigProperties() {
|
public List<ProviderConfigProperty> getConfigProperties() {
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
package org.keycloak.authentication.authenticators.x509;
|
package org.keycloak.authentication.authenticators.x509;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -89,9 +90,7 @@ public abstract class AbstractX509ClientCertificateAuthenticatorFactory implemen
|
||||||
protected static final List<ProviderConfigProperty> configProperties;
|
protected static final List<ProviderConfigProperty> configProperties;
|
||||||
static {
|
static {
|
||||||
List<String> mappingSourceTypes = new LinkedList<>();
|
List<String> mappingSourceTypes = new LinkedList<>();
|
||||||
for (String s : mappingSources) {
|
Collections.addAll(mappingSourceTypes, mappingSources);
|
||||||
mappingSourceTypes.add(s);
|
|
||||||
}
|
|
||||||
ProviderConfigProperty mappingMethodList = new ProviderConfigProperty();
|
ProviderConfigProperty mappingMethodList = new ProviderConfigProperty();
|
||||||
mappingMethodList.setType(ProviderConfigProperty.LIST_TYPE);
|
mappingMethodList.setType(ProviderConfigProperty.LIST_TYPE);
|
||||||
mappingMethodList.setName(MAPPING_SOURCE_SELECTION);
|
mappingMethodList.setName(MAPPING_SOURCE_SELECTION);
|
||||||
|
@ -123,9 +122,7 @@ public abstract class AbstractX509ClientCertificateAuthenticatorFactory implemen
|
||||||
regExp.setHelpText("The regular expression to extract a user identity. The expression must contain a single group. For example, 'uniqueId=(.*?)(?:,|$)' will match 'uniqueId=somebody@company.org, CN=somebody' and give somebody@company.org");
|
regExp.setHelpText("The regular expression to extract a user identity. The expression must contain a single group. For example, 'uniqueId=(.*?)(?:,|$)' will match 'uniqueId=somebody@company.org, CN=somebody' and give somebody@company.org");
|
||||||
|
|
||||||
List<String> mapperTypes = new LinkedList<>();
|
List<String> mapperTypes = new LinkedList<>();
|
||||||
for (String m : userModelMappers) {
|
Collections.addAll(mapperTypes, userModelMappers);
|
||||||
mapperTypes.add(m);
|
|
||||||
}
|
|
||||||
|
|
||||||
ProviderConfigProperty userMapperList = new ProviderConfigProperty();
|
ProviderConfigProperty userMapperList = new ProviderConfigProperty();
|
||||||
userMapperList.setType(ProviderConfigProperty.LIST_TYPE);
|
userMapperList.setType(ProviderConfigProperty.LIST_TYPE);
|
||||||
|
|
|
@ -35,7 +35,7 @@ import java.util.Map;
|
||||||
public abstract class AbstractX509ClientCertificateDirectGrantAuthenticator extends AbstractX509ClientCertificateAuthenticator {
|
public abstract class AbstractX509ClientCertificateDirectGrantAuthenticator extends AbstractX509ClientCertificateAuthenticator {
|
||||||
|
|
||||||
public Response errorResponse(int status, String error, String errorDescription) {
|
public Response errorResponse(int status, String error, String errorDescription) {
|
||||||
Map<String, String> e = new HashMap<String, String>();
|
Map<String, String> e = new HashMap<>();
|
||||||
e.put(OAuth2Constants.ERROR, error);
|
e.put(OAuth2Constants.ERROR, error);
|
||||||
if (errorDescription != null) {
|
if (errorDescription != null) {
|
||||||
e.put(OAuth2Constants.ERROR_DESCRIPTION, errorDescription);
|
e.put(OAuth2Constants.ERROR_DESCRIPTION, errorDescription);
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.keycloak.authorization.admin;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -104,11 +105,8 @@ public class PolicyEvaluationService {
|
||||||
if (givenAttributes != null) {
|
if (givenAttributes != null) {
|
||||||
givenAttributes.forEach((key, entryValue) -> {
|
givenAttributes.forEach((key, entryValue) -> {
|
||||||
if (entryValue != null) {
|
if (entryValue != null) {
|
||||||
List<String> values = new ArrayList();
|
List<String> values = new ArrayList<>();
|
||||||
|
Collections.addAll(values, entryValue.split(","));
|
||||||
for (String value : entryValue.split(",")) {
|
|
||||||
values.add(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
claims.put(key, values);
|
claims.put(key, values);
|
||||||
}
|
}
|
||||||
|
@ -140,11 +138,8 @@ public class PolicyEvaluationService {
|
||||||
if (givenAttributes != null) {
|
if (givenAttributes != null) {
|
||||||
givenAttributes.forEach((key, entryValue) -> {
|
givenAttributes.forEach((key, entryValue) -> {
|
||||||
if (entryValue != null) {
|
if (entryValue != null) {
|
||||||
List<String> values = new ArrayList();
|
List<String> values = new ArrayList<>();
|
||||||
|
Collections.addAll(values, entryValue.split(","));
|
||||||
for (String value : entryValue.split(",")) {
|
|
||||||
values.add(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
attributes.put(key, values);
|
attributes.put(key, values);
|
||||||
}
|
}
|
||||||
|
@ -166,7 +161,7 @@ public class PolicyEvaluationService {
|
||||||
Set<ScopeRepresentation> givenScopes = resource.getScopes();
|
Set<ScopeRepresentation> givenScopes = resource.getScopes();
|
||||||
|
|
||||||
if (givenScopes == null) {
|
if (givenScopes == null) {
|
||||||
givenScopes = new HashSet();
|
givenScopes = new HashSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopeStore scopeStore = storeFactory.getScopeStore();
|
ScopeStore scopeStore = storeFactory.getScopeStore();
|
||||||
|
|
|
@ -116,7 +116,7 @@ public class PermissionTicketService {
|
||||||
if (!match)
|
if (!match)
|
||||||
throw new ErrorResponseException("invalid_resource_id", "Resource set with id [" + representation.getResource() + "] does not have Scope [" + scope.getName() + "]", Response.Status.BAD_REQUEST);
|
throw new ErrorResponseException("invalid_resource_id", "Resource set with id [" + representation.getResource() + "] does not have Scope [" + scope.getName() + "]", Response.Status.BAD_REQUEST);
|
||||||
|
|
||||||
Map<String, String> attributes = new HashMap<String, String>();
|
Map<String, String> attributes = new HashMap<>();
|
||||||
attributes.put(PermissionTicket.RESOURCE, resource.getId());
|
attributes.put(PermissionTicket.RESOURCE, resource.getId());
|
||||||
attributes.put(PermissionTicket.SCOPE, scope.getId());
|
attributes.put(PermissionTicket.SCOPE, scope.getId());
|
||||||
attributes.put(PermissionTicket.REQUESTER, user.getId());
|
attributes.put(PermissionTicket.REQUESTER, user.getId());
|
||||||
|
|
|
@ -155,7 +155,7 @@ public class SAMLIdentityProviderFactory extends AbstractIdentityProviderFactory
|
||||||
throw new RuntimeException("Could not parse IdP SAML Metadata", pe);
|
throw new RuntimeException("Could not parse IdP SAML Metadata", pe);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new HashMap<String, String>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -104,7 +104,7 @@ public class FreeMarkerEmailTemplateProvider implements EmailTemplateProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendEvent(Event event) throws EmailException {
|
public void sendEvent(Event event) throws EmailException {
|
||||||
Map<String, Object> attributes = new HashMap<String, Object>();
|
Map<String, Object> attributes = new HashMap<>();
|
||||||
attributes.put("user", new ProfileBean(user));
|
attributes.put("user", new ProfileBean(user));
|
||||||
attributes.put("event", new EventBean(event));
|
attributes.put("event", new EventBean(event));
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ public class FreeMarkerEmailTemplateProvider implements EmailTemplateProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPasswordReset(String link, long expirationInMinutes) throws EmailException {
|
public void sendPasswordReset(String link, long expirationInMinutes) throws EmailException {
|
||||||
Map<String, Object> attributes = new HashMap<String, Object>(this.attributes);
|
Map<String, Object> attributes = new HashMap<>(this.attributes);
|
||||||
attributes.put("user", new ProfileBean(user));
|
attributes.put("user", new ProfileBean(user));
|
||||||
addLinkInfoIntoAttributes(link, expirationInMinutes, attributes);
|
addLinkInfoIntoAttributes(link, expirationInMinutes, attributes);
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ public class FreeMarkerEmailTemplateProvider implements EmailTemplateProvider {
|
||||||
setRealm(session.getContext().getRealm());
|
setRealm(session.getContext().getRealm());
|
||||||
setUser(user);
|
setUser(user);
|
||||||
|
|
||||||
Map<String, Object> attributes = new HashMap<String, Object>(this.attributes);
|
Map<String, Object> attributes = new HashMap<>(this.attributes);
|
||||||
attributes.put("user", new ProfileBean(user));
|
attributes.put("user", new ProfileBean(user));
|
||||||
attributes.put("realmName", realm.getName());
|
attributes.put("realmName", realm.getName());
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ public class FreeMarkerEmailTemplateProvider implements EmailTemplateProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendConfirmIdentityBrokerLink(String link, long expirationInMinutes) throws EmailException {
|
public void sendConfirmIdentityBrokerLink(String link, long expirationInMinutes) throws EmailException {
|
||||||
Map<String, Object> attributes = new HashMap<String, Object>(this.attributes);
|
Map<String, Object> attributes = new HashMap<>(this.attributes);
|
||||||
attributes.put("user", new ProfileBean(user));
|
attributes.put("user", new ProfileBean(user));
|
||||||
addLinkInfoIntoAttributes(link, expirationInMinutes, attributes);
|
addLinkInfoIntoAttributes(link, expirationInMinutes, attributes);
|
||||||
|
|
||||||
|
@ -150,13 +150,13 @@ public class FreeMarkerEmailTemplateProvider implements EmailTemplateProvider {
|
||||||
attributes.put("identityProviderContext", brokerContext);
|
attributes.put("identityProviderContext", brokerContext);
|
||||||
attributes.put("identityProviderAlias", idpAlias);
|
attributes.put("identityProviderAlias", idpAlias);
|
||||||
|
|
||||||
List<Object> subjectAttrs = Arrays.<Object> asList(idpAlias);
|
List<Object> subjectAttrs = Arrays.asList(idpAlias);
|
||||||
send("identityProviderLinkSubject", subjectAttrs, "identity-provider-link.ftl", attributes);
|
send("identityProviderLinkSubject", subjectAttrs, "identity-provider-link.ftl", attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendExecuteActions(String link, long expirationInMinutes) throws EmailException {
|
public void sendExecuteActions(String link, long expirationInMinutes) throws EmailException {
|
||||||
Map<String, Object> attributes = new HashMap<String, Object>(this.attributes);
|
Map<String, Object> attributes = new HashMap<>(this.attributes);
|
||||||
attributes.put("user", new ProfileBean(user));
|
attributes.put("user", new ProfileBean(user));
|
||||||
addLinkInfoIntoAttributes(link, expirationInMinutes, attributes);
|
addLinkInfoIntoAttributes(link, expirationInMinutes, attributes);
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ public class FreeMarkerEmailTemplateProvider implements EmailTemplateProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendVerifyEmail(String link, long expirationInMinutes) throws EmailException {
|
public void sendVerifyEmail(String link, long expirationInMinutes) throws EmailException {
|
||||||
Map<String, Object> attributes = new HashMap<String, Object>(this.attributes);
|
Map<String, Object> attributes = new HashMap<>(this.attributes);
|
||||||
attributes.put("user", new ProfileBean(user));
|
attributes.put("user", new ProfileBean(user));
|
||||||
addLinkInfoIntoAttributes(link, expirationInMinutes, attributes);
|
addLinkInfoIntoAttributes(link, expirationInMinutes, attributes);
|
||||||
|
|
||||||
|
|
|
@ -34,12 +34,12 @@ import java.util.Set;
|
||||||
*/
|
*/
|
||||||
public class EmailEventListenerProviderFactory implements EventListenerProviderFactory {
|
public class EmailEventListenerProviderFactory implements EventListenerProviderFactory {
|
||||||
|
|
||||||
private static final Set<EventType> SUPPORTED_EVENTS = new HashSet<EventType>();
|
private static final Set<EventType> SUPPORTED_EVENTS = new HashSet<>();
|
||||||
static {
|
static {
|
||||||
Collections.addAll(SUPPORTED_EVENTS, EventType.LOGIN_ERROR, EventType.UPDATE_PASSWORD, EventType.REMOVE_TOTP, EventType.UPDATE_TOTP);
|
Collections.addAll(SUPPORTED_EVENTS, EventType.LOGIN_ERROR, EventType.UPDATE_PASSWORD, EventType.REMOVE_TOTP, EventType.UPDATE_TOTP);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<EventType> includedEvents = new HashSet<EventType>();
|
private Set<EventType> includedEvents = new HashSet<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EventListenerProvider create(KeycloakSession session) {
|
public EventListenerProvider create(KeycloakSession session) {
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class DirImportProvider implements ImportProvider {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
List<String> realmNames = new ArrayList<String>();
|
List<String> realmNames = new ArrayList<>();
|
||||||
for (File file : realmFiles) {
|
for (File file : realmFiles) {
|
||||||
String fileName = file.getName();
|
String fileName = file.getName();
|
||||||
// Parse "foo" from "foo-realm.json"
|
// Parse "foo" from "foo-realm.json"
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class SingleFileExportProvider implements ExportProvider {
|
||||||
@Override
|
@Override
|
||||||
protected void runExportImportTask(KeycloakSession session) throws IOException {
|
protected void runExportImportTask(KeycloakSession session) throws IOException {
|
||||||
List<RealmModel> realms = session.realms().getRealms();
|
List<RealmModel> realms = session.realms().getRealms();
|
||||||
List<RealmRepresentation> reps = new ArrayList<RealmRepresentation>();
|
List<RealmRepresentation> reps = new ArrayList<>();
|
||||||
for (RealmModel realm : realms) {
|
for (RealmModel realm : realms) {
|
||||||
reps.add(ExportUtils.exportRealm(session, realm, true, true));
|
reps.add(ExportUtils.exportRealm(session, realm, true, true));
|
||||||
}
|
}
|
||||||
|
|
|
@ -410,7 +410,7 @@ public class ExportUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> getRoleNames(Collection<RoleModel> roles) {
|
public static List<String> getRoleNames(Collection<RoleModel> roles) {
|
||||||
List<String> roleNames = new ArrayList<String>();
|
List<String> roleNames = new ArrayList<>();
|
||||||
for (RoleModel role : roles) {
|
for (RoleModel role : roles) {
|
||||||
roleNames.add(role.getName());
|
roleNames.add(role.getName());
|
||||||
}
|
}
|
||||||
|
@ -479,7 +479,7 @@ public class ExportUtils {
|
||||||
|
|
||||||
// Social links
|
// Social links
|
||||||
Set<FederatedIdentityModel> socialLinks = session.users().getFederatedIdentities(user, realm);
|
Set<FederatedIdentityModel> socialLinks = session.users().getFederatedIdentities(user, realm);
|
||||||
List<FederatedIdentityRepresentation> socialLinkReps = new ArrayList<FederatedIdentityRepresentation>();
|
List<FederatedIdentityRepresentation> socialLinkReps = new ArrayList<>();
|
||||||
for (FederatedIdentityModel socialLink : socialLinks) {
|
for (FederatedIdentityModel socialLink : socialLinks) {
|
||||||
FederatedIdentityRepresentation socialLinkRep = exportSocialLink(socialLink);
|
FederatedIdentityRepresentation socialLinkRep = exportSocialLink(socialLink);
|
||||||
socialLinkReps.add(socialLinkRep);
|
socialLinkReps.add(socialLinkRep);
|
||||||
|
@ -517,7 +517,7 @@ public class ExportUtils {
|
||||||
|
|
||||||
// Credentials
|
// Credentials
|
||||||
List<CredentialModel> creds = session.userCredentialManager().getStoredCredentials(realm, user);
|
List<CredentialModel> creds = session.userCredentialManager().getStoredCredentials(realm, user);
|
||||||
List<CredentialRepresentation> credReps = new ArrayList<CredentialRepresentation>();
|
List<CredentialRepresentation> credReps = new ArrayList<>();
|
||||||
for (CredentialModel cred : creds) {
|
for (CredentialModel cred : creds) {
|
||||||
CredentialRepresentation credRep = exportCredential(cred);
|
CredentialRepresentation credRep = exportCredential(cred);
|
||||||
credReps.add(credRep);
|
credReps.add(credRep);
|
||||||
|
@ -527,7 +527,7 @@ public class ExportUtils {
|
||||||
|
|
||||||
// Grants
|
// Grants
|
||||||
List<UserConsentModel> consents = session.users().getConsents(realm, user.getId());
|
List<UserConsentModel> consents = session.users().getConsents(realm, user.getId());
|
||||||
LinkedList<UserConsentRepresentation> consentReps = new LinkedList<UserConsentRepresentation>();
|
LinkedList<UserConsentRepresentation> consentReps = new LinkedList<>();
|
||||||
for (UserConsentModel consent : consents) {
|
for (UserConsentModel consent : consents) {
|
||||||
UserConsentRepresentation consentRep = ModelToRepresentation.toRepresentation(consent);
|
UserConsentRepresentation consentRep = ModelToRepresentation.toRepresentation(consent);
|
||||||
consentReps.add(consentRep);
|
consentReps.add(consentRep);
|
||||||
|
@ -657,7 +657,7 @@ public class ExportUtils {
|
||||||
|
|
||||||
// Social links
|
// Social links
|
||||||
Set<FederatedIdentityModel> socialLinks = session.userFederatedStorage().getFederatedIdentities(id, realm);
|
Set<FederatedIdentityModel> socialLinks = session.userFederatedStorage().getFederatedIdentities(id, realm);
|
||||||
List<FederatedIdentityRepresentation> socialLinkReps = new ArrayList<FederatedIdentityRepresentation>();
|
List<FederatedIdentityRepresentation> socialLinkReps = new ArrayList<>();
|
||||||
for (FederatedIdentityModel socialLink : socialLinks) {
|
for (FederatedIdentityModel socialLink : socialLinks) {
|
||||||
FederatedIdentityRepresentation socialLinkRep = exportSocialLink(socialLink);
|
FederatedIdentityRepresentation socialLinkRep = exportSocialLink(socialLink);
|
||||||
socialLinkReps.add(socialLinkRep);
|
socialLinkReps.add(socialLinkRep);
|
||||||
|
@ -697,7 +697,7 @@ public class ExportUtils {
|
||||||
|
|
||||||
// Credentials
|
// Credentials
|
||||||
List<CredentialModel> creds = session.userFederatedStorage().getStoredCredentials(realm, id);
|
List<CredentialModel> creds = session.userFederatedStorage().getStoredCredentials(realm, id);
|
||||||
List<CredentialRepresentation> credReps = new ArrayList<CredentialRepresentation>();
|
List<CredentialRepresentation> credReps = new ArrayList<>();
|
||||||
for (CredentialModel cred : creds) {
|
for (CredentialModel cred : creds) {
|
||||||
CredentialRepresentation credRep = exportCredential(cred);
|
CredentialRepresentation credRep = exportCredential(cred);
|
||||||
credReps.add(credRep);
|
credReps.add(credRep);
|
||||||
|
@ -706,7 +706,7 @@ public class ExportUtils {
|
||||||
|
|
||||||
// Grants
|
// Grants
|
||||||
List<UserConsentModel> consents = session.users().getConsents(realm, id);
|
List<UserConsentModel> consents = session.users().getConsents(realm, id);
|
||||||
LinkedList<UserConsentRepresentation> consentReps = new LinkedList<UserConsentRepresentation>();
|
LinkedList<UserConsentRepresentation> consentReps = new LinkedList<>();
|
||||||
for (UserConsentModel consent : consents) {
|
for (UserConsentModel consent : consents) {
|
||||||
UserConsentRepresentation consentRep = ModelToRepresentation.toRepresentation(consent);
|
UserConsentRepresentation consentRep = ModelToRepresentation.toRepresentation(consent);
|
||||||
consentReps.add(consentRep);
|
consentReps.add(consentRep);
|
||||||
|
|
Loading…
Reference in a new issue