-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
749 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
jans-auth-server/client/src/main/java/io/jans/as/client/ssa/revoke/SsaRevokeClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Janssen Project software is available under the Apache License (2004). See http://www.apache.org/licenses/ for full text. | ||
* | ||
* Copyright (c) 2020, Janssen Project | ||
*/ | ||
|
||
package io.jans.as.client.ssa.revoke; | ||
|
||
import io.jans.as.client.BaseClient; | ||
import io.jans.as.model.config.Constants; | ||
import jakarta.ws.rs.HttpMethod; | ||
import jakarta.ws.rs.client.Invocation.Builder; | ||
import org.apache.commons.lang.StringUtils; | ||
import org.apache.log4j.Logger; | ||
|
||
public class SsaRevokeClient extends BaseClient<SsaRevokeRequest, SsaRevokeResponse> { | ||
|
||
private static final Logger LOG = Logger.getLogger(SsaRevokeClient.class); | ||
|
||
public SsaRevokeClient(String url) { | ||
super(url); | ||
} | ||
|
||
@Override | ||
public String getHttpMethod() { | ||
return HttpMethod.DELETE; | ||
} | ||
|
||
public SsaRevokeResponse execSsaRevoke(String accessToken, String jti, Long orgId) { | ||
SsaRevokeRequest req = new SsaRevokeRequest(); | ||
req.setAccessToken(accessToken); | ||
req.setJti(jti); | ||
req.setOrgId(orgId); | ||
setRequest(req); | ||
return exec(); | ||
} | ||
|
||
public SsaRevokeResponse exec() { | ||
try { | ||
initClient(); | ||
|
||
String uriWithParams = getUrl() + "?" + getRequest().getQueryString(); | ||
Builder clientRequest = resteasyClient.target(uriWithParams).request(); | ||
applyCookies(clientRequest); | ||
|
||
clientRequest.header("Content-Type", request.getContentType()); | ||
if (StringUtils.isNotBlank(request.getAccessToken())) { | ||
clientRequest.header(Constants.AUTHORIZATION, "Bearer ".concat(request.getAccessToken())); | ||
} | ||
|
||
clientResponse = clientRequest.buildDelete().invoke(); | ||
final SsaRevokeResponse res = new SsaRevokeResponse(clientResponse); | ||
setResponse(res); | ||
|
||
} catch (Exception e) { | ||
LOG.error(e.getMessage(), e); | ||
} finally { | ||
closeConnection(); | ||
} | ||
|
||
return getResponse(); | ||
} | ||
} | ||
|
60 changes: 60 additions & 0 deletions
60
jans-auth-server/client/src/main/java/io/jans/as/client/ssa/revoke/SsaRevokeRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Janssen Project software is available under the Apache License (2004). See http://www.apache.org/licenses/ for full text. | ||
* | ||
* Copyright (c) 2020, Janssen Project | ||
*/ | ||
|
||
package io.jans.as.client.ssa.revoke; | ||
|
||
import io.jans.as.client.BaseRequest; | ||
import io.jans.as.model.common.AuthorizationMethod; | ||
import io.jans.as.model.ssa.SsaRequestParam; | ||
import io.jans.as.model.util.QueryBuilder; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
public class SsaRevokeRequest extends BaseRequest { | ||
|
||
private String accessToken; | ||
|
||
private String jti; | ||
|
||
private Long orgId; | ||
|
||
public SsaRevokeRequest() { | ||
setContentType(MediaType.APPLICATION_JSON); | ||
setMediaType(MediaType.APPLICATION_JSON); | ||
setAuthorizationMethod(AuthorizationMethod.AUTHORIZATION_REQUEST_HEADER_FIELD); | ||
} | ||
|
||
public String getAccessToken() { | ||
return accessToken; | ||
} | ||
|
||
public void setAccessToken(String accessToken) { | ||
this.accessToken = accessToken; | ||
} | ||
|
||
public String getJti() { | ||
return jti; | ||
} | ||
|
||
public void setJti(String jti) { | ||
this.jti = jti; | ||
} | ||
|
||
public Long getOrgId() { | ||
return orgId; | ||
} | ||
|
||
public void setOrgId(Long orgId) { | ||
this.orgId = orgId; | ||
} | ||
|
||
@Override | ||
public String getQueryString() { | ||
QueryBuilder builder = QueryBuilder.instance(); | ||
builder.append(SsaRequestParam.JTI.getName(), jti); | ||
builder.append(SsaRequestParam.ORG_ID.getName(), orgId != null ? orgId.toString() : ""); | ||
return builder.toString(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
jans-auth-server/client/src/main/java/io/jans/as/client/ssa/revoke/SsaRevokeResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Janssen Project software is available under the Apache License (2004). See http://www.apache.org/licenses/ for full text. | ||
* | ||
* Copyright (c) 2020, Janssen Project | ||
*/ | ||
|
||
package io.jans.as.client.ssa.revoke; | ||
|
||
import io.jans.as.client.BaseResponseWithErrors; | ||
import io.jans.as.model.ssa.SsaErrorResponseType; | ||
import jakarta.ws.rs.core.Response; | ||
|
||
public class SsaRevokeResponse extends BaseResponseWithErrors<SsaErrorResponseType> { | ||
|
||
public SsaRevokeResponse(Response clientResponse) { | ||
super(clientResponse); | ||
} | ||
|
||
@Override | ||
public SsaErrorResponseType fromString(String p_str) { | ||
return SsaErrorResponseType.fromString(p_str); | ||
} | ||
|
||
@Override | ||
public void injectDataFromJson(String json) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.