Java Code Examples for com.microsoft.azure.management.graphrbac.RoleDefinition#permissions()

The following examples show how to use com.microsoft.azure.management.graphrbac.RoleDefinition#permissions() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AzureAadRoleScanner.java    From clouditor with Apache License 2.0 5 votes vote down vote up
@Override
protected Asset transform(RoleDefinition role) throws ScanException {
  var asset = super.transform(role);

  var hasGlobalScope = false;
  var isAdminRole = false;

  for (var scope : role.assignableScopes()) {
    if (scope.equals("/") || scope.contains("subscription")) {
      hasGlobalScope = true;
    }
  }

  if (hasGlobalScope) {
    for (var permission : role.permissions()) {
      for (var action : permission.actions()) {
        if (action.equals("*")) {
          isAdminRole = true;
        }
      }
    }
  }

  asset.setProperty("customAdminRole", isAdminRole);

  return asset;
}
 
Example 2
Source File: Utils.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Print Active Directory User info.
 * @param role role definition
 */
public static void print(RoleDefinition role) {
    StringBuilder builder = new StringBuilder()
            .append("Role Definition: ").append(role.id())
            .append("\n\tName: ").append(role.name())
            .append("\n\tRole Name: ").append(role.roleName())
            .append("\n\tType: ").append(role.type())
            .append("\n\tDescription: ").append(role.description())
            .append("\n\tType: ").append(role.type());

    Set<Permission> permissions = role.permissions();
    builder.append("\n\tPermissions: ").append(permissions.size());
    for (Permission permission : permissions) {
        builder.append("\n\t\tPermission Actions: " + permission.actions().size());
        for (String action : permission.actions()) {
            builder.append("\n\t\t\tName :").append(action);
        }
        builder.append("\n\t\tPermission Not Actions: " + permission.notActions().size());
        for (String notAction : permission.notActions()) {
            builder.append("\n\t\t\tName :").append(notAction);
        }
    }

    Set<String> assignableScopes = role.assignableScopes();
    builder.append("\n\tAssignable scopes: ").append(assignableScopes.size());
    for (String scope : assignableScopes) {
        builder.append("\n\t\tAssignable Scope: ")
                .append("\n\t\t\tName :").append(scope);
    }

    System.out.println(builder.toString());
}