csip.PropertyTokenAuthentication Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of csip-core Show documentation
Show all versions of csip-core Show documentation
The Cloud Services Integration Platform is a SoA implementation to offer a Model-as-a-Service framework, Application Programming Interface, deployment infrastructure, and service implementations for environmental modeling.
/*
* $Id: PropertyTokenAuthentication.java 379f181a6dac 2020-07-14 od $
*
* This file is part of the Cloud Services Integration Platform (CSIP),
* a Model-as-a-Service framework, API and application suite.
*
* 2012-2020, Olaf David and others, OMSLab, Colorado State University.
*
* OMSLab licenses this file to you under the MIT license.
* See the LICENSE file in the project root for more information.
*/
package csip;
import java.util.Arrays;
import java.util.List;
/** PropertyTokenAuthentication
*
* config (as json):
*
* ...
* "csip.token.authentication" : "property",
* "csip.auth.tokens": "token1, token1"
* ...
*
*
* @author od
*/
class PropertyTokenAuthentication implements TokenAuthentication {
List tokens;
PropertyTokenAuthentication(String t) {
if (t == null) {
throw new RuntimeException("Missing configuration: 'csip.auth.tokens'");
}
tokens = Arrays.asList(t.split("\\s*,\\s*"));
}
@Override
public void validate(String token) throws SecurityException {
if (token != null && !token.isEmpty() && tokens.contains(token)) {
return;
}
throw new SecurityException("Invalid or missing Authentication token '" + token + "'");
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy