use of org.keycloak.models.IdentityProviderModel in project keycloak by keycloak.
the class SerializedBrokeredIdentityContext method deserialize.
public BrokeredIdentityContext deserialize(KeycloakSession session, AuthenticationSessionModel authSession) {
BrokeredIdentityContext ctx = new BrokeredIdentityContext(getId());
ctx.setUsername(getBrokerUsername());
ctx.setModelUsername(getModelUsername());
ctx.setEmail(getEmail());
ctx.setFirstName(getFirstName());
ctx.setLastName(getLastName());
ctx.setBrokerSessionId(getBrokerSessionId());
ctx.setBrokerUserId(getBrokerUserId());
ctx.setToken(getToken());
RealmModel realm = authSession.getRealm();
IdentityProviderModel idpConfig = realm.getIdentityProviderByAlias(getIdentityProviderId());
if (idpConfig == null) {
throw new ModelException("Can't find identity provider with ID " + getIdentityProviderId() + " in realm " + realm.getName());
}
IdentityProvider idp = IdentityBrokerService.getIdentityProvider(session, realm, idpConfig.getAlias());
ctx.setIdpConfig(idpConfig);
ctx.setIdp(idp);
IdentityProviderDataMarshaller serializer = idp.getMarshaller();
for (Map.Entry<String, ContextDataEntry> entry : getContextData().entrySet()) {
try {
ContextDataEntry value = entry.getValue();
Class<?> clazz = Reflections.classForName(value.getClazz(), this.getClass().getClassLoader());
Object deserialized = serializer.deserialize(value.getData(), clazz);
ctx.getContextData().put(entry.getKey(), deserialized);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
ctx.setAuthenticationSession(authSession);
return ctx;
}
use of org.keycloak.models.IdentityProviderModel in project keycloak by keycloak.
the class MapIdentityProviderEntity method toModel.
static IdentityProviderModel toModel(MapIdentityProviderEntity entity) {
if (entity == null)
return null;
IdentityProviderModel model = new IdentityProviderModel();
model.setInternalId(entity.getId());
model.setAlias(entity.getAlias());
model.setDisplayName(entity.getDisplayName());
model.setProviderId(entity.getProviderId());
model.setFirstBrokerLoginFlowId(entity.getFirstBrokerLoginFlowId());
model.setPostBrokerLoginFlowId(entity.getPostBrokerLoginFlowId());
Boolean enabled = entity.isEnabled();
model.setEnabled(enabled == null ? false : enabled);
Boolean trustEmail = entity.isTrustEmail();
model.setTrustEmail(trustEmail == null ? false : trustEmail);
Boolean storeToken = entity.isStoreToken();
model.setStoreToken(storeToken == null ? false : storeToken);
Boolean linkOnly = entity.isLinkOnly();
model.setLinkOnly(linkOnly == null ? false : linkOnly);
Boolean addReadTokenRoleOnCreate = entity.isAddReadTokenRoleOnCreate();
model.setAddReadTokenRoleOnCreate(addReadTokenRoleOnCreate == null ? false : addReadTokenRoleOnCreate);
Boolean authenticateByDefault = entity.isAuthenticateByDefault();
model.setAuthenticateByDefault(authenticateByDefault == null ? false : authenticateByDefault);
model.setConfig(entity.getConfig() == null ? null : new HashMap<>(entity.getConfig()));
return model;
}
Aggregations