}
private URI getCurrentUser()
throws StoreException
{
Session session = SessionManager.get();
if (session != null) {
URI userId = session.getUserId();
if (userId != null) {
return userId;
}
String username = session.getUsername();
if (username != null) {
// backdoor for administrator user.
if (username.equals("administrator")) {
session.setUserId(ACL.ADMIN);
}
else {
Literal usernameLiteral = this.getValueFactory().createLiteral(username, XMLSchema.STRING);
Cursor<? extends Statement> statements = super.getStatements(null, ACL.USERNAME,
usernameLiteral, true, ACL.CONTEXT);
try {
Statement st;
if ((st = statements.next()) != null) {
session.setUserId((URI)st.getSubject());
}
}
finally {
statements.close();
}
}
return session.getUserId();
}
}
return null;
}