use of org.keycloak.models.RealmModel in project keycloak by keycloak.
the class TestingResourceProvider method getResetCredFlow.
@GET
@Path("/get-reset-cred-flow")
@Produces(MediaType.APPLICATION_JSON)
public AuthenticationFlowRepresentation getResetCredFlow(@QueryParam("realmName") String realmName) {
RealmModel realm = getRealmByName(realmName);
AuthenticationFlowModel flow = realm.getResetCredentialsFlow();
if (flow == null)
return null;
return ModelToRepresentation.toRepresentation(realm, flow);
}
use of org.keycloak.models.RealmModel in project keycloak by keycloak.
the class TestingResourceProvider method removeUserSession.
@POST
@Path("/remove-user-session")
@Produces(MediaType.APPLICATION_JSON)
public Response removeUserSession(@QueryParam("realm") final String name, @QueryParam("session") final String sessionId) {
RealmModel realm = getRealmByName(name);
UserSessionModel sessionModel = session.sessions().getUserSession(realm, sessionId);
if (sessionModel == null) {
throw new NotFoundException("Session not found");
}
session.sessions().removeUserSession(realm, sessionModel);
return Response.noContent().build();
}
use of org.keycloak.models.RealmModel in project keycloak by keycloak.
the class TestingResourceProvider method getUserByServiceAccountClient.
@GET
@Path("/get-user-by-service-account-client")
@Produces(MediaType.APPLICATION_JSON)
public UserRepresentation getUserByServiceAccountClient(@QueryParam("realmName") String realmName, @QueryParam("clientId") String clientId) {
RealmModel realm = getRealmByName(realmName);
ClientModel client = realm.getClientByClientId(clientId);
UserModel user = session.users().getServiceAccount(client);
if (user == null)
return null;
return ModelToRepresentation.toRepresentation(session, realm, user);
}
use of org.keycloak.models.RealmModel in project keycloak by keycloak.
the class TestingResourceProvider method removeExpired.
@POST
@Path("/remove-expired")
@Produces(MediaType.APPLICATION_JSON)
public Response removeExpired(@QueryParam("realm") final String name) {
RealmModel realm = getRealmByName(name);
session.sessions().removeExpired(realm);
session.authenticationSessions().removeExpired(realm);
session.realms().removeExpiredClientInitialAccess();
return Response.noContent().build();
}
use of org.keycloak.models.RealmModel in project keycloak by keycloak.
the class TestingResourceProvider method getLastSessionRefresh.
@GET
@Path("/get-last-session-refresh")
@Produces(MediaType.APPLICATION_JSON)
public Integer getLastSessionRefresh(@QueryParam("realm") final String name, @QueryParam("session") final String sessionId, @QueryParam("offline") boolean offline) {
RealmModel realm = getRealmByName(name);
UserSessionModel sessionModel = offline ? session.sessions().getOfflineUserSession(realm, sessionId) : session.sessions().getUserSession(realm, sessionId);
if (sessionModel == null) {
throw new NotFoundException("Session not found");
}
return sessionModel.getLastSessionRefresh();
}
Aggregations