org.wso2.carbon.identity.core.util.IdentityCoreConstants Java Examples

The following examples show how to use org.wso2.carbon.identity.core.util.IdentityCoreConstants. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SAMLSSOServiceProviderDO.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
public SAMLSSOServiceProviderDO() {
    if (StringUtils.isNotBlank(IdentityUtil.getProperty(IdentityConstants.ServerConfig
            .SSO_DEFAULT_SIGNING_ALGORITHM))) {
        signingAlgorithmUri = IdentityUtil.getProperty(IdentityConstants.ServerConfig
                .SSO_DEFAULT_SIGNING_ALGORITHM).trim();
    } else {
        signingAlgorithmUri = IdentityCoreConstants.XML_SIGNATURE_ALGORITHM_RSA_SHA1_URI;
    }
    if (StringUtils.isNotBlank(IdentityUtil.getProperty(IdentityConstants.ServerConfig
            .SSO_DEFAULT_DIGEST_ALGORITHM))) {
        digestAlgorithmUri = IdentityUtil.getProperty(IdentityConstants.ServerConfig
                .SSO_DEFAULT_DIGEST_ALGORITHM).trim();
    } else {
        digestAlgorithmUri = IdentityCoreConstants.XML_DIGEST_ALGORITHM_SHA1;
    }
}
 
Example #2
Source File: FrameworkUtils.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
public static String getMultiAttributeSeparator() {

        String multiAttributeSeparator = null;
        try {
            multiAttributeSeparator = CarbonContext.getThreadLocalCarbonContext().getUserRealm().
                    getRealmConfiguration().getUserStoreProperty(IdentityCoreConstants.MULTI_ATTRIBUTE_SEPARATOR);
        } catch (UserStoreException e) {
            log.warn("Error while retrieving MultiAttributeSeparator from UserRealm.");
            if (log.isDebugEnabled()) {
                log.debug("Error while retrieving MultiAttributeSeparator from UserRealm." + e);
            }
        }

        if (StringUtils.isBlank(multiAttributeSeparator)) {
            multiAttributeSeparator = IdentityCoreConstants.MULTI_ATTRIBUTE_SEPARATOR_DEFAULT;
            if (log.isDebugEnabled()) {
                log.debug("Multi Attribute Separator is defaulting to " + multiAttributeSeparator);
            }
        }

        return multiAttributeSeparator;
    }
 
Example #3
Source File: DefaultServiceURLBuilder.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
private String fetchAbsolutePublicUrl() throws URLBuilderException {

            StringBuilder absolutePublicUrl = new StringBuilder();
            if (StringUtils.isBlank(protocol)) {
                throw new URLBuilderException("Protocol of service URL is not available");
            }
            if (StringUtils.isBlank(proxyHostName)) {
                throw new URLBuilderException("Hostname of service URL is not available");
            }
            absolutePublicUrl.append(protocol).append("://");
            absolutePublicUrl.append(proxyHostName.toLowerCase());
            // If it's well known HTTPS port, skip adding port.
            if (port != IdentityCoreConstants.DEFAULT_HTTPS_PORT) {
                absolutePublicUrl.append(":").append(port);
            }
            absolutePublicUrl.append(fetchRelativePublicUrl());
            return absolutePublicUrl.toString();
        }
 
Example #4
Source File: DefaultServiceURLBuilder.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
private String fetchAbsoluteInternalUrl() throws URLBuilderException {

            StringBuilder absoluteInternalUrl = new StringBuilder();
            if (StringUtils.isBlank(protocol)) {
                throw new URLBuilderException("Protocol of service URL is not available");
            }
            if (StringUtils.isBlank(internalHostName)) {
                throw new URLBuilderException("Internal hostname of service URL is not available");
            }
            absoluteInternalUrl.append(protocol).append("://");
            absoluteInternalUrl.append(internalHostName.toLowerCase());
            // If it's well known HTTPS port, skip adding port.
            if (port != IdentityCoreConstants.DEFAULT_HTTPS_PORT) {
                absoluteInternalUrl.append(":").append(port);
            }
            absoluteInternalUrl.append(fetchRelativeInternalUrl());
            return absoluteInternalUrl.toString();
        }
 
