*/
public static AdminAccessController.Access authenticateViaAdminRealm(Habitat habitat, GrizzlyRequest req, String remoteHost) throws IOException, LoginException {
String[] up = AdminAdapter.getUserPassword(req.getRequest());
String user = up[0];
String password = up.length > 1 ? up[1] : "";
AdminAccessController authenticator = habitat.getByContract(AdminAccessController.class);
AdminAccessController.Access access = AdminAccessController.Access.FULL; //if the authenticator is not available, allow all access - per Jerome
if (authenticator != null) {
// This is temporary workaround for a Grizzly issue that prohibits uploading (deploy) files larger than 2MB when secure admin is enabled.
// The workaround will not be required in trunk when the corresponding Grizzly issue is fixed.
// Please see http://java.net/jira/browse/GLASSFISH-16665 for details
// The workaround duplicates code from AdminAdapter.
ServerEnvironment serverEnvironment = habitat.getByContract(ServerEnvironment.class);
final Principal sslPrincipal = !serverEnvironment.isDas() || Boolean.getBoolean(DAS_LOOK_FOR_CERT_PROPERTY_NAME) ? req.getUserPrincipal() : null;
AdminService as = habitat.getByType(AdminService.class);
access = authenticator.loginAsAdmin(user, password, as.getAuthRealmName(), remoteHost, getAuthRelatedHeaders(req), sslPrincipal);
}
return access;
}