use of com.sun.enterprise.web.session.SessionCookieConfig in project Payara by payara.
the class DynamicWebServletRegistrationImpl method configureCookieProperties.
/**
* Configure the settings for the session cookie using the values
* in sun-web.xml's cookie-property
*/
private void configureCookieProperties(CookieProperties bean) {
if (bean != null) {
WebProperty[] props = bean.getWebProperty();
if (props != null) {
SessionCookieConfig cookieConfig = new SessionCookieConfig();
for (WebProperty prop : props) {
String name = prop.getAttributeValue(WebProperty.NAME);
String value = prop.getAttributeValue(WebProperty.VALUE);
if (name == null || value == null) {
throw new IllegalArgumentException(rb.getString(LogFacade.NULL_WEB_MODULE_PROPERTY));
}
if ("cookieName".equalsIgnoreCase(name)) {
cookieConfig.setName(value);
} else if ("cookiePath".equalsIgnoreCase(name)) {
cookieConfig.setPath(value);
} else if ("cookieMaxAgeSeconds".equalsIgnoreCase(name)) {
try {
cookieConfig.setMaxAge(Integer.parseInt(value));
} catch (NumberFormatException e) {
// XXX need error message
}
} else if ("cookieDomain".equalsIgnoreCase(name)) {
cookieConfig.setDomain(value);
} else if ("cookieComment".equalsIgnoreCase(name)) {
cookieConfig.setComment(value);
} else if ("cookieSecure".equalsIgnoreCase(name)) {
cookieConfig.setSecure(value);
} else if ("cookieHttpOnly".equalsIgnoreCase(name)) {
cookieConfig.setHttpOnly(Boolean.valueOf(value));
} else {
Object[] params = { name, value };
logger.log(Level.WARNING, LogFacade.INVALID_PROPERTY, params);
}
}
if (props.length > 0) {
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, LogFacade.CONFIGURE_COOKIE_PROPERTIES, new Object[] { getPath(), cookieConfig });
}
setSessionCookieConfigFromSunWebXml(cookieConfig);
}
}
}
}
Aggregations