2014年5月28日 星期三

Spring Security OAuth2 Client anonymous 存取 Oauth2 resource

spring-projects/spring-security-oauth 在這個專案有 OAuth1, OAuth2的 Server, Client實作,在 OAuth1 Client 存取 Server resource時是可以直接存取的,但在 OAuth2 Client的設計是要先登入才能存取 Server resource,如果要直接存取的話,則會出現錯誤如下

org.springframework.security.authentication.InsufficientAuthenticationException: Authentication is required to obtain an access token (anonymous not allowed)



這邊有一邊文章 (Integrating Google Calendar into a Wicket Application) 可以達到直接存取的目的,
作法大約如下:

1.實作一 class extends AbstractAuthenticationProcessingFilter, 最主要是在

  attemptAuthentication 內產生一個 TestingAuthenticationToken,只要是作為 anonymous登入用


   public class AnoAuthenicationProcessingFilter extends AbstractAuthenticationProcessingFilter {
private static java.util.logging.Logger log1 = java.util.logging.Logger.getLogger("");

    protected AnoAuthenicationProcessingFilter() {
    //super內的參數不可為空白
        super("/login.jsp");
    }

    @Override
    public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException, IOException, ServletException {
   
        //Authentication authentication = new TestingAuthenticationToken(request.getRemoteAddr(), request.getRemoteAddr(), "ROLE_ANONYMOUS");
   
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
   
    if ( authentication == null) {
            log1.log(Level.WARNING,".........establish a new tem Test token for "+ request.getRemoteAddr());
    authentication = new TestingAuthenticationToken(request.getRemoteAddr(), request.getRemoteAddr(), "ROLE_ANONYMOUS");
            authentication.setAuthenticated(true);
    }
   
   
        return getAuthenticationManager().authenticate(authentication);
     
    }

    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
            throws IOException, ServletException {

        if (SecurityContextHolder.getContext().getAuthentication() == null) {
            SecurityContextHolder.getContext().setAuthentication(attemptAuthentication((HttpServletRequest) req, (HttpServletResponse) res));

            if (logger.isDebugEnabled()) {
                logger.debug("Populated SecurityContextHolder with dummy token: '"
                        + SecurityContextHolder.getContext().getAuthentication() + "'");
            }
        } else {
            if (logger.isDebugEnabled()) {
                logger.debug("SecurityContextHolder not populated with dummy token, as it already contained: '"
                        + SecurityContextHolder.getContext().getAuthentication() + "'");
            }
        }
   
        chain.doFilter(req, res);
    }
}

2.實作 implements AuthenticationProvider
    我希望使用者部份功能需要帳號密碼才能使用,所以在這邊有判斷 Authentication是那一種類
    別,在實作 support時就要加上可允許的 token類別

public class CattonOAuthClientProvider implements AuthenticationProvider{
private static java.util.logging.Logger log1 = java.util.logging.Logger.getLogger("");

public CattonOAuthClientProvider() {
super();
}

public Authentication authenticate(Authentication authentication)    throws AuthenticationException {
log1.log(Level.WARNING,"authentication class type............. " +authentication.getClass().toString());

        if (authentication instanceof UsernamePasswordAuthenticationToken)  {
        ‧‧‧‧‧
                ‧‧‧‧
        log1.log(Level.WARNING, "...login by account password...................");
        System.out.println("...login by account password...................");
       
       
        }else if (authentication instanceof TestingAuthenticationToken ) {
        log1.log(Level.WARNING, "...anonymous..............");
       
        } else {
        log1.log(Level.WARNING, "faile to authenicate in provder..............");
        }
       
     
       return authentication;
    }

     public boolean supports(Class authentication) {
          return TestingAuthenticationToken.class.isAssignableFrom(authentication)
       || UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication);

     }
}


 3.修改 spring-servlet.xml
 
    在 custom-filter after="EXCEPTION_TRANSLATION_FILTER" ref="oauth2ClientFilter" 之前加上
    custom-filter before="ANONYMOUS_FILTER" ref="authProcessingFilter"
 
    之後再加上
    bean class="com.catton.spring.security.AnoAuthenicationProcessingFilter" id="authProcessingFilter"
