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
@@ -1,10 +1,8 @@
package com.auth0.client.mgmt;

import com.auth0.client.auth.AuthAPI;
import com.auth0.client.mgmt.filter.PageBasedPaginationFilter;
import com.auth0.json.mgmt.selfserviceprofiles.SelfServiceProfile;
import com.auth0.json.mgmt.selfserviceprofiles.SelfServiceProfileResponse;
import com.auth0.json.mgmt.selfserviceprofiles.SelfServiceProfileResponsePage;
import com.auth0.json.mgmt.selfserviceprofiles.SsoAccessTicketResponse;
import com.auth0.json.mgmt.selfserviceprofiles.*;
import com.auth0.net.*;
import com.auth0.net.client.Auth0HttpClient;
import com.auth0.net.client.HttpMethod;
Expand Down Expand Up @@ -187,14 +185,43 @@ public Request<Object> setCustomText(String id, String language, String page, Ob
return request;
}

/**
* Create a new SSO access ticket.
* A token with {@code create:sso_access_tickets} scope is needed
* @see <a href="https://auth0.com/docs/api/management/v2#!/self-service-profiles/post-sso-ticket">https://auth0.com/docs/api/management/v2#!/self-service-profiles/post-sso-ticket</a>
* @param id the self-service profile ID.
* @param requestBody the payload.
* @return a Request to execute.
*/
public Request<SsoAccessTicketResponse> createSsoAccessTicket(String id, SsoAccessTicketRequest requestBody) {
Asserts.assertNotNull(id, "id");
Asserts.assertNotNull(requestBody, "request body");

HttpUrl.Builder builder = baseUrl.newBuilder()
.addPathSegments(ORGS_PATH)
.addPathSegment(id)
.addPathSegment("sso-ticket");

String url = builder.build().toString();

BaseRequest<SsoAccessTicketResponse> request = new BaseRequest<>(this.client, tokenProvider, url, HttpMethod.POST, new TypeReference<SsoAccessTicketResponse>() {
});
request.setBody(requestBody);
return request;
}