Example #5
Source File: ApplicationResourceManagementListener.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
/**
 * Get the execution order identifier for this listener.
 *
 * @return The execution order identifier integer value.
 */
default int getExecutionOrderId() {

    IdentityEventListenerConfig identityEventListenerConfig = IdentityUtil.readEventListenerProperty
            (ApplicationResourceManagementListener.class.getName(), this.getClass().getName());
    int orderId;
    if (identityEventListenerConfig == null) {
        orderId = IdentityCoreConstants.EVENT_LISTENER_ORDER_ID;
    } else {
        orderId = identityEventListenerConfig.getOrder();
    }

    if (orderId != IdentityCoreConstants.EVENT_LISTENER_ORDER_ID) {
        return orderId;
    }

    return getDefaultOrderId();
}
 
Example #6
Source File: DefaultServiceURLBuilderTest.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
@Test(dataProvider = "getRelativePublicURLData")
public void testGetRelativePublicURL(String protocol, String hostName, int port, String proxyContextPath,
                                     String tenantNameFromContext, boolean enableTenantURLSupport,
                                     String expected, String urlPath) {

    when(CarbonUtils.getManagementTransport()).thenReturn(protocol);
    when(ServerConfiguration.getInstance().getFirstProperty(IdentityCoreConstants.HOST_NAME)).thenReturn(hostName);
    when(CarbonUtils.getTransportProxyPort(mockAxisConfiguration, protocol)).thenReturn(port);
    when(ServerConfiguration.getInstance().getFirstProperty(IdentityCoreConstants
            .PROXY_CONTEXT_PATH)).thenReturn(proxyContextPath);
    when(IdentityTenantUtil.isTenantQualifiedUrlsEnabled()).thenReturn(enableTenantURLSupport);
    when(IdentityTenantUtil.getTenantDomainFromContext()).thenReturn(tenantNameFromContext);
    when(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()).thenReturn("carbon.super");

    String relativePublicUrl = null;
    try {
        relativePublicUrl = ServiceURLBuilder.create().addPath(urlPath).build().getRelativePublicURL();
    } catch (URLBuilderException e) {
        //Mock behaviour, hence ignored
    }
    assertEquals(relativePublicUrl, expected);
}
 
Example #7
Source File: DefaultServiceURLBuilderTest.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
@Test(dataProvider = "getRelativeInternalURLData")
public void testGetRelativeInternalURL(String protocol, String hostName, int port, String proxyContextPath,
                                       String tenantNameFromContext, boolean enableTenantURLSupport,
                                       String expected, String urlPath) {

    when(CarbonUtils.getManagementTransport()).thenReturn(protocol);
    when(ServerConfiguration.getInstance().getFirstProperty(IdentityCoreConstants.HOST_NAME)).thenReturn(hostName);
    when(CarbonUtils.getTransportProxyPort(mockAxisConfiguration, protocol)).thenReturn(port);
    when(ServerConfiguration.getInstance().getFirstProperty(IdentityCoreConstants
            .PROXY_CONTEXT_PATH)).thenReturn(proxyContextPath);
    when(IdentityTenantUtil.isTenantQualifiedUrlsEnabled()).thenReturn(enableTenantURLSupport);
    when(IdentityTenantUtil.getTenantDomainFromContext()).thenReturn(tenantNameFromContext);
    when(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()).thenReturn("carbon.super");

    String relativeInternalUrl = null;
    try {
        relativeInternalUrl = ServiceURLBuilder.create().addPath(urlPath).build().getRelativeInternalURL();
    } catch (URLBuilderException e) {
        //Mock behaviour, hence ignored
    }
    assertEquals(relativeInternalUrl, expected);
}
 
Example #8
Source File: FilterTreeBuilder.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
/**
 * We build the parser using the recursive descent parser technique.
 */
