CPD Results

The following document contains the results of PMD's CPD 5.5.1.

Duplications

File Line
net\sf\michaelo\tomcat\realm\ActiveDirectoryRealm.java 289
net\sf\michaelo\tomcat\realm\CombinedActiveDirectoryRealm.java 201
	}

	@Override
	public boolean hasRole(Wrapper wrapper, Principal principal, String role) {
		// Check for a role alias defined in a <security-role-ref> element
		if (wrapper != null) {
			String realRole = wrapper.findSecurityReference(role);
			if (realRole != null)
				role = realRole;
		}

		if (principal == null || role == null || !(principal instanceof ActiveDirectoryPrincipal))
			return false;

		ActiveDirectoryPrincipal adp = (ActiveDirectoryPrincipal) principal;

		boolean result;
		if (getContainer() instanceof Context) {
			Context context = (Context) getContainer();
			result = adp.hasRole(context.findRoleMapping(role));
		} else
			result = adp.hasRole(role);

		if (logger.isDebugEnabled()) {
			if (result)
				logger.debug(sm.getString("activeDirectoryRealm.hasRole", principal, role));
			else
				logger.debug(sm.getString("activeDirectoryRealm.hasNotRole", principal, role));
		}

		return result;
	}
File Line
net\sf\michaelo\tomcat\realm\ActiveDirectoryRealm.java 226
net\sf\michaelo\tomcat\realm\GSSUserDatabaseRealm.java 50
		return getPrincipal(gssName, gssCredential);
	}

	@Override
	public Principal authenticate(GSSContext gssContext, boolean storeCreds) {
		if (gssContext.isEstablished()) {
			GSSName gssName = null;
			try {
				gssName = gssContext.getSrcName();
			} catch (GSSException e) {
				logger.error(sm.getString("activeDirectoryRealm.gssNameFailed"), e);
			}

			if (gssName != null) {
				GSSCredential gssCredential = null;
				if (storeCreds) {
					if (gssContext.getCredDelegState()) {
						try {
							gssCredential = gssContext.getDelegCred();
						} catch (GSSException e) {
							logger.warn(sm.getString(
									"activeDirectoryRealm.delegatedCredentialFailed", gssName), e);
						}
					} else {
						if (logger.isDebugEnabled())
							logger.debug(sm.getString("activeDirectoryRealm.credentialNotDelegable",
									gssName));
					}
				}

				return getPrincipal(gssName, gssCredential);