diff --git a/forms/account-freemarker/src/main/java/org/keycloak/account/freemarker/FreeMarkerAccount.java b/forms/account-freemarker/src/main/java/org/keycloak/account/freemarker/FreeMarkerAccount.java index 884484ff5d..fb30dacac4 100755 --- a/forms/account-freemarker/src/main/java/org/keycloak/account/freemarker/FreeMarkerAccount.java +++ b/forms/account-freemarker/src/main/java/org/keycloak/account/freemarker/FreeMarkerAccount.java @@ -22,6 +22,7 @@ import org.keycloak.models.UserModel; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriInfo; import java.io.IOException; import java.net.URI; @@ -85,6 +86,11 @@ public class FreeMarkerAccount implements Account { } URI baseUri = uriInfo.getBaseUri(); + UriBuilder baseUriBuilder = uriInfo.getBaseUriBuilder(); + for (Map.Entry> e : uriInfo.getQueryParameters().entrySet()) { + baseUriBuilder.queryParam(e.getKey(), e.getValue().toArray()); + } + URI baseQueryUri = baseUriBuilder.build(); if (message != null) { attributes.put("message", new MessageBean(messages.containsKey(message) ? messages.getProperty(message) : message, messageType)); @@ -94,7 +100,7 @@ public class FreeMarkerAccount implements Account { attributes.put("referrer", new ReferrerBean(referrer)); } - attributes.put("url", new UrlBean(realm, theme, baseUri)); + attributes.put("url", new UrlBean(realm, theme, baseUri, baseQueryUri)); attributes.put("features", new FeaturesBean(social, audit, passwordUpdateSupported)); diff --git a/forms/account-freemarker/src/main/java/org/keycloak/account/freemarker/model/UrlBean.java b/forms/account-freemarker/src/main/java/org/keycloak/account/freemarker/model/UrlBean.java index e626ddf33f..6467146dc3 100644 --- a/forms/account-freemarker/src/main/java/org/keycloak/account/freemarker/model/UrlBean.java +++ b/forms/account-freemarker/src/main/java/org/keycloak/account/freemarker/model/UrlBean.java @@ -14,43 +14,45 @@ public class UrlBean { private String realm; private Theme theme; private URI baseURI; + private URI baseQueryURI; - public UrlBean(RealmModel realm, Theme theme, URI baseURI) { + public UrlBean(RealmModel realm, Theme theme, URI baseURI, URI baseQueryURI) { this.realm = realm.getName(); this.theme = theme; this.baseURI = baseURI; + this.baseQueryURI = baseQueryURI; } public String getAccessUrl() { - return Urls.accountAccessPage(baseURI, realm).toString(); + return Urls.accountAccessPage(baseQueryURI, realm).toString(); } public String getAccountUrl() { - return Urls.accountPage(baseURI, realm).toString(); + return Urls.accountPage(baseQueryURI, realm).toString(); } public String getPasswordUrl() { - return Urls.accountPasswordPage(baseURI, realm).toString(); + return Urls.accountPasswordPage(baseQueryURI, realm).toString(); } public String getSocialUrl() { - return Urls.accountSocialPage(baseURI, realm).toString(); + return Urls.accountSocialPage(baseQueryURI, realm).toString(); } public String getTotpUrl() { - return Urls.accountTotpPage(baseURI, realm).toString(); + return Urls.accountTotpPage(baseQueryURI, realm).toString(); } public String getLogUrl() { - return Urls.accountLogPage(baseURI, realm).toString(); + return Urls.accountLogPage(baseQueryURI, realm).toString(); } public String getTotpRemoveUrl() { - return Urls.accountTotpRemove(baseURI, realm).toString(); + return Urls.accountTotpRemove(baseQueryURI, realm).toString(); } public String getLogoutUrl() { - return Urls.accountLogout(baseURI, realm).toString(); + return Urls.accountLogout(baseQueryURI, realm).toString(); } public String getResourcesPath() { diff --git a/integration/jaxrs-oauth-client/pom.xml b/integration/jaxrs-oauth-client/pom.xml index 7530219d55..ce520e89d5 100755 --- a/integration/jaxrs-oauth-client/pom.xml +++ b/integration/jaxrs-oauth-client/pom.xml @@ -14,6 +14,11 @@ + + org.jboss.logging + jboss-logging + provided + org.jboss.resteasy jaxrs-api diff --git a/integration/jaxrs-oauth-client/src/main/java/org/keycloak/jaxrs/JaxrsBearerTokenFilter.java b/integration/jaxrs-oauth-client/src/main/java/org/keycloak/jaxrs/JaxrsBearerTokenFilter.java index 6335762e3b..90af01253d 100755 --- a/integration/jaxrs-oauth-client/src/main/java/org/keycloak/jaxrs/JaxrsBearerTokenFilter.java +++ b/integration/jaxrs-oauth-client/src/main/java/org/keycloak/jaxrs/JaxrsBearerTokenFilter.java @@ -1,6 +1,6 @@ package org.keycloak.jaxrs; -import org.jboss.resteasy.logging.Logger; +import org.jboss.logging.Logger; import org.jboss.resteasy.spi.ResteasyProviderFactory; import org.keycloak.KeycloakSecurityContext; import org.keycloak.KeycloakPrincipal; diff --git a/integration/jaxrs-oauth-client/src/main/java/org/keycloak/jaxrs/JaxrsOAuthClient.java b/integration/jaxrs-oauth-client/src/main/java/org/keycloak/jaxrs/JaxrsOAuthClient.java index 2a825571c6..b453203ab6 100755 --- a/integration/jaxrs-oauth-client/src/main/java/org/keycloak/jaxrs/JaxrsOAuthClient.java +++ b/integration/jaxrs-oauth-client/src/main/java/org/keycloak/jaxrs/JaxrsOAuthClient.java @@ -1,6 +1,6 @@ package org.keycloak.jaxrs; -import org.jboss.resteasy.logging.Logger; +import org.jboss.logging.Logger; import org.keycloak.AbstractOAuthClient; import org.keycloak.OAuth2Constants; import org.keycloak.representations.AccessTokenResponse; diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/JpaModelProvider.java b/model/jpa/src/main/java/org/keycloak/models/jpa/JpaModelProvider.java index 03473e5d41..f49e1f2e2e 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/JpaModelProvider.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/JpaModelProvider.java @@ -1,9 +1,7 @@ package org.keycloak.models.jpa; -import java.util.Map; import java.util.Properties; -import org.jboss.resteasy.logging.Logger; import org.keycloak.models.KeycloakSessionFactory; import org.keycloak.models.ModelProvider; diff --git a/services/src/main/java/org/keycloak/services/email/EmailSender.java b/services/src/main/java/org/keycloak/services/email/EmailSender.java index aec3d57b84..6b8af21e08 100755 --- a/services/src/main/java/org/keycloak/services/email/EmailSender.java +++ b/services/src/main/java/org/keycloak/services/email/EmailSender.java @@ -21,14 +21,13 @@ */ package org.keycloak.services.email; -import org.jboss.resteasy.logging.Logger; +import org.jboss.logging.Logger; import org.keycloak.models.RealmModel; import org.keycloak.models.UserModel; import org.keycloak.services.managers.AccessCodeEntry; import org.keycloak.services.resources.flows.Urls; import javax.mail.Message; -import javax.mail.MessagingException; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; @@ -37,7 +36,6 @@ import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriInfo; import java.net.URI; import java.util.Map; -import java.util.Map.Entry; import java.util.Properties; import java.util.concurrent.TimeUnit; diff --git a/services/src/main/java/org/keycloak/services/managers/AppAuthManager.java b/services/src/main/java/org/keycloak/services/managers/AppAuthManager.java index 7f4e95240a..2d218873a9 100755 --- a/services/src/main/java/org/keycloak/services/managers/AppAuthManager.java +++ b/services/src/main/java/org/keycloak/services/managers/AppAuthManager.java @@ -1,15 +1,11 @@ package org.keycloak.services.managers; -import org.jboss.resteasy.logging.Logger; -import org.jboss.resteasy.spi.HttpResponse; -import org.jboss.resteasy.spi.ResteasyProviderFactory; +import org.jboss.logging.Logger; import org.jboss.resteasy.spi.UnauthorizedException; import org.keycloak.RSATokenVerifier; import org.keycloak.VerificationException; -import org.keycloak.jose.jws.JWSBuilder; import org.keycloak.jose.jws.JWSInput; import org.keycloak.jose.jws.crypto.RSAProvider; -import org.keycloak.models.ApplicationModel; import org.keycloak.models.ClientModel; import org.keycloak.models.RealmModel; import org.keycloak.models.UserModel; @@ -99,7 +95,7 @@ public class AppAuthManager extends AuthenticationManager { logger.info("authenticateCookie"); Cookie cookie = headers.getCookies().get(cookieName); if (cookie == null) { - logger.info("authenticateCookie could not find cookie: {0}", cookieName); + logger.infov("authenticateCookie could not find cookie: {0}", cookieName); return null; } diff --git a/services/src/main/java/org/keycloak/services/managers/ApplianceBootstrap.java b/services/src/main/java/org/keycloak/services/managers/ApplianceBootstrap.java index 2b1a6b4f6a..a7f01139e5 100755 --- a/services/src/main/java/org/keycloak/services/managers/ApplianceBootstrap.java +++ b/services/src/main/java/org/keycloak/services/managers/ApplianceBootstrap.java @@ -2,7 +2,7 @@ package org.keycloak.services.managers; import java.util.Arrays; -import org.jboss.resteasy.logging.Logger; +import org.jboss.logging.Logger; import org.keycloak.models.AdminRoles; import org.keycloak.models.ApplicationModel; import org.keycloak.models.AuthenticationProviderModel; diff --git a/services/src/main/java/org/keycloak/services/managers/ApplicationManager.java b/services/src/main/java/org/keycloak/services/managers/ApplicationManager.java index 6b7c9012d9..1bb7e52a99 100755 --- a/services/src/main/java/org/keycloak/services/managers/ApplicationManager.java +++ b/services/src/main/java/org/keycloak/services/managers/ApplicationManager.java @@ -2,7 +2,7 @@ package org.keycloak.services.managers; import org.codehaus.jackson.annotate.JsonProperty; import org.codehaus.jackson.annotate.JsonPropertyOrder; -import org.jboss.resteasy.logging.Logger; +import org.jboss.logging.Logger; import org.keycloak.models.ApplicationModel; import org.keycloak.models.ClaimMask; import org.keycloak.models.ClientModel; @@ -77,7 +77,7 @@ public class ApplicationManager { } if (resourceRep.getWebOrigins() != null) { for (String webOrigin : resourceRep.getWebOrigins()) { - logger.debug("Application: {0} webOrigin: {1}", resourceRep.getName(), webOrigin); + logger.debugv("Application: {0} webOrigin: {1}", resourceRep.getName(), webOrigin); applicationModel.addWebOrigin(webOrigin); } } diff --git a/services/src/main/java/org/keycloak/services/managers/AuthenticationManager.java b/services/src/main/java/org/keycloak/services/managers/AuthenticationManager.java index f276f8f999..81d253f991 100755 --- a/services/src/main/java/org/keycloak/services/managers/AuthenticationManager.java +++ b/services/src/main/java/org/keycloak/services/managers/AuthenticationManager.java @@ -1,6 +1,6 @@ package org.keycloak.services.managers; -import org.jboss.resteasy.logging.Logger; +import org.jboss.logging.Logger; import org.jboss.resteasy.spi.HttpResponse; import org.jboss.resteasy.spi.ResteasyProviderFactory; import org.keycloak.RSATokenVerifier; @@ -82,7 +82,7 @@ public class AuthenticationManager { } String encoded = encodeToken(realm, identityToken); boolean secureOnly = !realm.isSslNotRequired(); - logger.debug("creatingLoginCookie - name: {0} path: {1}", cookieName, cookiePath); + logger.debugv("creatingLoginCookie - name: {0} path: {1}", cookieName, cookiePath); int maxAge = NewCookie.DEFAULT_MAX_AGE; if (rememberMe) { maxAge = realm.getCentralLoginLifespan(); @@ -131,7 +131,7 @@ public class AuthenticationManager { logger.debug("can't expire identity cookie, no HttpResponse"); return; } - logger.debug("Expiring cookie: {0} path: {1}", cookieName, path); + logger.debugv("Expiring cookie: {0} path: {1}", cookieName, path); NewCookie expireIt = new NewCookie(cookieName, "", path, null, "Expiring cookie", 0, false); response.addNewCookie(expireIt); } @@ -150,7 +150,7 @@ public class AuthenticationManager { logger.info("authenticateIdentityCookie"); Cookie cookie = headers.getCookies().get(cookieName); if (cookie == null) { - logger.info("authenticateCookie could not find cookie: {0}", cookieName); + logger.infov("authenticateCookie could not find cookie: {0}", cookieName); return null; } diff --git a/services/src/main/java/org/keycloak/services/managers/RealmManager.java b/services/src/main/java/org/keycloak/services/managers/RealmManager.java index ff76a99da0..7770077b67 100755 --- a/services/src/main/java/org/keycloak/services/managers/RealmManager.java +++ b/services/src/main/java/org/keycloak/services/managers/RealmManager.java @@ -1,6 +1,6 @@ package org.keycloak.services.managers; -import org.jboss.resteasy.logging.Logger; +import org.jboss.logging.Logger; import org.keycloak.models.AccountRoles; import org.keycloak.models.AdminRoles; import org.keycloak.models.ApplicationModel; diff --git a/services/src/main/java/org/keycloak/services/managers/ResourceAdminManager.java b/services/src/main/java/org/keycloak/services/managers/ResourceAdminManager.java index e87de5e062..df6fc052df 100755 --- a/services/src/main/java/org/keycloak/services/managers/ResourceAdminManager.java +++ b/services/src/main/java/org/keycloak/services/managers/ResourceAdminManager.java @@ -4,7 +4,7 @@ import org.apache.http.client.HttpClient; import org.jboss.resteasy.client.ClientRequest; import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor; -import org.jboss.resteasy.logging.Logger; +import org.jboss.logging.Logger; import org.keycloak.TokenIdGenerator; import org.keycloak.adapters.AdapterConstants; import org.keycloak.models.ApplicationModel; @@ -57,7 +57,7 @@ public class ResourceAdminManager { SessionStatsAction adminAction = new SessionStatsAction(TokenIdGenerator.generateId(), Time.currentTime() + 30, application.getName()); adminAction.setListUsers(users); String token = new TokenManager().encodeToken(realm, adminAction); - logger.info("session stats for application: {0} url: {1}", application.getName(), managementUrl); + logger.infov("session stats for application: {0} url: {1}", application.getName(), managementUrl); ClientRequest request = client.createRequest(UriBuilder.fromUri(managementUrl).path(AdapterConstants.K_GET_SESSION_STATS).build().toString()); ClientResponse response = null; try { @@ -111,7 +111,7 @@ public class ResourceAdminManager { if (managementUrl != null) { UserStatsAction adminAction = new UserStatsAction(TokenIdGenerator.generateId(), Time.currentTime() + 30, application.getName(), user.getId()); String token = new TokenManager().encodeToken(realm, adminAction); - logger.info("session stats for application: {0} url: {1}", application.getName(), managementUrl); + logger.infov("session stats for application: {0} url: {1}", application.getName(), managementUrl); ClientRequest request = client.createRequest(UriBuilder.fromUri(managementUrl).path(AdapterConstants.K_GET_USER_STATS).build().toString()); ClientResponse response = null; try { @@ -143,7 +143,7 @@ public class ResourceAdminManager { try { // don't set user notBefore as we don't want a database hit on a user driven logout List resources = realm.getApplications(); - logger.debug("logging out {0} resources ", resources.size()); + logger.debugv("logging out {0} resources ", resources.size()); for (ApplicationModel resource : resources) { logoutApplication(realm, resource, user.getId(), executor, 0); } @@ -157,7 +157,7 @@ public class ResourceAdminManager { try { realm.setNotBefore(Time.currentTime()); List resources = realm.getApplications(); - logger.debug("logging out {0} resources ", resources.size()); + logger.debugv("logging out {0} resources ", resources.size()); for (ApplicationModel resource : resources) { logoutApplication(realm, resource, null, executor, realm.getNotBefore()); } @@ -184,7 +184,7 @@ public class ResourceAdminManager { if (managementUrl != null) { LogoutAction adminAction = new LogoutAction(TokenIdGenerator.generateId(), Time.currentTime() + 30, resource.getName(), user, notBefore); String token = new TokenManager().encodeToken(realm, adminAction); - logger.info("logout user: {0} resource: {1} url: {2}", user, resource.getName(), managementUrl); + logger.infov("logout user: {0} resource: {1} url: {2}", user, resource.getName(), managementUrl); ClientRequest request = client.createRequest(UriBuilder.fromUri(managementUrl).path(AdapterConstants.K_LOGOUT).build().toString()); ClientResponse response = null; try { @@ -234,7 +234,7 @@ public class ResourceAdminManager { if (managementUrl != null) { PushNotBeforeAction adminAction = new PushNotBeforeAction(TokenIdGenerator.generateId(), Time.currentTime() + 30, resource.getName(), notBefore); String token = new TokenManager().encodeToken(realm, adminAction); - logger.info("pushRevocation resource: {0} url: {1}", resource.getName(), managementUrl); + logger.infov("pushRevocation resource: {0} url: {1}", resource.getName(), managementUrl); ClientRequest request = client.createRequest(UriBuilder.fromUri(managementUrl).path(AdapterConstants.K_PUSH_NOT_BEFORE).build().toString()); ClientResponse response = null; try { diff --git a/services/src/main/java/org/keycloak/services/managers/TokenManager.java b/services/src/main/java/org/keycloak/services/managers/TokenManager.java index 0c158075b0..0816c0e286 100755 --- a/services/src/main/java/org/keycloak/services/managers/TokenManager.java +++ b/services/src/main/java/org/keycloak/services/managers/TokenManager.java @@ -1,6 +1,6 @@ package org.keycloak.services.managers; -import org.jboss.resteasy.logging.Logger; +import org.jboss.logging.Logger; import org.jboss.resteasy.specimpl.MultivaluedMapImpl; import org.keycloak.OAuthErrorException; import org.keycloak.audit.Audit; diff --git a/services/src/main/java/org/keycloak/services/resources/AccountService.java b/services/src/main/java/org/keycloak/services/resources/AccountService.java index 28f3df0372..e72eec50a0 100755 --- a/services/src/main/java/org/keycloak/services/resources/AccountService.java +++ b/services/src/main/java/org/keycloak/services/resources/AccountService.java @@ -21,7 +21,7 @@ */ package org.keycloak.services.resources; -import org.jboss.resteasy.logging.Logger; +import org.jboss.logging.Logger; import org.jboss.resteasy.spi.BadRequestException; import org.jboss.resteasy.spi.HttpRequest; import org.keycloak.OAuth2Constants; diff --git a/services/src/main/java/org/keycloak/services/resources/AdminResource.java b/services/src/main/java/org/keycloak/services/resources/AdminResource.java index 668ffa532a..41960a6e23 100755 --- a/services/src/main/java/org/keycloak/services/resources/AdminResource.java +++ b/services/src/main/java/org/keycloak/services/resources/AdminResource.java @@ -1,6 +1,6 @@ package org.keycloak.services.resources; -import org.jboss.resteasy.logging.Logger; +import org.jboss.logging.Logger; import org.keycloak.models.Config; import org.keycloak.freemarker.Theme; import org.keycloak.freemarker.ThemeLoader; diff --git a/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java b/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java index 2cab3d08d4..eae7360e01 100755 --- a/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java +++ b/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java @@ -1,7 +1,7 @@ package org.keycloak.services.resources; import org.jboss.resteasy.core.Dispatcher; -import org.jboss.resteasy.logging.Logger; +import org.jboss.logging.Logger; import org.jboss.resteasy.spi.ResteasyProviderFactory; import org.keycloak.SkeletonKeyContextResolver; import org.keycloak.audit.AuditListener; diff --git a/services/src/main/java/org/keycloak/services/resources/PublicRealmResource.java b/services/src/main/java/org/keycloak/services/resources/PublicRealmResource.java index fdced11c58..20298a38db 100755 --- a/services/src/main/java/org/keycloak/services/resources/PublicRealmResource.java +++ b/services/src/main/java/org/keycloak/services/resources/PublicRealmResource.java @@ -1,17 +1,15 @@ package org.keycloak.services.resources; +import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; -import org.jboss.resteasy.logging.Logger; import org.keycloak.models.RealmModel; import org.keycloak.representations.idm.PublishedRealmRepresentation; import org.keycloak.services.resources.admin.AdminService; import javax.ws.rs.GET; -import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; -import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriInfo; /** diff --git a/services/src/main/java/org/keycloak/services/resources/QRCodeResource.java b/services/src/main/java/org/keycloak/services/resources/QRCodeResource.java index b2196131b3..3ae4b6756e 100755 --- a/services/src/main/java/org/keycloak/services/resources/QRCodeResource.java +++ b/services/src/main/java/org/keycloak/services/resources/QRCodeResource.java @@ -20,7 +20,7 @@ import java.io.OutputStream; /** * @author Stian Thorgersen */ -@Path("/rest/qrcode") +@Path("/qrcode") public class QRCodeResource { @GET diff --git a/services/src/main/java/org/keycloak/services/resources/RealmsResource.java b/services/src/main/java/org/keycloak/services/resources/RealmsResource.java index daa8762be1..5aab5842e0 100755 --- a/services/src/main/java/org/keycloak/services/resources/RealmsResource.java +++ b/services/src/main/java/org/keycloak/services/resources/RealmsResource.java @@ -1,6 +1,6 @@ package org.keycloak.services.resources; -import org.jboss.resteasy.logging.Logger; +import org.jboss.logging.Logger; import org.jboss.resteasy.spi.NotFoundException; import org.jboss.resteasy.spi.ResteasyProviderFactory; import org.keycloak.audit.Audit; @@ -8,8 +8,8 @@ import org.keycloak.models.ApplicationModel; import org.keycloak.models.Constants; import org.keycloak.models.KeycloakSession; import org.keycloak.models.RealmModel; -import org.keycloak.services.ClientConnection; import org.keycloak.provider.ProviderSession; +import org.keycloak.services.ClientConnection; import org.keycloak.services.managers.AuditManager; import org.keycloak.services.managers.AuthenticationManager; import org.keycloak.services.managers.BruteForceProtector; diff --git a/services/src/main/java/org/keycloak/services/resources/RequiredActionsService.java b/services/src/main/java/org/keycloak/services/resources/RequiredActionsService.java index 151fe885c1..1343ec4bff 100755 --- a/services/src/main/java/org/keycloak/services/resources/RequiredActionsService.java +++ b/services/src/main/java/org/keycloak/services/resources/RequiredActionsService.java @@ -21,7 +21,7 @@ */ package org.keycloak.services.resources; -import org.jboss.resteasy.logging.Logger; +import org.jboss.logging.Logger; import org.jboss.resteasy.spi.HttpRequest; import org.keycloak.OAuth2Constants; import org.keycloak.audit.Audit; @@ -364,14 +364,14 @@ public class RequiredActionsService { } if (accessCodeEntry.isExpired()) { - logger.debug("getAccessCodeEntry: access code id: {0}", accessCodeEntry.getId()); - logger.debug("getAccessCodeEntry access code entry expired: {0}", accessCodeEntry.getExpiration()); - logger.debug("getAccessCodeEntry current time: {0}", Time.currentTime()); + logger.debugv("getAccessCodeEntry: access code id: {0}", accessCodeEntry.getId()); + logger.debugv("getAccessCodeEntry access code entry expired: {0}", accessCodeEntry.getExpiration()); + logger.debugv("getAccessCodeEntry current time: {0}", Time.currentTime()); return null; } if (accessCodeEntry.getRequiredActions() == null || !accessCodeEntry.getRequiredActions().contains(requiredAction)) { - logger.debug("getAccessCodeEntry required actions null || entry does not contain required action: {0}|{1}", (accessCodeEntry.getRequiredActions() == null),!accessCodeEntry.getRequiredActions().contains(requiredAction) ); + logger.debugv("getAccessCodeEntry required actions null || entry does not contain required action: {0}|{1}", (accessCodeEntry.getRequiredActions() == null),!accessCodeEntry.getRequiredActions().contains(requiredAction) ); return null; } @@ -392,7 +392,7 @@ public class RequiredActionsService { return Flows.forms(realm, uriInfo).setAccessCode(accessCode.getId(), accessCode.getCode()).setUser(user) .createResponse(requiredActions.iterator().next()); } else { - logger.debug("redirectOauth: redirecting to: {0}", accessCode.getRedirectUri()); + logger.debugv("redirectOauth: redirecting to: {0}", accessCode.getRedirectUri()); accessCode.setExpiration(Time.currentTime() + realm.getAccessCodeLifespan()); audit.success(); diff --git a/services/src/main/java/org/keycloak/services/resources/SocialResource.java b/services/src/main/java/org/keycloak/services/resources/SocialResource.java index 683a399db7..98f8837e80 100755 --- a/services/src/main/java/org/keycloak/services/resources/SocialResource.java +++ b/services/src/main/java/org/keycloak/services/resources/SocialResource.java @@ -21,7 +21,7 @@ */ package org.keycloak.services.resources; -import org.jboss.resteasy.logging.Logger; +import org.jboss.logging.Logger; import org.jboss.resteasy.specimpl.MultivaluedMapImpl; import org.jboss.resteasy.spi.HttpRequest; import org.keycloak.OAuth2Constants; diff --git a/services/src/main/java/org/keycloak/services/resources/ThemeResource.java b/services/src/main/java/org/keycloak/services/resources/ThemeResource.java index 8a2df04507..bec6c4ee90 100755 --- a/services/src/main/java/org/keycloak/services/resources/ThemeResource.java +++ b/services/src/main/java/org/keycloak/services/resources/ThemeResource.java @@ -1,6 +1,6 @@ package org.keycloak.services.resources; -import org.jboss.resteasy.logging.Logger; +import org.jboss.logging.Logger; import org.keycloak.freemarker.Theme; import org.keycloak.freemarker.ThemeLoader; @@ -10,7 +10,6 @@ import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.Response; -import java.io.IOException; import java.io.InputStream; /** diff --git a/services/src/main/java/org/keycloak/services/resources/TokenService.java b/services/src/main/java/org/keycloak/services/resources/TokenService.java index aa2bade0a5..dbfaa3e0ae 100755 --- a/services/src/main/java/org/keycloak/services/resources/TokenService.java +++ b/services/src/main/java/org/keycloak/services/resources/TokenService.java @@ -1,7 +1,7 @@ package org.keycloak.services.resources; +import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; -import org.jboss.resteasy.logging.Logger; import org.jboss.resteasy.spi.BadRequestException; import org.jboss.resteasy.spi.HttpRequest; import org.jboss.resteasy.spi.HttpResponse; @@ -14,6 +14,8 @@ import org.keycloak.audit.Audit; import org.keycloak.audit.Details; import org.keycloak.audit.Errors; import org.keycloak.audit.Events; +import org.keycloak.authentication.AuthenticationProviderException; +import org.keycloak.authentication.AuthenticationProviderManager; import org.keycloak.jose.jws.JWSInput; import org.keycloak.jose.jws.crypto.RSAProvider; import org.keycloak.models.ClientModel; @@ -40,8 +42,6 @@ import org.keycloak.services.messages.Messages; import org.keycloak.services.resources.flows.Flows; import org.keycloak.services.resources.flows.OAuthFlows; import org.keycloak.services.validation.Validation; -import org.keycloak.authentication.AuthenticationProviderException; -import org.keycloak.authentication.AuthenticationProviderManager; import org.keycloak.util.BasicAuthHelper; import org.keycloak.util.Time; @@ -718,7 +718,7 @@ public class TokenService { // authenticate identity cookie, but ignore an access token timeout as we're logging out anyways. UserModel user = authManager.authenticateIdentityCookie(realm, uriInfo, headers, false); if (user != null) { - logger.info("Logging out: {0}", user.getLoginName()); + logger.infov("Logging out: {0}", user.getLoginName()); authManager.expireIdentityCookie(realm, uriInfo); authManager.expireRememberMeCookie(realm, uriInfo); resourceAdminManager.logoutUser(realm, user); diff --git a/services/src/main/java/org/keycloak/services/resources/admin/AdminService.java b/services/src/main/java/org/keycloak/services/resources/admin/AdminService.java index 7be45c5a6e..968b41e8d1 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/AdminService.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/AdminService.java @@ -1,8 +1,8 @@ package org.keycloak.services.resources.admin; import org.codehaus.jackson.annotate.JsonProperty; +import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; -import org.jboss.resteasy.logging.Logger; import org.jboss.resteasy.spi.HttpRequest; import org.jboss.resteasy.spi.HttpResponse; import org.jboss.resteasy.spi.NotFoundException; @@ -303,7 +303,7 @@ public class AdminService { OAuthRedirect oauth = new OAuthRedirect(); String authUrl = TokenService.loginPageUrl(uriInfo).build(Config.getAdminRealm()).toString(); - logger.debug("authUrl: {0}", authUrl); + logger.debugv("authUrl: {0}", authUrl); oauth.setAuthUrl(authUrl); oauth.setClientId(Constants.ADMIN_CONSOLE_APPLICATION); @@ -312,7 +312,7 @@ public class AdminService { redirectBuilder.queryParam("path", path); } URI redirectUri = redirectBuilder.build(); - logger.debug("redirectUri: {0}", redirectUri.toString()); + logger.debugv("redirectUri: {0}", redirectUri.toString()); oauth.setStateCookiePath(redirectUri.getRawPath()); return oauth.redirect(uriInfo, redirectUri.toString()); } diff --git a/services/src/main/java/org/keycloak/services/resources/admin/ApplicationResource.java b/services/src/main/java/org/keycloak/services/resources/admin/ApplicationResource.java index 8878c6bfa5..0c8052ebf6 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/ApplicationResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/ApplicationResource.java @@ -1,7 +1,7 @@ package org.keycloak.services.resources.admin; +import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; -import org.jboss.resteasy.logging.Logger; import org.jboss.resteasy.spi.NotFoundException; import org.keycloak.models.ApplicationModel; import org.keycloak.models.KeycloakSession; @@ -31,14 +31,12 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Application; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import java.io.IOException; import java.util.HashMap; -import java.util.Map; import java.util.Set; /** diff --git a/services/src/main/java/org/keycloak/services/resources/admin/ApplicationsResource.java b/services/src/main/java/org/keycloak/services/resources/admin/ApplicationsResource.java index d3e954397a..7241a15433 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/ApplicationsResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/ApplicationsResource.java @@ -1,7 +1,7 @@ package org.keycloak.services.resources.admin; +import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; -import org.jboss.resteasy.logging.Logger; import org.jboss.resteasy.spi.NotFoundException; import org.jboss.resteasy.spi.ResteasyProviderFactory; import org.keycloak.models.ApplicationModel; diff --git a/services/src/main/java/org/keycloak/services/resources/admin/OAuthClientResource.java b/services/src/main/java/org/keycloak/services/resources/admin/OAuthClientResource.java index 5b07018c26..dce37c171b 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/OAuthClientResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/OAuthClientResource.java @@ -1,7 +1,7 @@ package org.keycloak.services.resources.admin; +import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; -import org.jboss.resteasy.logging.Logger; import org.jboss.resteasy.spi.NotFoundException; import org.keycloak.models.KeycloakSession; import org.keycloak.models.ModelDuplicateException; @@ -23,7 +23,6 @@ import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; -import javax.ws.rs.core.Application; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; diff --git a/services/src/main/java/org/keycloak/services/resources/admin/OAuthClientsResource.java b/services/src/main/java/org/keycloak/services/resources/admin/OAuthClientsResource.java index f940c931c2..66da95e492 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/OAuthClientsResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/OAuthClientsResource.java @@ -1,7 +1,7 @@ package org.keycloak.services.resources.admin; +import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; -import org.jboss.resteasy.logging.Logger; import org.jboss.resteasy.spi.NotFoundException; import org.jboss.resteasy.spi.ResteasyProviderFactory; import org.keycloak.models.KeycloakSession; diff --git a/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java b/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java index 7ec8c169a9..ab6fa496ec 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java @@ -1,7 +1,7 @@ package org.keycloak.services.resources.admin; +import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; -import org.jboss.resteasy.logging.Logger; import org.jboss.resteasy.spi.NotFoundException; import org.jboss.resteasy.spi.ResteasyProviderFactory; import org.keycloak.audit.AuditProvider; @@ -11,17 +11,24 @@ import org.keycloak.models.ApplicationModel; import org.keycloak.models.KeycloakSession; import org.keycloak.models.ModelDuplicateException; import org.keycloak.models.RealmModel; +import org.keycloak.provider.ProviderSession; import org.keycloak.representations.adapters.action.SessionStats; import org.keycloak.representations.idm.RealmAuditRepresentation; import org.keycloak.representations.idm.RealmRepresentation; -import org.keycloak.provider.ProviderSession; import org.keycloak.services.managers.ModelToRepresentation; import org.keycloak.services.managers.RealmManager; import org.keycloak.services.managers.ResourceAdminManager; import org.keycloak.services.managers.TokenManager; import org.keycloak.services.resources.flows.Flows; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; diff --git a/services/src/main/java/org/keycloak/services/resources/admin/RealmsAdminResource.java b/services/src/main/java/org/keycloak/services/resources/admin/RealmsAdminResource.java index 81377d36e9..616c85f8e1 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/RealmsAdminResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/RealmsAdminResource.java @@ -1,7 +1,7 @@ package org.keycloak.services.resources.admin; +import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; -import org.jboss.resteasy.logging.Logger; import org.jboss.resteasy.plugins.providers.multipart.InputPart; import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; import org.jboss.resteasy.spi.NotFoundException; @@ -21,7 +21,12 @@ import org.keycloak.services.managers.RealmManager; import org.keycloak.services.managers.TokenManager; import org.keycloak.services.resources.flows.Flows; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; import javax.ws.rs.core.CacheControl; import javax.ws.rs.core.Context; import javax.ws.rs.core.HttpHeaders; @@ -97,7 +102,7 @@ public class RealmsAdminResource { throw new ForbiddenException(); } - logger.debug("importRealm: {0}", rep.getRealm()); + logger.debugv("importRealm: {0}", rep.getRealm()); RealmManager realmManager = new RealmManager(session); try { @@ -105,7 +110,7 @@ public class RealmsAdminResource { grantPermissionsToRealmCreator(realm); URI location = realmUrl(uriInfo).build(realm.getName()); - logger.debug("imported realm success, sending back: {0}", location.toString()); + logger.debugv("imported realm success, sending back: {0}", location.toString()); return Response.created(location).build(); } catch (ModelDuplicateException e) { return Flows.errors().exists("Realm " + rep.getRealm() + " already exists"); diff --git a/services/src/main/java/org/keycloak/services/resources/admin/RoleByIdResource.java b/services/src/main/java/org/keycloak/services/resources/admin/RoleByIdResource.java index a0f1da8f79..bb7ff14e5e 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/RoleByIdResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/RoleByIdResource.java @@ -1,10 +1,9 @@ package org.keycloak.services.resources.admin; +import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; -import org.jboss.resteasy.logging.Logger; import org.jboss.resteasy.spi.NotFoundException; import org.keycloak.models.ApplicationModel; -import org.keycloak.models.Constants; import org.keycloak.models.OAuthClientModel; import org.keycloak.models.RealmModel; import org.keycloak.models.RoleModel; diff --git a/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java b/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java index 8857e44988..47c8128cf5 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java @@ -1,7 +1,7 @@ package org.keycloak.services.resources.admin; +import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.cache.NoCache; -import org.jboss.resteasy.logging.Logger; import org.jboss.resteasy.spi.BadRequestException; import org.jboss.resteasy.spi.NotFoundException; import org.keycloak.models.ApplicationModel; @@ -317,7 +317,7 @@ public class UsersResource { public void addRealmRoleMappings(@PathParam("username") String username, List roles) { auth.requireManage(); - logger.debug("** addRealmRoleMappings: {0}", roles); + logger.debugv("** addRealmRoleMappings: {0}", roles); UserModel user = realm.getUser(username); if (user == null) { throw new NotFoundException("User not found"); @@ -388,7 +388,7 @@ public class UsersResource { for (RoleModel roleModel : mappings) { mapRep.add(ModelToRepresentation.toRepresentation(roleModel)); } - logger.debug("getApplicationRoleMappings.size() = {0}", mapRep.size()); + logger.debugv("getApplicationRoleMappings.size() = {0}", mapRep.size()); return mapRep; } diff --git a/services/src/main/java/org/keycloak/services/resources/flows/OAuthFlows.java b/services/src/main/java/org/keycloak/services/resources/flows/OAuthFlows.java index 536df819ba..569ff93f76 100755 --- a/services/src/main/java/org/keycloak/services/resources/flows/OAuthFlows.java +++ b/services/src/main/java/org/keycloak/services/resources/flows/OAuthFlows.java @@ -21,7 +21,7 @@ */ package org.keycloak.services.resources.flows; -import org.jboss.resteasy.logging.Logger; +import org.jboss.logging.Logger; import org.jboss.resteasy.spi.HttpRequest; import org.keycloak.OAuth2Constants; import org.keycloak.audit.Audit; @@ -86,7 +86,7 @@ public class OAuthFlows { return Flows.forms(realm, uriInfo).setAccessCode(accessCode.getId(), code).createCode(); } else { UriBuilder redirectUri = UriBuilder.fromUri(redirect).queryParam(OAuth2Constants.CODE, code); - log.debug("redirectAccessCode: state: {0}", state); + log.debugv("redirectAccessCode: state: {0}", state); if (state != null) redirectUri.queryParam(OAuth2Constants.STATE, state); Response.ResponseBuilder location = Response.status(302).location(redirectUri.build()); @@ -124,8 +124,8 @@ public class OAuthFlows { accessCode.setRememberMe(rememberMe); accessCode.setAuthMethod(authMethod); - log.debug("processAccessCode: isResource: {0}", isResource); - log.debug("processAccessCode: go to oauth page?: {0}", + log.debugv("processAccessCode: isResource: {0}", isResource); + log.debugv("processAccessCode: go to oauth page?: {0}", (!isResource && (accessCode.getRealmRolesRequested().size() > 0 || accessCode.getResourceRolesRequested() .size() > 0))); diff --git a/services/src/main/java/org/keycloak/services/resources/flows/OAuthRedirect.java b/services/src/main/java/org/keycloak/services/resources/flows/OAuthRedirect.java index cda6a7c19c..7d3eef017d 100755 --- a/services/src/main/java/org/keycloak/services/resources/flows/OAuthRedirect.java +++ b/services/src/main/java/org/keycloak/services/resources/flows/OAuthRedirect.java @@ -1,10 +1,9 @@ package org.keycloak.services.resources.flows; -import org.jboss.resteasy.logging.Logger; +import org.jboss.logging.Logger; import org.jboss.resteasy.spi.BadRequestException; import org.keycloak.AbstractOAuthClient; import org.keycloak.OAuth2Constants; -import org.keycloak.representations.AccessTokenResponse; import javax.ws.rs.core.Cookie; import javax.ws.rs.core.HttpHeaders; @@ -13,7 +12,6 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriInfo; import java.net.URI; -import java.util.Map; /** * Helper code to obtain oauth access tokens via browser redirects diff --git a/testsuite/integration/src/main/java/org/keycloak/testutils/KeycloakServer.java b/testsuite/integration/src/main/java/org/keycloak/testutils/KeycloakServer.java index e8c4029b75..f3eb078f9d 100755 --- a/testsuite/integration/src/main/java/org/keycloak/testutils/KeycloakServer.java +++ b/testsuite/integration/src/main/java/org/keycloak/testutils/KeycloakServer.java @@ -27,7 +27,7 @@ import io.undertow.servlet.Servlets; import io.undertow.servlet.api.DefaultServletConfig; import io.undertow.servlet.api.DeploymentInfo; import io.undertow.servlet.api.FilterInfo; -import org.jboss.resteasy.logging.Logger; +import org.jboss.logging.Logger; import org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer; import org.jboss.resteasy.spi.ResteasyDeployment; import org.keycloak.models.Config; diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/account/AccountTest.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/account/AccountTest.java index 663eb6af56..78f82b4ce5 100755 --- a/testsuite/integration/src/test/java/org/keycloak/testsuite/account/AccountTest.java +++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/account/AccountTest.java @@ -57,6 +57,7 @@ import org.keycloak.testsuite.rule.KeycloakRule; import org.keycloak.testsuite.rule.KeycloakRule.KeycloakSetup; import org.keycloak.testsuite.rule.WebResource; import org.keycloak.testsuite.rule.WebRule; +import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import java.util.Collections; @@ -167,6 +168,19 @@ public class AccountTest { Assert.assertTrue(appPage.isCurrent()); Assert.assertEquals(appPage.baseUrl + "?test", driver.getCurrentUrl()); + driver.navigate().to(AccountUpdateProfilePage.PATH + "?referrer=test-app"); + Assert.assertTrue(profilePage.isCurrent()); + + driver.findElement(By.linkText("Authenticator")).click(); + Assert.assertTrue(totpPage.isCurrent()); + + driver.findElement(By.linkText("Account")).click(); + Assert.assertTrue(profilePage.isCurrent()); + + profilePage.backToApplication(); + + Assert.assertTrue(appPage.isCurrent()); + events.clear(); } diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/pages/AccountTotpPage.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/pages/AccountTotpPage.java index 02d6f4bac9..cd454de02f 100644 --- a/testsuite/integration/src/test/java/org/keycloak/testsuite/pages/AccountTotpPage.java +++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/pages/AccountTotpPage.java @@ -54,7 +54,7 @@ public class AccountTotpPage extends AbstractAccountPage { } public boolean isCurrent() { - return driver.getTitle().contains("Account Management") && driver.getCurrentUrl().endsWith("/account/totp"); + return driver.getTitle().contains("Account Management") && driver.getCurrentUrl().split("\\?")[0].endsWith("/account/totp"); } public void open() {