use of de.ids_mannheim.korap.user.Userdata in project Kustvakt by KorAP.
the class ShibbolethUserController method updateSettings.
@Deprecated
@POST
@Path("settings")
@Consumes({ MediaType.APPLICATION_JSON })
@ResourceFilters({ AuthenticationFilter.class, PiwikFilter.class, BlockingFilter.class })
public Response updateSettings(@Context SecurityContext context, @Context Locale locale, Map settings) {
TokenContext ctx = (TokenContext) context.getUserPrincipal();
if (settings == null)
return Response.notModified().build();
try {
User user = controller.getUser(ctx.getUsername());
if (User.UserFactory.isDemo(ctx.getUsername()))
return Response.notModified().build();
Userdata data = controller.getUserData(user, UserSettingProcessor.class);
// todo: check setting only within the scope of user settings permissions; not foundry range. Latter is part of
// frontend which only displays available foundries and
// SecurityManager.findbyId(us.getDefaultConstfoundry(), user, Foundry.class);
// SecurityManager.findbyId(us.getDefaultLemmafoundry(), user, Foundry.class);
// SecurityManager.findbyId(us.getDefaultPOSfoundry(), user, Foundry.class);
// SecurityManager.findbyId(us.getDefaultRelfoundry(), user, Foundry.class);
Userdata new_data = new UserSettingProcessor(user.getId());
new_data.readQuietly((Map<String, Object>) settings, false);
data.update(new_data);
controller.updateUserData(data);
} catch (KustvaktException e) {
jlog.error("Exception encountered!", e);
throw kustvaktResponseHandler.throwit(e);
}
return Response.ok().build();
}
use of de.ids_mannheim.korap.user.Userdata in project Kustvakt by KorAP.
the class KustvaktAuthenticationManagerTest method testUserdetailsGet.
@Test
@Ignore
public void testUserdetailsGet() throws KustvaktException {
User user = authenticationManager.getUser((String) KustvaktConfiguration.KUSTVAKT_USER.get(Attributes.USERNAME));
Userdata data = authenticationManager.getUserData(user, UserDetails.class);
assertNotNull(data);
}
use of de.ids_mannheim.korap.user.Userdata in project Kustvakt by KorAP.
the class KustvaktAuthenticationManagerTest method testUsersettingsGet.
@Test
@Ignore
public void testUsersettingsGet() throws KustvaktException {
User user = authenticationManager.getUser((String) KustvaktConfiguration.KUSTVAKT_USER.get(Attributes.USERNAME));
Userdata data = authenticationManager.getUserData(user, UserSettingProcessor.class);
assertNotNull(data);
}
use of de.ids_mannheim.korap.user.Userdata in project Kustvakt by KorAP.
the class JWTSigner method signContent.
public SignedJWT signContent(User user, Map<String, Object> attr, int ttl) {
String scopes;
Builder csBuilder = new JWTClaimsSet.Builder();
csBuilder.issuer(this.issuer.toString());
if ((scopes = (String) attr.get(Attributes.SCOPE)) != null) {
Userdata data = new GenericUserData();
data.readQuietly(attr, false);
Scopes claims = Scopes.mapScopes(scopes, data);
Map<String, Object> map = claims.toMap();
for (String key : map.keySet()) {
csBuilder.claim(key, map.get(key));
}
}
csBuilder.subject(user.getUsername());
if (attr.get(Attributes.CLIENT_ID) != null) {
csBuilder.audience((String) attr.get(Attributes.CLIENT_ID));
}
csBuilder.expirationTime(TimeUtils.getNow().plusSeconds(ttl).toDate());
csBuilder.claim(Attributes.AUTHENTICATION_TIME, attr.get(Attributes.AUTHENTICATION_TIME));
JWTClaimsSet jwtClaimsSet = csBuilder.build();
if (DEBUG)
jlog.debug(jwtClaimsSet.getClaim(Attributes.AUTHENTICATION_TIME));
SignedJWT signedJWT = new SignedJWT(new JWSHeader(JWSAlgorithm.HS256), jwtClaimsSet);
try {
signedJWT.sign(signer);
} catch (JOSEException e) {
e.printStackTrace();
}
return signedJWT;
}
use of de.ids_mannheim.korap.user.Userdata in project Kustvakt by KorAP.
the class ShibbolethUserController method getDetails.
@GET
@Path("details")
@ResourceFilters({ AuthenticationFilter.class, DemoUserFilter.class, PiwikFilter.class, BlockingFilter.class })
public Response getDetails(@Context SecurityContext context, @Context Locale locale, @QueryParam("pointer") String pointer) {
TokenContext ctx = (TokenContext) context.getUserPrincipal();
String result;
try {
User user = controller.getUser(ctx.getUsername());
Userdata data = controller.getUserData(user, UserDetails.class);
data.setField(Attributes.USERNAME, ctx.getUsername());
if (pointer != null)
result = data.get(pointer).toString();
else
result = data.serialize();
} catch (KustvaktException e) {
jlog.error("Exception encountered: " + e.string());
throw kustvaktResponseHandler.throwit(e);
}
return Response.ok(result).build();
}
Aggregations