Commit 68133fad authored by Gradl, Tobias's avatar Gradl, Tobias
Browse files

5: Implement compatible User/Role behavior from CommonProfile

Task-Url: #5
parent 64dcc6ee
Pipeline #17802 passed with stage
in 1 minute and 54 seconds
......@@ -14,6 +14,7 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper=true)
public class ExtendedUserProfile extends CommonProfile {
private boolean transientId;
private String issuerId;
private Set<String> externalRoles;
private int level;
......
......@@ -23,6 +23,7 @@ public class LocalProfileCreator extends BaseProfileCreator implements ProfileCr
return Optional.empty();
}
ExtendedUserProfile profile = new ExtendedUserProfile(credentials.getUserProfile());
profile.setIssuerId("local");
this.mapAndAssignRoles(profile);
return Optional.ofNullable(profile);
}
......
......@@ -22,6 +22,7 @@ import lombok.extern.slf4j.Slf4j;
public class SamlProfileCreator extends BaseProfileCreator implements ProfileCreator<SAML2Credentials> {
public static final String EXTERNAL_ROLES_MAPPED_NAME = "externalRoles";
public static final String ID_MAPPED_NAME = "id";
public static final String ISSUER_ID_NAME = "issuerId";
private final SecurityConfig securityConfig;
......@@ -38,6 +39,7 @@ public class SamlProfileCreator extends BaseProfileCreator implements ProfileCre
ExtendedUserProfile profile = new ExtendedUserProfile(credentials.getUserProfile());
this.assignExternalRoles(profile);
this.setIdPersistenceInfo(profile);
this.setIssuerId(profile);
this.mapAndAssignRoles(profile);
return Optional.ofNullable(profile);
}
......@@ -61,6 +63,17 @@ public class SamlProfileCreator extends BaseProfileCreator implements ProfileCre
}
profile.setTransientId(transientId);
}
private void setIssuerId(ExtendedUserProfile profile) {
try {
Object issuerId = profile.getAuthenticationAttribute(ISSUER_ID_NAME);
if (issuerId!=null) {
profile.setIssuerId(issuerId.toString());
}
} catch (Exception e) {
log.warn("Unable to issuerId of the profile", e);
}
}
private void assignExternalRoles(ExtendedUserProfile profile) {
try {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment