Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static UriBuilder realmUrl(UriInfo uriInfo) {
@NoCache
@Produces("application/json")
public PublishedRealmRepresentation getRealm(@PathParam("realm") String id) {
return new Transaction() {
return new Transaction<PublishedRealmRepresentation>() {
protected PublishedRealmRepresentation callImpl() {
return realmRep(realm, uriInfo);
}
Expand All @@ -53,7 +53,7 @@ protected PublishedRealmRepresentation callImpl() {
@Path("html")
@Produces("text/html")
public String getRealmHtml(@PathParam("realm") String id) {
return new Transaction() {
return new Transaction<String>() {
protected String callImpl() {
StringBuffer html = new StringBuffer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static UriBuilder realmBaseUrl(UriInfo uriInfo) {

@Path("{realm}/tokens")
public TokenService getTokenService(final @PathParam("realm") String id) {
return new Transaction(false) {
return new Transaction<TokenService>(false) {
@Override
protected TokenService callImpl() {
RealmManager realmManager = new RealmManager(session);
Expand All @@ -72,7 +72,7 @@ protected TokenService callImpl() {

@Path("{realm}")
public PublicRealmResource getRealmResource(final @PathParam("realm") String id) {
return new Transaction(false) {
return new Transaction<PublicRealmResource>(false) {
@Override
protected PublicRealmResource callImpl() {
RealmManager realmManager = new RealmManager(session);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void setDisplayName(String displayName) {
@NoCache
public Response keepalive(final @Context HttpHeaders headers) {
logger.info("keepalive");
return new Transaction() {
return new Transaction<Response>() {
@Override
public Response callImpl() {
RealmManager realmManager = new RealmManager(session);
Expand All @@ -101,7 +101,7 @@ public Response callImpl() {
@Produces("application/json")
@NoCache
public Response whoAmI(final @Context HttpHeaders headers) {
return new Transaction() {
return new Transaction<Response>() {
@Override
public Response callImpl() {
RealmManager realmManager = new RealmManager(session);
Expand All @@ -122,7 +122,7 @@ public Response callImpl() {
@Produces("application/javascript")
@NoCache
public String isLoggedIn(final @Context HttpHeaders headers) {
return new Transaction() {
return new Transaction<String>() {
@Override
public String callImpl() {
logger.info("WHOAMI Javascript start.");
Expand Down Expand Up @@ -152,7 +152,7 @@ public static UriBuilder saasCookiePath(UriInfo uriInfo) {

@Path("admin/realms")
public RealmsAdminResource getRealmsAdmin(@Context final HttpHeaders headers) {
return new Transaction(false) {
return new Transaction<RealmsAdminResource>(false) {
@Override
protected RealmsAdminResource callImpl() {
RealmManager realmManager = new RealmManager(session);
Expand Down Expand Up @@ -239,7 +239,7 @@ protected void runImpl() {
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response processLogin(final MultivaluedMap<String, String> formData) {
logger.info("processLogin start");
return new Transaction() {
return new Transaction<Response>() {
@Override
protected Response callImpl() {
RealmManager realmManager = new RealmManager(session);
Expand Down Expand Up @@ -283,7 +283,7 @@ protected Response callImpl() {
@POST
@Consumes(MediaType.APPLICATION_JSON)
public Response register(final UserRepresentation newUser) {
return new Transaction() {
return new Transaction<Response>() {
@Override
protected Response callImpl() {
RealmManager realmManager = new RealmManager(session);
Expand All @@ -302,7 +302,7 @@ protected Response callImpl() {
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response processRegister(final MultivaluedMap<String, String> formData) {
return new Transaction() {
return new Transaction<Response>() {
@Override
protected Response callImpl() {
RealmManager realmManager = new RealmManager(session);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public SocialResource(TokenManager tokenManager, SocialRequestManager socialRequ
@GET
@Path("callback")
public Response callback() throws URISyntaxException {
return new Transaction() {
return new Transaction<Response>() {
protected Response callImpl() {
Map<String, String[]> queryParams = getQueryParams();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public static UriBuilder processOAuthUrl(UriInfo uriInfo) {
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.APPLICATION_JSON)
public Response grantIdentityToken(final MultivaluedMap<String, String> form) {
return new Transaction() {
return new Transaction<Response>() {
protected Response callImpl() {
String username = form.getFirst(AuthenticationManager.FORM_USERNAME);
if (username == null) {
Expand Down Expand Up @@ -151,7 +151,7 @@ protected Response callImpl() {
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.APPLICATION_JSON)
public Response grantAccessToken(final MultivaluedMap<String, String> form) {
return new Transaction() {
return new Transaction<Response>() {
protected Response callImpl() {
String username = form.getFirst(AuthenticationManager.FORM_USERNAME);
if (username == null) {
Expand Down Expand Up @@ -185,7 +185,7 @@ protected Response callImpl() {
public Response processLogin(@QueryParam("client_id") final String clientId, @QueryParam("scope") final String scopeParam,
@QueryParam("state") final String state, @QueryParam("redirect_uri") final String redirect,
final MultivaluedMap<String, String> formData) {
return new Transaction() {
return new Transaction<Response>() {
protected Response callImpl() {
OAuthFlows oauth = Flows.oauth(realm, request, uriInfo, authManager, tokenManager);

Expand Down Expand Up @@ -229,7 +229,7 @@ protected Response callImpl() {
public Response processRegister(@QueryParam("client_id") final String clientId,
@QueryParam("scope") final String scopeParam, @QueryParam("state") final String state,
@QueryParam("redirect_uri") final String redirect, final MultivaluedMap<String, String> formData) {
return new Transaction() {
return new Transaction<Response>() {
@Override
protected Response callImpl() {
OAuthFlows oauth = Flows.oauth(realm, request, uriInfo, authManager, tokenManager);
Expand Down Expand Up @@ -310,7 +310,7 @@ protected Response callImpl() {
@POST
@Produces("application/json")
public Response accessCodeToToken(final MultivaluedMap<String, String> formData) {
return new Transaction() {
return new Transaction<Response>() {
protected Response callImpl() {
logger.info("accessRequest <---");
if (!realm.isEnabled()) {
Expand Down Expand Up @@ -438,7 +438,7 @@ protected AccessTokenResponse accessTokenResponse(SkeletonKeyToken token, String
public Response loginPage(final @QueryParam("response_type") String responseType,
final @QueryParam("redirect_uri") String redirect, final @QueryParam("client_id") String clientId,
final @QueryParam("scope") String scopeParam, final @QueryParam("state") String state) {
return new Transaction() {
return new Transaction<Response>() {
protected Response callImpl() {
OAuthFlows oauth = Flows.oauth(realm, request, uriInfo, authManager, tokenManager);

Expand Down Expand Up @@ -486,7 +486,7 @@ protected Response callImpl() {
public Response registerPage(final @QueryParam("response_type") String responseType,
final @QueryParam("redirect_uri") String redirect, final @QueryParam("client_id") String clientId,
final @QueryParam("scope") String scopeParam, final @QueryParam("state") String state) {
return new Transaction() {
return new Transaction<Response>() {
protected Response callImpl() {
OAuthFlows oauth = Flows.oauth(realm, request, uriInfo, authManager, tokenManager);

Expand Down Expand Up @@ -517,7 +517,7 @@ protected Response callImpl() {
@GET
@NoCache
public Response logout(final @QueryParam("redirect_uri") String redirectUri) {
return new Transaction() {
return new Transaction<Response>() {
protected Response callImpl() {
// todo do we care if anybody can trigger this?

Expand All @@ -537,7 +537,7 @@ protected Response callImpl() {
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response processOAuth(final MultivaluedMap<String, String> formData) {
return new Transaction() {
return new Transaction<Response>() {
protected Response callImpl() {
OAuthFlows oauth = Flows.oauth(realm, request, uriInfo, authManager, tokenManager);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @author <a href="mailto:[email protected]">Bill Burke</a>
* @version $Revision: 1 $
*/
public class Transaction {
public class Transaction<T> {
protected KeycloakSession session;
protected KeycloakTransaction transaction;
protected boolean closeSession;
Expand Down Expand Up @@ -83,15 +83,15 @@ public void run() {
}
}

protected <T> T callImpl() {
protected T callImpl() {
return null;
}

/**
* Will not begin or end a transaction or close a session if the transaction was already active when called
*
*/
public <T> T call() {
public T call() {
boolean wasActive = transaction.isActive();
if (!wasActive) transaction.begin();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public ApplicationResource(UserModel admin, RealmModel realm, ApplicationModel a
@PUT
@Consumes(MediaType.APPLICATION_JSON)
public void update(final ApplicationRepresentation rep) {
new Transaction() {
new Transaction<Void>() {
@Override
protected void runImpl() {
ResourceManager resourceManager = new ResourceManager(new RealmManager(session));
Expand All @@ -50,7 +50,7 @@ protected void runImpl() {
@NoCache
@Produces(MediaType.APPLICATION_JSON)
public ApplicationRepresentation getResource(final @PathParam("id") String id) {
return new Transaction() {
return new Transaction<ApplicationRepresentation>() {
@Override
protected ApplicationRepresentation callImpl() {
ResourceManager resourceManager = new ResourceManager(new RealmManager(session));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public ApplicationsResource(UserModel admin, RealmModel realm) {
@Produces(MediaType.APPLICATION_JSON)
@NoCache
public List<ApplicationRepresentation> getResources() {
return new Transaction() {
return new Transaction<List<ApplicationRepresentation>>() {
@Override
protected List<ApplicationRepresentation> callImpl() {
List<ApplicationRepresentation> rep = new ArrayList<ApplicationRepresentation>();
Expand All @@ -59,7 +59,7 @@ protected List<ApplicationRepresentation> callImpl() {
@POST
@Consumes(MediaType.APPLICATION_JSON)
public Response createResource(final @Context UriInfo uriInfo, final ApplicationRepresentation rep) {
return new Transaction() {
return new Transaction<Response>() {
@Override
protected Response callImpl() {
ResourceManager resourceManager = new ResourceManager(new RealmManager(session));
Expand All @@ -71,7 +71,7 @@ protected Response callImpl() {

@Path("{id}")
public ApplicationResource getResource(final @PathParam("id") String id) {
return new Transaction(false) {
return new Transaction<ApplicationResource>(false) {
@Override
protected ApplicationResource callImpl() {
ApplicationModel applicationModel = realm.getApplicationById(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public ApplicationsResource getResources() {
@NoCache
@Produces("application/json")
public RealmRepresentation getRealm() {
return new Transaction() {
return new Transaction<RealmRepresentation>() {
@Override
protected RealmRepresentation callImpl() {
return new RealmManager(session).toRepresentation(realm);
Expand All @@ -63,7 +63,7 @@ protected RealmRepresentation callImpl() {
@NoCache
@Produces("application/json")
public List<RoleRepresentation> getRoles() {
return new Transaction() {
return new Transaction<List<RoleRepresentation>>() {
@Override
protected List<RoleRepresentation> callImpl() {
List<RoleModel> roleModels = realm.getRoles();
Expand Down Expand Up @@ -95,7 +95,7 @@ protected void runImpl() {
@NoCache
@Produces("application/json")
public RoleRepresentation getRole(final @PathParam("id") String id) {
return new Transaction() {
return new Transaction<RoleRepresentation>() {
@Override
protected RoleRepresentation callImpl() {
RoleModel roleModel = realm.getRoleById(id);
Expand Down Expand Up @@ -132,7 +132,7 @@ protected void runImpl() {
@POST
@Consumes("application/json")
public Response createRole(final @Context UriInfo uriInfo, final RoleRepresentation rep) {
return new Transaction() {
return new Transaction<Response>() {
@Override
protected Response callImpl() {
if (realm.getRole(rep.getName()) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public RealmsAdminResource(UserModel admin) {
@NoCache
@Produces("application/json")
public List<RealmRepresentation> getRealms() {
return new Transaction() {
return new Transaction<List<RealmRepresentation>>() {
@Override
protected List<RealmRepresentation> callImpl() {
logger.info(("getRealms()"));
Expand All @@ -81,7 +81,7 @@ public static UriBuilder realmsUrl(UriInfo uriInfo) {
@Consumes("application/json")
public Response importRealm(@Context final UriInfo uriInfo, final RealmRepresentation rep) {
logger.info("importRealm: " + rep.getRealm());
return new Transaction() {
return new Transaction<Response>() {
@Override
protected Response callImpl() {
RealmManager realmManager = new RealmManager(session);
Expand All @@ -96,7 +96,7 @@ protected Response callImpl() {
@Path("{id}")
public RealmAdminResource getRealmAdmin(@Context final HttpHeaders headers,
@PathParam("id") final String id) {
return new Transaction(false) {
return new Transaction<RealmAdminResource>(false) {
@Override
protected RealmAdminResource callImpl() {
RealmManager realmManager = new RealmManager(session);
Expand Down