• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Credentials类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.guacamole.net.auth.Credentials的典型用法代码示例。如果您正苦于以下问题:Java Credentials类的具体用法?Java Credentials怎么用?Java Credentials使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Credentials类属于org.apache.guacamole.net.auth包,在下文中一共展示了Credentials类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: authenticateUser

import org.apache.guacamole.net.auth.Credentials; //导入依赖的package包/类
/**
 * Returns an AuthenticatedUser representing the user authenticated by the
 * given credentials.
 *
 * @param credentials
 *     The credentials to use for authentication.
 *
 * @return
 *     An AuthenticatedUser representing the user authenticated by the
 *     given credentials.
 *
 * @throws GuacamoleException
 *     If an error occurs while authenticating the user, or if access is
 *     denied.
 */
public AuthenticatedUser authenticateUser(Credentials credentials)
        throws GuacamoleException {

    // Request UserData for the given credentials
    UserData userData = callbackService.retrieveUserData(credentials);
    if (userData == null)
        throw new GuacamoleInvalidCredentialsException("Permission denied.",
                CredentialsInfo.EMPTY);

    // Produce AuthenticatedUser associated with derived UserData
    AuthenticatedUser authenticatedUser = authenticatedUserProvider.get();
    authenticatedUser.init(credentials, userData);
    return authenticatedUser;

}
 
开发者ID:glyptodon,项目名称:guacamole-auth-callback,代码行数:31,代码来源:AuthenticationProviderService.java


示例2: testHostnameFailure

import org.apache.guacamole.net.auth.Credentials; //导入依赖的package包/类
@Test
public void testHostnameFailure() {

    // invalid payload
    Date exp = new Date(System.currentTimeMillis() + 10000L);
    Claims claims = getClaims();
    claims.remove("guac.hostname");
    claims.put("guac.hostnam", "192.168.42.2");
    String token = Jwts.builder().setClaims(claims).setExpiration(exp).signWith(SignatureAlgorithm.HS512, secretKey.getBytes()).compact();

    HttpServletRequest request = getHttpServletRequest(token);

    Credentials credentials = new Credentials();
    credentials.setRequest(request);

    JwtAuthenticationProvider authProvider = new JwtAuthenticationProvider(getInjector(), environment);

    Map<String, GuacamoleConfiguration> configs = authProvider.getAuthorizedConfigurations(credentials);

    assertNull(configs);
}
 
开发者ID:aiden0z,项目名称:guacamole-auth-jwt,代码行数:22,代码来源:JwtAuthenticationProviderTest.java


示例3: SimpleAuthenticatedUser

import org.apache.guacamole.net.auth.Credentials; //导入依赖的package包/类
/**
 * Creates a new SimpleAuthenticatedUser associated with the given
 * credentials and having access to the given Map of
 * GuacamoleConfigurations.
 *
 * @param credentials
 *     The credentials provided by the user when they authenticated.
 *
 * @param configs
 *     A Map of all GuacamoleConfigurations for which this user has
 *     access. The keys of this Map are Strings which uniquely identify
 *     each configuration.
 */
public SimpleAuthenticatedUser(Credentials credentials, Map<String, GuacamoleConfiguration> configs) {

    // Store credentials and configurations
    this.credentials = credentials;
    this.configs = configs;

    // Pull username from credentials if it exists
    String username = credentials.getUsername();
    if (username != null && !username.isEmpty())
        setIdentifier(username);

    // Otherwise generate a random username
    else
        setIdentifier(UUID.randomUUID().toString());

}
 
开发者ID:apache,项目名称:guacamole-client,代码行数:30,代码来源:SimpleAuthenticationProvider.java


示例4: getFilteredAuthorizedConfigurations

import org.apache.guacamole.net.auth.Credentials; //导入依赖的package包/类
/**
 * Given an arbitrary credentials object, returns a Map containing all
 * configurations authorized by those credentials, filtering those
 * configurations using a TokenFilter and the standard credential tokens
 * (like ${GUAC_USERNAME} and ${GUAC_PASSWORD}). The keys of this Map
 * are Strings which uniquely identify each configuration.
 *
 * @param credentials
 *     The credentials to use to retrieve authorized configurations.
 *
 * @return
 *     A Map of all configurations authorized by the given credentials, or
 *     null if the credentials given are not authorized.
 *
 * @throws GuacamoleException
 *     If an error occurs while retrieving configurations.
 */
