use of org.gluu.model.passport.Provider in project oxTrust by GluuFederation.
the class PassportProviderWebResourceTest method getProvider.
private Provider getProvider(String name) {
Provider provider = new Provider();
provider.setEmailLinkingSafe(true);
provider.setEnabled(false);
provider.setOptions(new HashMap<>());
provider.setDisplayName(name);
provider.setPassportStrategyId("passport-saml");
provider.setType("saml");
provider.setMapping("saml_ldap_profile");
provider.setRequestForEmail(true);
return provider;
}
use of org.gluu.model.passport.Provider in project oxTrust by GluuFederation.
the class PassportProvidersAction method save.
public String save() {
try {
if (this.provider.getLogoImg().isEmpty()) {
this.provider.setLogoImg(null);
}
if (this.provider.getPassportAuthnParams().isEmpty()) {
this.provider.setPassportAuthnParams(null);
}
if (providerIdContainsBadCharacters()) {
facesMessages.add(FacesMessage.SEVERITY_ERROR, "This provider id contains unauthorized characters.");
return OxTrustConstants.RESULT_FAILURE;
}
if (!update) {
if (providerIdIsInUse()) {
facesMessages.add(FacesMessage.SEVERITY_ERROR, "This provider id is already in use. Please provide a new one.");
return OxTrustConstants.RESULT_FAILURE;
}
setCallbackUrl();
this.id = this.provider.getId();
this.provider.setOptions(options.stream().filter(e -> e.getKey() != null).collect(Collectors.toMap(OptionEntry::getKey, OptionEntry::getValue)));
loadProviders();
this.providers.add(provider);
} else {
this.provider.setOptions(options.stream().filter(e -> e.getKey() != null).collect(Collectors.toMap(OptionEntry::getKey, OptionEntry::getValue)));
loadProviders();
for (Provider pro : this.providers) {
if (pro.getId().equalsIgnoreCase(this.provider.getId())) {
this.providers.remove(pro);
this.providers.add(provider);
break;
}
}
}
performSave();
if (!update) {
facesMessages.add(FacesMessage.SEVERITY_INFO, "Provider '#{passportProvidersAction.provider.displayName}' added successfully");
conversationService.endConversation();
return OxTrustConstants.RESULT_SUCCESS;
} else {
facesMessages.add(FacesMessage.SEVERITY_INFO, "Provider '#{passportProvidersAction.provider.displayName}' updated successfully");
conversationService.endConversation();
return OxTrustConstants.RESULT_CONFIRM;
}
} catch (Exception e) {
log.debug("", e);
conversationService.endConversation();
return OxTrustConstants.RESULT_FAILURE;
}
}
use of org.gluu.model.passport.Provider in project oxTrust by GluuFederation.
the class PassportProvidersAction method add.
public String add() {
try {
loadProviders();
this.update = false;
this.provider = new Provider();
this.provider.setOptions(new HashMap<>());
this.options = this.provider.getOptions().entrySet().stream().map(e -> new OptionEntry(e.getKey(), e.getValue())).collect(Collectors.toList());
return OxTrustConstants.RESULT_SUCCESS;
} catch (Exception e) {
log.debug("", e);
conversationService.endConversation();
return OxTrustConstants.RESULT_FAILURE;
}
}
use of org.gluu.model.passport.Provider in project oxTrust by GluuFederation.
the class PassportProviderWebResource method updatePassportProvider.
@PUT
@Operation(summary = "Update passport provider", description = "Update passport provider")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Provider.class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response updatePassportProvider(Provider provider) {
String id = provider.getId();
id = id.equalsIgnoreCase("") ? null : id;
log(logger, "Update passport provider " + id);
try {
Objects.requireNonNull(id, "id should not be null");
this.ldapOxPassportConfiguration = passportService.loadConfigurationFromLdap();
this.passportConfiguration = this.ldapOxPassportConfiguration.getPassportConfiguration();
List<Provider> providers = new ArrayList<>();
providers.addAll(this.passportConfiguration.getProviders());
Provider existingProvider = getExistingProvider(providers, id);
if (existingProvider != null) {
providers.remove(existingProvider);
providers.add(provider);
this.passportConfiguration.setProviders(providers);
this.ldapOxPassportConfiguration.setPassportConfiguration(this.passportConfiguration);
this.passportService.updateLdapOxPassportConfiguration(this.ldapOxPassportConfiguration);
return Response.ok(provider).build();
} else {
return Response.status(Response.Status.NOT_FOUND).build();
}
} catch (Exception e) {
log(logger, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
use of org.gluu.model.passport.Provider in project oxTrust by GluuFederation.
the class PassportProviderWebResource method getProviderById.
@GET
@Path(ApiConstants.ID_PARAM_PATH)
@Operation(summary = "Get passport provider by id", description = "Get passport provider by id")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Provider.class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { READ_ACCESS })
public Response getProviderById(@PathParam(ApiConstants.ID) @NotNull String id) {
log(logger, "Get group having group" + id);
id = id.equalsIgnoreCase("") ? null : id;
try {
Objects.requireNonNull(id, "inum should not be null");
this.ldapOxPassportConfiguration = passportService.loadConfigurationFromLdap();
this.passportConfiguration = this.ldapOxPassportConfiguration.getPassportConfiguration();
List<Provider> providers = new ArrayList<>();
providers.addAll(this.passportConfiguration.getProviders());
Provider existingProvider = getExistingProvider(providers, id);
if (existingProvider != null) {
return Response.ok(existingProvider).build();
} else {
return Response.status(Response.Status.NOT_FOUND).build();
}
} catch (Exception e) {
log(logger, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
Aggregations