/** * Initialize the handler context and other related services. */ public void init(Map<String, String> handlerProps) throws Exception { this.handlerProps = handlerProps; Constraint constraint = new Constraint(); constraint.setRoles(new String[]{"*"}); constraint.setAuthenticate(true); if (Boolean.parseBoolean(handlerProps.get(Constants.Security.SSL.EXTERNAL_ENABLED))) { constraint.setDataConstraint(Constraint.DC_CONFIDENTIAL); } ConstraintMapping constraintMapping = new ConstraintMapping(); constraintMapping.setConstraint(constraint); constraintMapping.setPathSpec("/*"); this.setConstraintMappings(new ConstraintMapping[]{constraintMapping}); this.setStrict(false); this.setIdentityService(getHandlerIdentityService()); this.setAuthenticator(getHandlerAuthenticator()); this.setLoginService(getHandlerLoginService()); this.doStart(); }
/** * Initializes the handlers. */ private void initHandlers() throws Exception { Map<String, String> handlerProps = new HashMap<>(); // used by CertificateAuthenticationHandler (see CDAP-7287) copyPropIfExists(handlerProps, cConfiguration, "security.auth.server.ssl.truststore.path"); copyPropIfExists(handlerProps, cConfiguration, "security.auth.server.ssl.truststore.type"); copyPropIfExists(handlerProps, cConfiguration, "security.auth.server.ssl.truststore.password"); // used by AbstractAuthenticationHandler copyPropIfExists(handlerProps, cConfiguration, Constants.Security.SSL.EXTERNAL_ENABLED); // used by BasicAuthenticationHandler copyPropIfExists(handlerProps, cConfiguration, Constants.Security.BASIC_REALM_FILE); // used by BJASPIAuthenticationHandler copyPropIfExists(handlerProps, cConfiguration, Constants.Security.LOGIN_MODULE_CLASS_NAME); copyProps(handlerProps, getAuthHandlerConfigs(cConfiguration)); copyProps(handlerProps, getAuthHandlerConfigs(sConfiguration)); authenticationHandler.init(handlerProps); grantAccessToken.init(); }