private Map<String, GuacamoleConfiguration>
        getFilteredAuthorizedConfigurations(Credentials credentials)
        throws GuacamoleException {

    // Get configurations
    Map<String, GuacamoleConfiguration> configs =
            getAuthorizedConfigurations(credentials);

    // Return as unauthorized if not authorized to retrieve configs
    if (configs == null)
        return null;

    // Build credential TokenFilter
    TokenFilter tokenFilter = new TokenFilter();
    StandardTokens.addStandardTokens(tokenFilter, credentials);

    // Filter each configuration
    for (GuacamoleConfiguration config : configs.values())
        tokenFilter.filterValues(config.getParameters());

    return configs;

}
 
开发者ID:apache,项目名称:guacamole-client,代码行数:41,代码来源:SimpleAuthenticationProvider.java


示例5: getAuthorizedConfigurations

import org.apache.guacamole.net.auth.Credentials; //导入依赖的package包/类
@Override
public Map<String, GuacamoleConfiguration>
        getAuthorizedConfigurations(Credentials credentials)
        throws GuacamoleException {

    // Abort authorization if no user mapping exists
    UserMapping userMapping = getUserMapping();
    if (userMapping == null)
        return null;

    // Validate and return info for given user and pass
    Authorization auth = userMapping.getAuthorization(credentials.getUsername());
    if (auth != null && auth.validate(credentials.getUsername(), credentials.getPassword()))
        return auth.getConfigurations();

    // Unauthorized
    return null;

}
 
开发者ID:apache,项目名称:guacamole-client,代码行数:20,代码来源:FileAuthenticationProvider.java


示例6: getAuthorizedConfigurations

import org.apache.guacamole.net.auth.Credentials; //导入依赖的package包/类
@Override
public Map<String, GuacamoleConfiguration> getAuthorizedConfigurations(Credentials credentials) throws GuacamoleException {

    // Check mapping file mod time
    File configFile = getConfigurationFile();
    if (configFile.exists() && configTime < configFile.lastModified()) {

        // If modified recently, gain exclusive access and recheck
        synchronized (this) {
            if (configFile.exists() && configTime < configFile.lastModified()) {
                logger.debug("Configuration file \"{}\" has been modified.", configFile);
                init(); // If still not up to date, re-init
            }
        }

    }

    // If no mapping available, report as such
    if (configs == null)
        throw new GuacamoleServerException("Configuration could not be read.");

    return configs;

}
 
开发者ID:apache,项目名称:guacamole-client,代码行数:25,代码来源:NoAuthenticationProvider.java


示例7: getRemoteHost

import org.apache.guacamole.net.auth.Credentials; //导入依赖的package包/类
/**
 * Derives the remote host of the authenticating user from the given
 * credentials object. The remote host is derived from X-Forwarded-For
 * in addition to the actual source IP of the request, and thus is not
 * trusted. The derived remote host is really only useful for logging,
 * unless the server is configured such that X-Forwarded-For is guaranteed
 * to be trustworthy.
 *
 * @param credentials
 *     The credentials to derive the remote host from.
 *
 * @return
 *     The remote host from which the user with the given credentials is
 *     authenticating.
 */
private static String getRemoteHost(Credentials credentials) {

    HttpServletRequest request = credentials.getRequest();

    // Use X-Forwarded-For, if present and valid
    String header = request.getHeader("X-Forwarded-For");
    if (header != null) {
        Matcher matcher = X_FORWARDED_FOR.matcher(header);
        if (matcher.matches())
            return matcher.group(1);
    }

    // If header absent or invalid, just use source IP
    return request.getRemoteAddr();

}
 
开发者ID:apache,项目名称:guacamole-client,代码行数:32,代码来源:RemoteAuthenticatedUser.java


示例8: retrieveAuthenticatedUser

