|
18 | 18 | import lombok.extern.jbosslog.JBossLog;
|
19 | 19 | import org.keycloak.models.IdentityProviderModel;
|
20 | 20 | import org.keycloak.models.utils.ModelToRepresentation;
|
| 21 | +import org.keycloak.models.utils.RepresentationToModel; |
21 | 22 | import org.keycloak.models.utils.StripSecretsUtils;
|
22 | 23 | import org.keycloak.representations.idm.ComponentRepresentation;
|
23 | 24 | import org.keycloak.representations.idm.IdentityProviderRepresentation;
|
@@ -119,10 +120,10 @@ public Response createIdentityProvider(IdentityProviderRepresentation representa
|
119 | 120 | }
|
120 | 121 |
|
121 | 122 | idpDefaults(representation, Optional.empty());
|
122 |
| - deactivateOtherIdps(representation); |
123 | 123 |
|
124 | 124 | Response resp = getIdpResource().create(representation);
|
125 | 125 | if (resp.getStatus() == Response.Status.CREATED.getStatusCode()) {
|
| 126 | + deactivateOtherIdps(representation); |
126 | 127 | return createdResponse(representation);
|
127 | 128 | } else {
|
128 | 129 | return resp;
|
@@ -164,13 +165,15 @@ public Response linkIdp(LinkIdp linkIdp) {
|
164 | 165 | if (!Strings.isNullOrEmpty(linkIdp.getPostBrokerFlow())) {
|
165 | 166 | representation.setPostBrokerLoginFlowAlias(linkIdp.getPostBrokerFlow());
|
166 | 167 | }
|
167 |
| - deactivateOtherIdps(representation); |
168 | 168 |
|
169 |
| - Response resp = getIdpResource().getIdentityProvider(linkIdp.getAlias()).update(representation); |
170 |
| - if (resp.getStatus() == Response.Status.NO_CONTENT.getStatusCode()) { |
| 169 | + try { |
| 170 | + IdentityProviderModel updated = RepresentationToModel.toModel(realm, representation, session); |
| 171 | + realm.updateIdentityProvider(updated); |
| 172 | + deactivateOtherIdps(representation); |
171 | 173 | return createdResponse(representation);
|
172 |
| - } else { |
173 |
| - return resp; |
| 174 | + } catch (Exception e) { |
| 175 | + throw new InternalServerErrorException( |
| 176 | + String.format("Error updating IdP %s", representation.getAlias()), e); |
174 | 177 | }
|
175 | 178 | }
|
176 | 179 |
|
|
0 commit comments