Exemplo n.º 1
0
 public void doView(RenderRequest request, RenderResponse response)
     throws PortletException, IOException {
   String siteName = request.getPreferences().getValue("SRC", null);
   SSOSite site = null;
   if (siteName != null) {
     site = sso.getSiteByUrl(siteName);
   }
   if (site == null) {
     response.getWriter().print(NO_CREDENTIALS);
     return;
   } else {
     PasswordCredential pwc = SSOPortletUtil.getCredentialsForSite(sso, siteName, request);
     if (pwc != null) {
       request.setAttribute(SSO_REQUEST_ATTRIBUTE_USERNAME, pwc.getUserName());
       request.setAttribute(SSO_REQUEST_ATTRIBUTE_PASSWORD, pwc.getPassword());
     } else {
       response.getWriter().print(NO_CREDENTIALS);
       return;
     }
   }
   StatusMessage msg =
       (StatusMessage) PortletMessaging.consume(request, "SSOWebContent", "status");
   if (msg != null) {
     this.getContext(request).put("statusMsg", msg);
   }
   super.doView(request, response);
 }
Exemplo n.º 2
0
 public void doEdit(RenderRequest request, RenderResponse response)
     throws PortletException, IOException {
   String site = request.getPreferences().getValue("SRC", "");
   PasswordCredential pwc = SSOPortletUtil.getCredentialsForSite(sso, site, request);
   if (pwc != null) {
     getContext(request).put(SSO_EDIT_FIELD_PRINCIPAL, pwc.getUserName());
     getContext(request).put(SSO_EDIT_FIELD_CREDENTIAL, pwc.getPassword());
   } else {
     // no credentials configured in SSO store
     // switch to SSO Configure View
     getContext(request).put(SSO_EDIT_FIELD_PRINCIPAL, "");
     getContext(request).put(SSO_EDIT_FIELD_CREDENTIAL, "");
   }
   StatusMessage msg =
       (StatusMessage) PortletMessaging.consume(request, "SSOWebContent", "status");
   if (msg != null) {
     this.getContext(request).put("statusMsg", msg);
   }
   this.getContext(request).put("ssoTypes", SSO_TYPES);
   this.getContext(request)
       .put("ssoTypeSelected", request.getPreferences().getValue("sso.type", SSO_TYPE_BASIC));
   super.doEdit(request, response);
 }