Search in sources :

Example 1 with OptionEntry

use of org.gluu.oxtrust.model.OptionEntry in project oxTrust by GluuFederation.

the class PassportIdpInitiatedAction method editAuthParam.

public void editAuthParam(AuthzParams param) {
    this.options = param.getExtraParams().entrySet().stream().map(e -> new OptionEntry(e.getKey(), e.getValue())).collect(Collectors.toList());
    this.scopes = Stream.of(param.getScopes()).collect(Collectors.toList());
    this.responseTypes = Stream.of(param.getResponseType()).collect(Collectors.toList());
    this.previousParam = param;
    this.authzParam = param;
    this.isEdition = true;
    this.showForm = true;
}
Also used : OptionEntry(org.gluu.oxtrust.model.OptionEntry)

Example 2 with OptionEntry

use of org.gluu.oxtrust.model.OptionEntry 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;
    }
}
Also used : OptionEntry(org.gluu.oxtrust.model.OptionEntry) PassportProvider(org.gluu.oxtrust.model.PassportProvider) Provider(org.gluu.model.passport.Provider)

Example 3 with OptionEntry

use of org.gluu.oxtrust.model.OptionEntry 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;
    }
}
Also used : OptionEntry(org.gluu.oxtrust.model.OptionEntry) PassportProvider(org.gluu.oxtrust.model.PassportProvider) Provider(org.gluu.model.passport.Provider)

Example 4 with OptionEntry

use of org.gluu.oxtrust.model.OptionEntry in project oxTrust by GluuFederation.

the class PassportProvidersAction method update.

public String update() {
    try {
        this.update = true;
        loadProviders();
        for (Provider pro : providers) {
            if (pro.getId().equalsIgnoreCase(id)) {
                this.provider = pro;
                this.optionsKeys = new ArrayList<>(this.provider.getOptions().keySet());
                break;
            }
        }
        this.options = this.provider.getOptions().entrySet().stream().map(e -> new OptionEntry(e.getKey(), e.getValue())).collect(Collectors.toList());
        this.options.sort(Comparator.comparing(OptionEntry::getKey));
        return OxTrustConstants.RESULT_SUCCESS;
    } catch (Exception e) {
        log.debug("", e);
        conversationService.endConversation();
        return OxTrustConstants.RESULT_FAILURE;
    }
}
Also used : OptionEntry(org.gluu.oxtrust.model.OptionEntry) PassportProvider(org.gluu.oxtrust.model.PassportProvider) Provider(org.gluu.model.passport.Provider)

Example 5 with OptionEntry

use of org.gluu.oxtrust.model.OptionEntry in project oxTrust by GluuFederation.

the class PassportProvidersAction method handleRequiredOptions.

public void handleRequiredOptions(ValueChangeEvent e) {
    String type = e.getNewValue().toString();
    if (!this.update && type != null) {
        if (type.equalsIgnoreCase(providerTypes[0])) {
            this.options = new ArrayList<>();
            this.options.add(new OptionEntry("entryPoint", "https://idp.example.com/idp/profile/SAML2/POST/SSO"));
            this.options.add(new OptionEntry("identifierFormat", "urn:oasis:names:tc:SAML:2.0:nameid-format:transient"));
            this.options.add(new OptionEntry("authnRequestBinding", "HTTP-POST"));
            this.options.add(new OptionEntry(ISSUER, DEFAULT_ISSUER));
            this.options.add(new OptionEntry("cert", ""));
        }
        if (type.equalsIgnoreCase(providerTypes[1])) {
            String scopes = "[\"openid\",\"email\",\"profile\"]";
            this.options = new ArrayList<>();
            this.options.add(new OptionEntry("client_id", ""));
            this.options.add(new OptionEntry("client_secret", ""));
            this.options.add(new OptionEntry(ISSUER, "https://server.example.com"));
            this.options.add(new OptionEntry("scope", scopes));
            this.options.add(new OptionEntry("token_endpoint_auth_method", "client_secret_post"));
        }
        if (type.equalsIgnoreCase(providerTypes[2])) {
            this.options = new ArrayList<>();
            this.options.add(new OptionEntry(CLIENT_ID, ""));
            this.options.add(new OptionEntry(CLIENT_SECRET, ""));
            this.options.add(new OptionEntry("oxdID", ""));
            this.options.add(new OptionEntry(ISSUER, "https://server.example.com"));
            this.options.add(new OptionEntry("oxdServer", "https://oxd-server.acme.com:8443"));
        }
        if (type.equalsIgnoreCase(providerTypes[3])) {
            this.options = new ArrayList<>();
            this.options.add(new OptionEntry(CLIENT_ID, ""));
            this.options.add(new OptionEntry(CLIENT_SECRET, ""));
        }
    }
}
Also used : OptionEntry(org.gluu.oxtrust.model.OptionEntry)

Aggregations

OptionEntry (org.gluu.oxtrust.model.OptionEntry)6 Provider (org.gluu.model.passport.Provider)3 PassportProvider (org.gluu.oxtrust.model.PassportProvider)3 AuthzParams (org.gluu.model.passport.idpinitiated.AuthzParams)1