/**
* Create a new SSO access ticket.
* A token with {@code create:sso_access_tickets} scope is needed
* @see <a href="https://auth0.com/docs/api/management/v2#!/self-service-profiles/post-sso-ticket">https://auth0.com/docs/api/management/v2#!/self-service-profiles/post-sso-ticket</a>
* @param id the self-service profile ID.
* @param payload the payload.
* @return a Request to execute.
*
* @deprecated Use {@link #createSsoAccessTicket(String, SsoAccessTicketRequest)} to create sso access ticket.
*/
@Deprecated
public Request<SsoAccessTicketResponse> createSsoAccessTicket(String id, Object payload) {
Asserts.assertNotNull(id, "id");
Asserts.assertNotNull(payload, "payload");
Expand All @@ -203,7 +230,6 @@ public Request<SsoAccessTicketResponse> createSsoAccessTicket(String id, Object
.addPathSegments(ORGS_PATH)
.addPathSegment(id)
.addPathSegment("sso-ticket");

String url = builder.build().toString();

BaseRequest<SsoAccessTicketResponse> request = new BaseRequest<>(this.client, tokenProvider, url, HttpMethod.POST, new TypeReference<SsoAccessTicketResponse>() {
Expand Down
38 changes: 38 additions & 0 deletions src/main/java/com/auth0/json/mgmt/connections/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public class Connection {
private Map<String, String> metadata;
@JsonProperty("realms")
private List<String> realms;
@JsonProperty("show_as_button")
private boolean showAsButton;
@JsonProperty("is_domain_connection")
private boolean isDomainConnection;

public Connection() {
}
Expand Down Expand Up @@ -183,4 +187,38 @@ public List<String> getRealms() {
public void setRealms(List<String> realms) {
this.realms = realms;
}

/**
* Getter for the show as button flag.
*
* @return the show as button flag.
*/
public boolean isShowAsButton() {
return showAsButton;
}

/**
* Setter for the show as button flag.
*
* @param showAsButton the show as button flag to set.
*/
public void setShowAsButton(boolean showAsButton) {
this.showAsButton = showAsButton;
}

/**
* Getter for the domain connection flag.
* @return the domain connection flag.
*/
public boolean isDomainConnection() {
return isDomainConnection;
}

/**
* Setter for the domain connection flag.
* @param domainConnection the domain connection flag to set.
*/
public void setDomainConnection(boolean domainConnection) {
isDomainConnection = domainConnection;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.auth0.json.mgmt.selfserviceprofiles;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class DomainAliasesConfig {
@JsonProperty("domain_verification")
private String domainVerification;

/**
* Creates a new instance of the DomainAliasesConfig class.
*/
@JsonCreator
public DomainAliasesConfig(@JsonProperty("domain_verification") String domainVerification) {
this.domainVerification = domainVerification;
}

/**
* Getter for the domain verification.
* @return the domain verification.
*/
public String getDomainVerification() {
return domainVerification;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.auth0.json.mgmt.selfserviceprofiles;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class EnabledOrganizations {
@JsonProperty("organization_id")
private String organizationId;
@JsonProperty("assign_membership_on_login")
private boolean assignMembershipOnLogin;
@JsonProperty("show_as_button")
private boolean showAsButton;

/**
* Getter for the organization id.
* @return the organization id.
*/
public String getOrganizationId() {
return organizationId;
}

/**
* Setter for the organization id.
* @param organizationId the organization id to set.
*/
public void setOrganizationId(String organizationId) {
this.organizationId = organizationId;
}

/**
* Getter for the assign membership on login.
* @return the assign membership on login.
*/
public boolean isAssignMembershipOnLogin() {
return assignMembershipOnLogin;
}

/**
* Setter for the assign membership on login.
* @param assignMembershipOnLogin the assign membership on login to set.
*/
public void setAssignMembershipOnLogin(boolean assignMembershipOnLogin) {
this.assignMembershipOnLogin = assignMembershipOnLogin;
}

/**
* Getter for the show as button.
* @return the show as button.
*/
public boolean isShowAsButton() {
return showAsButton;
}

/**
* Setter for the show as button.
* @param showAsButton the show as button to set.
*/
public void setShowAsButton(boolean showAsButton) {
this.showAsButton = showAsButton;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package com.auth0.json.mgmt.selfserviceprofiles;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;
import java.util.Map;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class SsoAccessTicketRequest {
@JsonProperty("connection_id")
private String connectionId;
@JsonProperty("connection_config")
private Map<String, Object> connectionConfig;
@JsonProperty("enabled_clients")
private List<String> enabledClients;
@JsonProperty("enabled_organizations")
private List<EnabledOrganizations> enabledOrganizations;
@JsonProperty("ttl_sec")
private int ttlSec;
@JsonProperty("domain_aliases_config")
private DomainAliasesConfig domainAliasesConfig;

/**
* Creates a new instance.
* @return the new instance.
*/
public String getConnectionId() {
return connectionId;
}

/**
* Sets the connection ID.
* @param connectionId the connection ID to set.
*/
public void setConnectionId(String connectionId) {
this.connectionId = connectionId;
}

/**
* Getter for the connection configuration.
* @return the connection configuration.
*/
public Map<String, Object> getConnectionConfig() {
return connectionConfig;
}

/**
* Setter for the connection configuration.
* @param connectionConfig the connection configuration to set.
*/
public void setConnectionConfig(Map<String, Object> connectionConfig) {
this.connectionConfig = connectionConfig;
}

/**
* Getter for the enabled clients.
* @return the enabled clients.
*/
public List<String> getEnabledClients() {
return enabledClients;
}

/**
* Setter for the enabled clients.
* @param enabledClients the enabled clients to set.
*/
public void setEnabledClients(List<String> enabledClients) {
this.enabledClients = enabledClients;
}

/**
* Getter for the enabled organizations.
* @return the enabled organizations.
*/
public List<EnabledOrganizations> getEnabledOrganizations() {
return enabledOrganizations;
}

/**
* Setter for the enabled organizations.
* @param enabledOrganizations the enabled organizations to set.
*/
public void setEnabledOrganizations(List<EnabledOrganizations> enabledOrganizations) {
this.enabledOrganizations = enabledOrganizations;
}

/**
* Getter for the TTL in seconds.
* @return the TTL in seconds.
*/
public int getTtlSec() {
return ttlSec;
}

/**
* Setter for the TTL in seconds.
* @param ttlSec the TTL in seconds to set.
*/
public void setTtlSec(int ttlSec) {
this.ttlSec = ttlSec;
}

/**
* Getter for the domain aliases configuration.
* @return the domain aliases configuration.
*/
public DomainAliasesConfig getDomainAliasesConfig() {
return domainAliasesConfig;
}

/**
* Setter for the domain aliases configuration.
* @param domainAliasesConfig the domain aliases configuration to set.
*/
public void setDomainAliasesConfig(DomainAliasesConfig domainAliasesConfig) {
this.domainAliasesConfig = domainAliasesConfig;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public void shouldCreateConnection() throws Exception {
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));

Map<String, Object> body = bodyFromRequest(recordedRequest);
assertThat(body.size(), is(2));
assertThat(body.size(), is(5));
assertThat(body, hasEntry("name", "my-connection"));
assertThat(body, hasEntry("strategy", "auth0"));

Expand Down Expand Up @@ -244,7 +244,7 @@ public void shouldUpdateConnection() throws Exception {
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));

Map<String, Object> body = bodyFromRequest(recordedRequest);
assertThat(body.size(), is(2));
assertThat(body.size(), is(5));
assertThat(body, hasEntry("name", "my-connection"));
assertThat(body, hasEntry("strategy", "auth0"));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.auth0.client.mgmt;

import com.auth0.client.mgmt.filter.PageBasedPaginationFilter;
import com.auth0.json.mgmt.selfserviceprofiles.SelfServiceProfile;
import com.auth0.json.mgmt.selfserviceprofiles.SelfServiceProfileResponse;
import com.auth0.json.mgmt.selfserviceprofiles.SelfServiceProfileResponsePage;
import com.auth0.json.mgmt.selfserviceprofiles.SsoAccessTicketResponse;
import com.auth0.json.mgmt.selfserviceprofiles.*;
import com.auth0.net.Request;
import com.auth0.net.client.HttpMethod;
import okhttp3.mockwebserver.RecordedRequest;
Expand Down Expand Up @@ -268,22 +265,21 @@ public void shouldSetCustomText() throws Exception {
@Test
public void shouldThrowOnCreateSsoAccessTicketWhenIdIsNull() {
verifyThrows(IllegalArgumentException.class,
() -> api.selfServiceProfiles().createSsoAccessTicket(null, new Object()), "'id' cannot be null!");
() -> api.selfServiceProfiles().createSsoAccessTicket(null, new SsoAccessTicketRequest()), "'id' cannot be null!");
}

@Test
public void shouldThrowOnCreateSsoAccessTicketWhenPayloadIsNull() {
verifyThrows(IllegalArgumentException.class,
() -> api.selfServiceProfiles().createSsoAccessTicket("id", null), "'payload' cannot be null!");
() -> api.selfServiceProfiles().createSsoAccessTicket("id", null), "'request body' cannot be null!");
}

@Test
public void shouldCreateSsoAccessTicket() throws Exception{
Map<String, Object> payload = new HashMap<>();
SsoAccessTicketRequest requestBody = new SsoAccessTicketRequest();
requestBody.setConnectionId("test-connection");

payload.put("connection_id", "test-connection");

Request<SsoAccessTicketResponse> request = api.selfServiceProfiles().createSsoAccessTicket("id", payload);
Request<SsoAccessTicketResponse> request = api.selfServiceProfiles().createSsoAccessTicket("id", requestBody);
assertThat(request, is(notNullValue()));

server.jsonResponse(SELF_SERVICE_PROFILE_SSO_TICKET, 200);
Expand Down
Loading
Loading