Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fix_db_connection_i…
Browse files Browse the repository at this point in the history
…ssues

Conflicts:
	components/oauth/org.wso2.carbon.identity.oauth/src/main/java/org/wso2/carbon/identity/oauth/dao/OAuthAppDAO.java
	components/oauth/org.wso2.carbon.identity.oauth/src/main/java/org/wso2/carbon/identity/oauth2/dao/TokenMgtDAO.java
	components/openid/org.wso2.carbon.identity.provider/src/main/java/org/wso2/carbon/identity/provider/openid/dao/OpenIDAssociationDAO.java
	components/openid/org.wso2.carbon.identity.provider/src/main/java/org/wso2/carbon/identity/provider/openid/dao/OpenIDRememberMeTokenDAO.java
  • Loading branch information
hpmtissera committed Jun 17, 2015
2 parents b150b8a + 84b7503 commit d859d78
Show file tree
Hide file tree
Showing 1,693 changed files with 43,974 additions and 33,618 deletions.
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
Copyright (c) 2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
WSO2 Inc. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<parent>
<groupId>org.wso2.carbon.identity</groupId>
<artifactId>agents</artifactId>
<version>4.4.2-SNAPSHOT</version>
<version>4.5.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
/*
* Copyright (c) WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/

package org.wso2.carbon.identity.entitlement.filter;

public class EntitlementConstants {


public static final String CLIENT = "client";

public static final String SERVER_URL = "serverUrl";
Expand Down Expand Up @@ -93,4 +96,9 @@ public class EntitlementConstants {

public static final String defaultThriftPort = "10500";


private EntitlementConstants(){

}

}
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
/*
* Copyright (c) WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/

package org.wso2.carbon.identity.entitlement.filter;


Expand All @@ -29,7 +31,11 @@
import org.wso2.carbon.identity.entitlement.proxy.PEPProxyConfig;
import org.wso2.carbon.identity.entitlement.proxy.exception.EntitlementProxyException;

import javax.servlet.*;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.xml.namespace.QName;
import java.util.HashMap;
Expand All @@ -40,7 +46,6 @@ public class EntitlementFilter implements Filter {

private static final Log log = LogFactory.getLog(EntitlementFilter.class);

private FilterConfig filterConfig = null;
private PEPProxy pepProxy;
private String client;
private String remoteServiceUrl;
Expand All @@ -63,7 +68,6 @@ public class EntitlementFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws EntitlementFilterException {

this.filterConfig = filterConfig;

//This Attributes are mandatory So have to be specified in the web.xml
authRedirectURL = filterConfig.getInitParameter(EntitlementConstants.AUTH_REDIRECT_URL);
Expand Down Expand Up @@ -111,40 +115,40 @@ public void init(FilterConfig filterConfig) throws EntitlementFilterException {
thriftPort = EntitlementConstants.defaultThriftPort;
}

//Initializing the PDP Proxy
//If you are not using a WSO2 product please uncomment these lines to use provided keystore
//System.setProperty("javax.net.ssl.trustStore","wso2carbon.jks");
//System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");


Map<String, Map<String, String>> appToPDPClientConfigMap = new HashMap<String, Map<String, String>>();
Map<String, String> clientConfigMap = new HashMap<String, String>();

if (client != null && client.equals(EntitlementConstants.SOAP)) {
clientConfigMap.put(EntitlementConstants.CLIENT, client);
clientConfigMap.put(EntitlementConstants.SERVER_URL, remoteServiceUrl);
clientConfigMap.put(EntitlementConstants.USERNAME, remoteServiceUserName);
clientConfigMap.put(EntitlementConstants.PASSWORD, remoteServicePassword);
clientConfigMap.put(EntitlementConstants.REUSE_SESSION, reuseSession);
} else if (client != null && client.equals(EntitlementConstants.BASIC_AUTH)) {
clientConfigMap.put(EntitlementConstants.CLIENT, client);
clientConfigMap.put(EntitlementConstants.SERVER_URL, remoteServiceUrl);
clientConfigMap.put(EntitlementConstants.USERNAME, remoteServiceUserName);
clientConfigMap.put(EntitlementConstants.PASSWORD, remoteServicePassword);
} else if (client != null && client.equals(EntitlementConstants.THRIFT)) {
clientConfigMap.put(EntitlementConstants.CLIENT, client);
clientConfigMap.put(EntitlementConstants.SERVER_URL, remoteServiceUrl);
clientConfigMap.put(EntitlementConstants.USERNAME, remoteServiceUserName);
clientConfigMap.put(EntitlementConstants.PASSWORD, remoteServicePassword);
clientConfigMap.put(EntitlementConstants.REUSE_SESSION, reuseSession);
clientConfigMap.put(EntitlementConstants.THRIFT_HOST, thriftHost);
clientConfigMap.put(EntitlementConstants.THRIFT_PORT, thriftPort);
} else if (client == null) {

if(client!=null){
if(client.equals(EntitlementConstants.SOAP)){
clientConfigMap.put(EntitlementConstants.CLIENT, client);
clientConfigMap.put(EntitlementConstants.SERVER_URL, remoteServiceUrl);
clientConfigMap.put(EntitlementConstants.USERNAME, remoteServiceUserName);
clientConfigMap.put(EntitlementConstants.PASSWORD, remoteServicePassword);
clientConfigMap.put(EntitlementConstants.REUSE_SESSION, reuseSession);
} else if (client.equals(EntitlementConstants.BASIC_AUTH)) {
clientConfigMap.put(EntitlementConstants.CLIENT, client);
clientConfigMap.put(EntitlementConstants.SERVER_URL, remoteServiceUrl);
clientConfigMap.put(EntitlementConstants.USERNAME, remoteServiceUserName);
clientConfigMap.put(EntitlementConstants.PASSWORD, remoteServicePassword);
}else if (client.equals(EntitlementConstants.THRIFT)) {
clientConfigMap.put(EntitlementConstants.CLIENT, client);
clientConfigMap.put(EntitlementConstants.SERVER_URL, remoteServiceUrl);
clientConfigMap.put(EntitlementConstants.USERNAME, remoteServiceUserName);
clientConfigMap.put(EntitlementConstants.PASSWORD, remoteServicePassword);
clientConfigMap.put(EntitlementConstants.REUSE_SESSION, reuseSession);
clientConfigMap.put(EntitlementConstants.THRIFT_HOST, thriftHost);
clientConfigMap.put(EntitlementConstants.THRIFT_PORT, thriftPort);
}else {
throw new EntitlementFilterException("EntitlementMediator initialization error: Unsupported client");
}

}else {
clientConfigMap.put(EntitlementConstants.SERVER_URL, remoteServiceUrl);
clientConfigMap.put(EntitlementConstants.USERNAME, remoteServiceUserName);
clientConfigMap.put(EntitlementConstants.PASSWORD, remoteServicePassword);
} else {
log.error("EntitlementMediator initialization error: Unsupported client");
throw new EntitlementFilterException("EntitlementMediator initialization error: Unsupported client");
}

appToPDPClientConfigMap.put("EntitlementMediator", clientConfigMap);
Expand All @@ -153,8 +157,7 @@ public void init(FilterConfig filterConfig) throws EntitlementFilterException {
try {
pepProxy = new PEPProxy(config);
} catch (EntitlementProxyException e) {
log.error("Error while initializing the PEP Proxy" + e);
throw new EntitlementFilterException("Error while initializing the Entitlement PEP Proxy");
throw new EntitlementFilterException("Error while initializing the Entitlement PEP Proxy",e);
}
}

Expand Down Expand Up @@ -190,17 +193,16 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
simpleDecision = decisionElement.getFirstChildWithName(new QName(namespace, "Result")).
getFirstChildWithName(new QName(namespace, "Decision")).getText();
} catch (Exception e) {
e.printStackTrace();
throw new EntitlementFilterException("Exception while making the decision : " + e);

throw new EntitlementFilterException("Exception while making the decision " , e);
}
}
completeAuthorization(simpleDecision, servletRequest, servletResponse, filterConfig, filterChain);
completeAuthorization(simpleDecision, servletRequest, servletResponse, filterChain);
}

@Override
public void destroy() {

filterConfig = null;
pepProxy = null;
client = null;
remoteServiceUrl = null;
Expand Down Expand Up @@ -240,7 +242,7 @@ private String findUserName(HttpServletRequest request, String subjectScope,
+ " \'" + EntitlementConstants.REQUEST_PARAM + "\', " + EntitlementConstants.REQUEST_ATTIBUTE + "\' and \'"
+ EntitlementConstants.SESSION + "\'");
}
if (subject == null || subject.equals("null")) {
if (subject == null || "null".equals(subject)) {
log.error("Username not provided in " + subjectScope);
throw new EntitlementFilterException("Username not provided in " + subjectScope);
}
Expand All @@ -256,7 +258,7 @@ private String findAction(HttpServletRequest request) {
}

private void completeAuthorization(String decision, ServletRequest servletRequest,
ServletResponse servletResponse, FilterConfig filterConfig,
ServletResponse servletResponse,
FilterChain filterChain)
throws EntitlementFilterException {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* Copyright (c) WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
Expand All @@ -15,26 +15,34 @@
* specific language governing permissions and limitations
* under the License.
*/

