List of usage examples for org.apache.wicket WicketRuntimeException WicketRuntimeException
public WicketRuntimeException(final String message, final Throwable cause)
From source file:at.molindo.wicketutils.openid.OpenIdSession.java
License:Apache License
public void processReturn(PageParameters params) { ParameterList response = new ParameterList(WicketUtils.toMap(params)); try {/*from www . j av a2 s .c o m*/ VerificationResult verificationResult = getConsumerManager().verify(getOpenIdReturnUrl(), response, discoveryInformation); Identifier verifiedIdentifier = verificationResult.getVerifiedId(); if (verifiedIdentifier != null) { AuthSuccess authSuccess = (AuthSuccess) verificationResult.getAuthResponse(); OpenIdDetails details = new OpenIdDetails(); details.setOpenId(verifiedIdentifier.getIdentifier()); // try to get additional details if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) { MessageExtension ext = authSuccess.getExtension(AxMessage.OPENID_NS_AX); if (ext instanceof FetchResponse) { FetchResponse fetchResp = (FetchResponse) ext; details.setMail(fetchResp.getAttributeValue("email")); String fullname = fetchResp.getAttributeValue("fullname"); if (fullname == null) { String firstname = fetchResp.getAttributeValue("firstname"); String lastname = fetchResp.getAttributeValue("lastname"); if (firstname == null) { fullname = lastname == null ? null : lastname; } else if (lastname != null) { fullname = firstname + " " + lastname; } else { fullname = firstname; } } details.setName(fullname); } } else if (authSuccess.hasExtension(SRegMessage.OPENID_NS_SREG)) { MessageExtension extension = authSuccess.getExtension(SRegMessage.OPENID_NS_SREG); if (extension instanceof SRegResponse) { SRegResponse sRegResponse = (SRegResponse) extension; details.setMail(sRegResponse.getAttributeValue("email")); details.setName(sRegResponse.getAttributeValue("fullname")); } } getWebSession().onOpenIdAuthSuccess(details); } else { getWebSession().onOpenIdAuthError(); } } catch (MessageException e) { throw new WicketRuntimeException("verification failed", e); } catch (DiscoveryException e) { throw new WicketRuntimeException("discovery failed", e); } catch (AssociationException e) { throw new WicketRuntimeException("association failed", e); } }
From source file:at.molindo.wicketutils.openid.OpenIdSession.java
License:Apache License
private AuthRequest createOpenIdAuthRequest() { try {/*from w w w . j a va 2 s .c om*/ ConsumerManager consumerManager = OpenIdSession.get().getConsumerManager(); AuthRequest auth = consumerManager.authenticate(discoveryInformation, OpenIdSession.get().getOpenIdReturnUrl()); if (discoveryInformation.getTypes().contains(AxMessage.OPENID_NS_AX)) { FetchRequest fetch = FetchRequest.createFetchRequest(); fetch.addAttribute("email", "http://axschema.org/contact/email", true); fetch.addAttribute("fullname", "http://axschema.org/namePerson", false); fetch.addAttribute("firstname", "http://axschema.org/namePerson/first", false); fetch.addAttribute("lastname", "http://axschema.org/namePerson/last", false); auth.addExtension(fetch); } else if (discoveryInformation.getTypes().contains(SRegMessage.OPENID_NS_SREG)) { SRegRequest sregReq = SRegRequest.createFetchRequest(); sregReq.addAttribute("fullname", true); sregReq.addAttribute("email", true); auth.addExtension(sregReq); } return auth; } catch (MessageException e) { throw new WicketRuntimeException("failed to create OpenID AuthRequest", e); } catch (ConsumerException e) { throw new WicketRuntimeException("failed to create OpenID AuthRequest", e); } }
From source file:at.molindo.wicketutils.openid.OpenIdSession.java
License:Apache License
private DiscoveryInformation performDiscovery(String openId) { try {/* ww w . jav a 2 s. c o m*/ ConsumerManager consumerManager = getConsumerManager(); List<?> discoveries = consumerManager.discover(openId); return consumerManager.associate(discoveries); } catch (DiscoveryException e) { throw new WicketRuntimeException("discovery failed", e); } }
From source file:at.molindo.wicketutils.utils.WicketUtils.java
License:Apache License
public static String getRequestContextPath() { final HttpServletRequest r = getHttpServletRequest(); if (r == null) { return null; }/*w w w . j av a 2 s . co m*/ try { final URL url = new URL(r.getRequestURL().toString()); final StringBuilder buf = new StringBuilder(100); buf.append(url.getProtocol()).append("://").append(url.getHost()); if (url.getPort() != -1) { buf.append(":").append(url.getPort()); } return buf.append(r.getContextPath()).toString(); } catch (final MalformedURLException e) { throw new WicketRuntimeException("client sent an illegal url?", e); } }
From source file:at.molindo.wicketutils.utils.WicketUtils.java
License:Apache License
public static String getHost() { final HttpServletRequest r = getHttpServletRequest(); if (r == null) { return null; }//w w w.j av a 2 s. co m try { return new URL(r.getRequestURL().toString()).getHost(); } catch (final MalformedURLException e) { throw new WicketRuntimeException("client sent an illegal url?", e); } }
From source file:at.molindo.wicketutils.utils.WicketUtils.java
License:Apache License
public static URL toUrl(final Class<? extends Page> pageClass, final PageParameters params) { try {// w w w . j ava2 s . c om String relativePagePath = RequestCycle.get().urlFor(pageClass, params).toString(); URL requestUrl = new URL(getHttpServletRequest().getRequestURL().toString()); URI resolved = URIUtils.resolve(requestUrl.toURI(), relativePagePath); return resolved.toURL(); } catch (MalformedURLException e) { throw new WicketRuntimeException("failed to create URL", e); } catch (URISyntaxException e) { throw new WicketRuntimeException("failed to create URL", e); } }
From source file:ca.travelagency.components.resources.FileImageResource.java
License:Apache License
@Override protected byte[] getImageData(Attributes attributes) { try {// w w w. j a v a 2s . c om return Files.toByteArray(file); } catch (IOException e) { throw new WicketRuntimeException("Can not load file:" + file.getAbsolutePath(), e); } }
From source file:com.googlecode.wicketwebbeans.fields.FileUploaderField.java
License:Apache License
/** * Called when the upload load is uploaded and ready to be used * Return the url of the new uploaded resource * @param upload {@link FileUpload}//from w ww . j av a2s.co m * @return */ public String onFileUploaded(FileUpload upload) { if (upload == null) { return null; } // Try to use same file extension as client String clientFileName = upload.getClientFileName(); int idx = clientFileName.lastIndexOf('.'); String suffix = ""; if (idx > 0 && clientFileName.length() > (idx + 1)) { suffix = clientFileName.substring(idx); } try { return File.createTempFile("FileUploaderField", suffix).getAbsolutePath(); } catch (IOException e) { throw new WicketRuntimeException("Cannot create temp file", e); } }
From source file:com.norconex.jefmon.instance.action.impl.ViewJobSuiteLogAction.java
License:Apache License
@Override public boolean isVisible(JobStatusTreeNode jobStatus) { ILogManager logManager = jobStatus.getSuiteStatusSnapshot().getLogManager(); if (logManager == null) { return false; }/*ww w.j av a 2s . c o m*/ if (!(logManager instanceof FileLogManager)) { return false; } File file = ((FileLogManager) logManager).getLogFile(jobStatus.getJobId()); if (file == null || !file.exists() || !file.isFile()) { return false; } try { return jobStatus.isRoot() && logManager.getLog(jobStatus.getJobId()) != null; } catch (IOException e) { throw new WicketRuntimeException( "Could not obtain log for suite:" + jobStatus.getSuiteStatusSnapshot().getRoot().getJobId(), e); } }
From source file:com.norconex.jefmon.instances.InstancesManager.java
License:Apache License
public static void addInstance(String url) { JEFMonConfig config = getConfig();//ww w . jav a 2s . c om synchronized (config) { config.setRemoteInstanceUrls(ArrayUtils.add(config.getRemoteInstanceUrls(), url)); try { ConfigurationDAO.saveConfig(config); } catch (IOException e) { throw new WicketRuntimeException("Config file not found: " + ConfigurationDAO.CONFIG_FILE, e); } } }