2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
19 import { Injectable } from '@angular/core';
20 import {ArchivaRequestService} from "@app/services/archiva-request.service";
21 import {SecurityConfiguration} from "@app/model/security-configuration";
22 import {Observable, throwError} from "rxjs";
23 import {catchError} from "rxjs/operators";
24 import {HttpErrorResponse, HttpResponse} from "@angular/common/http";
25 import {BeanInformation} from "@app/model/bean-information";
30 export class SecurityService {
32 constructor(private rest:ArchivaRequestService) {
36 getConfiguration() : Observable<SecurityConfiguration> {
37 return this.rest.executeRestCall<SecurityConfiguration>("get", "archiva", "security/config", null).pipe(
38 catchError((error: HttpErrorResponse) => {
39 return throwError(this.rest.getTranslatedErrorResult(error));
44 updateConfiguration(securityConfiguration : SecurityConfiguration) : Observable<HttpResponse<any>> {
45 return this.rest.executeResponseCall<any>("put", "archiva", "security/config", securityConfiguration).pipe(
46 catchError((error: HttpErrorResponse) => {
47 console.log("Error thrown " + typeof (error));
48 return throwError(this.rest.getTranslatedErrorResult(error));
53 getRbacManagers() : Observable<BeanInformation[]> {
54 return this.rest.executeRestCall<BeanInformation[]>("get", "archiva", "security/rbac_managers", null).pipe(
55 catchError((error: HttpErrorResponse) => {
56 return throwError(this.rest.getTranslatedErrorResult(error));
61 getUserManagers() : Observable<BeanInformation[]> {
62 return this.rest.executeRestCall<BeanInformation[]>("get", "archiva", "security/user_managers", null).pipe(
63 catchError((error: HttpErrorResponse) => {
64 return throwError(this.rest.getTranslatedErrorResult(error));