import org.apache.guacamole.net.auth.Credentials; //导入依赖的package包/类
/**
 * Retrieves the user corresponding to the given credentials from the
 * database. Note that this function will not enforce any additional
 * account restrictions, including explicitly disabled accounts,
 * scheduling, and password expiration. It is the responsibility of the
 * caller to enforce such restrictions, if desired.
 *
 * @param authenticationProvider
 *     The AuthenticationProvider on behalf of which the user is being
 *     retrieved.
 *
 * @param credentials
 *     The credentials to use when locating the user.
 *
 * @return
 *     An AuthenticatedUser containing the existing ModeledUser object if
 *     the credentials given are valid, null otherwise.
 *
 * @throws GuacamoleException
 *     If the provided credentials to not conform to expectations.
 */
public ModeledAuthenticatedUser retrieveAuthenticatedUser(AuthenticationProvider authenticationProvider,
        Credentials credentials) throws GuacamoleException {

    // Get username and password
    String username = credentials.getUsername();
    String password = credentials.getPassword();

    // Retrieve corresponding user model, if such a user exists
    UserModel userModel = userMapper.selectOne(username);
    if (userModel == null)
        return null;

    // Verify provided password is correct
    byte[] hash = encryptionService.createPasswordHash(password, userModel.getPasswordSalt());
    if (!Arrays.equals(hash, userModel.getPasswordHash()))
        return null;

    // Create corresponding user object, set up cyclic reference
    ModeledUser user = getObjectInstance(null, userModel);
    user.setCurrentUser(new ModeledAuthenticatedUser(authenticationProvider, user, credentials));

    // Return now-authenticated user
    return user.getCurrentUser();

}
 
开发者ID:apache,项目名称:guacamole-client,代码行数:47,代码来源:UserService.java


示例9: getUserContext

import org.apache.guacamole.net.auth.Credentials; //导入依赖的package包/类
/**
 * Returns a UserContext object initialized with data accessible to the
 * given AuthenticatedUser.
 *
 * @param authenticatedUser
 *     The AuthenticatedUser to retrieve data for.
 *
 * @return
 *     A UserContext object initialized with data accessible to the given
 *     AuthenticatedUser.
 *
 * @throws GuacamoleException
 *     If the UserContext cannot be created due to an error.
 */
public UserContext getUserContext(org.apache.guacamole.net.auth.AuthenticatedUser authenticatedUser)
        throws GuacamoleException {

    // Bind using credentials associated with AuthenticatedUser
    Credentials credentials = authenticatedUser.getCredentials();
    LDAPConnection ldapConnection = bindAs(credentials);
    if (ldapConnection == null)
        return null;

    try {

        // Build user context by querying LDAP
        UserContext userContext = userContextProvider.get();
        userContext.init(authenticatedUser, ldapConnection);
        return userContext;

    }

    // Always disconnect
    finally {
        ldapService.disconnect(ldapConnection);
    }

}
 
开发者ID:apache,项目名称:guacamole-client,代码行数:39,代码来源:AuthenticationProviderService.java


示例10: authenticateUser

import org.apache.guacamole.net.auth.Credentials; //导入依赖的package包/类
/**
 * Returns an AuthenticatedUser representing the user authenticated by the
 * given credentials.
 *
 * @param credentials
 *     The credentials to use for authentication.
 *
 * @return
 *     An AuthenticatedUser representing the user authenticated by the
 *     given credentials.
 *
 * @throws GuacamoleException
 *     If an error occurs while authenticating the user, or if access is
 *     denied.
 */
public AuthenticatedUser authenticateUser(Credentials credentials)
        throws GuacamoleException {

    // Pull HTTP header from request if present
    HttpServletRequest request = credentials.getRequest();
    if (request != null) {

        // Get the username from the header configured in guacamole.properties
        String username = request.getHeader(confService.getHttpAuthHeader());

        if (username != null) {
            AuthenticatedUser authenticatedUser = authenticatedUserProvider.get();
            authenticatedUser.init(username, credentials);
            return authenticatedUser;
        }

    }

    // Authentication not provided via header, yet, so we request it.
    throw new GuacamoleInvalidCredentialsException("Invalid login.", CredentialsInfo.USERNAME_PASSWORD);

}
 
