AEM 6.5 Custom OSGI Config is not visible | Community
Skip to main content
January 7, 2020
Solved

AEM 6.5 Custom OSGI Config is not visible

  • January 7, 2020
  • 1 reply
  • 2314 views

Hey guys,

I am using AEM 6.5 and I've deployed a custom OSGI service config. I was expecting to find the config under http://localhost:4502/system/console/configMgr

Here is my Service. 

MyService.java

public interface MyService { /** * This method returns the entered password into a hash equivalent with some * properties passed by the user * * @90521 type * @2007960 {@link String} */ String getPassword(String type); }


MyServiceImpl.java

 

@Component(service = MyService.class,
property = {
"label=My Service Implementation"
}
)
@Designate(ocd = MyConfiguration.class)
public class MyServiceImpl implements MyService {

private final Logger log = LoggerFactory.getLogger(this.getClass());

// Two properties to be read
private String propertyOne;
private String propertyTwo;

@Activate
protected void activate(MyConfiguration config) {
// Reading properties from the configuration
propertyOne = config.getPropertyOne();
propertyTwo = config.getPropertyTwo();

}

@Override
public String getPassword(String type) {

// MD5 equivalent of password string
String passwordHash = null;

try {

type = type + propertyOne + propertyTwo;

log.info("Resulant password: " + type);

// Convert string to bytes - this is for the sample implementation (for show casing)
byte[] passwordByte = type.getBytes("UTF-8");

// Getting instance of MessageDigest
MessageDigest md = MessageDigest.getInstance("MD5");

// Convert bytes array to hash using MD5 algorithm
byte[] digest = md.digest(passwordByte);

passwordHash = new String(digest);

} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}

return passwordHash;
}

}



MyConfiguration.java

import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.AttributeType;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;

@ObjectClassDefinition(name = "My Configuration",
description = "This configuration will be used to read the value of properties.")
public @interface MyConfiguration {

@AttributeDefinition(name = "Property One", description = "Read property one", type = AttributeType.STRING)
public String getPropertyOne() default "Property One";

@AttributeDefinition(name = "Property Two", description = "Read property two", type = AttributeType.STRING)
public String getPropertyTwo() default "Property Two";
}

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by arunpatidar

Hi,

Could you please check if your bundle is active or not? Code looks fine, could be issue with imports.

I have a sample code you can refer just to cross check in case you missed something

https://github.com/arunpatidar02/aem63app-repo/tree/master/java/page/json/com/acc/aem64/core/services

 

1 reply

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
January 7, 2020

Hi,

Could you please check if your bundle is active or not? Code looks fine, could be issue with imports.

I have a sample code you can refer just to cross check in case you missed something

https://github.com/arunpatidar02/aem63app-repo/tree/master/java/page/json/com/acc/aem64/core/services

 

Arun Patidar