com.stormpath.sdk.impl.okta.DefaultOktaApplicationConfigResource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stormpath-sdk-impl Show documentation
Show all versions of stormpath-sdk-impl Show documentation
The Stormpath Java SDK core implemenation .jar is used at runtime to support API invocations. This
implementation jar should be a runtime dependency only and should NOT be depended on at compile time by
your code. The implementations within this jar can change at any time without warning - use it with runtime
scope only.
package com.stormpath.sdk.impl.okta;
import com.stormpath.sdk.impl.ds.InternalDataStore;
import com.stormpath.sdk.impl.resource.AbstractInstanceResource;
import com.stormpath.sdk.impl.resource.MapProperty;
import com.stormpath.sdk.impl.resource.Property;
import com.stormpath.sdk.impl.resource.StringProperty;
import com.stormpath.sdk.okta.OktaApplicationConfigResource;
import java.util.Arrays;
import java.util.Map;
/**
*/
public class DefaultOktaApplicationConfigResource extends AbstractInstanceResource implements OktaApplicationConfigResource {
private static final MapProperty SETTINGS = new MapProperty("settings");
private static final MapProperty NOTIFICATIONS = new MapProperty("notifications");
private static final MapProperty VPN = new MapProperty("vpn");
private static final StringProperty MESSAGE = new StringProperty("message");
private static final Map PROPERTY_DESCRIPTORS = createPropertyDescriptorMap(SETTINGS);
public DefaultOktaApplicationConfigResource(InternalDataStore dataStore) {
super(dataStore);
}
public DefaultOktaApplicationConfigResource(InternalDataStore dataStore, Map properties) {
super(dataStore, properties);
}
@Override
public Map getPropertyDescriptors() {
return PROPERTY_DESCRIPTORS;
}
@Override
public String getAuthorizationServerId() {
// This is a bit of a hack, but for the migration we are _reusing_ 'settings.notifications.vpn.message'
// to link the authorization server.
// if anything in the path is null, just return null
// not the most elegant way of doing this, but it should be pretty easy to debug if
// there are changes in the future.
Map settings = getMap(SETTINGS);
Map notifications = nullSafeGetMap(settings, NOTIFICATIONS);
Map vpn = nullSafeGetMap(notifications, VPN);
return nullSafeGetString(vpn, MESSAGE.getName());
}
private String nullSafeGetString(Map map, String key) {
if (map == null) {
return null;
}
return (String) map.get(key);
}
private Map nullSafeGetMap(Map map, MapProperty key) {
if (map == null) {
return null;
}
return (Map) map.get(key.getName());
}
}