Search in sources :

Example 41 with NoCache

use of org.jboss.resteasy.annotations.cache.NoCache in project keycloak by keycloak.

the class ClientResource method getClientSecret.

/**
 * Get the client secret
 *
 * @return
 */
@Path("client-secret")
@GET
@NoCache
@Produces(MediaType.APPLICATION_JSON)
public CredentialRepresentation getClientSecret() {
    auth.clients().requireView(client);
    logger.debug("getClientSecret");
    UserCredentialModel model = UserCredentialModel.secret(client.getSecret());
    if (model == null)
        throw new NotFoundException("Client does not have a secret");
    return ModelToRepresentation.toRepresentation(model);
}
Also used : NotFoundException(javax.ws.rs.NotFoundException) UserCredentialModel(org.keycloak.models.UserCredentialModel) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Example 42 with NoCache

use of org.jboss.resteasy.annotations.cache.NoCache in project keycloak by keycloak.

the class ClientResource method getInstallationProvider.

@GET
@NoCache
@Path("installation/providers/{providerId}")
public Response getInstallationProvider(@PathParam("providerId") String providerId) {
    auth.clients().requireView(client);
    ClientInstallationProvider provider = session.getProvider(ClientInstallationProvider.class, providerId);
    if (provider == null)
        throw new NotFoundException("Unknown Provider");
    return provider.generateInstallation(session, realm, client, session.getContext().getUri().getBaseUri());
}
Also used : ClientInstallationProvider(org.keycloak.protocol.ClientInstallationProvider) NotFoundException(javax.ws.rs.NotFoundException) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Example 43 with NoCache

use of org.jboss.resteasy.annotations.cache.NoCache in project keycloak by keycloak.

the class RoleContainerResource method setManagementPermissionsEnabled.

/**
 * Return object stating whether role Authorization permissions have been initialized or not and a reference
 *
 * @param roleName
 * @return initialized manage permissions reference
 */
@Path("{role-name}/management/permissions")
@PUT
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@NoCache
public ManagementPermissionReference setManagementPermissionsEnabled(@PathParam("role-name") final String roleName, ManagementPermissionReference ref) {
    auth.roles().requireManage(roleContainer);
    RoleModel role = roleContainer.getRole(roleName);
    if (role == null) {
        throw new NotFoundException("Could not find role");
    }
    AdminPermissionManagement permissions = AdminPermissions.management(session, realm);
    permissions.roles().setPermissionsEnabled(role, ref.isEnabled());
    if (ref.isEnabled()) {
        return RoleByIdResource.toMgmtRef(role, permissions);
    } else {
        return new ManagementPermissionReference();
    }
}
Also used : NotFoundException(javax.ws.rs.NotFoundException) ManagementPermissionReference(org.keycloak.representations.idm.ManagementPermissionReference) RoleModel(org.keycloak.models.RoleModel) AdminPermissionManagement(org.keycloak.services.resources.admin.permissions.AdminPermissionManagement) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) NoCache(org.jboss.resteasy.annotations.cache.NoCache) PUT(javax.ws.rs.PUT)

Example 44 with NoCache

use of org.jboss.resteasy.annotations.cache.NoCache in project keycloak by keycloak.

the class ClientScopeEvaluateResource method generateExampleAccessToken.

/**
 * Create JSON with payload of example access token
 *
 * @return
 */
@GET
@Path("generate-example-access-token")
@NoCache
@Produces(MediaType.APPLICATION_JSON)
public AccessToken generateExampleAccessToken(@QueryParam("scope") String scopeParam, @QueryParam("userId") String userId) {
    auth.clients().requireView(client);
    UserModel user = getUserModel(userId);
    logger.debugf("generateExampleAccessToken invoked. User: %s, Scope param: %s", user.getUsername(), scopeParam);
    return sessionAware(user, scopeParam, (userSession, clientSessionCtx) -> {
        TokenManager tokenManager = new TokenManager();
        return tokenManager.responseBuilder(realm, client, null, session, userSession, clientSessionCtx).generateAccessToken().getAccessToken();
    });
}
Also used : UserModel(org.keycloak.models.UserModel) TokenManager(org.keycloak.protocol.oidc.TokenManager) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Example 45 with NoCache

use of org.jboss.resteasy.annotations.cache.NoCache in project keycloak by keycloak.

the class ClientScopeEvaluateResource method generateExampleUserinfo.

/**
 * Create JSON with payload of example user info
 *
 * @return
 */
@GET
@Path("generate-example-userinfo")
@NoCache
@Produces(MediaType.APPLICATION_JSON)
public Map<String, Object> generateExampleUserinfo(@QueryParam("scope") String scopeParam, @QueryParam("userId") String userId) {
    auth.clients().requireView(client);
    UserModel user = getUserModel(userId);
    logger.debugf("generateExampleUserinfo invoked. User: %s", user.getUsername());
    return sessionAware(user, scopeParam, (userSession, clientSessionCtx) -> {
        AccessToken userInfo = new AccessToken();
        TokenManager tokenManager = new TokenManager();
        tokenManager.transformUserInfoAccessToken(session, userInfo, userSession, clientSessionCtx);
        return tokenManager.generateUserInfoClaims(userInfo, user);
    });
}
Also used : UserModel(org.keycloak.models.UserModel) AccessToken(org.keycloak.representations.AccessToken) TokenManager(org.keycloak.protocol.oidc.TokenManager) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Aggregations

NoCache (org.jboss.resteasy.annotations.cache.NoCache)152 Path (javax.ws.rs.Path)128 Produces (javax.ws.rs.Produces)100 GET (javax.ws.rs.GET)82 NotFoundException (javax.ws.rs.NotFoundException)67 POST (javax.ws.rs.POST)49 Consumes (javax.ws.rs.Consumes)48 PUT (javax.ws.rs.PUT)24 DELETE (javax.ws.rs.DELETE)23 HashMap (java.util.HashMap)20 RoleModel (org.keycloak.models.RoleModel)18 UserModel (org.keycloak.models.UserModel)18 BadRequestException (javax.ws.rs.BadRequestException)17 Response (javax.ws.rs.core.Response)16 ErrorResponseException (org.keycloak.services.ErrorResponseException)16 ClientModel (org.keycloak.models.ClientModel)15 AuthenticationFlowModel (org.keycloak.models.AuthenticationFlowModel)14 RealmModel (org.keycloak.models.RealmModel)14 List (java.util.List)12 Map (java.util.Map)12