
io.getlime.security.powerauth.rest.api.spring.controller.ServerStatusController Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of powerauth-restful-security-spring Show documentation
Show all versions of powerauth-restful-security-spring Show documentation
PowerAuth 2.0 RESTful API Security Additions for Spring
The newest version!
/*
* PowerAuth integration libraries for RESTful API applications, examples and
* related software components
*
* Copyright (C) 2023 Wultra s.r.o.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
package io.getlime.security.powerauth.rest.api.spring.controller;
import io.getlime.core.rest.model.base.response.ObjectResponse;
import io.getlime.security.powerauth.rest.api.model.response.ServerStatusResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.info.BuildProperties;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
/**
* Controller that provides a user information.
* PowerAuth protocol versions:
*
* - 3.0
* - 3.1
* - 3.2
* - 3.3
*
*
* @author Petr Dvorak, [email protected]
*/
@RestController
@RequestMapping("pa/v3")
@Slf4j
public class ServerStatusController {
private BuildProperties buildProperties;
@Autowired(required = false)
public void setBuildProperties(BuildProperties buildProperties) {
this.buildProperties = buildProperties;
}
/**
* Obtain server status.
* @return Server status.
*/
@PostMapping("status")
public ObjectResponse getServerStatus() {
final long serverTime = new Date().getTime();
final String version;
final String name;
if (buildProperties != null) {
version = buildProperties.getVersion();
name = buildProperties.getName();
} else {
name = "UNKNOWN";
version = "UNKNOWN";
}
final ServerStatusResponse.Application application = new ServerStatusResponse.Application(name, version);
final ServerStatusResponse response = new ServerStatusResponse(serverTime, application);
return new ObjectResponse<>(response);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy