use of ru.ydn.wicket.wicketorientdb.IOrientDbSettings 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.IOrientDbSettings 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");
}
Aggregations