perfsonar-dev - [pS-dev] [GEANT/SA2/ps-java-services] r6021 - in trunk/perfsonar_base/src/main/java/org/perfsonar: base/auxiliary/components/authn base/auxiliary/components/authn/wssec service/base/authn service/base/messages service/measurementArchive/metadataConfig
Subject: perfsonar development work
List archive
[pS-dev] [GEANT/SA2/ps-java-services] r6021 - in trunk/perfsonar_base/src/main/java/org/perfsonar: base/auxiliary/components/authn base/auxiliary/components/authn/wssec service/base/authn service/base/messages service/measurementArchive/metadataConfig
Chronological Thread
- From:
- To:
- Subject: [pS-dev] [GEANT/SA2/ps-java-services] r6021 - in trunk/perfsonar_base/src/main/java/org/perfsonar: base/auxiliary/components/authn base/auxiliary/components/authn/wssec service/base/authn service/base/messages service/measurementArchive/metadataConfig
- Date: Fri, 5 Oct 2012 10:22:58 +0100 (BST)
Author: nordunet.behrmann
Date: 2012-10-05 10:22:57 +0100 (Fri, 05 Oct 2012)
New Revision: 6021
Modified:
trunk/perfsonar_base/src/main/java/org/perfsonar/base/auxiliary/components/authn/DynamicCrypto.java
trunk/perfsonar_base/src/main/java/org/perfsonar/base/auxiliary/components/authn/wssec/WSSecAuthNComponent.java
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/authn/AttrResponse.java
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/messages/DataRequest.java
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/messages/LinkRequest.java
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/messages/Request.java
trunk/perfsonar_base/src/main/java/org/perfsonar/service/measurementArchive/metadataConfig/MetadataConfigurationStorageManager.java
Log:
perfsonar_base: Fixed several PMD warnings
Issue: PSSERVICES-597
Modified:
trunk/perfsonar_base/src/main/java/org/perfsonar/base/auxiliary/components/authn/DynamicCrypto.java
===================================================================
---
trunk/perfsonar_base/src/main/java/org/perfsonar/base/auxiliary/components/authn/DynamicCrypto.java
2012-10-05 09:22:57 UTC (rev 6020)
+++
trunk/perfsonar_base/src/main/java/org/perfsonar/base/auxiliary/components/authn/DynamicCrypto.java
2012-10-05 09:22:57 UTC (rev 6021)
@@ -41,6 +41,8 @@
protected static CertificateFactory certFact;
protected Properties properties = null;
protected KeyStore keystore = null;
+
+ @SuppressWarnings("PMD.AvoidUsingHardCodedIP")
static final String SKI_OID = "2.5.29.14";
public DynamicCrypto() throws CredentialException
Modified:
trunk/perfsonar_base/src/main/java/org/perfsonar/base/auxiliary/components/authn/wssec/WSSecAuthNComponent.java
===================================================================
---
trunk/perfsonar_base/src/main/java/org/perfsonar/base/auxiliary/components/authn/wssec/WSSecAuthNComponent.java
2012-10-05 09:22:57 UTC (rev 6020)
+++
trunk/perfsonar_base/src/main/java/org/perfsonar/base/auxiliary/components/authn/wssec/WSSecAuthNComponent.java
2012-10-05 09:22:57 UTC (rev 6021)
@@ -123,21 +123,19 @@
@Override
public void requestAuthN(String messageType) throws PerfSONARException
{
- if (isRequiredAuthN()) {
- if (messageTypesAuthN.contains(messageType)) {
- SecurityToken st = new
SecurityToken(SecTokenManagerFactory.getDefaultSecTokenManager());
- if (!st.hasSecTokenInRequest()) {
- throw new PerfSONARException("error.authn.not_sectoken",
"WSSecAuthNComponent: It has not sent any Security Token");
- }
- st.setSecTokenFromRequest();
- AuthNRequest authnReq = new AuthNRequest(st);
- AADispatchManager aadm = new
AADispatchManager(AADispatchProtocolFactory.getDefaultAADispatchProtocol());
- AuthNResponse authnRes = aadm.getAuthentication(authnReq);
- if (authnRes.getStatus() != AuthNResponse.AUTHENTICATED) {
- logger.debug("WSSecAuthNComponent: Authentication failed
(" + authnRes.getResultCode() + ")");
- throw new PerfSONARException(authnRes.getResultCode(),
"Authentication failed");
- }
+ if (isRequiredAuthN() && messageTypesAuthN.contains(messageType)) {
+ SecurityToken st = new
SecurityToken(SecTokenManagerFactory.getDefaultSecTokenManager());
+ if (!st.hasSecTokenInRequest()) {
+ throw new PerfSONARException("error.authn.not_sectoken",
"WSSecAuthNComponent: It has not sent any Security Token");
}
+ st.setSecTokenFromRequest();
+ AuthNRequest authnReq = new AuthNRequest(st);
+ AADispatchManager aadm = new
AADispatchManager(AADispatchProtocolFactory.getDefaultAADispatchProtocol());
+ AuthNResponse authnRes = aadm.getAuthentication(authnReq);
+ if (authnRes.getStatus() != AuthNResponse.AUTHENTICATED) {
+ logger.debug("WSSecAuthNComponent: Authentication failed ("
+ authnRes.getResultCode() + ")");
+ throw new PerfSONARException(authnRes.getResultCode(),
"Authentication failed");
+ }
}
}
@@ -154,32 +152,30 @@
public void requestAuthR(String messageType, String eventType) throws
PerfSONARException
{
boolean authr = false;
- if (isRequiredAuthR()) {
- if (messageTypesAuthR.contains(messageType)) {
- authr = true;
- SecurityToken st = new
SecurityToken(SecTokenManagerFactory.getDefaultSecTokenManager());
- if (!st.hasSecTokenInRequest()) {
- throw new PerfSONARException("error.authn.not_sectoken",
"WSSecAuthNComponent: It has not sent any Security Token");
- }
- st.setSecTokenFromRequest();
- AuthRRequest authrReq = new AuthRRequest(st, messageType);
- authrReq.setResource(getResource());
- if (!(eventType == null || eventType.isEmpty())) {
- authrReq.setAction(URLEncoder.encode(messageType) + ":"
+ URLEncoder.encode(eventType));
- }
- try {
- authrReq.setSubject(SecTokenSOAPManager.getSubject(st));
- } catch (Exception e) {
- throw new PerfSONARException("error.authn.not_sectoken",
"WSSecAuthNComponent: Cannot get authR data from the Security Token");
- }
+ if (isRequiredAuthR() && messageTypesAuthR.contains(messageType)) {
+ authr = true;
+ SecurityToken st = new
SecurityToken(SecTokenManagerFactory.getDefaultSecTokenManager());
+ if (!st.hasSecTokenInRequest()) {
+ throw new PerfSONARException("error.authn.not_sectoken",
"WSSecAuthNComponent: It has not sent any Security Token");
+ }
+ st.setSecTokenFromRequest();
+ AuthRRequest authrReq = new AuthRRequest(st, messageType);
+ authrReq.setResource(getResource());
+ if (!(eventType == null || eventType.isEmpty())) {
+ authrReq.setAction(URLEncoder.encode(messageType) + ":" +
URLEncoder.encode(eventType));
+ }
+ try {
+ authrReq.setSubject(SecTokenSOAPManager.getSubject(st));
+ } catch (Exception e) {
+ throw new PerfSONARException("error.authn.not_sectoken",
"WSSecAuthNComponent: Cannot get authR data from the Security Token");
+ }
- AADispatchProtocol prot =
AADispatchProtocolFactory.getDefaultAADispatchProtocol();
- AADispatchManager aadm = new AADispatchManager(prot);
- AuthRResponse authrRes = aadm.getAuthorization(authrReq);
- if (authrRes.getStatus() != AuthNResponse.AUTHENTICATED) {
- logger.debug("WSSecAuthNComponent: Authentication failed
(" + authrRes.getResultCode() + ")");
- throw new PerfSONARException(authrRes.getResultCode(),
"Authentication failed");
- }
+ AADispatchProtocol prot =
AADispatchProtocolFactory.getDefaultAADispatchProtocol();
+ AADispatchManager aadm = new AADispatchManager(prot);
+ AuthRResponse authrRes = aadm.getAuthorization(authrReq);
+ if (authrRes.getStatus() != AuthNResponse.AUTHENTICATED) {
+ logger.debug("WSSecAuthNComponent: Authentication failed ("
+ authrRes.getResultCode() + ")");
+ throw new PerfSONARException(authrRes.getResultCode(),
"Authentication failed");
}
}
if (!authr) {
Modified:
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/authn/AttrResponse.java
===================================================================
---
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/authn/AttrResponse.java
2012-10-05 09:22:57 UTC (rev 6020)
+++
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/authn/AttrResponse.java
2012-10-05 09:22:57 UTC (rev 6021)
@@ -87,11 +87,9 @@
responseMetadata = metadata;
}
- if (et != null) {
- if (et.getEventType().trim().contains("success.as.attr")) {
- res.setStatus(AttrResponse.ATTR_BAD_RESPONSE);
- res.setResultCode(et.getEventType());
- }
+ if (et != null &&
et.getEventType().trim().contains("success.as.attr")) {
+ res.setStatus(AttrResponse.ATTR_BAD_RESPONSE);
+ res.setResultCode(et.getEventType());
}
if (res.getStatus() == AttrResponse.ATTR_OK_RESPONSE) {
Iterator<?> it = responseMetadata.getChildIterator();
Modified:
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/messages/DataRequest.java
===================================================================
---
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/messages/DataRequest.java
2012-10-05 09:22:57 UTC (rev 6020)
+++
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/messages/DataRequest.java
2012-10-05 09:22:57 UTC (rev 6021)
@@ -57,18 +57,16 @@
Key key = head.getKey();
- if (mustKey) {
+ if (mustKey && key == null) {
// If this metadata does not hold a key, then the
// chain is not a "key" chain.
- if (key == null) {
- logger.fatal(
- "SetupDataRequest: Metadata MUST hold a key " +
- "for GET_DATA");
- throw new PerfSONARException(
- "SetupDataRequest: Metadata MUST hold a key " +
- "for GET_DATA");
- }
+ logger.fatal(
+ "SetupDataRequest: Metadata MUST hold a key " +
+ "for GET_DATA");
+ throw new PerfSONARException(
+ "SetupDataRequest: Metadata MUST hold a key " +
+ "for GET_DATA");
}
// filter chaining is done using the Subject element.
Modified:
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/messages/LinkRequest.java
===================================================================
---
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/messages/LinkRequest.java
2012-10-05 09:22:57 UTC (rev 6020)
+++
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/messages/LinkRequest.java
2012-10-05 09:22:57 UTC (rev 6021)
@@ -109,17 +109,16 @@
Collection<Metadata> collection =
inputMessage.getMetadataMap().values();
- Subject subject;
- Node node;
- Vector nodes;
for (Metadata metadata : collection) {
-
- if ((subject = metadata.getSubject()) != null) {
- if ((nodes = subject.getChildrenByType("node")).isEmpty())
- continue;
- else if ((node = (Node) nodes.get(0)) != null)
- if (nodeId.equals(node.getId()))
+ Subject subject = metadata.getSubject();
+ if (subject != null) {
+ Vector nodes = subject.getChildrenByType("node");
+ if (!nodes.isEmpty()) {
+ Node node = (Node) nodes.get(0);
+ if (node != null && nodeId.equals(node.getId())) {
return metadata.getId();
+ }
+ }
}
}
Modified:
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/messages/Request.java
===================================================================
---
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/messages/Request.java
2012-10-05 09:22:57 UTC (rev 6020)
+++
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/messages/Request.java
2012-10-05 09:22:57 UTC (rev 6021)
@@ -335,15 +335,14 @@
//metadataIdRef in Subject
//prevent endless loop
- if (metadata.getSubject() != null) {
- if (!(metadata.getSubject().getMetadataIdRef() != null &&
metadata.getSubject().getMetadataIdRef().isEmpty()) &&
+ if (metadata.getSubject() != null &&
+ !(metadata.getSubject().getMetadataIdRef() != null &&
metadata.getSubject().getMetadataIdRef().isEmpty()) &&
!(metadata.getId().equals(metadata.getSubject().getMetadataIdRef()))) {
- getChaining(
- inputMessage,
- metadata.getSubject().getMetadataIdRef(),
- metadatas);
- }
+ getChaining(
+ inputMessage,
+ metadata.getSubject().getMetadataIdRef(),
+ metadatas);
}
String chainedMetadataId = metadata.getMetadataIdRef();
Modified:
trunk/perfsonar_base/src/main/java/org/perfsonar/service/measurementArchive/metadataConfig/MetadataConfigurationStorageManager.java
===================================================================
---
trunk/perfsonar_base/src/main/java/org/perfsonar/service/measurementArchive/metadataConfig/MetadataConfigurationStorageManager.java
2012-10-05 09:22:57 UTC (rev 6020)
+++
trunk/perfsonar_base/src/main/java/org/perfsonar/service/measurementArchive/metadataConfig/MetadataConfigurationStorageManager.java
2012-10-05 09:22:57 UTC (rev 6021)
@@ -107,12 +107,11 @@
+ "No metadata in the metadata configuration");
}
- if (xmlResults.length == 1) {
- if (xmlResults[0].trim().isEmpty())
- throw new PerfSONARException(
- "warning.ma.metadata_configuration",
- "MetadataConfigurationStorageManager.fetch: "
- + "No metadata in the metadata configuration");
+ if (xmlResults.length == 1 && xmlResults[0].trim().isEmpty()) {
+ throw new PerfSONARException(
+ "warning.ma.metadata_configuration",
+ "MetadataConfigurationStorageManager.fetch: "
+ + "No metadata in the metadata configuration");
}
- [pS-dev] [GEANT/SA2/ps-java-services] r6021 - in trunk/perfsonar_base/src/main/java/org/perfsonar: base/auxiliary/components/authn base/auxiliary/components/authn/wssec service/base/authn service/base/messages service/measurementArchive/metadataConfig, svn-noreply, 10/05/2012
Archive powered by MHonArc 2.6.16.