Search in sources :

Example 16 with Scope

use of org.oxauth.persistence.model.Scope in project oxTrust by GluuFederation.

the class UmaScopeWebResourceTest method getUmaScope.

private Scope getUmaScope(String name) {
    Scope scope = new Scope();
    scope.setDescription(name + " description");
    scope.setDisplayName(name);
    scope.setIconUrl("https://api.gluu.org/icon/jl25");
    scope.setId(UUID.randomUUID().toString());
    scope.setUmaAuthorizationPolicies(new ArrayList<>());
    return scope;
}
Also used : Scope(org.oxauth.persistence.model.Scope)

Example 17 with Scope

use of org.oxauth.persistence.model.Scope in project oxTrust by GluuFederation.

the class UpdateClientAction method updateScopes.

private void updateScopes() {
    List<Scope> currentResponseTypes = this.scopes;
    if (currentResponseTypes == null || currentResponseTypes.size() == 0) {
        this.client.setOxAuthScopes(null);
        return;
    }
    List<String> scopes = new ArrayList<String>();
    for (Scope scope : this.scopes) {
        scopes.add(scope.getDn());
    }
    this.client.setOxAuthScopes(scopes);
}
Also used : Scope(org.oxauth.persistence.model.Scope) ArrayList(java.util.ArrayList)

Example 18 with Scope

use of org.oxauth.persistence.model.Scope in project oxTrust by GluuFederation.

the class UpdateClientAction method getMarkDown.

public String getMarkDown() {
    try {
        StringBuilder sb = new StringBuilder();
        sb.append(new Heading("OPENID CONNECT CLIENTS DETAILS", 2)).append("\n");
        List<Object> items = new ArrayList<Object>();
        if (client.getDisplayName() != null && !client.getDisplayName().isEmpty()) {
            items.add("**Name:** " + client.getDisplayName());
        }
        if (client.getDescription() != null && !client.getDescription().isEmpty()) {
            items.add("**Description:** " + client.getDescription());
        }
        if (client.getInum() != null && !client.getInum().isEmpty()) {
            items.add("**Client ID:** " + client.getInum());
        }
        if (client.getSubjectType() != null && !client.getSubjectType().name().isEmpty()) {
            items.add("**Subject Type:** " + client.getSubjectType());
        }
        if (client.getExp() != null && !client.getExp().toString().isEmpty()) {
            items.add("**Expirattion date:** " + client.getExp());
        }
        if (client.getOxAuthClientSecret() != null && !client.getOxAuthClientSecret().toString().isEmpty()) {
            items.add("**ClientSecret:** XXXXXXXXXXX");
        }
        if (client.getClientUri() != null && !client.getClientUri().toString().isEmpty()) {
            items.add("**Client Uri:** " + client.getClientUri());
        }
        if (client.getIdTokenTokenBindingCnf() != null && !client.getIdTokenTokenBindingCnf().toString().isEmpty()) {
            items.add("**TokenTokenBindingCnf:** " + client.getIdTokenTokenBindingCnf());
        }
        if (client.getOxAuthAppType() != null) {
            items.add("**Application Type:** " + client.getOxAuthAppType().getValue());
        }
        items.add("**Persist Client Authorizations:** " + client.getOxAuthPersistClientAuthorizations());
        items.add("**Pre-Authorization:** " + client.getOxAuthTrustedClient());
        items.add("**Authentication method for the Token Endpoint:** " + client.getTokenEndpointAuthMethod());
        items.add("**Logout Session Required:** " + client.getLogoutSessionRequired());
        items.add("**Include Claims In Id Token:** " + client.getOxIncludeClaimsInIdToken());
        items.add("**Disabled:** " + client.isDisabled());
        if (client.getLogoutUri() != null && !client.getLogoutUri().isEmpty()) {
            items.add("**Logout Uri:** " + client.getLogoutUri().toString());
        }
        if (client.getOxAuthPostLogoutRedirectURIs() != null && !client.getOxAuthPostLogoutRedirectURIs().isEmpty()) {
            items.add("**Logout Redirect URIs:** " + client.getOxAuthPostLogoutRedirectURIs().toString());
        }
        if (client.getOxAuthRedirectURIs() != null && !client.getOxAuthRedirectURIs().isEmpty()) {
            items.add("**Login Redirect URIs:** " + client.getOxAuthRedirectURIs().toString());
        }
        if (client.getOxAuthClaims() != null && !client.getOxAuthClaims().isEmpty()) {
            items.add("**Claims:** " + client.getOxAuthClaims().toString());
        }
        if (client.getAccessTokenSigningAlg() != null && !client.getAccessTokenSigningAlg().name().isEmpty()) {
            items.add("**AccessTokenSigningAlg:** " + client.getAccessTokenSigningAlg().name().toString());
        }
        if (client.getOxAuthScopes() != null && !client.getOxAuthScopes().isEmpty()) {
            List<String> scopes = new ArrayList<String>();
            for (Scope scope : this.scopes) {
                scopes.add(scope.getId());
            }
            items.add("**Scopes:** " + scopes.toString());
        }
        if (client.getGrantTypes() != null && client.getGrantTypes().length > 0) {
            items.add("**Grant types:** " + this.grantTypes.toString());
        }
        if (client.getResponseTypes() != null && client.getResponseTypes().length > 0) {
            items.add("**Response types:** " + this.responseTypes.toString());
        }
        if (client.getContacts() != null && !client.getContacts().toString().isEmpty()) {
            items.add("**Contacts:** " + this.contacts.toString());
        }
        if (client.getDefaultAcrValues() != null && client.getDefaultAcrValues().length > 0) {
            items.add("**DefaultAcrValues:** " + Arrays.asList(client.getDefaultAcrValues()).toString());
        }
        sb.append(new UnorderedList<Object>(items)).append("\n");
        markDown = sb.toString();
    } catch (Exception e) {
        log.error("Error computing markdown", e);
    }
    return markDown;
}
Also used : Heading(net.steppschuh.markdowngenerator.text.heading.Heading) Scope(org.oxauth.persistence.model.Scope) ArrayList(java.util.ArrayList) UnorderedList(net.steppschuh.markdowngenerator.list.UnorderedList) EncryptionException(org.gluu.util.security.StringEncrypter.EncryptionException) BasePersistenceException(org.gluu.persist.exception.BasePersistenceException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) JSONException(org.codehaus.jettison.json.JSONException)

