Search in sources :

Example 1 with AuthenticationRule

use of com.google.api.AuthenticationRule in project toolkit by googleapis.

the class ProductServiceConfig method getAuthScopes.

/**
 * Return a list of scopes for authentication.
 */
public List<String> getAuthScopes(Model model) {
    Set<String> result = new TreeSet<>();
    Service config = model.getServiceConfig();
    Authentication auth = config.getAuthentication();
    for (AuthenticationRule rule : auth.getRulesList()) {
        // Scopes form a union and the union is used for down-scoping, so adding more scopes that
        // are subsets of the others already in the union essentially has no effect.
        // We are doing this for implementation simplicity so we don't have to compute which scopes
        // are subsets of the others.
        String scopesString = rule.getOauth().getCanonicalScopes();
        for (String scope : scopesString.split(",")) {
            result.add(scope.trim());
        }
    }
    return new ArrayList<>(result);
}
Also used : TreeSet(java.util.TreeSet) Authentication(com.google.api.Authentication) AuthenticationRule(com.google.api.AuthenticationRule) ArrayList(java.util.ArrayList) Service(com.google.api.Service)

Example 2 with AuthenticationRule

use of com.google.api.AuthenticationRule in project toolkit by googleapis.

the class ProtoApiModel method getAuthScopes.

@Override
public List<String> getAuthScopes() {
    Set<String> result = new TreeSet<>();
    Service config = protoModel.getServiceConfig();
    Authentication auth = config.getAuthentication();
    for (AuthenticationRule rule : auth.getRulesList()) {
        // Scopes form a union and the union is used for down-scoping, so adding more scopes that
        // are subsets of the others already in the union essentially has no effect.
        // We are doing this for implementation simplicity so we don't have to compute which scopes
        // are subsets of the others.
        String scopesString = rule.getOauth().getCanonicalScopes();
        for (String scope : scopesString.split(",")) {
            result.add(scope.trim());
        }
    }
    return new ArrayList<>(result);
}
Also used : TreeSet(java.util.TreeSet) Authentication(com.google.api.Authentication) AuthenticationRule(com.google.api.AuthenticationRule) ArrayList(java.util.ArrayList) Service(com.google.api.Service)

Aggregations

Authentication (com.google.api.Authentication)2 AuthenticationRule (com.google.api.AuthenticationRule)2 Service (com.google.api.Service)2 ArrayList (java.util.ArrayList)2 TreeSet (java.util.TreeSet)2