Commit 1944e08e authored by Francesco Chicchiriccò's avatar Francesco Chicchiriccò
Browse files

SecurityContext as enum

parent e126fd55
package eu.chorevolution.rest;
import eu.chorevolution.securityfilter.api.RuntimeInfo;
import eu.chorevolution.securityfilter.api.SecurityContext;
import eu.chorevolution.securityfilter.api.SecurityFilterManagement;
import eu.chorevolution.securityfilter.api.Status;
......@@ -24,7 +25,7 @@ public class SecurityFilterManagementImpl implements SecurityFilterManagement {
public RuntimeInfo info() {
logger.debug("RuntimeInfo");
RuntimeInfo f = new RuntimeInfo();
f.setSecurityContext((String) context.getAttribute("Securitycontext"));
f.setSecurityContext((SecurityContext) context.getAttribute("Securitycontext"));
if (context.getAttribute("Status") != null) {
f.setStatus(Status.valueOf((String) context.getAttribute("Status")));
}
......@@ -33,14 +34,14 @@ public class SecurityFilterManagementImpl implements SecurityFilterManagement {
@Override
public void status(Status status) {
logger.debug("status " + status.toString());
context.setAttribute("Status", status.toString());
logger.debug("status {}", status);
context.setAttribute("Status", status.name());
}
@Override
public void securityContext(String securityContext) {
public void securityContext(SecurityContext securityContext) {
logger.debug("securityContext");
logger.debug(securityContext);
logger.debug("securityContext {}", securityContext);
context.setAttribute("Securitycontext", securityContext);
}
......
......@@ -23,7 +23,7 @@ public class RuntimeInfo implements Serializable {
private Status status;
private String securityContext;
private SecurityContext securityContext;
public Status getStatus() {
return status;
......@@ -33,11 +33,11 @@ public class RuntimeInfo implements Serializable {
this.status = status;
}
public String getSecurityContext() {
public SecurityContext getSecurityContext() {
return securityContext;
}
public void setSecurityContext(final String securityContext) {
public void setSecurityContext(final SecurityContext securityContext) {
this.securityContext = securityContext;
}
......
/*
* Copyright 2015 The CHOReVOLUTION project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package eu.chorevolution.securityfilter.api;
public enum SecurityContext {
AUTHENTICATED_ONLY,
NOT_ENFORCED,
DENY_ACCESS;
}
......@@ -58,5 +58,5 @@ public interface SecurityFilterManagement {
@POST
@Path("securityContext")
@Consumes({ MediaType.APPLICATION_JSON })
void securityContext(String securityContext);
void securityContext(SecurityContext securityContext);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment