lunes, 16 de enero de 2017

WCP 12.2.x.x: BUG Customizing the Welcome / Login Page

Hello everyone and welcome to 2017!.

We comeback again to the Blog and not sharing a BUG I have raised to Oracle.

The bugs can be tracked as following:

Bug 22748849 : System page customization for Welcome Page not working
Bug 22921957: - UNCAUGHT SECURITYERROR: FAILED TO EXECUTE 'REPLACESTATE' ON 'HISTORY' ON PAGELOA

Summary of the Bug:

"If you customise the Login Page then a JavaScript error will happen in the ADF JS boot.js. This error will block you to try to login again after a first fail attempt which is quite annoying.
In addition, restoring the Welcome Page to the default one will not fix the issue".

ADF JS Error
Basically, the steps to reproduce it are the following:

1. Go to http://wcp.vm.oracle.com/webcenter/system/welcome.jsp
2. Enter wrong password and then sign in
3. It will redirect to http://wcp.vm.oracle.com/webcenter/system/login.jsp?login_fail=true
4. Try now to re-enter the password and I am logged in.
5. Go to Administration->System Pages and Customize Webcenter Portal Welcome Page
6. The page being edited is http://wcp.vm.oracle.com/webcenter/portal/oracle/webcenter/page/scopedMD/s8bba98ff_4cbb_40b8_beee_296c916a23ed/businessRolePages/Landing.jspx
7. For example, change the color for User Name and Password.
8. Save and Close
9. Logout and Remove the cookie from browser history.
10. Go to http://wcp.vm.oracle.com/webcenter/system/welcome.jsp - You can see the color is changed
11. In addition, you can also see the boot-ASPEN-6282.js:244 Uncaught DOMException: Failed to execute 'replaceState' on 'History': A history state object with URL message in the Console
Uncaught DOMException: Failed to execute 'replaceState' on 'History': A history state object with URL 'http://wcp.vm.or/oracle/webcenter/page/scopedMD/s8bba98ff_4cbb_40b8_beee_296c916a23ed/businessRolePages/Landing.jspx' cannot be created in a document with origin 'http://wcp.vm.oracle.com' and URL 'http://wcp.vm.oracle.com/webcenter/system/welcome.jsp'.

12. Enter the wrong password and You will not be redirected to http://wcp.vm.oracle.com/webcenter/system/login.jsp?login_fail=true

Note: When Oracle provides a solution I will share it. Meanwhile, I will wait or just publish my "Workaround"

miércoles, 27 de abril de 2016

WCP 11gR1: Change the Password Programmatically

Recently we implemented a Custom Interface for changing the password in a WebCenter Portal 11.1.1.8 environment. Here I am sharing some of the code to achieve it (taken from WebCenter API).

Java Code Snippet:

public void setPassword(ActionEvent event) {
    String METHOD_NAME = "setPassword";
    logger.entering(CLASS_NAME, "setPassword");
    final String userName = WebCenterSecurityUtils.getUserName();
    try {
      FacesContext fCtx = FacesContext.getCurrentInstance();
      Application app = fCtx.getApplication();
      // This managed bean returns if the Change Password is allowed in WebCenter
   boolean allowPasswordChange = ((Boolean)ADFContext.getCurrent().getExpressionEvaluator().evaluate("#{o_w_wa_i_v_b_changePasswordBean.passwordChangeAllowed}")).booleanValue()
      if (!allowPasswordChange) {
        logger.fine(CLASS_NAME, "setPassword", "skipping passwd change as admin has disabled it");
        WCApplicationContext.getCurrentInstance().displayWarning(WebCenterResourceBundle.class.getCanonicalName(), "PREFERENCE_PASSWORD_DISABLED", null);
      }
      else {
        String oldPassword = getOldPassword();
        String newPassword = getNewPassword();
        if (logger.isFiner()) {
          logger.finer(CLASS_NAME, "setPassword", "Changing the password for useName = " + userName);
        }
        WebCenterSecurityUtils.setPassword(userName, oldPassword, newPassword);
        setOldPassword("");
        setNewPassword("");
        setNewPasswordConfirm("");
        if (logger.isFiner()) {
          logger.finer(CLASS_NAME, "setPassword", "After invoking method binding object for service using EL: #{bindings.setUserPassword.execute}");
        }
      }
    }
    catch (Exception ex) {
      WebCenterException wex;
      if ((ex instanceof WebCenterException)) {
        wex = (WebCenterException)ex;
      } else {
        wex = new WebCenterException("Unable to set the password");
      }
      WCApplicationContext.getCurrentInstance().displayError(wex);
    }
    finally {
      logger.exiting(CLASS_NAME, "setPassword");
    }
}

As you can see in the code above, the important 

JSFF Snippet:

<af:panelFormLayout labelWidth="200" rows="3" maxColumns="1"
     partialTriggers="save" id="pfl1">
 <af:inputText label="Old Password"
    value="#{backingBeanScope.myPasswordBean.oldPassword}"
    secret="true"
    validator="#{webcenterValidator.oldPasswordValidator}"
    required="true" id="it1"/>
 <af:spacer height="10" id="s3"/>
 <af:inputText label="New Password"
    value="#{backingBeanScope.myPasswordBean.newPassword}"
    secret="true"
    validator="#{webcenterValidator.newPasswordValidator}"
    required="true" id="it2"/>
 <af:spacer height="10" id="s4"/>
 <af:inputText label="Confirm New Password"
    value="#{backingBeanScope.myPasswordBean.newPasswordConfirm}"
    secret="true"
    validator="#{webcenterValidator.newPasswordConfirmValidator}"
   required="true" id="it3"/>
</af:panelFormLayout>
<af:commandButton id="save" partialSubmit="true"
                          text="Save"
                          actionListener="#{backingBeanScope.myPasswordBean.setPassword}"/>

Note: Remember that your LDAP has to be conigured with the rights for allowing users to change the password.

TIP: Validators where not included in this post, but it is using the defined by WebCenter ;).

lunes, 25 de abril de 2016

WCP 11gR1: Last Login of Portal Users

Hi.

Recently I was asked about how to retrieve the latest login time of a specific user in WebCenter Portal 11.1.1.8

Basically, the solution was consuming WebCenter Analytics schema which holds analytics about user login.

SELECT DISTINCT ASDIM_USERS.USERID AS "User", ASFACT_WC_LOGINS_0.OCCURRED as "last_login"
FROM ASFACT_WC_LOGINS_0 , ASDIM_USERS
WHERE ASFACT_WC_LOGINS_0.USERID = ASDIM_USERS.ID AND ASDIM_USERS.USERID = 'myuser'
ORDER BY ASFACT_WC_LOGINS_0.OCCURRED DESC

 Obviously, WebCenter Portal has to be configured with WebCenter Analytics Collector for using the above query consuming the ACTIVITIES Schema.

Thanks to Paco Roldán for collaborating on it :).