Merge pull request #1514 from stianst/master
KEYCLOAK-1714 Add @JsonIgnoreProperties(ignoreUnknown = true) to JWSH…
This commit is contained in:
commit
630597746e
8 changed files with 33 additions and 34 deletions
|
@ -90,18 +90,7 @@ public class DefaultFileConnectionProviderFactory implements FileConnectionProvi
|
|||
ImportUtils.importFromStream(session, JsonSerialization.mapper, fis, Strategy.IGNORE_EXISTING);
|
||||
session.realms().getMigrationModel().setStoredVersion(model.getModelVersion());
|
||||
|
||||
List<RealmRepresentation> realmReps = new ArrayList<RealmRepresentation>();
|
||||
for (RealmRepresentation realmRep : model.getRealms()) {
|
||||
if (Config.getAdminRealm().equals(realmRep.getRealm())) {
|
||||
realmReps.add(0, realmRep);
|
||||
} else {
|
||||
realmReps.add(realmRep);
|
||||
}
|
||||
}
|
||||
for (RealmRepresentation realmRep : realmReps) {
|
||||
ImportUtils.importRealm(session, realmRep, Strategy.IGNORE_EXISTING);
|
||||
}
|
||||
|
||||
ImportUtils.importRealms(session, model.getRealms(), Strategy.IGNORE_EXISTING);
|
||||
} catch (IOException ioe) {
|
||||
logger.error("Unable to read model file " + kcdata.getAbsolutePath(), ioe);
|
||||
} finally {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.keycloak.jose.jws;
|
||||
|
||||
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
|
||||
import org.codehaus.jackson.annotate.JsonProperty;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.codehaus.jackson.map.annotate.JsonSerialize;
|
||||
|
@ -11,6 +12,7 @@ import java.io.Serializable;
|
|||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||
* @version $Revision: 1 $
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class JWSHeader implements Serializable {
|
||||
@JsonProperty("alg")
|
||||
private Algorithm algorithm;
|
||||
|
|
|
@ -24,6 +24,7 @@ Install to Android phone or emulator
|
|||
|
||||
mkdir platforms plugins
|
||||
cordova plugin add org.apache.cordova.inappbrowser
|
||||
cordova plugin add cordova-plugin-whitelist
|
||||
cordova platform add android
|
||||
cordova run android
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<preference name="permissions" value="none"/>
|
||||
|
||||
<gap:plugin name="org.apache.cordova.inappbrowser" />
|
||||
<gap:plugin name="cordova-plugin-whitelist" version="1.0.0" source="npm" />
|
||||
|
||||
<access origin="*"/>
|
||||
</widget>
|
||||
|
|
|
@ -20,10 +20,8 @@ import org.keycloak.representations.idm.UserRepresentation;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import org.keycloak.exportimport.ExportImportConfig;
|
||||
|
||||
/**
|
||||
|
@ -33,6 +31,21 @@ public class ImportUtils {
|
|||
|
||||
private static final Logger logger = Logger.getLogger(ImportUtils.class);
|
||||
|
||||
public static void importRealms(KeycloakSession session, Collection<RealmRepresentation> realms, Strategy strategy) {
|
||||
// Import admin realm first
|
||||
for (RealmRepresentation realm : realms) {
|
||||
if (Config.getAdminRealm().equals(realm.getRealm())) {
|
||||
importRealm(session, realm, strategy);
|
||||
}
|
||||
}
|
||||
|
||||
for (RealmRepresentation realm : realms) {
|
||||
if (!Config.getAdminRealm().equals(realm.getRealm())) {
|
||||
importRealm(session, realm, strategy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fully import realm from representation, save it to model and return model of newly created realm
|
||||
*
|
||||
|
@ -41,7 +54,7 @@ public class ImportUtils {
|
|||
* @param strategy specifies whether to overwrite or ignore existing realm or user entries
|
||||
* @return newly imported realm (or existing realm if ignoreExisting is true and realm of this name already exists)
|
||||
*/
|
||||
public static RealmModel importRealm(KeycloakSession session, RealmRepresentation rep, Strategy strategy) {
|
||||
public static void importRealm(KeycloakSession session, RealmRepresentation rep, Strategy strategy) {
|
||||
String realmName = rep.getRealm();
|
||||
RealmProvider model = session.realms();
|
||||
RealmModel realm = model.getRealmByName(realmName);
|
||||
|
@ -49,7 +62,7 @@ public class ImportUtils {
|
|||
if (realm != null) {
|
||||
if (strategy == Strategy.IGNORE_EXISTING) {
|
||||
logger.infof("Realm '%s' already exists. Import skipped", realmName);
|
||||
return realm;
|
||||
return;
|
||||
} else {
|
||||
logger.infof("Realm '%s' already exists. Removing it before import", realmName);
|
||||
if (Config.getAdminRealm().equals(realm.getId())) {
|
||||
|
@ -73,7 +86,7 @@ public class ImportUtils {
|
|||
logger.infof("Realm '%s' imported", realmName);
|
||||
}
|
||||
|
||||
return realm;
|
||||
return;
|
||||
}
|
||||
|
||||
private static void refreshMasterAdminApps(RealmProvider model, RealmModel realm) {
|
||||
|
@ -145,9 +158,7 @@ public class ImportUtils {
|
|||
*/
|
||||
public static void importFromStream(KeycloakSession session, ObjectMapper mapper, InputStream is, Strategy strategy) throws IOException {
|
||||
Map<String, RealmRepresentation> realmReps = getRealmsFromStream(mapper, is);
|
||||
for (RealmRepresentation realmRep : realmReps.values()) {
|
||||
importRealm(session, realmRep, strategy);
|
||||
}
|
||||
importRealms(session, realmReps.values(), strategy);
|
||||
}
|
||||
|
||||
public static Map<String, RealmRepresentation> getRealmsFromStream(ObjectMapper mapper, InputStream is) throws IOException {
|
||||
|
|
|
@ -42,9 +42,7 @@ public class SingleFileImportProvider implements ImportProvider {
|
|||
|
||||
@Override
|
||||
protected void runExportImportTask(KeycloakSession session) throws IOException {
|
||||
for (RealmRepresentation realmRep : realmReps.values()) {
|
||||
ImportUtils.importRealm(session, realmRep, strategy);
|
||||
}
|
||||
ImportUtils.importRealms(session, realmReps.values(), strategy);
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -992,10 +992,6 @@ module.controller('UserFederationMapperCtrl', function($scope, realm, provider,
|
|||
$scope.changed = false;
|
||||
};
|
||||
|
||||
$scope.cancel = function() {
|
||||
window.history.back();
|
||||
};
|
||||
|
||||
$scope.remove = function() {
|
||||
Dialog.confirmDelete($scope.mapper.name, 'mapper', function() {
|
||||
UserFederationMapper.remove({ realm: realm.realm, provider: provider.id, mapperId : $scope.mapper.id }, function() {
|
||||
|
@ -1016,6 +1012,7 @@ module.controller('UserFederationMapperCreateCtrl', function($scope, realm, prov
|
|||
$scope.mapper = { federationProviderDisplayName: provider.displayName, config: {}};
|
||||
$scope.mapperTypes = mapperTypes;
|
||||
$scope.mapperType = null;
|
||||
$scope.changed = true;
|
||||
|
||||
$scope.$watch('mapperType', function() {
|
||||
if ($scope.mapperType != null) {
|
||||
|
@ -1052,8 +1049,8 @@ module.controller('UserFederationMapperCreateCtrl', function($scope, realm, prov
|
|||
});
|
||||
};
|
||||
|
||||
$scope.cancel = function() {
|
||||
window.history.back();
|
||||
$scope.reset = function() {
|
||||
$location.url("/realms/" + realm.realm + '/user-federation/providers/' + provider.providerName + '/' + provider.id + '/mappers');
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -50,9 +50,9 @@
|
|||
</fieldset>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-10 col-md-offset-2" data-ng-show="!create && access.manageRealm">
|
||||
<button kc-save data-ng-show="changed">Save</button>
|
||||
<button kc-reset data-ng-disabled="!changed">Clear changes</button>
|
||||
<div class="col-md-10 col-md-offset-2" data-ng-show="access.manageRealm">
|
||||
<button kc-save data-ng-disabled="!changed">Save</button>
|
||||
<button kc-reset data-ng-disabled="!changed">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
Loading…
Reference in a new issue