Skip to content

Commit

Permalink
Rename classes (issue 1 from jacekkow#49 (comment))
Browse files Browse the repository at this point in the history
  • Loading branch information
XSmeets committed Aug 17, 2024
1 parent 04a2ba0 commit 5996d3b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/keycloak/protocol/cas/CASLoginProtocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.keycloak.protocol.LoginProtocol;
import org.keycloak.protocol.cas.endpoints.AbstractValidateEndpoint;
import org.keycloak.protocol.cas.utils.LogoutHelper;
import org.keycloak.protocol.cas.utils.UsernameMapperHelper;
import org.keycloak.protocol.cas.utils.UserMapperHelper;
import org.keycloak.protocol.oidc.utils.OAuth2Code;
import org.keycloak.protocol.oidc.utils.OAuth2CodeParser;
import org.keycloak.services.ErrorPage;
Expand Down Expand Up @@ -103,7 +103,7 @@ public Response authenticated(AuthenticationSessionModel authSession, UserSessio
AuthenticatedClientSessionModel clientSession = clientSessionCtx.getClientSession();

// Verify that if a username mapper is set - there is a username being returned
if(UsernameMapperHelper.getMappedUsername(session, clientSession) == null) {
if(UserMapperHelper.getMappedUser(session, clientSession) == null) {
return ErrorPage.error(session, authSession, Response.Status.INTERNAL_SERVER_ERROR, "Unable to map username for CAS client");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.keycloak.protocol.cas.representations.CASErrorCode;
import org.keycloak.protocol.cas.representations.SamlResponseHelper;
import org.keycloak.protocol.cas.utils.CASValidationException;
import org.keycloak.protocol.cas.utils.UsernameMapperHelper;
import org.keycloak.protocol.cas.utils.UserMapperHelper;
import org.keycloak.services.Urls;
import org.xml.sax.InputSource;

Expand Down Expand Up @@ -62,7 +62,7 @@ public Response validate(String input) {

Map<String, Object> attributes = getUserAttributes();

SAML11ResponseType response = SamlResponseHelper.successResponse(issuer, UsernameMapperHelper.getMappedUsername(session,clientSession), attributes);
SAML11ResponseType response = SamlResponseHelper.successResponse(issuer, UserMapperHelper.getMappedUser(session,clientSession), attributes);

return Response.ok(SamlResponseHelper.soap(response)).build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.keycloak.protocol.cas.utils.CASValidationException;
import org.keycloak.protocol.cas.utils.ContentTypeHelper;
import org.keycloak.protocol.cas.utils.ServiceResponseHelper;
import org.keycloak.protocol.cas.utils.UsernameMapperHelper;
import org.keycloak.protocol.cas.utils.UserMapperHelper;

import java.util.Map;

Expand All @@ -23,7 +23,7 @@ public ServiceValidateEndpoint(KeycloakSession session, RealmModel realm, EventB
protected Response successResponse() {
UserSessionModel userSession = clientSession.getUserSession();
Map<String, Object> attributes = getUserAttributes();
CASServiceResponse serviceResponse = ServiceResponseHelper.createSuccess(UsernameMapperHelper.getMappedUsername(session,clientSession), attributes);
CASServiceResponse serviceResponse = ServiceResponseHelper.createSuccess(UserMapperHelper.getMappedUser(session,clientSession), attributes);
return prepare(Response.Status.OK, serviceResponse);
}

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

import java.util.Map;

public class UsernameMapperHelper {
public static String getMappedUsername(KeycloakSession session, AuthenticatedClientSessionModel clientSession) {
public class UserMapperHelper {
public static String getMappedUser(KeycloakSession session, AuthenticatedClientSessionModel clientSession) {
// CAS protocol does not support scopes, so pass null scopeParam
ClientSessionContext clientSessionCtx = DefaultClientSessionContext.fromClientSessionAndScopeParameter(clientSession, null, session);
UserSessionModel userSession = clientSession.getUserSession();
Expand All @@ -20,13 +20,13 @@ public static String getMappedUsername(KeycloakSession session, AuthenticatedCli
.findFirst()
.orElse(null);

String mappedUsername = userSession.getUser().getUsername();
String mappedUser = userSession.getUser().getUsername();

if(mapperPair != null) {
ProtocolMapperModel mapping = mapperPair.getKey();
CASUserMapper casUsernameMapper = (CASUserMapper) mapperPair.getValue();
mappedUsername = casUsernameMapper.getMappedUsername(mapping, session, userSession, clientSession);
CASUserMapper casUserMapper = (CASUserMapper) mapperPair.getValue();
mappedUser = casUserMapper.getMappedUsername(mapping, session, userSession, clientSession);
}
return mappedUsername;
return mappedUser;
}
}

0 comments on commit 5996d3b

Please sign in to comment.