Search in sources :

Example 71 with RealmModel

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);
}
Also used : RealmModel(org.keycloak.models.RealmModel) AuthenticationFlowModel(org.keycloak.models.AuthenticationFlowModel) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 72 with RealmModel

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();
}
Also used : RealmModel(org.keycloak.models.RealmModel) UserSessionModel(org.keycloak.models.UserSessionModel) NotFoundException(javax.ws.rs.NotFoundException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 73 with RealmModel

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);
}
Also used : RealmModel(org.keycloak.models.RealmModel) UserModel(org.keycloak.models.UserModel) ClientModel(org.keycloak.models.ClientModel) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 74 with RealmModel

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();
}
Also used : RealmModel(org.keycloak.models.RealmModel) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 75 with RealmModel

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();
}
Also used : RealmModel(org.keycloak.models.RealmModel) UserSessionModel(org.keycloak.models.UserSessionModel) NotFoundException(javax.ws.rs.NotFoundException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

RealmModel (org.keycloak.models.RealmModel)591 Test (org.junit.Test)249 UserModel (org.keycloak.models.UserModel)225 KeycloakSession (org.keycloak.models.KeycloakSession)152 ClientModel (org.keycloak.models.ClientModel)149 AbstractTestRealmKeycloakTest (org.keycloak.testsuite.AbstractTestRealmKeycloakTest)90 ModelTest (org.keycloak.testsuite.arquillian.annotation.ModelTest)84 ComponentModel (org.keycloak.component.ComponentModel)83 RoleModel (org.keycloak.models.RoleModel)73 UserSessionModel (org.keycloak.models.UserSessionModel)64 LDAPObject (org.keycloak.storage.ldap.idm.model.LDAPObject)62 List (java.util.List)55 LDAPStorageProvider (org.keycloak.storage.ldap.LDAPStorageProvider)51 GroupModel (org.keycloak.models.GroupModel)47 HashMap (java.util.HashMap)38 Collectors (java.util.stream.Collectors)34 CachedUserModel (org.keycloak.models.cache.CachedUserModel)34 Path (javax.ws.rs.Path)30 AbstractAuthTest (org.keycloak.testsuite.AbstractAuthTest)30 Map (java.util.Map)29