List of usage examples for org.apache.wicket Application get
public static Application get()
From source file:org.dcm4chee.wizard.common.component.MainWebPage.java
License:LGPL
protected String getBrowserTitle() { Class<?> clazz = Application.get().getHomePage(); String s = new ClassStringResourceLoader(clazz).loadStringResource(this.getClass(), "application.browser_title", getSession().getLocale(), null, null); if (s == null) { s = new PackageStringResourceLoader().loadStringResource(this.getClass(), "application.browser_title", getSession().getLocale(), null, null); }/*from w w w .j a va 2 s .c o m*/ return s == null ? "DCM4CHEE" : s; }
From source file:org.dcm4chee.wizard.common.login.context.LoginContextSecurityHelper.java
License:LGPL
static Map<String, String> readSwarmPrincipals() throws MalformedURLException, IOException { InputStream in = ((WebApplication) Application.get()).getServletContext() .getResource("/WEB-INF/dcm4chee.hive").openStream(); BufferedReader dis = new BufferedReader(new InputStreamReader(in)); HashMap<String, String> principals = new LinkedHashMap<String, String>(); String line;/*from w ww . j a v a2 s. co m*/ String principal = null; while ((line = dis.readLine()) != null) if (line.startsWith("grant principal ")) { principal = line.substring(line.indexOf("\"") + 1, line.lastIndexOf("\"")); principals.put(principal, null); } else if ((principal != null) && (line.trim().startsWith("// KEY:"))) { principals.put(principal, line.substring(line.indexOf("// KEY:") + 7).trim()); principal = null; } in.close(); return principals; }
From source file:org.dcm4chee.wizard.common.login.context.LoginContextSecurityHelper.java
License:LGPL
public static String getJaasRolesGroupName() { if (rolesGroupName == null) { try {//from w ww. j a v a 2 s . c om rolesGroupName = ((WebApplication) Application.get()).getInitParameter("rolesGroupName"); if (rolesGroupName == null) rolesGroupName = "Roles"; } catch (Exception x) { log.error("Can't get InitParameter 'rolesGroupName' from Wicket Application!", x); } } return rolesGroupName; }
From source file:org.dcm4chee.wizard.common.login.context.LoginContextSecurityHelper.java
License:LGPL
public static final List<String> getJaasRoles() { getJaasRolesGroupName();// www .j a va2 s. com List<String> roles = new ArrayList<String>(); String rolesGroupName = ((WebApplication) Application.get()).getInitParameter("rolesGroupName"); if (rolesGroupName == null) rolesGroupName = "Roles"; try { for (Principal principal : ((Subject) PolicyContext.getContext("javax.security.auth.Subject.container")) .getPrincipals()) { if ((principal instanceof Group) && rolesGroupName.equalsIgnoreCase(principal.getName())) { Enumeration<? extends Principal> members = ((Group) principal).members(); while (members.hasMoreElements()) roles.add(members.nextElement().getName()); } } } catch (Exception e) { log.error("Failed to get jaas subject from javax.security.auth.Subject.container", e); } return roles; }
From source file:org.dcm4chee.wizard.common.login.context.WebLoginContext.java
License:LGPL
@Override protected org.wicketstuff.security.hive.authentication.Subject getSubject(String username, String password) throws LoginException { WebApplication app = (WebApplication) Application.get(); String webApplicationPolicy = app.getInitParameter("webApplicationPolicy"); if (webApplicationPolicy == null) webApplicationPolicy = "dcm4chee"; String rolesGroupName = app.getInitParameter("rolesGroupName"); if (rolesGroupName == null) rolesGroupName = "Roles"; LoginCallbackHandler handler = new LoginCallbackHandler(username, password); LoginContext context;//from w ww. ja va2 s. c o m SecureSession secureSession; try { secureSession = (SecureSession) Session.get(); // secureSession.setManageUsers(BaseCfgDelegate.getInstance().getManageUsers()); context = new LoginContext(webApplicationPolicy, handler); context.login(); secureSession.setUsername(username); } catch (Exception e) { log.warn("Login failed. Reason: " + e.getMessage()); throw new LoginException(); } if (!readHiveFile()) return null; DefaultSubject subject; try { subject = LoginContextSecurityHelper.mapSwarmSubject(context.getSubject(), null); if (!LoginContextSecurityHelper.checkLoginAllowed(subject)) { ((SecureSession) Session.get()).invalidate(); log.warn( "Failed to authorize subject for login, denied. See 'LoginAllowedRolename' parameter in web.xml."); } secureSession.extendedLogin(username, password, subject); } catch (Exception e) { log.error("Login failed for user " + username, e); ((SecureSession) Session.get()).invalidate(); subject = new DefaultSubject(); } return subject; }
From source file:org.dcm4chee.wizard.common.login.LoginPage.java
License:LGPL
protected String getBrowserTitle() { Class<?> clazz = Application.get().getHomePage(); String s = new ClassStringResourceLoader(clazz).loadStringResource(this.getClass(), "application.browser_title", getSession().getLocale(), null, null); if (s == null) { s = new PackageStringResourceLoader().loadStringResource(this.getClass(), "application.browser_title", getSession().getLocale(), null, null); }/*from ww w .j a v a 2 s. co m*/ return (s == null ? "DCM4CHEE" : s) + ": " + this.getString("application.login", null, "Login"); }
From source file:org.dcm4chee.wizard.ProxyManifest.java
License:LGPL
public static Map<String, String> get(String proxyJarNameProperty) { Map<String, String> properties = new HashMap<String, String>(); String wizardWarName = null;/* w w w . ja v a 2s.c om*/ String proxyJarName = null; String manifestPath = null; try { wizardWarName = ((WebApplication) Application.get()).getInitParameter("wizardWarName"); proxyJarName = ((WebApplication) Application.get()).getInitParameter(proxyJarNameProperty); if (wizardWarName == null) throw new RuntimeException("Can't get InitParameter 'wizardWarName' from Wicket Application!"); if (proxyJarName == null) throw new RuntimeException("Can't get InitParameter 'proxyJarName' from Wicket Application!"); String osName = System.getProperty("os.name"); manifestPath = osName != null && osName.toLowerCase().contains("windows") ? "vfs:/" + System.getProperty("jboss.home.dir").replace("\\", "/") + "/bin/content/" + wizardWarName + "/WEB-INF/lib/" + proxyJarName + "/META-INF/MANIFEST.MF" : "vfs:/content/" + wizardWarName + "/WEB-INF/lib/" + proxyJarName + "/META-INF/MANIFEST.MF"; final Attributes attributes = new Manifest(new URL(manifestPath).openStream()).getMainAttributes(); for (Object key : attributes.keySet()) properties.put(key.toString(), attributes.getValue((Name) key)); } catch (Exception e) { log.error("Failed to retrieve " + manifestPath, e); } return properties; }
From source file:org.dcm4chee.wizard.tree.ConfigTreeProvider.java
License:LGPL
public static DicomConfigurationManager getDicomConfigurationManager() { return ((WizardApplication) Application.get()).getDicomConfigurationManager(); }
From source file:org.devgateway.eudevfin.ui.common.ApplicationJavaScript.java
License:Open Source License
@Override public Iterable<? extends HeaderItem> getDependencies() { final List<HeaderItem> dependencies = Lists.newArrayList(super.getDependencies()); dependencies.add(JavaScriptHeaderItem .forReference(Application.get().getJavaScriptLibrarySettings().getJQueryReference())); dependencies.add(JavaScriptHeaderItem.forReference(BootstrapJavaScriptReference.instance())); return dependencies; }
From source file:org.devgateway.eudevfin.ui.common.JQueryUICoreJavaScriptReference.java
License:Open Source License
@Override public Iterable<? extends HeaderItem> getDependencies() { final List<HeaderItem> dependencies = Lists.newArrayList(super.getDependencies()); dependencies.add(JavaScriptHeaderItem .forReference(Application.get().getJavaScriptLibrarySettings().getJQueryReference())); return dependencies; }