use of io.jans.scim.model.scim2.Meta in project jans by JanssenProject.
the class ServiceProviderConfigWS method serve.
@GET
@Produces(MEDIA_TYPE_SCIM_JSON + UTF8_CHARSET_FRAGMENT)
@HeaderParam("Accept")
@DefaultValue(MEDIA_TYPE_SCIM_JSON)
@RejectFilterParam
public Response serve() {
try {
ServiceProviderConfig serviceProviderConfig = new ServiceProviderConfig();
serviceProviderConfig.getFilter().setMaxResults(appConfiguration.getMaxCount());
Meta meta = new Meta();
meta.setLocation(endpointUrl);
meta.setResourceType(ScimResourceUtil.getType(serviceProviderConfig.getClass()));
serviceProviderConfig.setMeta(meta);
serviceProviderConfig.setAuthenticationSchemes(Collections.singletonList(AuthenticationScheme.createOAuth2(true)));
return Response.ok(resourceSerializer.serialize(serviceProviderConfig)).build();
} catch (Exception e) {
log.error(e.getMessage(), e);
return getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Unexpected error: " + e.getMessage());
}
}
use of io.jans.scim.model.scim2.Meta in project jans by JanssenProject.
the class Fido2DeviceTest method updateWithObject.
@Test(dependsOnMethods = "updateWithJson")
public void updateWithObject() throws Exception {
logger.debug("Updating device to original attributes");
Response response = client.updateF2Device(device, device.getId(), null, null);
assertEquals(response.getStatus(), OK.getStatusCode());
Fido2DeviceResource updated = response.readEntity(fido2Class);
// Naively compare (property-to-property) the original and new object. It's feasible since all of them are strings
for (String path : IntrospectUtil.allAttrs.get(fido2Class)) {
String val = BeanUtils.getProperty(device, path);
// Exclude metas since they diverge and skip if original attribute was null (when passing null for an update, server ignores)
if (!path.startsWith("meta") && val != null) {
assertEquals(BeanUtils.getProperty(updated, path), val);
}
}
// Update an immutable attribute
updated.setCounter(Integer.MIN_VALUE);
response = client.updateF2Device(updated, updated.getId(), null, null);
assertEquals(response.getStatus(), BAD_REQUEST.getStatusCode());
}
use of io.jans.scim.model.scim2.Meta in project oxTrust by GluuFederation.
the class CopyUtils2 method copy.
public FidoDevice copy(GluuCustomFidoDevice source, FidoDevice destination) {
if (source == null) {
return null;
}
if (destination == null) {
destination = new FidoDevice();
}
destination.setId(source.getId());
destination.setCreationDate(source.getCreationDate());
destination.setApplication(source.getApplication());
destination.setCounter(source.getCounter());
destination.setDeviceData(source.getDeviceData());
destination.setDeviceHashCode(source.getDeviceHashCode());
destination.setDeviceKeyHandle(source.getDeviceKeyHandle());
destination.setDeviceRegistrationConf(source.getDeviceRegistrationConf());
destination.setLastAccessTime(source.getLastAccessTime());
destination.setStatus(source.getStatus());
destination.setDisplayName(source.getDisplayName());
destination.setDescription(source.getDescription());
if (source.getDn() != null) {
String[] dnArray = source.getDn().split("\\,");
for (String e : dnArray) {
if (e.startsWith("inum=")) {
String[] inumArray = e.split("\\=");
if (inumArray.length > 1) {
destination.setUserId(inumArray[1]);
}
}
}
}
Meta meta = (destination.getMeta() != null) ? destination.getMeta() : new Meta();
if (source.getMetaVersion() != null) {
meta.setVersion(source.getMetaVersion());
}
String location = source.getMetaLocation();
if (location != null && !location.isEmpty()) {
if (!location.startsWith("https://") && !location.startsWith("http://")) {
location = appConfiguration.getBaseEndpoint() + location;
}
} else {
location = appConfiguration.getBaseEndpoint() + "/scim/v2/FidoDevices/" + source.getId();
}
meta.setLocation(location);
if (source.getCreationDate() != null && !source.getCreationDate().isEmpty()) {
try {
meta.setCreated(new SimpleDateFormat("yyyyMMddHHmmss.SSS'Z'").parse(source.getCreationDate()));
} catch (Exception e) {
log.error(" Date parse exception (OLD format)", e);
}
}
if (source.getMetaLastModified() != null && !source.getMetaLastModified().isEmpty()) {
try {
DateTime dateTimeUtc = new DateTime(source.getMetaLastModified(), DateTimeZone.UTC);
meta.setLastModified(dateTimeUtc.toDate());
} catch (Exception e) {
log.error(" Date parse exception (NEW format), continuing...", e);
try {
meta.setLastModified(new SimpleDateFormat("yyyyMMddHHmmss.SSS'Z'").parse(source.getMetaLastModified()));
} catch (Exception ex) {
log.error(" Date parse exception (OLD format)", ex);
}
}
}
destination.setMeta(meta);
return destination;
}
use of io.jans.scim.model.scim2.Meta in project oxTrust by GluuFederation.
the class GroupCoreLoadingStrategy method load.
@Override
public SchemaType load(AppConfiguration appConfiguration, SchemaType schemaType) throws Exception {
log.info(" load() ");
Meta meta = new Meta();
meta.setLocation(appConfiguration.getBaseEndpoint() + "/scim/v2/Schemas/" + schemaType.getId());
meta.setResourceType("Schema");
schemaType.setMeta(meta);
// Use serializer to walk the class structure
ObjectMapper mapper = new ObjectMapper();
mapper.disable(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS);
SimpleModule groupCoreLoadingStrategyModule = new SimpleModule("GroupCoreLoadingStrategyModule", new Version(1, 0, 0, ""));
SchemaTypeGroupSerializer serializer = new SchemaTypeGroupSerializer();
serializer.setSchemaType(schemaType);
groupCoreLoadingStrategyModule.addSerializer(Group.class, serializer);
mapper.registerModule(groupCoreLoadingStrategyModule);
mapper.writeValueAsString(createDummyGroup());
return serializer.getSchemaType();
}
use of io.jans.scim.model.scim2.Meta in project oxTrust by GluuFederation.
the class UserCoreLoadingStrategy method load.
@Override
public SchemaType load(AppConfiguration appConfiguration, SchemaType schemaType) throws Exception {
log.info(" load() ");
Meta meta = new Meta();
meta.setLocation(appConfiguration.getBaseEndpoint() + "/scim/v2/Schemas/" + schemaType.getId());
meta.setResourceType("Schema");
schemaType.setMeta(meta);
// Use serializer to walk the class structure
ObjectMapper mapper = new ObjectMapper();
mapper.disable(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS);
SimpleModule userCoreLoadingStrategyModule = new SimpleModule("UserCoreLoadingStrategyModule", new Version(1, 0, 0, ""));
SchemaTypeUserSerializer serializer = new SchemaTypeUserSerializer();
serializer.setSchemaType(schemaType);
userCoreLoadingStrategyModule.addSerializer(User.class, serializer);
mapper.registerModule(userCoreLoadingStrategyModule);
mapper.writeValueAsString(createDummyUser());
return serializer.getSchemaType();
}
Aggregations