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


Java OAuthServerConfiguration类代码示例

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


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

示例1: getAllowedGrantTypes

import org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration; //导入依赖的package包/类
public String[] getAllowedGrantTypes() {
    if (allowedGrants == null) {
        synchronized (OAuthAdminService.class) {
            if (allowedGrants == null) {
                Set<String> allowedGrantSet =
                        OAuthServerConfiguration.getInstance().getSupportedGrantTypes().keySet();
                Set<String> modifiableGrantSet = new HashSet(allowedGrantSet);
                if (OAuthServerConfiguration.getInstance().getSupportedResponseTypes().containsKey("token")) {
                    modifiableGrantSet.add(IMPLICIT);
                }
                allowedGrants = new ArrayList<>(modifiableGrantSet);
            }
        }
    }
    return allowedGrants.toArray(new String[allowedGrants.size()]);
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:17,代码来源:OAuthAdminService.java

示例2: activate

import org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration; //导入依赖的package包/类
protected void activate(ComponentContext context) {
    // initialize the OAuth Server configuration
    OAuthServerConfiguration oauthServerConfig = OAuthServerConfiguration.getInstance();

    if (oauthServerConfig.isCacheEnabled()) {
        log.debug("OAuth Caching is enabled. Initializing the cache.");
        // initialize the cache
        OAuthCache cache = OAuthCache.getInstance();
        if (cache != null) {
            log.debug("OAuth Cache initialization was successful.");
        } else {
            log.debug("OAuth Cache initialization was unsuccessful.");
        }
    }

    listener = new IdentityOathEventListener();
    serviceRegistration = context.getBundleContext().registerService(UserOperationEventListener.class.getName(),
            listener, null);
    log.debug("Identity Oath Event Listener is enabled");

    if (log.isDebugEnabled()) {
        log.info("Identity OAuth bundle is activated");
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:25,代码来源:OAuthServiceComponent.java

示例3: initValidator

import org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration; //导入依赖的package包/类
/**
 * Initialize a grant type validator
 *
 * @return an instance of OAuthValidator
 * @throws OAuthProblemException
 * @throws OAuthSystemException
 */
@Override
protected OAuthValidator<HttpServletRequest> initValidator() throws OAuthProblemException, OAuthSystemException {

    String requestTypeValue = getParam(OAuth.OAUTH_GRANT_TYPE);
    if (OAuthUtils.isEmpty(requestTypeValue)) {
        throw OAuthUtils.handleOAuthProblemException("Missing grant_type parameter value");
    }

    Class<? extends OAuthValidator<HttpServletRequest>> clazz = OAuthServerConfiguration
            .getInstance().getSupportedGrantTypeValidators().get(requestTypeValue);

    if (clazz == null) {
        if (log.isDebugEnabled()) {
            //Do not change this log format as these logs use by external applications
            log.debug("Unsupported Grant Type : " + requestTypeValue +
                    " for client id : " + getClientId());
        }
        throw OAuthUtils.handleOAuthProblemException("Invalid grant_type parameter value");
    }

    return OAuthUtils.instantiateClass(clazz);
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:30,代码来源:CarbonOAuthTokenRequest.java

示例4: initValidator

import org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration; //导入依赖的package包/类
protected OAuthValidator<HttpServletRequest> initValidator() throws OAuthProblemException, OAuthSystemException {

        String responseTypeValue = getParam(OAuth.OAUTH_RESPONSE_TYPE);
        if (OAuthUtils.isEmpty(responseTypeValue)) {
            throw OAuthUtils.handleOAuthProblemException("Missing response_type parameter value");
        }

        Class<? extends OAuthValidator<HttpServletRequest>> clazz = OAuthServerConfiguration
                .getInstance().getSupportedResponseTypeValidators().get(responseTypeValue);

        if (clazz == null) {
            if (log.isDebugEnabled()) {
                //Do not change this log format as these logs use by external applications
                log.debug("Unsupported Response Type : " + responseTypeValue +
                        " for client id : " + getClientId());
            }
            throw OAuthUtils.handleOAuthProblemException("Invalid response_type parameter value");
        }

        return OAuthUtils.instantiateClass(clazz);
    }
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:22,代码来源:CarbonOAuthAuthzRequest.java

示例5: getTTL

import org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration; //导入依赖的package包/类
private long getTTL() {
    if (ttl != -1) {
        return ttl;
    }

    synchronized (JWTTokenGenerator.class) {
        if (ttl != -1) {
            return ttl;
        }
        String ttlValue = OAuthServerConfiguration.getInstance().getAuthorizationContextTTL();
        if (ttlValue != null) {
            ttl = Long.parseLong(ttlValue);
        } else {
            ttl = 15L;
        }
        return ttl;
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:19,代码来源:JWTTokenGenerator.java

示例6: getAccessTokenExpirationTime

import org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration; //导入依赖的package包/类
/**
    * 
    * @param accessTokenDO
    * @return
    */
   private long getAccessTokenExpirationTime(AccessTokenDO accessTokenDO) {
long expiryTime = OAuth2Util.getAccessTokenExpireMillis(accessTokenDO);

if (OAuthConstants.UserType.APPLICATION_USER.equals(accessTokenDO.getTokenType())
	&& OAuthServerConfiguration.getInstance().getUserAccessTokenValidityPeriodInSeconds() < 0) {
    return Long.MAX_VALUE;
} else if (OAuthConstants.UserType.APPLICATION.equals(accessTokenDO.getTokenType())
	&& OAuthServerConfiguration.getInstance().getApplicationAccessTokenValidityPeriodInSeconds() < 0) {
    return Long.MAX_VALUE;
} else if (expiryTime < 0) {
    return Long.MAX_VALUE;
}

return expiryTime / 1000;
   }
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:21,代码来源:TokenValidationHandler.java

示例7: validateAccessTokenDO

import org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration; //导入依赖的package包/类
public static AccessTokenDO validateAccessTokenDO(AccessTokenDO accessTokenDO) {

        long validityPeriodMillis = accessTokenDO.getValidityPeriodInMillis();
        long issuedTime = accessTokenDO.getIssuedTime().getTime();
        long currentTime = System.currentTimeMillis();

        //check the validity of cached OAuth2AccessToken Response
        long skew = OAuthServerConfiguration.getInstance().getTimeStampSkewInSeconds() * 1000;
        if (issuedTime + validityPeriodMillis - (currentTime + skew) > 1000) {
            long refreshValidity = OAuthServerConfiguration.getInstance()
                    .getRefreshTokenValidityPeriodInSeconds() * 1000;
            if (issuedTime + refreshValidity - currentTime + skew > 1000) {
                //Set new validity period to response object
                accessTokenDO.setValidityPeriod((issuedTime + validityPeriodMillis - (currentTime + skew)) / 1000);
                accessTokenDO.setValidityPeriodInMillis(issuedTime + validityPeriodMillis - (currentTime + skew));
                //Set issued time period to response object
                accessTokenDO.setIssuedTime(new Timestamp(currentTime));
                return accessTokenDO;
            }
        }
        //returns null if cached OAuth2AccessToken response object is expired
        return null;
    }
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:24,代码来源:OAuth2Util.java

示例8: JWTAccessTokenBuilder

import org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration; //导入依赖的package包/类
public JWTAccessTokenBuilder() throws IdentityOAuth2Exception {
    if (log.isDebugEnabled()) {
        log.debug("JWT Access token builder is initiated");
    }
    config = OAuthServerConfiguration.getInstance();
    //map signature algorithm from identity.xml to nimbus format, this is a one time configuration
    signatureAlgorithm = mapSignatureAlgorithm(config.getSignatureAlgorithm());
}
 
开发者ID:wso2,项目名称:msf4j,代码行数:9,代码来源:JWTAccessTokenBuilder.java

示例9: buildIDToken

import org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration; //导入依赖的package包/类
/**
 * To build id token from OauthToken request message context
 *
 * @param request Token request message context
 * @return Signed jwt string.
 * @throws IdentityOAuth2Exception
 */
protected String buildIDToken(OAuthTokenReqMessageContext request)
        throws IdentityOAuth2Exception {

    String issuer = OAuth2Util.getIDTokenIssuer();
    long lifetimeInMillis = OAuthServerConfiguration.getInstance().
            getApplicationAccessTokenValidityPeriodInSeconds() * 1000;
    long curTimeInMillis = Calendar.getInstance().getTimeInMillis();
    // setting subject
    String subject = request.getAuthorizedUser().getAuthenticatedSubjectIdentifier();
    if (!StringUtils.isNotBlank(subject)) {
        subject = request.getAuthorizedUser().getUserName();
    }
    // Set claims to jwt token.
    JWTClaimsSet jwtClaimsSet = new JWTClaimsSet();
    jwtClaimsSet.setIssuer(issuer);
    jwtClaimsSet.setSubject(subject);
    jwtClaimsSet.setAudience(Arrays.asList(request.getOauth2AccessTokenReqDTO().getClientId()));
    jwtClaimsSet.setClaim(Constants.AUTHORIZATION_PARTY, request.getOauth2AccessTokenReqDTO().getClientId());
    jwtClaimsSet.setExpirationTime(new Date(curTimeInMillis + lifetimeInMillis));
    jwtClaimsSet.setIssueTime(new Date(curTimeInMillis));
    addUserClaims(jwtClaimsSet, request.getAuthorizedUser());

    if (JWSAlgorithm.NONE.getName().equals(signatureAlgorithm.getName())) {
        return new PlainJWT(jwtClaimsSet).serialize();
    }
    return signJWT(jwtClaimsSet, request);
}
 
开发者ID:wso2,项目名称:msf4j,代码行数:35,代码来源:JWTAccessTokenBuilder.java

示例10: clearOAuthCache

import org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration; //导入依赖的package包/类
public static void clearOAuthCache(String oauthCacheKey) {
    if (OAuthServerConfiguration.getInstance().isCacheEnabled()) {
        OAuthCache oauthCache = OAuthCache.getInstance();
        OAuthCacheKey cacheKey = new OAuthCacheKey(oauthCacheKey);
        oauthCache.clearCacheEntry(cacheKey);
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:8,代码来源:OAuthUtil.java

示例11: OAuthAppDAO

import org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration; //导入依赖的package包/类
public OAuthAppDAO() {

        try {
            persistenceProcessor = OAuthServerConfiguration.getInstance().getPersistenceProcessor();
        } catch (IdentityOAuth2Exception e) {
            log.error("Error retrieving TokenPersistenceProcessor. Defaulting to PlainTextPersistenceProcessor");
            persistenceProcessor = new PlainTextPersistenceProcessor();
        }

    }
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:11,代码来源:OAuthAppDAO.java

示例12: OAuthConsumerDAO

import org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration; //导入依赖的package包/类
public OAuthConsumerDAO() {

        try {
            persistenceProcessor = OAuthServerConfiguration.getInstance().getPersistenceProcessor();
        } catch (IdentityOAuth2Exception e) {
            log.error("Error retrieving TokenPersistenceProcessor. Defaulting to PlainTextProcessor", e);
            persistenceProcessor = new PlainTextPersistenceProcessor();
        }

    }
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:11,代码来源:OAuthConsumerDAO.java

示例13: updateConsumerApplication

import org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration; //导入依赖的package包/类
/**
 * Update existing consumer application.
 *
 * @param consumerAppDTO <code>OAuthConsumerAppDTO</code> with updated application information
 * @throws IdentityOAuthAdminException Error when updating the underlying identity persistence store.
 */
public void updateConsumerApplication(OAuthConsumerAppDTO consumerAppDTO) throws IdentityOAuthAdminException {
    String userName = CarbonContext.getThreadLocalCarbonContext().getUsername();
    String tenantAwareUsername = MultitenantUtils.getTenantAwareUsername(userName);
    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
    OAuthAppDAO dao = new OAuthAppDAO();
    OAuthAppDO oauthappdo = new OAuthAppDO();
    AuthenticatedUser user = new AuthenticatedUser();
    user.setUserName(UserCoreUtil.removeDomainFromName(tenantAwareUsername));
    user.setTenantDomain(tenantDomain);
    user.setUserStoreDomain(IdentityUtil.extractDomainFromName(userName));
    oauthappdo.setUser(user);
    oauthappdo.setOauthConsumerKey(consumerAppDTO.getOauthConsumerKey());
    oauthappdo.setOauthConsumerSecret(consumerAppDTO.getOauthConsumerSecret());
    oauthappdo.setCallbackUrl(consumerAppDTO.getCallbackUrl());
    oauthappdo.setApplicationName(consumerAppDTO.getApplicationName());
    if (OAuthConstants.OAuthVersions.VERSION_2.equals(consumerAppDTO.getOAuthVersion())) {
        List<String> allowedGrants = new ArrayList<>(Arrays.asList(getAllowedGrantTypes()));
        String[] requestGrants = consumerAppDTO.getGrantTypes().split("\\s");
        for (String requestedGrant : requestGrants) {
            if (StringUtils.isBlank(requestedGrant)) {
                continue;
            }
            if (!allowedGrants.contains(requestedGrant)) {
                throw new IdentityOAuthAdminException(requestedGrant + " not allowed");
            }
        }
        oauthappdo.setGrantTypes(consumerAppDTO.getGrantTypes());
    }
    dao.updateConsumerApplication(oauthappdo);
    if (OAuthServerConfiguration.getInstance().isCacheEnabled()) {
        appInfoCache.addToCache(oauthappdo.getOauthConsumerKey(), oauthappdo);
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:41,代码来源:OAuthAdminService.java

示例14: removeOAuthApplicationData

import org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration; //导入依赖的package包/类
/**
 * Removes an OAuth consumer application.
 *
 * @param consumerKey Consumer Key
 * @throws Exception Error when removing the consumer information from the database.
 */
public void removeOAuthApplicationData(String consumerKey) throws IdentityOAuthAdminException {
    OAuthAppDAO dao = new OAuthAppDAO();
    dao.removeConsumerApplication(consumerKey);
    // remove client credentials from cache
    if (OAuthServerConfiguration.getInstance().isCacheEnabled()) {
        OAuthCache.getInstance().clearCacheEntry(new OAuthCacheKey(consumerKey));
        appInfoCache.clearCacheEntry(consumerKey);
        if (log.isDebugEnabled()) {
            log.debug("Client credentials are removed from the cache.");
        }
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:19,代码来源:OAuthAdminService.java

示例15: TokenMgtDAO

import org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration; //导入依赖的package包/类
public TokenMgtDAO() {
    try {
        persistenceProcessor = OAuthServerConfiguration.getInstance().getPersistenceProcessor();
    } catch (IdentityOAuth2Exception e) {
        log.error("Error retrieving TokenPersistenceProcessor. Defaulting to PlainTextProcessor", e);
        persistenceProcessor = new PlainTextPersistenceProcessor();
    }

    if (IdentityUtil.getProperty("JDBCPersistenceManager.TokenPersist.Enable") != null) {
        enablePersist = Boolean.parseBoolean(IdentityUtil.getProperty("JDBCPersistenceManager.TokenPersist.Enable"));
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:13,代码来源:TokenMgtDAO.java


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