Search in sources :

Example 1 with GrantedAuthorityImpl

use of org.springframework.security.core.authority.GrantedAuthorityImpl in project opencast by opencast.

the class OAuthSingleConsumerDetailsService method createConsumerDetails.

/**
 * Creates a spring security consumer details object, suitable to achieve two-legged OAuth.
 *
 * @param consumerKey
 *          the consumer key
 * @param consumerName
 *          the consumer name
 * @param consumerSecret
 *          the consumer secret
 * @return the consumer details
 */
private ExtraTrustConsumerDetails createConsumerDetails(String consumerKey, String consumerName, String consumerSecret) {
    SharedConsumerSecret secret = new SharedConsumerSecret(consumerSecret);
    BaseConsumerDetails bcd = new BaseConsumerDetails();
    bcd.setConsumerKey(consumerKey);
    bcd.setConsumerName(consumerName);
    bcd.setSignatureSecret(secret);
    List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
    authorities.add(new GrantedAuthorityImpl("ROLE_OAUTH_USER"));
    bcd.setAuthorities(authorities);
    // false for 2 legged OAuth
    bcd.setRequiredToObtainAuthenticatedToken(false);
    return bcd;
}
Also used : GrantedAuthorityImpl(org.springframework.security.core.authority.GrantedAuthorityImpl) SharedConsumerSecret(org.springframework.security.oauth.common.signature.SharedConsumerSecret) GrantedAuthority(org.springframework.security.core.GrantedAuthority) ArrayList(java.util.ArrayList) BaseConsumerDetails(org.springframework.security.oauth.provider.BaseConsumerDetails)

Example 2 with GrantedAuthorityImpl

use of org.springframework.security.core.authority.GrantedAuthorityImpl in project onebusaway-application-modules by camsys.

the class StandardAuthoritiesServiceImpl method createStandardAuthority.

private GrantedAuthority createStandardAuthority(final String name) {
    assert !_standardAuthoritiesMap.containsKey(name);
    assert !_userRoles.containsKey(name);
    UserRole role = _userDao.getUserRoleForName(name);
    if (role == null) {
        role = new UserRole(name);
        _userDao.saveOrUpdateUserRole(role);
    }
    _userRoles.put(name, role);
    final GrantedAuthority auth = new GrantedAuthorityImpl(name);
    _standardAuthoritiesMap.put(name, auth);
    return auth;
}
Also used : GrantedAuthorityImpl(org.springframework.security.core.authority.GrantedAuthorityImpl) UserRole(org.onebusaway.users.model.UserRole) GrantedAuthority(org.springframework.security.core.GrantedAuthority)

Aggregations

GrantedAuthority (org.springframework.security.core.GrantedAuthority)2 GrantedAuthorityImpl (org.springframework.security.core.authority.GrantedAuthorityImpl)2 ArrayList (java.util.ArrayList)1 UserRole (org.onebusaway.users.model.UserRole)1 SharedConsumerSecret (org.springframework.security.oauth.common.signature.SharedConsumerSecret)1 BaseConsumerDetails (org.springframework.security.oauth.provider.BaseConsumerDetails)1