private void factor() throws IdentityException {

    symbol = nextSymbol();
    if (symbol.equals(String.valueOf(IdentityCoreConstants.Filter.NOT))) {
        OperationNode not = new OperationNode(IdentityCoreConstants.Filter.NOT);
        factor();
        not.setRightNode(root);
        root = not;
    } else if (symbol.equals(String.valueOf("("))) {
        expression();
        symbol = nextSymbol(); // We don't care about ')'.
    } else {
        if (!(symbol.equals(String.valueOf(")")))) {
            ExpressionNode expressionNode = new ExpressionNode();
            validateAndBuildFilterExpression(symbol, expressionNode);
            root = expressionNode;
            symbol = nextSymbol();
        } else {
            throw new IdentityException("Invalid argument: Identity Provider filter name value is empty or " +
                    "invalid symbol: " + symbol);
        }
    }
}
 
Example #9
Source File: JWTTokenGenerator.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
private String getMultiAttributeSeparator(String authenticatedUser, int tenantId) {
    String claimSeparator = null;
    String userDomain = IdentityUtil.extractDomainFromName(authenticatedUser);

    try {
        RealmConfiguration realmConfiguration = null;
        RealmService realmService = OAuthComponentServiceHolder.getRealmService();

        if (realmService != null && tenantId != MultitenantConstants.INVALID_TENANT_ID) {
            UserStoreManager userStoreManager = (UserStoreManager) realmService.getTenantUserRealm(tenantId)
                    .getUserStoreManager();
            realmConfiguration = userStoreManager.getSecondaryUserStoreManager(userDomain).getRealmConfiguration();
        }

        if (realmConfiguration != null) {
            claimSeparator = realmConfiguration.getUserStoreProperty(IdentityCoreConstants.MULTI_ATTRIBUTE_SEPARATOR);
            if (claimSeparator != null && !claimSeparator.trim().isEmpty()) {
                return claimSeparator;
            }
        }
    } catch (UserStoreException e) {
        log.error("Error occurred while getting the realm configuration, User store properties might not be " +
                  "returned", e);
    }
    return null;
}
 
Example #10
Source File: AbstractWorkflowImplServiceListener.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * get order ID (priority of current listener)
 *
 * @return
 */
public int getOrderId() {
    IdentityEventListenerConfig workflowImplListener = IdentityUtil.readEventListenerProperty
            (WorkflowImplServiceListener.class.getName(), this.getClass().getName());
    if (workflowImplListener == null) {
        return IdentityCoreConstants.EVENT_LISTENER_ORDER_ID;
    }
    return workflowImplListener.getOrder();
}
 
Example #11
Source File: UserOperationEventListenerImpl.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
@Override
public int getExecutionOrderId() {
    int orderId = getOrderId();
    if (orderId != IdentityCoreConstants.EVENT_LISTENER_ORDER_ID) {
        return orderId;
    }
    return EXEC_ORDER;
}
 
Example #12
Source File: SCIMUserOperationListener.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
@Override
public int getExecutionOrderId() {
    int orderId = getOrderId();
    if (orderId != IdentityCoreConstants.EVENT_LISTENER_ORDER_ID) {
        return orderId;
    }
    return 90;
}
 
Example #13
Source File: UserOperationsNotificationListener.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
@Override
public int getExecutionOrderId() {
    int orderId = getOrderId();
    if (orderId != IdentityCoreConstants.EVENT_LISTENER_ORDER_ID) {
        return orderId;
    }
    return 80;
}
 
Example #14
Source File: AbstractWorkflowExecutorManagerListener.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * get order ID (priority of current listener)
 *
 * @return
 */
public int getOrderId() {
    IdentityEventListenerConfig listenerConfig = IdentityUtil.readEventListenerProperty
            (WorkflowExecutorManagerListener.class.getName(), this.getClass().getName());
    if (listenerConfig == null) {
        return IdentityCoreConstants.EVENT_LISTENER_ORDER_ID;
    }
    return listenerConfig.getOrder();
}
 
