Search in sources :

Example 26 with AccessTokenRegistration

use of org.apache.cxf.rs.security.oauth2.common.AccessTokenRegistration in project tesb-rt-se by Talend.

the class OAuthManager method createAccessToken.

// token management
public ServerAccessToken createAccessToken(AccessTokenRegistration reg) throws OAuthServiceException {
    ServerAccessToken token = new BearerAccessToken(reg.getClient(), 3600L);
    List<String> scope = reg.getApprovedScope().isEmpty() ? reg.getRequestedScope() : reg.getApprovedScope();
    token.setScopes(convertScopeToPermissions(reg.getClient(), scope));
    token.setSubject(reg.getSubject());
    token.setGrantType(reg.getGrantType());
    at = token;
    return token;
}
Also used : ServerAccessToken(org.apache.cxf.rs.security.oauth2.common.ServerAccessToken) BearerAccessToken(org.apache.cxf.rs.security.oauth2.tokens.bearer.BearerAccessToken)

Aggregations

ServerAccessToken (org.apache.cxf.rs.security.oauth2.common.ServerAccessToken)22 AccessTokenRegistration (org.apache.cxf.rs.security.oauth2.common.AccessTokenRegistration)21 Test (org.junit.Test)14 Client (org.apache.cxf.rs.security.oauth2.common.Client)12 OAuthPermission (org.apache.cxf.rs.security.oauth2.common.OAuthPermission)6 BearerAccessToken (org.apache.cxf.rs.security.oauth2.tokens.bearer.BearerAccessToken)5 Ignore (org.junit.Ignore)4 UserSubject (org.apache.cxf.rs.security.oauth2.common.UserSubject)3 RefreshToken (org.apache.cxf.rs.security.oauth2.tokens.refresh.RefreshToken)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 KeyPair (java.security.KeyPair)2 KeyPairGenerator (java.security.KeyPairGenerator)2 PrivateKey (java.security.PrivateKey)2 PublicKey (java.security.PublicKey)2 JSONProvider (org.apache.cxf.jaxrs.provider.json.JSONProvider)2 ClientAccessToken (org.apache.cxf.rs.security.oauth2.common.ClientAccessToken)2 SecretKey (javax.crypto.SecretKey)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1