property name="authenticationManager" ref="defaultAuthenticationManager"

    bean id="authenticationProvider"   class="com.catton.spring.security.provider.CattonOAuthClientProvider"

    最後再修改 authentication-manager 設定為 authentication-provider ref="authenticationProvider" 即
    可



Oracle EBS R12 AP Invoice Hold Troubleshooting

可參考如下連結:12: Invoice HOLDS: Causes and Troubleshooting [Video] (Doc ID 1472606.1)

今天有碰到使用者問我一張 invoice有一個 Matching Required的 hold,但我沒遇過,所以找到這篇文件,上面有寫到 supplier site設定上有一個參數 Unmatched Invoices 如果有打勾,代表 invoice line一定都要經過 match產生才可以,如果手動增加且沒有match就會出現這個 hold。  如果還有其它 hold的問題可以來這邊找找看如何解決。


2014年3月17日 星期一

大批付款一直無法捉取負項 AP Invoice

一般可能都是銀行帳戶沒有維護好的問題,可以先檢查 Reject Report看看被 Reject的有那些, 再來查詢 Selected Payment Schedules Report內 Unselected Scheduled Payments and Credits, 如果有出現 Credit reduces payment amount below zero的話,請先檢查該供應商所有該付的 Invoice,不管正、負, Schedule Payment內銀行帳號是否都有值或是正確的,如果沒有的話,請先維護正確,再重新跑一次看看是否問題解決了沒。

2014年2月11日 星期二

Oracle EBS R12 為何更改 AP Invoice date但 due date確不會自動更新


請至 supplier設定功能先檢查 Invoice Management ==> Term ==> Terms Date Basis是不是有設定正確,如果想要更改 invoice date後 due date就會自動更新的話,請把它設為 Invoice,其它值的話,請就參考下列的文章



參考文件:R12: How is a Payables Invoice Due Date Calculated? (Doc ID 1136143.1)

2013年10月23日 星期三

Extjs 4 使用 google speech api



想要在自行開發的網頁上能使用 google speech api 的話,input 要加上 x-webkit-speec 和 speech,
那如果使用 Extjs上要如何作呢。

因為我是使用 Extjs MVC,所以原本要在 Controller上加上 render function,但都沒有作用,所以還是把 render移回到 view上,程式碼如下

View :原本程式碼加上 listener

xtype: 'textfield',
,renderTo: Ext.getBody()
,listeners:: {
    render: function(cmp) {
cmp.el.dom.firstChild.firstChild.lastChild.firstChild.setAttribute("x-webkit-speech","x-webkit-speech");
cmp.el.dom.firstChild.firstChild.lastChild.firstChild.setAttribute("speech","speech");
     }

}

Controller: 加上 webkitspeechchange function

init: function() {
    this.control({
               'tellist textfield[name=param]' :{
        
            /* for google speech api*/
                    ,webkitspeechchange: function(fld,e) {
       
        this.doFetchTel();
                   }
     
                 }

    });  
     
}

這樣應該就可以使用了

2013年9月9日 星期一

已收料但後來 cancel 的 po還可以作退料嗎

跟據原廠的文件,答案是 no cancel line or line 是 final close的狀態,就不能作任何收退料的交易了。

Use the Receiving Returns window to return delivered items to receiving and to return received or delivered externally sourced items to the supplier if the purchase order has neither been cancelled nor final closed.

2013年8月7日 星期三

GL 主帳本 reversed journal 不設定自動轉至次帳本的可能原因

主帳本(Primary ledger) reversed 的Journal是否會自動拋至次帳本(Secondary Ledger)

上一次有說如何設定自動拋轉,但我們公司的設定是不自動拋轉,可能的原因之一就是在 FA有建立 Tax Book而且資料會拋至 GL,這樣在 GL 的主帳本和次帳本都會有由 FA Corporate Book, Tax Book的 Journal,使用者就可以在 GL主帳本把 FA Tax Book的資料作 reverse,然後再去 GL次帳本把 FA Corporate Book的資料作 reverse。在不同的 GL帳本就可以用來看不同 FA的帳本了。