Example #15
Source File: AbstractWorkflowListener.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * get order ID (priority of current listener)
 *
 * @return
 */
public int getOrderId() {
    IdentityEventListenerConfig workflowListener = IdentityUtil.readEventListenerProperty
            (WorkflowListener.class.getName(), this.getClass().getName());
    if (workflowListener == null) {
        return IdentityCoreConstants.EVENT_LISTENER_ORDER_ID;
    }
    return workflowListener.getOrder();
}
 
Example #16
Source File: UserStoreListener.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public int getExecutionOrderId() {
    int orderId = getOrderId();
    if (orderId != IdentityCoreConstants.EVENT_LISTENER_ORDER_ID) {
        return orderId;
    }
    return 20;
}
 
Example #17
Source File: AbstractIdentityProviderMgtListener.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public int getExecutionOrderId() {
    IdentityEventListenerConfig identityEventListenerConfig = IdentityUtil.readEventListenerProperty
            (IdentityProviderMgtListener.class.getName(), this.getClass().getName());
    int orderId;
    if (identityEventListenerConfig == null) {
        orderId = IdentityCoreConstants.EVENT_LISTENER_ORDER_ID;
    } else {
        orderId = identityEventListenerConfig.getOrder();
    }
    if (orderId != IdentityCoreConstants.EVENT_LISTENER_ORDER_ID) {
        return orderId;
    }
    return getDefaultOrderId();
}
 
Example #18
Source File: IdentityMgtEventListener.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * What is this ?
 */
@Override
public int getExecutionOrderId() {
    int orderId = getOrderId();
    if (orderId != IdentityCoreConstants.EVENT_LISTENER_ORDER_ID) {
        return orderId;
    }
    return 50;
}
 
Example #19
Source File: AbstractIdentityUserOperationEventListener.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public int getOrderId() {
    IdentityEventListenerConfig identityEventListenerConfig = IdentityUtil.readEventListenerProperty
            (UserOperationEventListener.class.getName(), this.getClass().getName());
    if (identityEventListenerConfig == null) {
        return IdentityCoreConstants.EVENT_LISTENER_ORDER_ID;
    }
    return identityEventListenerConfig.getOrder();
}
 
Example #20
Source File: OpenIDConnectAuthenticator.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
protected void buildClaimMappings(Map<ClaimMapping, String> claims, Map.Entry<String, Object> entry, String
        separator) {
    String claimValue = null;
    if (StringUtils.isBlank(separator)) {
        separator = IdentityCoreConstants.MULTI_ATTRIBUTE_SEPARATOR_DEFAULT;
    }
    try {
        JSONArray jsonArray = (JSONArray) JSONValue.parseWithException(entry.getValue().toString());
        if (jsonArray != null && jsonArray.size() > 0) {
            Iterator attributeIterator = jsonArray.iterator();
            while (attributeIterator.hasNext()) {
                if (claimValue == null) {
                    claimValue = attributeIterator.next().toString();
                } else {
                    claimValue = claimValue + separator + attributeIterator.next().toString();
                }
            }

        }
    } catch (Exception e) {
        claimValue = entry.getValue().toString();
    }

    claims.put(ClaimMapping.build(entry.getKey(), entry.getKey(), null, false), claimValue);
    if (log.isDebugEnabled() && IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.USER_CLAIMS)) {
        log.debug("Adding claim mapping : " + entry.getKey() + " <> " + entry.getKey() + " : " + claimValue);
    }

}
 
Example #21
Source File: AbstractApplicationMgtListener.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public int getExecutionOrderId() {
    IdentityEventListenerConfig identityEventListenerConfig = IdentityUtil.readEventListenerProperty
            (ApplicationMgtListener.class.getName(), this.getClass().getName());
    int orderId;
    if (identityEventListenerConfig == null) {
        orderId = IdentityCoreConstants.EVENT_LISTENER_ORDER_ID;
    } else {
        orderId = identityEventListenerConfig.getOrder();
    }
    if (orderId != IdentityCoreConstants.EVENT_LISTENER_ORDER_ID) {
        return orderId;
    }
    return getDefaultOrderId();
}
 