开发者ID:apache,项目名称:guacamole-client,代码行数:38,代码来源:AuthenticationProviderService.java


示例11: authenticateUser

import org.apache.guacamole.net.auth.Credentials; //导入依赖的package包/类
/**
 * Returns an AuthenticatedUser representing the user authenticated by the
 * given credentials.
 *
 * @param credentials
 *     The credentials to use for authentication.
 *
 * @return
 *     An AuthenticatedUser representing the user authenticated by the
 *     given credentials.
 *
 * @throws GuacamoleException
 *     If an error occurs while authenticating the user, or if access is
 *     denied.
 */
public AuthenticatedUser authenticateUser(Credentials credentials)
        throws GuacamoleException {

    String token = null;

    // Pull OAuth token from request if present
    HttpServletRequest request = credentials.getRequest();
    if (request != null)
        token = request.getParameter(OAuthTokenField.PARAMETER_NAME);

    // If token provided, validate and produce authenticated user
    if (token != null) {

        // Create corresponding authenticated user
        AuthenticatedUser authenticatedUser = authenticatedUserProvider.get();
        authenticatedUser.init(tokenService.processUsername(token), credentials);
        return authenticatedUser;

    }

    // Request OAuth token
    throw new GuacamoleInvalidCredentialsException("Invalid login.",
        new CredentialsInfo(Arrays.asList(new Field[] {

            // OAuth-specific token (will automatically redirect the user
            // to the authorization page via JavaScript)
            new OAuthTokenField(
                confService.getAuthorizationEndpoint(),
                confService.getClientID(),
                confService.getRedirectURI()
            )

        }))
    );

}
 
开发者ID:mike-jumper,项目名称:guacamole-auth-openid,代码行数:52,代码来源:AuthenticationProviderService.java


示例12: authenticateUser

import org.apache.guacamole.net.auth.Credentials; //导入依赖的package包/类
@Override
public AuthenticatedUser authenticateUser(Credentials credentials)
        throws GuacamoleException {

    // Attempt to authenticate user with given credentials
    AuthenticationProviderService authProviderService = injector.getInstance(AuthenticationProviderService.class);
    return authProviderService.authenticateUser(credentials);

}
 
开发者ID:mike-jumper,项目名称:guacamole-auth-openid,代码行数:10,代码来源:OAuthAuthenticationProvider.java


示例13: updateAuthenticatedUser

import org.apache.guacamole.net.auth.Credentials; //导入依赖的package包/类
@Override
public AuthenticatedUser updateAuthenticatedUser(
        AuthenticatedUser authenticatedUser, Credentials credentials)
        throws GuacamoleException {

    // No update necessary
    return authenticatedUser;

}
 
开发者ID:mike-jumper,项目名称:guacamole-auth-openid,代码行数:10,代码来源:OAuthAuthenticationProvider.java


示例14: updateUserContext

import org.apache.guacamole.net.auth.Credentials; //导入依赖的package包/类
@Override
public UserContext updateUserContext(UserContext context,
        AuthenticatedUser authenticatedUser, Credentials credentials)
        throws GuacamoleException {

    // No update necessary
    return context;

}
 
开发者ID:mike-jumper,项目名称:guacamole-auth-openid,代码行数:10,代码来源:OAuthAuthenticationProvider.java


示例15: addStandardTokens

import org.apache.guacamole.net.auth.Credentials; //导入依赖的package包/类
/**
 * Adds tokens which are standardized by guacamole-ext to the given
 * TokenFilter using the values from the given Credentials object. These
 * standardized tokens include the current username (GUAC_USERNAME),
 * password (GUAC_PASSWORD), and the server date and time (GUAC_DATE and
 * GUAC_TIME respectively). If either the username or password are not set
 * within the given credentials, the corresponding token(s) will remain
 * unset.
 *
 * @param filter
 *     The TokenFilter to add standard tokens to.
 *
 * @param credentials
 *     The Credentials to use when populating the GUAC_USERNAME and
 *     GUAC_PASSWORD tokens.
 */
