Samples JDK
BasicAuthInterceptor.java
1 package com.freemindcafe.apache.cxf.jaxrs.sample9;
2 import org.apache.cxf.configuration.security.AuthorizationPolicy;
3 import org.apache.cxf.interceptor.Fault;
4 import org.apache.cxf.message.XMLMessage;
5 import org.apache.cxf.phase.AbstractPhaseInterceptor;
6 import org.apache.cxf.phase.Phase;
7 import org.apache.log4j.Logger;
8 
9 //Phase.UNMARSHAL
10 public class BasicAuthInterceptor extends AbstractPhaseInterceptor<XMLMessage> {
11 
12  public BasicAuthInterceptor(){
13  super(Phase.UNMARSHAL);
14  }
15 
16  protected static final Logger logger = Logger.getLogger(BasicAuthInterceptor.class);
17 
18  @Override public void handleMessage(XMLMessage message) throws Fault {
19  System.out.println("BasicAuthInterceptor-----------------");
20  AuthorizationPolicy policy = message.get(AuthorizationPolicy.class);
21  if(policy != null){
22  System.out.println("usernname - " + policy.getUserName());
23  System.out.println("password - " + policy.getPassword());
24  }
25  }
26 }