Example 19 with Scope

use of org.oxauth.persistence.model.Scope in project oxTrust by GluuFederation.

the class UpdateGluuRadiusConfigAction method searchAvailableScopes.

public void searchAvailableScopes() {
    if (this.availableScopes != null) {
        selectAddedScopes();
        return;
    }
    List<SelectableEntity<Scope>> tmpAvailableScopes = new ArrayList<SelectableEntity<Scope>>();
    List<Scope> scopes = new ArrayList<Scope>();
    try {
        scopes = scopeService.getAllScopesList(100);
    } catch (Exception e) {
        log.warn(e.getMessage(), e);
    }
    for (Scope scope : scopes) tmpAvailableScopes.add(new SelectableEntity<Scope>(scope));
    this.availableScopes = tmpAvailableScopes;
    selectAddedScopes();
}
Also used : Scope(org.oxauth.persistence.model.Scope) SelectableEntity(org.gluu.model.SelectableEntity) ArrayList(java.util.ArrayList)

Example 20 with Scope

use of org.oxauth.persistence.model.Scope in project oxTrust by GluuFederation.

the class UpdateGluuRadiusConfigAction method save.

public String save() {
    List<String> scopednlist = new ArrayList<String>();
    for (Scope scope : this.scopes) {
        scopednlist.add(scope.getDn());
    }
    serverConfiguration.setScopes(scopednlist);
    try {
        gluuRadiusConfigService.updateServerConfiguration(serverConfiguration);
        facesMessages.add(FacesMessage.SEVERITY_INFO, "#{msgs['radius.config.save.success']}");
        conversationService.endConversation();
        return OxTrustConstants.RESULT_SUCCESS;
    } catch (Exception e) {
        log.error("Failed to save radius server configuration", e);
        facesMessages.add(FacesMessage.SEVERITY_ERROR, "#{msgs['radius.config.save.error']}");
        return OxTrustConstants.RESULT_FAILURE;
    }
}
Also used : Scope(org.oxauth.persistence.model.Scope) ArrayList(java.util.ArrayList)

Aggregations

Scope (org.oxauth.persistence.model.Scope)63 ArrayList (java.util.ArrayList)15 IOException (java.io.IOException)12 Operation (io.swagger.v3.oas.annotations.Operation)10 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)10 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)9 HttpEntity (org.apache.http.HttpEntity)8 HttpResponse (org.apache.http.HttpResponse)8 ParseException (org.apache.http.ParseException)8 GluuAttribute (org.gluu.model.GluuAttribute)8 Test (org.junit.Test)8 User (org.gluu.oxauth.model.common.User)7 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 Test (org.testng.annotations.Test)7 BasePersistenceException (org.gluu.persist.exception.BasePersistenceException)5 HttpGet (org.apache.http.client.methods.HttpGet)4 HttpPost (org.apache.http.client.methods.HttpPost)4 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)4 ByteArrayEntity (org.apache.http.entity.ByteArrayEntity)4 Filter (org.gluu.search.filter.Filter)4