package org.wso2.carbon.identity.entitlement.filter.callback;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.identity.entitlement.filter.exception.EntitlementFilterException;

import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;

public class BasicAuthCallBackHandler extends EntitlementFilterCallBackHandler {

private static final Log log = LogFactory.getLog(BasicAuthCallBackHandler.class);
private static final String AUTHORIZATION = "Authorization";
private static final String NULL_STRING = "null";

public BasicAuthCallBackHandler(HttpServletRequest request) throws EntitlementFilterException {
String authHeaderEn = null;
if (!(request.getHeader("Authorization") == null || request.getHeader("Authorization").equals("null"))) {
authHeaderEn = request.getHeader("Authorization");
String tempArr[] = authHeaderEn.split(" ");
if (!(request.getHeader(AUTHORIZATION) == null || NULL_STRING.equals(request.getHeader(AUTHORIZATION)))) {
authHeaderEn = request.getHeader(AUTHORIZATION);
String[] tempArr = authHeaderEn.split(" ");
if (tempArr.length == 2) {
String authHeaderDc = new String(Base64.decodeBase64(tempArr[1].getBytes()));
String authHeaderDc = null;
try {
authHeaderDc = new String(Base64.decodeBase64(tempArr[1].getBytes(Charset.forName("UTF-8"))),
"UTF-8");
} catch (UnsupportedEncodingException e) {
throw new EntitlementFilterException("authentication codec error", e);
}
tempArr = authHeaderDc.split(":");
if (tempArr.length == 2) {
setUserName(tempArr[0]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
/*
* Copyright (c) WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/

package org.wso2.carbon.identity.entitlement.filter.callback;

public class EntitlementFilterCallBackHandler {
Expand Down
Loading

0 comments on commit d859d78

Please sign in to comment.