All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.hawkbit.mgmt.rest.resource.MgmtBasicAuthResource Maven / Gradle / Ivy

There is a newer version: 0.5.0
Show newest version
/**
 * Copyright (c) 2021 Bosch.IO GmbH and others
 *
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 */
package org.eclipse.hawkbit.mgmt.rest.resource;

import org.eclipse.hawkbit.mgmt.json.model.auth.MgmtUserInfo;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtBasicAuthRestApi;
import org.eclipse.hawkbit.tenancy.TenantAware;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;

/**
 * REST Resource handling basic auth validation.
 */
@RestController
public class MgmtBasicAuthResource implements MgmtBasicAuthRestApi {

    private final TenantAware tenantAware;

    /**
     * Default constructor
     *
     * @param tenantAware
     *          tenantAware
     */
    public MgmtBasicAuthResource(TenantAware tenantAware) {
        this.tenantAware = tenantAware;
    }

    @Override
    public ResponseEntity validateBasicAuth() {
        MgmtUserInfo userInfo = new MgmtUserInfo();
        userInfo.setUsername(tenantAware.getCurrentUsername());
        userInfo.setTenant(tenantAware.getCurrentTenant());
        return ResponseEntity.ok(userInfo);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy