当前位置: 首页>>代码示例>>Java>>正文


Java AuthorizationPolicy.getUserName方法代码示例

本文整理汇总了Java中org.apache.cxf.configuration.security.AuthorizationPolicy.getUserName方法的典型用法代码示例。如果您正苦于以下问题:Java AuthorizationPolicy.getUserName方法的具体用法?Java AuthorizationPolicy.getUserName怎么用?Java AuthorizationPolicy.getUserName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.cxf.configuration.security.AuthorizationPolicy的用法示例。


在下文中一共展示了AuthorizationPolicy.getUserName方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleRequest

import org.apache.cxf.configuration.security.AuthorizationPolicy; //导入方法依赖的package包/类
public Response handleRequest(Message m, ClassResourceInfo resourceClass) {
    AuthorizationPolicy policy = m.get(AuthorizationPolicy.class);
    if (policy != null) {
        String username = policy.getUserName();
        String password = policy.getPassword();
        try {
            session = JcrSessionUtil.createSession(username, password);
            if (isAuthenticated(session)) {
                HttpServletRequest request = (HttpServletRequest) m.get(AbstractHTTPDestination.HTTP_REQUEST);
                request.setAttribute(AuthenticationConstants.HIPPO_SESSION, session);
                return null;
            } else {
                throw new UnauthorizedException();
            }
        } catch (LoginException e) {
            log.debug("Login failed: {}", e);
            throw new UnauthorizedException(e.getMessage());
        }
    }
    throw new UnauthorizedException();
}
 
开发者ID:jreijn,项目名称:hippo-addon-restful-webservices,代码行数:22,代码来源:HippoAuthenticationRequestHandler.java

示例2: getCurrentSystemAgentUri

import org.apache.cxf.configuration.security.AuthorizationPolicy; //导入方法依赖的package包/类
public URI getCurrentSystemAgentUri() throws RMapApiException {
    AuthorizationPolicy policy = getCurrentAuthPolicy();
	String key = policy.getUserName();
	String secret = policy.getPassword();
	URI sysAgentUri = getSystemAgentUri(key, secret);
	return sysAgentUri;
}
 
开发者ID:rmap-project,项目名称:rmap,代码行数:8,代码来源:ApiUserServiceImpl.java

示例3: getApiKeyForEvent

import org.apache.cxf.configuration.security.AuthorizationPolicy; //导入方法依赖的package包/类
@Override
public URI getApiKeyForEvent() throws RMapApiException {
    AuthorizationPolicy policy = getCurrentAuthPolicy();
	String key = policy.getUserName();
	String secret = policy.getPassword();
	return getApiKeyUriForEvent(key, secret);
}
 
开发者ID:rmap-project,项目名称:rmap,代码行数:8,代码来源:ApiUserServiceImpl.java

示例4: handleMessage

import org.apache.cxf.configuration.security.AuthorizationPolicy; //导入方法依赖的package包/类
/**
 * Gets basic authentication information from request and validates key
 * throws an error if key is invalid.
 *
 * @param message http message
 */
public void handleMessage(Message message) {

 try {   
 	//only authenticate if you are trying to write to the db... 
 	HttpServletRequest req = (HttpServletRequest) message.get("HTTP.REQUEST");
 	String method = req.getMethod();
 	
 	if (method!=HttpMethod.GET && method!=HttpMethod.OPTIONS && method!=HttpMethod.HEAD){
	 
  	AuthorizationPolicy policy = apiUserService.getCurrentAuthPolicy();
  	String accessKey = policy.getUserName();
  	String secret = policy.getPassword();
  
if (accessKey==null || accessKey.length()==0
		|| secret==null || secret.length()==0)	{
   	throw new RMapApiException(ErrorCode.ER_NO_USER_TOKEN_PROVIDED);
}		
			
apiUserService.validateKey(accessKey, secret);
 	}
 	
 } catch (RMapApiException ex){ 
 	//generate a response to intercept default message
 	Response response = exceptionHandler.toResponse(ex);
 	message.getExchange().put(Response.class, response);   	
 }
		
}
 
开发者ID:rmap-project,项目名称:rmap,代码行数:35,代码来源:AuthenticationInterceptor.java

示例5: handleBasicAuth

import org.apache.cxf.configuration.security.AuthorizationPolicy; //导入方法依赖的package包/类
protected Response handleBasicAuth(AuthorizationPolicy policy) {
    String username = policy.getUserName();
    String password = policy.getPassword();

    try {
        if (authenticate(username, password)) {
            return null;
        }
    } catch (RestApiBasicAuthenticationException e) {
        log.error("Could not authenticate user : " + username + "against carbon userStore", e);
    }
    return authenticationFail();
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:14,代码来源:AuthenticationHandler.java

示例6: handleMessage

import org.apache.cxf.configuration.security.AuthorizationPolicy; //导入方法依赖的package包/类
@Override
public void handleMessage(Message message) throws Fault
{

    LOGGER.info("In handleMessage");
    LOGGER.info("Message --> " + message);

    String name = null;
    String password = null;

    AuthUser user = null;

    AuthorizationPolicy policy = (AuthorizationPolicy) message.get(AuthorizationPolicy.class);
    if (policy != null)
    {
        name = policy.getUserName();
        password = policy.getPassword();

        LOGGER.info("Requesting user: " + name);
        // TODO: read user from DB
        // if user and pw do not match, throw new AuthenticationException("Unauthorized");

        user = new AuthUser();
        user.setName(name);

    }
    else
    {
        LOGGER.info("No requesting user -- GUEST access");
    }

    GeofenceSecurityContext securityContext = new GeofenceSecurityContext();
    GeofencePrincipal principal = (user != null) ? new GeofencePrincipal(user) : GeofencePrincipal.createGuest();
    securityContext.setPrincipal(principal);

    message.put(SecurityContext.class, securityContext);
}
 
开发者ID:geoserver,项目名称:geofence,代码行数:38,代码来源:GeofenceAuthenticationInterceptor.java

示例7: handleMessage

import org.apache.cxf.configuration.security.AuthorizationPolicy; //导入方法依赖的package包/类
@Override
public void handleMessage(Message message) throws Fault
{
    AuthorizationPolicy policy = (AuthorizationPolicy) message.get(AuthorizationPolicy.class);

    //
    // TODO: To manage the public access (guest).
    //
    if (policy == null)
    {
        sendErrorResponse(message, HttpURLConnection.HTTP_UNAUTHORIZED);

        return;
    }

    String username = policy.getUserName();
    String password = policy.getPassword();

    if (isAuthenticated(username, password))
    {
        // ////////////////////////////////////////
        // let request to continue
        // ////////////////////////////////////////
        return;
    }
    else
    {
        // /////////////////////////////////////////////////////////////////////
        // authentication failed, request the authetication,
        // add the realm name if needed to the value of WWW-Authenticate
        // /////////////////////////////////////////////////////////////////////
        sendErrorResponse(message, HttpURLConnection.HTTP_UNAUTHORIZED);

        return;
    }
}
 
开发者ID:geoserver,项目名称:geofence,代码行数:37,代码来源:AuthenticationHandler.java

示例8: handleBasicAuth

import org.apache.cxf.configuration.security.AuthorizationPolicy; //导入方法依赖的package包/类
protected Response handleBasicAuth(AuthorizationPolicy policy, Message message) {
    String username = policy.getUserName();
    String password = policy.getPassword();
    String tenantDomain = getTenantDomain(username , message);
    try {
        if (authenticate(username, password, tenantDomain)) {
            return null;
        }
    } catch (RestApiBasicAuthenticationException e) {
        log.error("Could not authenticate user : " + username + "against carbon userStore", e);
    }
    return authenticationFail();
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:14,代码来源:AuthenticationHandler.java

示例9: getAccessKey

import org.apache.cxf.configuration.security.AuthorizationPolicy; //导入方法依赖的package包/类
@Override
public String getAccessKey() throws RMapApiException {
    AuthorizationPolicy policy = getCurrentAuthPolicy();
    return policy.getUserName();
}
 
开发者ID:rmap-project,项目名称:rmap,代码行数:6,代码来源:ApiUserServiceImpl.java

示例10: handleMessage

import org.apache.cxf.configuration.security.AuthorizationPolicy; //导入方法依赖的package包/类
@Override 
  public void handleMessage(Message message) throws Fault {
  	log.debug("BasicAuthAuthorizationInterceptor - handleMessage init");
  	
  	// Verificamos si esta marcado la activacion mediante xml o es mediante propiedades
  	if (activar != null) {
  		// Activacion mediante XML
  		if ("false".equals(activar)) {
  			log.debug("BasicAuthAuthorizationInterceptor - handleMessage end (no basic auth)");
  			return;
  		}
  	} else {
   		 // Activacion mediante propiedades (para SISTRA)
   	 String auth = null;
	 try{		
		 Properties propiedades = ConfigurationUtil.getInstance().obtenerPropiedades();							
		 auth = propiedades.getProperty("sistra.ws.authenticacion");
	 }catch (Exception ex){
		 log.debug("BasicAuthAuthorizationInterceptor - exception: " + ex.getMessage(), ex);
		 throw new Fault(ex);
	 }
	 if (!"BASIC".equals(auth)) {
		 log.debug("BasicAuthAuthorizationInterceptor - handleMessage end (no basic auth: " + auth + ")");
		 return;
	 }
  	}
  	
  	
      // This is set by CXF
  	try {
   	AuthorizationPolicy policy = message.get(AuthorizationPolicy.class);
       
       // If the policy is not set, the user did not specify credentials
       // A 401 is sent to the client to indicate that authentication is required
       if (policy == null) {
       	log.error("BasicAuthAuthorizationInterceptor - handleMessage: suario intentando acceder sin las credenciales");
           sendErrorResponse(message, HttpURLConnection.HTTP_UNAUTHORIZED);
           return;
       }
       log.debug("BasicAuthAuthorizationInterceptor - handleMessage: accede el usuario " + policy.getUserName());
              
       // double check does not work on multiple processors, unfortunately
       if (!isInitialised) {
          synchronized (this) {
             if (!isInitialised) {
                initialise();
             }
          }
       }
       
       if (authMgr == null) {
       	log.debug("BasicAuthAuthorizationInterceptor - handleMessage: no hay ning�n dominio de seguridad asociado.");
       	sendErrorResponse(message, HttpURLConnection.HTTP_UNAUTHORIZED);
           return;
        }
  
	
       // we take the id out of the        
       String userID = policy.getUserName();
       // convert into a principal
       Principal userPrincipal = getPrincipal(userID);
       // the password that has been provided
       String passwd = policy.getPassword();
       // validate the user
       validate(userPrincipal, passwd);
       // associate the context 
       Subject subject = associate(userPrincipal, passwd);
       // with the security subject
       
       log.debug("BasicAuthAuthorizationInterceptor - handleMessage end");
       
} catch (Exception e) {
	log.error(e.getMessage()+"  "+ e.getCause());
	sendErrorResponse(message, HttpURLConnection.HTTP_UNAUTHORIZED);
          return;
}

  }
 
开发者ID:GovernIB,项目名称:sistra,代码行数:79,代码来源:BasicAuthAuthorizationInterceptor.java

示例11: createAuthenticationContext

import org.apache.cxf.configuration.security.AuthorizationPolicy; //导入方法依赖的package包/类
@Override
protected PasswordAuthenticationContext createAuthenticationContext(AuthorizationPolicy policy, ContainerRequestContext requestCtx){
	return new PasswordAuthenticationContext(policy.getUserName(), policy.getPassword());
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:5,代码来源:MidpointRestPasswordAuthenticator.java


注:本文中的org.apache.cxf.configuration.security.AuthorizationPolicy.getUserName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。