public static void addStandardTokens(TokenFilter filter, Credentials credentials) {

    // Add username token
    String username = credentials.getUsername();
    if (username != null)
        filter.setToken(USERNAME_TOKEN, username);

    // Add password token
    String password = credentials.getPassword();
    if (password != null)
        filter.setToken(PASSWORD_TOKEN, password);

    // Add client hostname token
    String hostname = credentials.getRemoteHostname();
    if (hostname != null)
        filter.setToken(CLIENT_HOSTNAME_TOKEN, hostname);

    // Add client address token
    String address = credentials.getRemoteAddress();
    if (address != null)
        filter.setToken(CLIENT_ADDRESS_TOKEN, address);

    // Add any tokens which do not require credentials
    addStandardTokens(filter);

}
 
开发者ID:apache,项目名称:guacamole-client,代码行数:43,代码来源:StandardTokens.java


示例16: authenticateUser

import org.apache.guacamole.net.auth.Credentials; //导入依赖的package包/类
@Override
public AuthenticatedUser authenticateUser(final Credentials credentials)
        throws GuacamoleException {

    // Get configurations
    Map<String, GuacamoleConfiguration> configs =
            getFilteredAuthorizedConfigurations(credentials);

    // Return as unauthorized if not authorized to retrieve configs
    if (configs == null)
        return null;

    return new SimpleAuthenticatedUser(credentials, configs);

}
 
开发者ID:apache,项目名称:guacamole-client,代码行数:16,代码来源:SimpleAuthenticationProvider.java


示例17: updateAuthenticatedUser

import org.apache.guacamole.net.auth.Credentials; //导入依赖的package包/类
@Override
public AuthenticatedUser updateAuthenticatedUser(AuthenticatedUser authenticatedUser,
        Credentials credentials) throws GuacamoleException {

    // Simply return the given user, updating nothing
    return authenticatedUser;

}
 
开发者ID:apache,项目名称:guacamole-client,代码行数:9,代码来源:SimpleAuthenticationProvider.java


示例18: updateUserContext

import org.apache.guacamole.net.auth.Credentials; //导入依赖的package包/类
@Override
public UserContext updateUserContext(UserContext context,
    AuthenticatedUser authorizedUser, Credentials credentials)
        throws GuacamoleException {

    // Simply return the given context, updating nothing
    return context;
    
}
 
开发者ID:apache,项目名称:guacamole-client,代码行数:10,代码来源:SimpleAuthenticationProvider.java


示例19: authenticateUser

import org.apache.guacamole.net.auth.Credentials; //导入依赖的package包/类
@Override
public AuthenticatedUser authenticateUser(Credentials credentials)
        throws GuacamoleException {

    // Ignore auth attempts if no auth provider could be loaded
    if (authProvider == null) {
        logger.warn("Authentication attempt denied because the authentication system could not be loaded. Please check for errors earlier in the logs.");
        throw new GuacamoleInvalidCredentialsException("Permission denied.", CredentialsInfo.USERNAME_PASSWORD);
    }

    // Delegate to underlying auth provider
    return authProvider.authenticateUser(credentials);

}
 
开发者ID:apache,项目名称:guacamole-client,代码行数:15,代码来源:AuthenticationProviderFacade.java


示例20: updateAuthenticatedUser

import org.apache.guacamole.net.auth.Credentials; //导入依赖的package包/类
@Override
public AuthenticatedUser updateAuthenticatedUser(AuthenticatedUser authenticatedUser,
        Credentials credentials) throws GuacamoleException {

    // Ignore auth attempts if no auth provider could be loaded
    if (authProvider == null) {
        logger.warn("Reauthentication attempt denied because the authentication system could not be loaded. Please check for errors earlier in the logs.");
        throw new GuacamoleInvalidCredentialsException("Permission denied.", CredentialsInfo.USERNAME_PASSWORD);
    }

    // Delegate to underlying auth provider
    return authProvider.updateAuthenticatedUser(authenticatedUser, credentials);

}
 
开发者ID:apache,项目名称:guacamole-client,代码行数:15,代码来源:AuthenticationProviderFacade.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Route类代码示例发布时间:2022-05-22
下一篇:
Java Version类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap