use of ru.ydn.wicket.wicketorientdb.OrientDbWebSession in project wicket-orientdb by OrienteerBAP.
the class OrientDBHttpAPIResource method mountOrientDbRestApi.
/**
* Mounts OrientDB REST API Bridge to an app
* @param resource {@link OrientDBHttpAPIResource} to mount
* @param app {@link WebApplication} to mount to
* @param mountPaths array of paths to mount to
*/
@SuppressWarnings("restriction")
public static void mountOrientDbRestApi(OrientDBHttpAPIResource resource, WebApplication app, String... mountPaths) {
app.getSharedResources().add(ORIENT_DB_KEY, resource);
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
String username;
String password;
OrientDbWebSession session = OrientDbWebSession.get();
if (session.isSignedIn()) {
username = session.getUsername();
password = session.getPassword();
} else {
IOrientDbSettings settings = OrientDbWebApplication.get().getOrientDbSettings();
username = settings.getGuestUserName();
password = settings.getGuestPassword();
}
return new PasswordAuthentication(username, password.toCharArray());
}
});
CookieHandler.setDefault(new PersonalCookieManager());
sun.net.www.protocol.http.AuthCacheValue.setAuthCache(new MultiUserCache());
for (String mountPath : mountPaths) {
app.mountResource(mountPath, new SharedResourceReference(ORIENT_DB_KEY));
}
}
use of ru.ydn.wicket.wicketorientdb.OrientDbWebSession in project wicket-orientdb by OrienteerBAP.
the class WicketSessionCookieJar method setSessionCookies.
protected void setSessionCookies(SessionCookies sessionCookies) {
OrientDbWebSession session = OrientDbWebSession.get();
session.setAttribute(OK_HTTP_COOKIES, sessionCookies);
}
use of ru.ydn.wicket.wicketorientdb.OrientDbWebSession in project wicket-orientdb by OrienteerBAP.
the class OrientDBHttpAPIResource method onMapHeaders.
@Override
protected void onMapHeaders(Attributes attributes, Headers.Builder builder) {
if (builder.get(LazyAuthorizationRequestCycleListener.AUTHORIZATION_HEADER) == null) {
String username;
String password;
OrientDbWebSession session = OrientDbWebSession.get();
if (session.isSignedIn()) {
username = session.getUsername();
password = session.getPassword();
} else {
IOrientDbSettings settings = OrientDbWebApplication.get().getOrientDbSettings();
username = settings.getGuestUserName();
password = settings.getGuestPassword();
}
builder.add(LazyAuthorizationRequestCycleListener.AUTHORIZATION_HEADER, Credentials.basic(username, password));
}
builder.add("Accept-Encoding", "identity");
}
use of ru.ydn.wicket.wicketorientdb.OrientDbWebSession in project wicket-orientdb by OrienteerBAP.
the class PersonalCookieManager method getPersonalCookieManager.
protected CookieManager getPersonalCookieManager() {
try {
if (!ThreadContext.exists() || RequestCycle.get() == null)
return defaultManager;
OrientDbWebSession session = OrientDbWebSession.get();
session.bind();
String id = session.getId();
if (session.isSignedIn())
id = session.getUsername() + '-' + id;
return cache.get(id, new Callable<CookieManager>() {
@Override
public CookieManager call() throws Exception {
return new CookieManager();
}
});
} catch (ExecutionException e) {
throw new IllegalStateException("Cookie Manager should be always calculated");
}
}
use of ru.ydn.wicket.wicketorientdb.OrientDbWebSession in project wicket-orientdb by OrienteerBAP.
the class WicketSessionCookieJar method getSessionCookies.
protected SessionCookies getSessionCookies() {
OrientDbWebSession session = OrientDbWebSession.get();
SessionCookies sessionCookies = (SessionCookies) session.getAttribute(OK_HTTP_COOKIES);
if (sessionCookies == null) {
sessionCookies = new SessionCookies();
setSessionCookies(sessionCookies);
}
return sessionCookies;
}
Aggregations