Example #22
Source File: DefaultInboundUserProvisioningListener.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
@Override
public int getExecutionOrderId() {
    int orderId = getOrderId();
    if (orderId != IdentityCoreConstants.EVENT_LISTENER_ORDER_ID) {
        return orderId;
    }
    return 30;
}
 
Example #23
Source File: IdentityOpenIDUserEventListener.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
@Override
public int getExecutionOrderId() {
    int orderId = getOrderId();
    if (orderId != IdentityCoreConstants.EVENT_LISTENER_ORDER_ID) {
        return orderId;
    }
    return 70;
}
 
Example #24
Source File: DefaultClaimHandler.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
private void addMultiAttributeSperatorToRequestedClaims(AuthenticatedUser authenticatedUser,
                                                        org.wso2.carbon.user.core.UserStoreManager userStore,
                                                        Map<String, String> spRequestedClaims) {
    if (!spRequestedClaims.isEmpty()) {
        RealmConfiguration realmConfiguration = userStore.getRealmConfiguration();

        String claimSeparator = realmConfiguration.getUserStoreProperty(IdentityCoreConstants
                .MULTI_ATTRIBUTE_SEPARATOR);
        if (StringUtils.isNotBlank(claimSeparator)) {
            spRequestedClaims.put(IdentityCoreConstants.MULTI_ATTRIBUTE_SEPARATOR, claimSeparator);
        }
    }
}
 
Example #25
Source File: AbstractWorkflowExecutorManagerListener.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * get order ID (priority of current listener)
 *
 * @return
 */
public int getOrderId() {
    IdentityEventListenerConfig listenerConfig = IdentityUtil.readEventListenerProperty
            (WorkflowExecutorManagerListener.class.getName(), this.getClass().getName());
    if (listenerConfig == null) {
        return IdentityCoreConstants.EVENT_LISTENER_ORDER_ID;
    }
    return listenerConfig.getOrder();
}
 
Example #26
Source File: AbstractWorkflowListener.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * get order ID (priority of current listener)
 *
 * @return
 */
public int getOrderId() {
    IdentityEventListenerConfig workflowListener = IdentityUtil.readEventListenerProperty
            (WorkflowListener.class.getName(), this.getClass().getName());
    if (workflowListener == null) {
        return IdentityCoreConstants.EVENT_LISTENER_ORDER_ID;
    }
    return workflowListener.getOrder();
}
 
Example #27
Source File: UserStoreListener.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
public int getExecutionOrderId() {
    int orderId = getOrderId();
    if (orderId != IdentityCoreConstants.EVENT_LISTENER_ORDER_ID) {
        return orderId;
    }
    return 20;
}
 
Example #28
Source File: AbstractIdentityProviderMgtListener.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
public int getExecutionOrderId() {
    IdentityEventListenerConfig identityEventListenerConfig = IdentityUtil.readEventListenerProperty
            (IdentityProviderMgtListener.class.getName(), this.getClass().getName());
    int orderId;
    if (identityEventListenerConfig == null) {
        orderId = IdentityCoreConstants.EVENT_LISTENER_ORDER_ID;
    } else {
        orderId = identityEventListenerConfig.getOrder();
    }
    if (orderId != IdentityCoreConstants.EVENT_LISTENER_ORDER_ID) {
        return orderId;
    }
    return getDefaultOrderId();
}
 
Example #29
Source File: UserManagementAuditLogger.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
@Override
public int getExecutionOrderId() {
    int orderId = getOrderId();
    if (orderId != IdentityCoreConstants.EVENT_LISTENER_ORDER_ID) {
        return orderId;
    }
    return 1;
}
 
Example #30
Source File: UserMgtAuditLogger.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
@Override
public int getExecutionOrderId() {

    int orderId = getOrderId();
    if (orderId != IdentityCoreConstants.EVENT_LISTENER_ORDER_ID) {
        return orderId;
    }

    return 8;
}